mirror of
https://github.com/storytold/effectcraft.git
synced 2026-11-27 01:08:33 +00:00
Tests send one press per step as next's runtime takes them; tab overflow cases follow next's clipping
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<u64> = 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 = {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user