EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust
Menus: tests that hover switching leaves submenus, a disabled bar and the arrow keys alone (#1290)
tylerjenningsw8220d96929de
diff --git a/crates/ui-egui/tests/it/ui_menus.rs b/crates/ui-egui/tests/it/ui_menus.rsindex c76f7fafd..dd750e81b 100644--- a/crates/ui-egui/tests/it/ui_menus.rs+++ b/crates/ui-egui/tests/it/ui_menus.rs@@ -373,3 +373,48 @@ fn outside_presses_and_focus_loss_close_the_menus() {h.run_steps(2);assert!(!shown(&h, "Open Project"), "losing focus closes the menus");}++/// From an open submenu, the pointer reaching another title switches menus too (#1290).+#[test]+fn hovering_a_title_from_an_open_submenu_switches_menus() {+ let mut h = harness();+ let (file, edit) = (rect(&h, "menu.File"), rect(&h, "menu.Edit"));+ click_at(&mut h, file.center());+ let new = h.query_by(|n| n.label().is_some_and(|l| l.trim_end_matches('\u{23f5}').trim() == "New")).expect("File ▸ New").rect();+ move_to(&mut h, new.center());+ h.run_steps(5);+ assert!(shown(&h, "New Project from Template"), "the New submenu is open");+ move_to(&mut h, edit.center());+ assert!(shown(&h, "Keyboard Shortcuts"), "hovering Edit opened it");+ assert!(!shown(&h, "New Project from Template") && !shown(&h, "Open Project"), "and closed File and its submenu");+}++/// A title the pointer can't reach (the app is disabled under a dialog) doesn't switch menus+/// (#1290).+#[test]+fn a_disabled_title_does_not_switch_menus() {+ let mut h = harness();+ let (file, edit) = (rect(&h, "menu.File"), rect(&h, "menu.Edit"));+ click_at(&mut h, file.center());+ h.state_mut().dialog = Some(effectcraft_ui_egui::Dialog::About);+ h.run_steps(2);+ move_to(&mut h, edit.center());+ assert!(!shown(&h, "Keyboard Shortcuts"), "Edit didn't open");+}++/// A pointer resting on a title doesn't undo Left / Right: only a moving pointer switches+/// (#1290).+#[test]+fn a_resting_pointer_does_not_override_the_arrow_keys() {+ if cfg!(target_os = "macos") {+ // (Right / Left between menus are tested where the in-window bar is the app's menu.)+ return;+ }+ let mut h = harness();+ let file = rect(&h, "menu.File");+ click_at(&mut h, file.center());+ key(&mut h, Key::ArrowRight);+ h.run_steps(3);+ assert!(shown(&h, "Keyboard Shortcuts"), "Right opened Edit with the pointer still on File");+ assert!(!shown(&h, "Open Project"));+}