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.
This commit is contained in:
aiongg
2026-11-20 04:33:13 +00:00
parent 49f60f8a12
commit eb8ac21eda
2 changed files with 17 additions and 8 deletions
+9 -2
View File
@@ -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<LayersEvent<u32>> {
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()
}
+8 -6
View File
@@ -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::<usize>::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());