diff --git a/crates/ui-contract/src/runtime/egui/injected.rs b/crates/ui-contract/src/runtime/egui/injected.rs index f852748e2..1702d345e 100644 --- a/crates/ui-contract/src/runtime/egui/injected.rs +++ b/crates/ui-contract/src/runtime/egui/injected.rs @@ -62,28 +62,14 @@ pub(crate) fn text_event(text: &str) -> Event { Event::Text(text.to_owned()) } -/// The announcement of `modifiers`, none when no modifier is held. -#[cfg(feature = "testing")] -fn announced(modifiers: Modifiers) -> Option { - (modifiers != Modifiers::NONE).then(|| modifiers_changed(modifiers)) -} - -/// The frame that clears `modifiers`, none when none was held. -#[cfg(feature = "testing")] -fn cleared(modifiers: Modifiers) -> Option { - announced(modifiers).map(|_| vec![modifiers_changed(Modifiers::NONE)]) -} - -/// A move to `pos` (with `modifiers` announced first), then `count` times a press and a release of `button`, one -/// frame each; `modifiers` are cleared in a last frame when they were set. +/// A move to `pos`, then `count` times a press and a release of `button` carrying the held `modifiers`, one frame each. #[cfg(feature = "testing")] pub(crate) fn click_frames(pos: Pos2, pressed_button: egui::PointerButton, count: u32, modifiers: Modifiers) -> Vec { - let mut frames = vec![announced(modifiers).into_iter().chain([pointer_moved(pos)]).collect()]; + let mut frames = vec![vec![pointer_moved(pos)]]; for _ in 0..count { frames.push(vec![button(pos, pressed_button, true, modifiers)]); frames.push(vec![button(pos, pressed_button, false, modifiers)]); } - frames.extend(cleared(modifiers)); frames } diff --git a/crates/ui-contract/src/testing/fixture.rs b/crates/ui-contract/src/testing/fixture.rs index 78d04e2e2..e531e8958 100644 --- a/crates/ui-contract/src/testing/fixture.rs +++ b/crates/ui-contract/src/testing/fixture.rs @@ -655,9 +655,10 @@ impl Fixture { self.click_at(target.center()) } - /// Hover, press and release at `pos`, in separate frames, then one idle frame. + /// Hover, press and release at `pos`, in separate frames, then one idle frame. The press and release carry the + /// modifiers [`Fixture::hold`] keeps. pub fn click_at(&mut self, pos: Pos2) -> &mut Self { - self.play(injected::click_frames(pos, egui::PointerButton::Primary, 1, Modifiers::NONE)); + self.play(injected::click_frames(pos, egui::PointerButton::Primary, 1, self.frames.held())); self.frame(Vec::new()) }