diff --git a/crates/ui-egui/src/tests.rs b/crates/ui-egui/src/tests.rs index dec6c0e58..45a43a7e6 100644 --- a/crates/ui-egui/src/tests.rs +++ b/crates/ui-egui/src/tests.rs @@ -1410,9 +1410,13 @@ fn input_target_changes_retract_a_queued_click() { let target = h.state().input_target(&ctx); let slide = h.state().slide_rect().unwrap(); let point = slide.min + slide.size() * 0.8; + // The window holds real input until the injected batch has run, so the arrow's press goes ahead of the click. + // The pointer rests on the arrow until the row has moved: a click whose first step ran is delivered whole. if case == "scroll" { let arrow = ribbon_arrow(&h); - WindowHost::of(&ctx).inject_move(egui::ViewportId::ROOT, arrow, craft::keymap::Mods::default(), 0.0); + let host = WindowHost::of(&ctx); + host.inject_click(egui::ViewportId::ROOT, arrow, craft::behavior::PointerButton::Primary, 1, craft::keymap::Mods::default(), false); + host.inject_move(egui::ViewportId::ROOT, arrow, craft::keymap::Mods::default(), 0.25); } WindowHost::of(&ctx).inject_click( egui::ViewportId::ROOT, @@ -1444,18 +1448,8 @@ fn input_target_changes_retract_a_queued_click() { "collapse" => h.state_mut().ui.ribbon_collapsed = true, "scroll" => { let before = crate::ribbon::scroll_position(h.state(), &ctx); - let at = ribbon_arrow(&h); - h.input_mut().events.push(egui::Event::PointerMoved(at)); - for pressed in [true, false] { - h.input_mut().events.push(egui::Event::PointerButton { - pos: at, - button: egui::PointerButton::Primary, - pressed, - modifiers: egui::Modifiers::NONE, - }); - } - // The press waits behind the injected batch, so the row may move a frame later. - for _ in 0..4 { + // The arrow's injected move, press and release each take a pass of their own. + for _ in 0..6 { h.run_steps(1); if crate::ribbon::scroll_position(h.state(), &ctx) != before { break;