From 0928cafab2312e4a1f98620f638b3fbebec31bb5 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sat, 10 Oct 2026 00:36:14 +0700 Subject: [PATCH] Native menu test: judge idle frames while the global generations hold still key_equivalents_run_through_the_normal_shortcut_path_once failed about one full ui-egui run in four ("the menus weren't read again", 5 vs 4). Each app mirrors its shortcut overrides into a process-wide store every frame, bumping shortcut_editor::GENERATION, and the plug-in registry's revision is process-wide too. Tests running alongside with other shortcuts flip them, which rightly makes the menus read again. The test now checks two idle frames during which those generations held still (trying up to 50 times), so it still fails if idle frames re-read the menus on their own. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/tests_nativemenu.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/tests_nativemenu.rs b/crates/ui-egui/src/tests_nativemenu.rs index 9ffe2814..afcca1ad 100644 --- a/crates/ui-egui/src/tests_nativemenu.rs +++ b/crates/ui-egui/src/tests_nativemenu.rs @@ -348,11 +348,18 @@ fn key_equivalents_run_through_the_normal_shortcut_path_once() { let before = undo(&m); m.key_equivalent("Cmd+Z"); assert_eq!(undo(&m), before - 1, "⌘Z undid one step"); - let synced = m.fake.synced(); - assert!(synced >= 1, "the menus were built"); - m.frame(vec![]); - m.frame(vec![]); - assert_eq!(m.fake.synced(), synced, "nothing changed: the menus weren't read again"); + assert!(m.fake.synced() >= 1, "the menus were built"); + // Idle frames don't read the menus again. The shortcut and plug-in generations are + // process-wide, and tests running alongside with other shortcuts bump them (rightly reading + // the menus again), so judge two idle frames in which they held still. + let globals = || (crate::shortcut_editor::GENERATION.load(std::sync::atomic::Ordering::Relaxed), crate::menus::plugin_revision()); + let quiet = (0..50).any(|_| { + let (before, synced) = (globals(), m.fake.synced()); + m.frame(vec![]); + m.frame(vec![]); + globals() == before && m.fake.synced() == synced + }); + assert!(quiet, "nothing changed: the menus weren't read again"); assert_eq!(crate::control::inspect(&m.app, &m.ctx)["nativeMenuBar"], json!(true)); }