Fix main: eyedropper cursor tests accept the native pipette bitmap (#12523)

#12523 shows the pipette as an OS cursor bitmap on native root viewports,
where the output is the visible-fallback Crosshair plus the bitmap, not the
drawn pipette's CursorIcon::None. Tests from #12145 and #12301 still looked
for the drawn pipette and failed on Windows unit.

tool_cursor::pipette_shown checks for the pipette either way (the exact
bitmap natively, the drawn one elsewhere), and the sampler, caps lock and
mixer cursor tests use it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
David MannandClaude Opus 5.5 committed 2026-11-11 16:08:09 +01:00
1 parent 2b61e5ddf0
commit 79a33dae9c
4 files changed
+44 -29

No files matched your search

@@ -65,27 +65,29 @@ fn hover_at(h: &mut Harness<'static, PhotocraftApp>, doc_x: f32, doc_y: f32, m:
h.output().platform_output.cursor_icon h.output().platform_output.cursor_icon
} }
/// The eyedropper's pipette: the OS bitmap where one uploads, else drawn (#12523).
fn pipette_shown(h: &Harness<'static, PhotocraftApp>) -> bool {
crate::tool_cursor::pipette_shown(&h.ctx, &h.output().platform_output)
}
#[test] #[test]
fn off_sampler_no_key_or_shift_or_alt_shows_eyedropper_with_sampler_target() { fn off_sampler_no_key_or_shift_or_alt_shows_eyedropper_with_sampler_target() {
let mut h = harness(); let mut h = harness();
// 1. Off a sampler, no key: eyedropper with small sampler target at top-left. // 1. Off a sampler, no key: eyedropper with small sampler target at top-left.
let icon = hover_at(&mut h, 80.0, 80.0, Modifiers::NONE); hover_at(&mut h, 80.0, 80.0, Modifiers::NONE);
assert_eq!(icon, egui::CursorIcon::None, "pipette cursor replaces OS pointer"); assert!(pipette_shown(&h), "pipette cursor replaces OS pointer");
assert!(cursor_area_visible(&h, "pc-icon-cursor"), "pipette icon is drawn");
assert!(cursor_area_visible(&h, "pc-sampler-badge"), "sampler target at top-left is drawn"); assert!(cursor_area_visible(&h, "pc-sampler-badge"), "sampler target at top-left is drawn");
assert!(!cursor_badge_visible(&h, "sampler") && !cursor_badge_visible(&h, "scissors"), "arrow badge is not drawn off sampler"); assert!(!cursor_badge_visible(&h, "sampler") && !cursor_badge_visible(&h, "scissors"), "arrow badge is not drawn off sampler");
// 2. Off a sampler, Shift held: still eyedropper with sampler target. // 2. Off a sampler, Shift held: still eyedropper with sampler target.
let icon_shift = hover_at(&mut h, 80.0, 80.0, Modifiers::SHIFT); hover_at(&mut h, 80.0, 80.0, Modifiers::SHIFT);
assert_eq!(icon_shift, egui::CursorIcon::None); assert!(pipette_shown(&h));
assert!(cursor_area_visible(&h, "pc-icon-cursor"));
assert!(cursor_area_visible(&h, "pc-sampler-badge")); assert!(cursor_area_visible(&h, "pc-sampler-badge"));
// 3. Off a sampler, Alt held: still eyedropper with sampler target. // 3. Off a sampler, Alt held: still eyedropper with sampler target.
let icon_alt = hover_at(&mut h, 80.0, 80.0, Modifiers::ALT); hover_at(&mut h, 80.0, 80.0, Modifiers::ALT);
assert_eq!(icon_alt, egui::CursorIcon::None); assert!(pipette_shown(&h));
assert!(cursor_area_visible(&h, "pc-icon-cursor"));
assert!(cursor_area_visible(&h, "pc-sampler-badge")); assert!(cursor_area_visible(&h, "pc-sampler-badge"));
} }
@@ -96,7 +98,7 @@ fn off_sampler_precise_other_cursors_shows_crosshair() {
let icon = hover_at(&mut h, 80.0, 80.0, Modifiers::NONE); let icon = hover_at(&mut h, 80.0, 80.0, Modifiers::NONE);
assert_eq!(icon, egui::CursorIcon::Crosshair, "Precise Other Cursors shows crosshair off sampler"); assert_eq!(icon, egui::CursorIcon::Crosshair, "Precise Other Cursors shows crosshair off sampler");
assert!(!cursor_area_visible(&h, "pc-icon-cursor"), "no pipette icon with precise cursor"); assert!(!pipette_shown(&h), "no pipette with precise cursor");
assert!(!cursor_area_visible(&h, "pc-sampler-badge"), "no sampler badge with precise cursor"); assert!(!cursor_area_visible(&h, "pc-sampler-badge"), "no sampler badge with precise cursor");
} }
@@ -111,7 +113,7 @@ fn over_sampler_shows_arrow_with_sampler_target_and_alt_shows_scissors() {
assert_eq!(icon, egui::CursorIcon::Default, "over sampler uses standard arrow pointer"); assert_eq!(icon, egui::CursorIcon::Default, "over sampler uses standard arrow pointer");
assert!(cursor_badge_visible(&h, "sampler"), "sampler target badge is drawn"); assert!(cursor_badge_visible(&h, "sampler"), "sampler target badge is drawn");
assert!(!cursor_badge_visible(&h, "scissors"), "scissors badge is not drawn without Alt"); assert!(!cursor_badge_visible(&h, "scissors"), "scissors badge is not drawn without Alt");
assert!(!cursor_area_visible(&h, "pc-icon-cursor"), "no pipette icon over sampler"); assert!(!pipette_shown(&h), "no pipette over sampler");
// Even with Precise Other Cursors, over a sampler is the arrow cursor. // Even with Precise Other Cursors, over a sampler is the arrow cursor.
h.state_mut().run("prefs.set", json!({"values": {"cursors.other": "precise"}})).unwrap(); h.state_mut().run("prefs.set", json!({"values": {"cursors.other": "precise"}})).unwrap();
@@ -159,9 +161,9 @@ fn cursor_follows_sampler_hit_test_tolerance() {
assert!(cursor_badge_visible(&h, "sampler")); assert!(cursor_badge_visible(&h, "sampler"));
assert!(!cursor_badge_visible(&h, "scissors")); assert!(!cursor_badge_visible(&h, "scissors"));
// Outside hit square (dx = 8.0 > 7.0): off sampler -> CursorIcon::None (eyedropper). // Outside hit square (dx = 8.0 > 7.0): off sampler -> the eyedropper's pipette.
let icon_out = hover_at(&mut h, 158.0, 150.0, Modifiers::NONE); hover_at(&mut h, 158.0, 150.0, Modifiers::NONE);
assert_eq!(icon_out, egui::CursorIcon::None, "dx = 8 px is outside tolerance"); assert!(pipette_shown(&h), "dx = 8 px is outside tolerance");
assert!(cursor_area_visible(&h, "pc-sampler-badge")); assert!(cursor_area_visible(&h, "pc-sampler-badge"));
// A press at dx = 6 grabs the existing sampler. // A press at dx = 6 grabs the existing sampler.
+11
View File
@@ -173,6 +173,17 @@ pub(crate) fn pipette(ctx: &egui::Context, at: Pos2) -> CursorIcon {
show(&painter, at, Shape::Pipette) show(&painter, at, Shape::Pipette)
} }
/// Whether the pass whose output is `out` shows the sampling pipette: the OS bitmap and its
/// visible-fallback crosshair where a bitmap can be uploaded, the drawn pipette elsewhere.
#[cfg(test)]
pub(crate) fn pipette_shown(ctx: &egui::Context, out: &egui::PlatformOutput) -> bool {
if !native(ctx) {
return out.cursor_icon == CursorIcon::None;
}
let expected = cached_pipette(ctx, native_scale(ctx), false).image;
out.cursor_icon == CursorIcon::Crosshair && expected.is_some() && out.cursor_image == expected
}
pub(crate) fn outline(painter: &Painter, at: Pos2, rings: Vec<Vec<Vec2>>, centre: bool) -> CursorIcon { pub(crate) fn outline(painter: &Painter, at: Pos2, rings: Vec<Vec<Vec2>>, centre: bool) -> CursorIcon {
show(painter, at, Shape::Outline { rings: rings.into(), centre }) show(painter, at, Shape::Outline { rings: rings.into(), centre })
} }
+15 -12
View File
@@ -74,6 +74,11 @@ fn fp(h: &Harness<'_, PhotocraftApp>) -> CursorFp {
} }
} }
/// The eyedropper's pipette: the OS bitmap where one uploads, else drawn (#12523).
fn pipette_shown(h: &Harness<'_, PhotocraftApp>) -> bool {
crate::tool_cursor::pipette_shown(&h.ctx, &h.output().platform_output)
}
fn painting(h: &mut Harness<'_, PhotocraftApp>, value: &str) { fn painting(h: &mut Harness<'_, PhotocraftApp>, value: &str) {
h.state_mut().run("prefs.set", json!({"path": "cursors.painting", "value": value})).unwrap(); h.state_mut().run("prefs.set", json!({"path": "cursors.painting", "value": value})).unwrap();
h.run_steps(2); h.run_steps(2);
@@ -204,13 +209,12 @@ fn caps_lock_gives_the_curves_eyedroppers_the_precise_crosshair() {
h.run_steps(3); h.run_steps(3);
other(&mut h, "standard"); other(&mut h, "standard");
let standard = fp(&h); let standard = fp(&h);
assert_eq!(standard.icon, CursorIcon::None, "the drawn pipette, not the Move tool's arrow over it"); assert!(pipette_shown(&h), "the pipette, not the Move tool's arrow over it");
other(&mut h, "precise"); other(&mut h, "precise");
let precise = fp(&h); let precise = fp(&h);
assert_eq!(precise.icon, CursorIcon::Crosshair, "Precise: the crosshair"); assert_eq!(precise.icon, CursorIcon::Crosshair, "Precise: the crosshair");
// CodeRabbit on #10406: the pipette is painted, not only the icon hidden. // CodeRabbit on #10406: the pipette is shown (drawn, or the OS bitmap), not only the icon hidden.
assert_ne!(standard.shapes, precise.shapes, "Standard paints a cursor of its own where Precise shows the crosshair"); assert_ne!(standard, precise, "Standard shows a cursor of its own where Precise shows the crosshair");
assert_ne!(standard, precise, "Standard: the pipette");
other(&mut h, "standard"); other(&mut h, "standard");
caps(&mut h, true); caps(&mut h, true);
assert_eq!(fp(&h), precise, "caps lock turns the pipette into the precise crosshair"); assert_eq!(fp(&h), precise, "caps lock turns the pipette into the precise crosshair");
@@ -232,12 +236,12 @@ fn caps_lock_gives_the_properties_eyedroppers_the_precise_crosshair() {
h.run_steps(3); h.run_steps(3);
other(&mut h, "standard"); other(&mut h, "standard");
let standard = fp(&h); let standard = fp(&h);
assert_eq!(standard.icon, CursorIcon::None, "the drawn pipette, not the Move tool's arrow over it"); assert!(pipette_shown(&h), "the pipette, not the Move tool's arrow over it");
other(&mut h, "precise"); other(&mut h, "precise");
let precise = fp(&h); let precise = fp(&h);
assert_eq!(precise.icon, CursorIcon::Crosshair, "Precise: the crosshair"); assert_eq!(precise.icon, CursorIcon::Crosshair, "Precise: the crosshair");
// CodeRabbit on #10406: the pipette is painted, not only the icon hidden. // CodeRabbit on #10406: the pipette is shown (drawn, or the OS bitmap), not only the icon hidden.
assert_ne!(standard.shapes, precise.shapes, "Standard paints a cursor of its own where Precise shows the crosshair"); assert_ne!(standard, precise, "Standard shows a cursor of its own where Precise shows the crosshair");
other(&mut h, "standard"); other(&mut h, "standard");
caps(&mut h, true); caps(&mut h, true);
assert_eq!(fp(&h), precise, "caps lock turns the pipette into the precise crosshair"); assert_eq!(fp(&h), precise, "caps lock turns the pipette into the precise crosshair");
@@ -257,13 +261,12 @@ fn caps_lock_gives_the_color_pickers_eyedropper_the_precise_crosshair() {
h.run_steps(3); h.run_steps(3);
other(&mut h, "standard"); other(&mut h, "standard");
let standard = fp(&h); let standard = fp(&h);
assert_eq!(standard.icon, CursorIcon::None, "the drawn pipette, not the Move tool's arrow over it"); assert!(pipette_shown(&h), "the pipette, not the Move tool's arrow over it");
other(&mut h, "precise"); other(&mut h, "precise");
let precise = fp(&h); let precise = fp(&h);
assert_eq!(precise.icon, CursorIcon::Crosshair, "Precise: the crosshair"); assert_eq!(precise.icon, CursorIcon::Crosshair, "Precise: the crosshair");
// CodeRabbit on #10406: the pipette is painted, not only the icon hidden. // CodeRabbit on #10406: the pipette is shown (drawn, or the OS bitmap), not only the icon hidden.
assert_ne!(standard.shapes, precise.shapes, "Standard paints a cursor of its own where Precise shows the crosshair"); assert_ne!(standard, precise, "Standard shows a cursor of its own where Precise shows the crosshair");
assert_ne!(standard, precise);
other(&mut h, "standard"); other(&mut h, "standard");
caps(&mut h, true); caps(&mut h, true);
assert_eq!(fp(&h), precise, "caps lock turns the pipette into the precise crosshair"); assert_eq!(fp(&h), precise, "caps lock turns the pipette into the precise crosshair");
@@ -283,7 +286,7 @@ fn a_lent_hand_shows_its_cursor_over_an_eyedropper_when_it_is_also_selected() {
assert!(crate::color_picker_ui::top(h.state()).is_some(), "the Color Picker owns the image"); assert!(crate::color_picker_ui::top(h.state()).is_some(), "the Color Picker owns the image");
other(&mut h, "standard"); other(&mut h, "standard");
let pipette = fp(&h); let pipette = fp(&h);
assert_eq!(pipette.icon, CursorIcon::None, "the eyedropper's drawn pipette"); assert!(pipette_shown(&h), "the eyedropper's pipette");
let p = h.state().last_canvas_rect.center(); let p = h.state().last_canvas_rect.center();
let middle = |pressed| egui::Event::PointerButton { pos: p, button: egui::PointerButton::Middle, pressed, modifiers: egui::Modifiers::NONE }; let middle = |pressed| egui::Event::PointerButton { pos: p, button: egui::PointerButton::Middle, pressed, modifiers: egui::Modifiers::NONE };
h.event(middle(true)); h.event(middle(true));
+2 -3
View File
@@ -54,10 +54,9 @@ fn hover(h: &mut Harness<'static, PhotocraftApp>, m: Modifiers) {
h.run_steps(2); h.run_steps(2);
} }
/// The pipette is drawn in its own tooltip-layer area. /// The Eyedropper's pipette: the OS bitmap where one uploads, else drawn (#12523).
fn pipette_shown(h: &Harness<'static, PhotocraftApp>) -> bool { fn pipette_shown(h: &Harness<'static, PhotocraftApp>) -> bool {
let layer = egui::LayerId::new(egui::Order::Tooltip, egui::Id::unique("pc-icon-cursor")); crate::tool_cursor::pipette_shown(&h.ctx, &h.output().platform_output)
h.ctx.memory(|memory| memory.areas().visible_layer_ids().contains(&layer))
} }
/// The OS cursor bitmap's size, hotspot and alpha channel. /// The OS cursor bitmap's size, hotspot and alpha channel.