From 80d5e41d6db97be986528f3d49c91de49a93a05d Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 21:21:51 +0000 Subject: [PATCH] Tests send one press per step as next's runtime takes them; tab overflow cases follow next's clipping --- crates/ui-egui/tests/it/ui_agent_audit.rs | 6 +++- crates/ui-egui/tests/it/ui_inline_edit.rs | 11 +++++-- crates/ui-egui/tests/it/ui_panel_focus.rs | 8 +++-- crates/ui-egui/tests/it/ui_panels.rs | 5 +++ crates/ui-egui/tests/it/ui_tabs.rs | 37 +++++++++++++++-------- crates/ui-egui/tests/it/ui_tail.rs | 2 ++ crates/ui-egui/tests/it/ui_viewer.rs | 4 +++ crates/ui-egui/tests/it/ui_viewers.rs | 6 +++- 8 files changed, 60 insertions(+), 19 deletions(-) diff --git a/crates/ui-egui/tests/it/ui_agent_audit.rs b/crates/ui-egui/tests/it/ui_agent_audit.rs index 325cf1331..56b887bca 100644 --- a/crates/ui-egui/tests/it/ui_agent_audit.rs +++ b/crates/ui-egui/tests/it/ui_agent_audit.rs @@ -173,7 +173,11 @@ fn every_panel_registers_automation_ids_for_its_widgets() { // DIAG: the accessibility nodes at the gap. { use egui_kittest::kittest::{By, NodeT, Queryable}; - for node in h.query_all(By::new().predicate(|_| true)).filter(|n| n.rect().contains(r.center()) && n.rect().width() < 200.0) { + for node in h + .query_all(By::new().predicate(|_| true)) + .filter(|n| n.accesskit_node().bounding_box().is_some()) + .filter(|n| n.rect().contains(r.center()) && n.rect().width() < 200.0) + { eprintln!("DIAG gap node {:?} {:?} {:?}", node.accesskit_node().role(), node.accesskit_node().label(), node.rect()); } } diff --git a/crates/ui-egui/tests/it/ui_inline_edit.rs b/crates/ui-egui/tests/it/ui_inline_edit.rs index eef6b3687..4c3e3b27c 100644 --- a/crates/ui-egui/tests/it/ui_inline_edit.rs +++ b/crates/ui-egui/tests/it/ui_inline_edit.rs @@ -31,10 +31,13 @@ fn center(h: &Harness<'_, EffectcraftApp>, id: &str) -> Pos2 { fn click(h: &mut Harness<'_, EffectcraftApp>, p: Pos2, times: usize) { h.input_mut().events.push(Event::PointerMoved(p)); h.step(); - // All in one frame (the harness' frames are longer apart than a double-click). + // One press per step, as the runtime takes them: the releases are one step (0.25 s) apart, + // within egui's double-click interval (0.3 s). + let button = |pressed| Event::PointerButton { pos: p, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE }; for _ in 0..times { - h.input_mut().events.push(Event::PointerButton { pos: p, button: PointerButton::Primary, pressed: true, modifiers: Modifiers::NONE }); - h.input_mut().events.push(Event::PointerButton { pos: p, button: PointerButton::Primary, pressed: false, modifiers: Modifiers::NONE }); + h.input_mut().events.push(button(true)); + h.step(); + h.input_mut().events.push(button(false)); } h.run_steps(3); } @@ -501,7 +504,9 @@ fn click_with(h: &mut Harness<'_, EffectcraftApp>, p: Pos2, modifiers: Modifiers h.input_mut().events.push(Event::PointerMoved(p)); h.input_mut().events.push(Event::ModifiersChanged(modifiers)); h.step(); + // One press per step: the release comes a step later, still with the modifiers held. h.input_mut().events.push(Event::PointerButton { pos: p, button: PointerButton::Primary, pressed: true, modifiers }); + h.step(); h.input_mut().events.push(Event::PointerButton { pos: p, button: PointerButton::Primary, pressed: false, modifiers }); h.step(); h.input_mut().events.push(Event::ModifiersChanged(Modifiers::NONE)); diff --git a/crates/ui-egui/tests/it/ui_panel_focus.rs b/crates/ui-egui/tests/it/ui_panel_focus.rs index 81a43d0c9..ce054d84a 100644 --- a/crates/ui-egui/tests/it/ui_panel_focus.rs +++ b/crates/ui-egui/tests/it/ui_panel_focus.rs @@ -38,9 +38,13 @@ fn rect(h: &Harness<'_, EffectcraftApp>, id: &str) -> egui::Rect { fn click_n(h: &mut Harness<'_, EffectcraftApp>, p: Pos2, n: u32) { h.event(Event::PointerMoved(p)); h.step(); + // One press per step, as the runtime takes them: the releases are one step (0.25 s) apart, + // within egui's double-click interval (0.3 s). + let button = |pressed| Event::PointerButton { pos: p, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; for _ in 0..n { - h.input_mut().events.push(Event::PointerButton { pos: p, button: egui::PointerButton::Primary, pressed: true, modifiers: Default::default() }); - h.input_mut().events.push(Event::PointerButton { pos: p, button: egui::PointerButton::Primary, pressed: false, modifiers: Default::default() }); + h.input_mut().events.push(button(true)); + h.step(); + h.input_mut().events.push(button(false)); } h.step(); h.run_steps(2); diff --git a/crates/ui-egui/tests/it/ui_panels.rs b/crates/ui-egui/tests/it/ui_panels.rs index c265e2ab7..48456a5d8 100644 --- a/crates/ui-egui/tests/it/ui_panels.rs +++ b/crates/ui-egui/tests/it/ui_panels.rs @@ -151,8 +151,13 @@ fn click_at(h: &mut Harness<'_, EffectcraftApp>, p: Pos2) { fn double_click_at(h: &mut Harness<'_, EffectcraftApp>, pos: Pos2) { h.input_mut().events.push(Event::PointerMoved(pos)); h.step(); + // One press per step, as the runtime takes them: the releases are one step (0.25 s) apart, + // within egui's double-click interval (0.3 s). for pressed in [true, false, true, false] { h.input_mut().events.push(Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }); + if pressed { + h.step(); + } } h.run_steps(3); } diff --git a/crates/ui-egui/tests/it/ui_tabs.rs b/crates/ui-egui/tests/it/ui_tabs.rs index 5829ceb4f..6914f3be2 100644 --- a/crates/ui-egui/tests/it/ui_tabs.rs +++ b/crates/ui-egui/tests/it/ui_tabs.rs @@ -420,13 +420,23 @@ fn a_tab_dropped_on_a_frame_joins_it() { assert!(group.starts_with(&[PanelKind::Properties]) && group.contains(&PanelKind::EffectControls), "{group:?}"); assert!(dock(&h).is_visible(PanelKind::EffectControls) && !dock(&h).is_visible(PanelKind::Properties)); assert!(dock(&h).is_visible(PanelKind::Preview)); - // DIAG: the right column's chrome after the drop. - for e in h.state().auto.elements.iter().filter(|e| e.id.starts_with("panel.tab") || e.id.starts_with("panel.drag") || e.id.starts_with("panel.menu")) { - eprintln!("DIAG {} {:?}", e.id, e.rect); + // The frame's other tab shows Properties again, the frame stays open. The right column is + // narrow: the active tab keeps its whole title and a tab with no room for its first letters + // is in the » menu. + if has(&h, "panel.tab.Properties") { + let tab = rect(&h, "panel.tab.Properties"); + click_n(&mut h, tab.center(), 1); + } else { + use egui_kittest::kittest::{NodeT, Queryable}; + let more = h.query_all_by_label("More tabs").map(|node| node.rect()).find(|r| props.x_range().contains(r.center().x)).expect("the frame's » menu"); + click_n(&mut h, more.center(), 1); + let item = h + .query_all_by_label("Properties") + .find(|node| node.accesskit_node().role() == egui::accesskit::Role::MenuItem) + .expect("Properties in the » menu") + .rect(); + click_n(&mut h, item.center(), 1); } - // The frame's other tab shows Properties again, the frame stays open. - let tab = rect(&h, "panel.tab.Properties"); - click_n(&mut h, tab.center(), 1); assert!(dock(&h).is_visible(PanelKind::Properties) && !dock(&h).is_visible(PanelKind::EffectControls)); // The layout (saved workspaces) round-trips. let s = serde_json::to_string(&dock(&h)).unwrap(); @@ -459,12 +469,12 @@ fn open_comps_are_tabs_in_the_timeline_row_and_the_rest_are_in_its_overflow_menu h.run_steps(3); h.state_mut().session.state.open_comps = comps.iter().map(|c| ItemId(*c)).collect(); h.run_steps(3); - // The comp tabs follow the panel tabs in the same row, in order (tabs that do not fit clip to - // their first letters). - let (tl, rq) = (rect(&h, "panel.tab.Timeline"), rect(&h, "panel.tab.RenderQueue")); + // The comp tabs follow the Timeline's tab in the same row, in order (tabs that do not fit clip + // to their first letters; a panel tab with no room for them is in the » menu too). + let tl = rect(&h, "panel.tab.Timeline"); let shown: Vec = comps.iter().copied().filter(|c| has(&h, &format!("panel.tab.Timeline.{c}"))).collect(); assert!(shown.contains(&comps[0]) && shown.len() < comps.len(), "{shown:?}"); - let mut x = rq.max.x; + let mut x = tl.max.x; for c in &shown { let tab = rect(&h, &format!("panel.tab.Timeline.{c}")); assert!(tl.y_range().contains(tab.center().y) && tab.min.x >= x - 0.5, "comp {c} at {tab:?} after x {x}"); @@ -472,8 +482,11 @@ fn open_comps_are_tabs_in_the_timeline_row_and_the_rest_are_in_its_overflow_menu } // A comp with no room is in the » menu; picking it shows it, and its tab joins the row. let hidden = comps.iter().copied().find(|c| !shown.contains(c)).unwrap(); - let more = named(&h, "More tabs"); - assert!(more.min.x >= x - 0.5 && tl.y_range().contains(more.center().y), "{more:?}"); + let more = { + use egui_kittest::kittest::{NodeT, Queryable}; + h.query_all_by_label("More tabs").map(|node| node.rect()).find(|r| tl.y_range().contains(r.center().y)).expect("the Timeline row's » menu") + }; + assert!(more.min.x >= x - 0.5, "{more:?}"); click_n(&mut h, more.center(), 1); let name = names[comps.iter().position(|c| *c == hidden).unwrap()]; let item = { diff --git a/crates/ui-egui/tests/it/ui_tail.rs b/crates/ui-egui/tests/it/ui_tail.rs index 5f429936a..54b4b4473 100644 --- a/crates/ui-egui/tests/it/ui_tail.rs +++ b/crates/ui-egui/tests/it/ui_tail.rs @@ -365,8 +365,10 @@ fn project_name_column_edge_resizes_and_fits_again() { let edge = rect(&h, "project.nameColumn.edge").center(); assert!((edge.x - (before.x + 80.0)).abs() < 2.0, "{edge:?} after dragging from {before:?}"); h.input_mut().events.push(Event::PointerMoved(edge)); + // A double-click, one press per step as the runtime takes them. for _ in 0..2 { h.input_mut().events.push(Event::PointerButton { pos: edge, button: egui::PointerButton::Primary, pressed: true, modifiers: Default::default() }); + h.step(); h.input_mut().events.push(Event::PointerButton { pos: edge, button: egui::PointerButton::Primary, pressed: false, modifiers: Default::default() }); } h.run_steps(3); diff --git a/crates/ui-egui/tests/it/ui_viewer.rs b/crates/ui-egui/tests/it/ui_viewer.rs index e6c53fee9..fa896812d 100644 --- a/crates/ui-egui/tests/it/ui_viewer.rs +++ b/crates/ui-egui/tests/it/ui_viewer.rs @@ -1346,8 +1346,12 @@ fn pen_mask_undoes_step_by_step_and_double_click_moves_the_whole_mask() { let at = screen(&h, [100.0, 300.0]); h.input_mut().events.push(Event::PointerMoved(at)); h.step(); + // One press per step, as the runtime takes them. for pressed in [true, false, true, false] { h.input_mut().events.push(Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }); + if pressed { + h.step(); + } } h.run_steps(3); assert_eq!(h.state().session.state.selected_vertices.len(), 4); diff --git a/crates/ui-egui/tests/it/ui_viewers.rs b/crates/ui-egui/tests/it/ui_viewers.rs index 038b0884e..ff3dcedfd 100644 --- a/crates/ui-egui/tests/it/ui_viewers.rs +++ b/crates/ui-egui/tests/it/ui_viewers.rs @@ -42,11 +42,15 @@ fn click(h: &mut Harness<'_, EffectcraftApp>, id: &str) { h.run_steps(3); } -/// Double-click element `id` (in one frame: the harness' frame time is longer than a double-click's). +/// Double-click element `id`, one press per step as the runtime takes them: the releases are one +/// step (0.25 s) apart, within egui's double-click interval (0.3 s). fn double_click(h: &mut Harness<'_, EffectcraftApp>, id: &str) { let p = hover(h, id); for pressed in [true, false, true, false] { button(h, p, pressed); + if pressed { + h.step(); + } } h.run_steps(3); }