From 51549175cd3cbbe28f4fe57763c1e54ecc67b10e Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 23:04:13 +0700 Subject: [PATCH] Give nine trials the frames their behaviour needs now that a frame runs its UI once --- crates/ui-egui/src/canvas/tests.rs | 16 ++++++++++++---- .../ui-egui/src/dialogs/tests_print_presets.rs | 2 ++ crates/ui-egui/src/shortcuts/held_tool/tests.rs | 2 ++ crates/ui-egui/src/shortcuts/tests.rs | 4 +++- crates/ui-egui/src/tests/nativemenu.rs | 4 +++- crates/ui-egui/src/tests/selectall.rs | 7 ++++--- 6 files changed, 26 insertions(+), 9 deletions(-) diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index 6116b95e91..ebd07025fc 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -2904,9 +2904,11 @@ fn double_clicking_type_with_the_selection_tool_puts_the_caret_there() { let at = xf.to_screen(b.center()); let button = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; timed(&mut app, 1.0, vec![egui::Event::PointerMoved(at), button(true), button(false), button(true), button(false)]); - // The framework holds a frame's second press for the next pass. + // The framework holds a frame's second press for the next frame; the double-click it completes hands the text + // to the Type tool two frames after that. timed(&mut app, 1.05, vec![]); timed(&mut app, 1.1, vec![]); + timed(&mut app, 1.15, vec![]); // The Type tool edits the text, with the caret inside it, where it was clicked: typing goes // into the text, not to tool shortcuts (X would swap fill and stroke). assert_eq!(app.session.tool_id(), "type"); @@ -3047,9 +3049,11 @@ fn double_clicking_type_with_the_direct_selection_tool_puts_the_caret_there() { let at = xf.to_screen(b.center()); let button = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; timed(&mut app, 1.0, vec![egui::Event::PointerMoved(at), button(true), button(false), button(true), button(false)]); - // The framework holds a frame's second press for the next pass. + // The framework holds a frame's second press for the next frame; the double-click it completes hands the text + // to the Type tool two frames after that. timed(&mut app, 1.05, vec![]); timed(&mut app, 1.1, vec![]); + timed(&mut app, 1.15, vec![]); // The Type tool edits the text, with the caret inside it, where it was clicked: typing goes // into the text, not to tool shortcuts. assert_eq!(app.session.tool_id(), "type"); @@ -3107,9 +3111,11 @@ fn double_clicking_type_in_a_missing_font_asks_before_editing() { let button = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; let double_click = |app: &mut VectorcraftApp, time: f64| { timed(app, time, vec![egui::Event::PointerMoved(at), button(true), button(false), button(true), button(false)]); - // The framework holds a frame's second press for the next pass. + // The framework holds a frame's second press for the next frame; the double-click it completes asks two + // frames after that. timed(app, time + 0.05, vec![]); timed(app, time + 0.1, vec![]); + timed(app, time + 0.15, vec![]); }; let asking = |app: &VectorcraftApp| app.dialogs().unwrap().with(|h| h.is_open::()); double_click(&mut app, 1.0); @@ -3209,9 +3215,11 @@ fn escape_while_editing_in_isolation_returns_to_selection_tool_and_keeps_isolati // 1st double-click on group enters isolation mode. timed(&mut app, 1.0, vec![egui::Event::PointerMoved(at), button(true), button(false), button(true), button(false)]); - // The framework holds a frame's second press for the next pass. + // The framework holds a frame's second press for the next frame; the double-click it completes isolates the group + // two frames after that. timed(&mut app, 1.05, vec![]); timed(&mut app, 1.1, vec![]); + timed(&mut app, 1.15, vec![]); assert!(app.session.active().unwrap().isolation.is_some(), "should be in isolation mode"); assert_eq!(app.session.tool_id(), "selection"); diff --git a/crates/ui-egui/src/dialogs/tests_print_presets.rs b/crates/ui-egui/src/dialogs/tests_print_presets.rs index 61c02b6d01..65f4d2217f 100644 --- a/crates/ui-egui/src/dialogs/tests_print_presets.rs +++ b/crates/ui-egui/src/dialogs/tests_print_presets.rs @@ -36,6 +36,8 @@ fn the_print_dialog_saves_and_loads_presets() { set(&mut app, "copies", json!(4)); set(&mut app, "media", json!("a4")); super::tests_print::press(&mut app, "New…"); + // The name field takes the keyboard in the frame after the press. + pump(&mut app); call(&mut app, "ui.text", json!({"text": "Proofs"})); call(&mut app, "ui.key", json!({"key": "Enter"})); pump(&mut app); diff --git a/crates/ui-egui/src/shortcuts/held_tool/tests.rs b/crates/ui-egui/src/shortcuts/held_tool/tests.rs index 58e7f55a5b..17fea6dfd4 100644 --- a/crates/ui-egui/src/shortcuts/held_tool/tests.rs +++ b/crates/ui-egui/src/shortcuts/held_tool/tests.rs @@ -78,7 +78,9 @@ fn a_tool_key_let_go_behind_the_update_prompt_returns_after_it() { keys.release_s(&mut app, 1.0); assert_eq!(app.session.tool_id(), "scale", "Scale stays behind the prompt"); crate::updates_ui::close_dialogs_for_test(&mut app); + // The prompt's layer is gone in the first frame after it closes, and the held tool returns in the next. keys.frame(&mut app, 1.1, vec![]); + keys.frame(&mut app, 1.15, vec![]); assert_eq!(app.session.tool_id(), "pen", "the Pen is back after the prompt"); } diff --git a/crates/ui-egui/src/shortcuts/tests.rs b/crates/ui-egui/src/shortcuts/tests.rs index 0f302c1551..3958ae2e0d 100644 --- a/crates/ui-egui/src/shortcuts/tests.rs +++ b/crates/ui-egui/src/shortcuts/tests.rs @@ -1482,9 +1482,11 @@ fn enter_opens_the_tools_dialog_and_leaves_it_open() { key_frame(&mut app, &ctx, vec![]); assert_eq!(dialog_kind(&app).as_deref(), Some(dialog), "{tool}: and it stays open"); assert_eq!(steps(&app), before, "{tool}: the Enter that opened it didn't confirm it"); - // With its default values only Reflect changes the art. A held OK closes its dialog on the window's next pass. + // With its default values only Reflect changes the art. A held OK closes its dialog on the window's next pass, + // and its field gives up the keyboard in the frame after that. key_frame(&mut app, &ctx, enter()); key_frame(&mut app, &ctx, vec![]); + key_frame(&mut app, &ctx, vec![]); let after = (before.0 + usize::from(dialog == "object.reflect"), before.1 + 1); assert_eq!((dialog_kind(&app), steps(&app)), (None, after), "{tool}: Enter confirms"); } diff --git a/crates/ui-egui/src/tests/nativemenu.rs b/crates/ui-egui/src/tests/nativemenu.rs index 40497b426c..27dd215565 100644 --- a/crates/ui-egui/src/tests/nativemenu.rs +++ b/crates/ui-egui/src/tests/nativemenu.rs @@ -315,7 +315,9 @@ fn applying_a_dialog_preview_reads_the_menus() { let read = m.angles(4); let synced = m.fake.synced(); crate::tests_synthetic::control(&mut m.app, &m.ctx, "ui.dialog.confirm", json!({})); - // OK applies in the dialog's pass, and its layer is gone from the next one. + // The OK enters the next frame's pass and applies there; the dialog's layer and the preview's interaction are + // gone two frames later. + m.frame(vec![]); m.frame(vec![]); m.frame(vec![]); (read, synced, !m.app.session.in_interaction() && !m.app.any_dialog_open(), m.fake.synced()) diff --git a/crates/ui-egui/src/tests/selectall.rs b/crates/ui-egui/src/tests/selectall.rs index ee7922c0fd..9c20603db8 100644 --- a/crates/ui-egui/src/tests/selectall.rs +++ b/crates/ui-egui/src/tests/selectall.rs @@ -478,11 +478,12 @@ fn panel_text_copied_before_the_art_formats_are_written_stays_on_the_clipboard() a.focused = false; let copy = a.menu(id); a.focused = true; - copy + // A fired command reaches the field in the next pass. + [copied(©), copied(&a.frame(vec![]))].concat() } else { - clipboard_chord(&mut a, event).0 + copied(&clipboard_chord(&mut a, event).0) }; - assert_eq!(copied(©), [length], "{id} copies the selected value (menu: {menu})"); + assert_eq!(copy, [length], "{id} copies the selected value (menu: {menu})"); assert_eq!(a.selected(), 1, "{id} leaves the art (menu: {menu})"); drop(hold); crate::background::wait_all(&mut a.app);