From 71acb4c47e546bc47bb1918fce756041f256b97d Mon Sep 17 00:00:00 2001 From: David Mann Date: Sun, 8 Nov 2026 18:51:36 +0100 Subject: [PATCH] native menu: test that an imported .kys set owns the system keys it binds (#7809) Review on #7809 asked for coverage of imported .kys bindings. The set moves Cmd+M to Levels and gives Fill Cmd+, as its second key; the menu bar shows Cmd+M on Levels only, Minimize keeps Ctrl+Cmd+M, Settings yields Cmd+, and the clash is reported. Fails without app_layout's dispatch ownership pass. Co-Authored-By: andeecollard <6765611+andeecollard@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/menus/native_menu/tests.rs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/crates/ui-egui/src/menus/native_menu/tests.rs b/crates/ui-egui/src/menus/native_menu/tests.rs index b1da625ca8..ff635b8a24 100644 --- a/crates/ui-egui/src/menus/native_menu/tests.rs +++ b/crates/ui-egui/src/menus/native_menu/tests.rs @@ -170,6 +170,41 @@ fn photoshop_defaults_hold_on_every_platform() { assert_eq!(l.bar.find("edit.preferences.general").unwrap().shortcut.as_deref(), Some("Cmd+K")); } +/// A Photoshop `.kys` set imported through Edit › Keyboard Shortcuts moves ⌘M to Levels and gives +/// Fill ⌘, as its second key: each key runs the imported command, so ⌘M shows on Levels only, +/// Minimize keeps ⌃⌘M, and Settings drops ⌘, though Fill's row shows its first key. The set's +/// Hide Photoshop row is not ours and changes nothing. +#[test] +fn an_imported_kys_set_owns_the_system_keys_it_binds() { + const SET: &str = "\u{feff} + +\tCmd+M +\tShift+F5Cmd+, +\tCmd+H + +"; + let mut a = app(true); + let r = a.session.execute("edit.keyboardShortcuts", json!({"importKys": SET})).unwrap(); + assert_eq!(r["import"]["unknown"], json!(["Hide Photoshop"]), "{r}"); + let keys = crate::shortcut_dispatch::bindings(&a); + let owner = |key: &str| keys.iter().find(|(_, sc)| Some(*sc) == crate::shortcuts::parse(key)).map(|(id, _)| id.clone()); + assert_eq!(owner("Cmd+M").as_deref(), Some("image.adjustments.levels")); + let fill = owner("Cmd+,").unwrap(); + assert_eq!(fill, "edit.fill"); + let l = app_layout(&a, &crate::menus::menu_items(&a), Lang::EN, "auto"); + let showing = |key: &str| -> Vec { + let parsed = crate::shortcuts::parse(key); + l.bar.items().into_iter().filter(|it| it.shortcut.as_deref().and_then(crate::shortcuts::parse) == parsed).map(|it| it.id.clone()).collect() + }; + assert_eq!(showing("Cmd+M"), ["image.adjustments.levels"]); + assert!(showing("Cmd+,").is_empty(), "{:?}", showing("Cmd+,")); + assert_eq!(l.bar.find(&fill).unwrap().shortcut.as_deref(), Some("Shift+F5")); + assert_eq!(l.bar.find(MINIMIZE).unwrap().shortcut.as_deref(), Some("Ctrl+Cmd+M")); + assert_eq!(l.bar.find(HIDE).unwrap().shortcut.as_deref(), Some("Ctrl+Cmd+H")); + assert_eq!(showing("Cmd+H"), ["view.extras"], "Hide Photoshop was not imported"); + assert!(l.clashes.iter().any(|c| c.shortcut == "Cmd+," && c.command == fill)); +} + /// Themes and the appearance-mode cycle move from Window to the app menu's Appearance. #[test] fn themes_move_to_the_app_menus_appearance() {