Give nine trials the frames their behaviour needs now that a frame runs its UI once

This commit is contained in:
bflatastic
2026-11-24 23:04:13 +07:00
parent ad9e45e7d3
commit 51549175cd
6 changed files with 26 additions and 9 deletions
+12 -4
View File
@@ -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::<crate::dialogs::confirm::MissingFontQuestion>());
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");
@@ -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);
@@ -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");
}
+3 -1
View File
@@ -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");
}
+3 -1
View File
@@ -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())
+4 -3
View File
@@ -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(&copy), copied(&a.frame(vec![]))].concat()
} else {
clipboard_chord(&mut a, event).0
copied(&clipboard_chord(&mut a, event).0)
};
assert_eq!(copied(&copy), [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);