From eb8ac21edaeeca4d3eae7fe0e0fe7b7ed51408a0 Mon Sep 17 00:00:00 2001 From: aiongg Date: Fri, 20 Nov 2026 04:33:13 +0000 Subject: [PATCH] tests: a label change runs its tab row once; a reveal measures again the rows the lead moves between The tab row measures the new label before it places its tabs, so the frame runs one pass and no discard pass runs the row again. A row whose measured state the pass changes after step 5 measured it is measured again with its new state. --- crates/layers/tests/it/panel_reveal.rs | 11 +++++++++-- crates/ui-patterns/tests/it/docking/runs.rs | 14 ++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/crates/layers/tests/it/panel_reveal.rs b/crates/layers/tests/it/panel_reveal.rs index ff8f90525..59d691d35 100644 --- a/crates/layers/tests/it/panel_reveal.rs +++ b/crates/layers/tests/it/panel_reveal.rs @@ -106,14 +106,21 @@ impl Rig { self.fixture.by_label(name).expect("the row is drawn").rect } - /// One frame that reveals `id`, with what it reported; asserts that the frame ran once and measured no row twice. + /// One frame that reveals `id`, with what it reported; asserts that the frame ran once and measured no row twice but + /// the rows the lead moves between. fn reveal(&mut self, id: u32, groups: Groups) -> Vec> { self.seen.borrow_mut().clear(); self.reveal.set(Some((id, groups))); self.fixture.idle(1); assert_eq!(self.fixture.passes(), 1, "a reveal runs its frame once"); let measures = craft_ui::runtime::measure::row_measures(self.fixture.ctx()); - assert!(measures.iter().all(|(_, count)| *count == 1), "a reveal measures no row twice: {measures:?}"); + // The lead moves to the revealed row: the row it leaves, measured before the move, is measured again with its + // new state, as is the revealed row when the pass measured it before the move. + let again = measures.iter().filter(|(_, count)| *count == 2).count(); + assert!( + measures.iter().all(|(_, count)| *count <= 2) && again <= 2, + "a reveal measures again only the rows the lead moves between: {measures:?}" + ); self.seen.borrow_mut().drain(..).collect() } diff --git a/crates/ui-patterns/tests/it/docking/runs.rs b/crates/ui-patterns/tests/it/docking/runs.rs index 8da246af1..c0b77acfb 100644 --- a/crates/ui-patterns/tests/it/docking/runs.rs +++ b/crates/ui-patterns/tests/it/docking/runs.rs @@ -296,20 +296,22 @@ fn a_tab_switch_runs_only_its_group() { assert_eq!(ran(&fixture), 0, "and they settle at it: {:?}", memo_runs(&fixture)); } -/// A new label for one panel runs only its group's tab row: the other groups' menus, which name it, are built only -/// while open. +/// A new label for one panel runs only its group's tab row, once: the other groups' menus, which name it, are built +/// only while open. #[trial] fn a_label_change_runs_only_its_groups_chrome() { let MemoDock { mut fixture, labels, .. } = memo_dock(side_by_side(3), None); labels.borrow_mut()[4] = "Renamed".to_owned(); fixture.frame(Vec::new()); let rows_ran = frame_ran_ids(&fixture, "TabRow"); - assert!( - rows_ran.len() == 2 && rows_ran[0] == rows_ran[1], - "only the third group's tab row ran: its real run, then one measuring run in the discard pass's sizing pass: {:?}", + assert_eq!( + rows_ran.len(), + 1, + "only the third group's tab row ran, once: it measures the new label before it places its tabs: {:?}", frame_memo_runs(&fixture) ); - assert_eq!(memo_of(&fixture, "TabRow"), (0, 3), "the last pass replays every tab row: {:?}", memo_runs(&fixture)); + assert_eq!(fixture.passes(), 1, "the frame runs once"); + assert_eq!(memo_of(&fixture, "TabRow"), (1, 2), "the other tab rows replay: {:?}", memo_runs(&fixture)); assert_eq!(body_runs(), Vec::::new(), "no body ran"); assert!(fixture.texts().iter().any(|text| text.text == "Renamed"), "the tab shows the new label"); fixture.idle(SETTLE).frame(Vec::new());