Main: the resting-card test checks only the New Document dialog's cards

resting_preset_cards_stand_on_a_tile took the first unselected list item
in the frame's access tree. That tree also holds the Home screen's
document cards behind the dialog, which lie flat by design, and the
update lists nodes in hash-map order, which changes from process to
process. When a Home card came first the test failed, so it failed on
some runs of the full workspace and passed alone.

The test now walks the dialog node's subtree and checks every unselected
card in it, so the result no longer depends on node order.
This commit is contained in:
dotCooCoo committed 2026-11-30 15:49:02 -08:00
1 parent cb0a23d293
commit e4506377ba
1 file changed
+24 -10
+24 -10
View File
@@ -1127,21 +1127,35 @@ mod tests {
open(&mut app);
let out = laid_out(&mut app);
let nodes = out.platform_output.accesskit_update.as_ref().map(|u| u.nodes.clone()).unwrap_or_default();
let card = nodes
// The Home screen's own document cards stand behind the dialog, and the update lists nodes in no fixed order:
// the card is looked for under the dialog only.
let by_id: std::collections::HashMap<_, _> = nodes.iter().map(|(id, n)| (*id, n)).collect();
let mut in_dialog = Vec::new();
let mut stack: Vec<_> = nodes.iter().filter(|(_, n)| n.role() == egui::accesskit::Role::Dialog).map(|(id, _)| *id).collect();
while let Some(id) = stack.pop() {
if let Some(node) = by_id.get(&id) {
in_dialog.push(*node);
stack.extend(node.children().iter().copied());
}
}
let cards: Vec<_> = in_dialog
.iter()
.find(|(_, n)| n.role() == egui::accesskit::Role::ListItem && n.label().is_some_and(|l| !l.is_empty()) && n.is_selected() == Some(false))
.and_then(|(_, n)| n.bounds())
.filter(|n| n.role() == egui::accesskit::Role::ListItem && n.label().is_some_and(|l| !l.is_empty()) && n.is_selected() == Some(false))
.filter_map(|n| n.bounds())
.map(|b| egui::Rect::from_min_max(egui::pos2(b.x0 as f32, b.y0 as f32), egui::pos2(b.x1 as f32, b.y1 as f32)))
.expect("a preset card that is not selected");
.collect();
assert!(!cards.is_empty(), "a preset card that is not selected");
let shapes = crate::tests_labels::flat_painted_shapes(&out.shapes);
let rects: Vec<_> = shapes.iter().filter_map(|shape| if let egui::Shape::Rect(rect) = shape { Some(rect) } else { None }).collect();
let veil = |fill: egui::Color32| fill.a() > 0 && fill.a() < scrim.a() && fill.to_opaque() == scrim.to_opaque();
assert!(
rects.iter().any(|rect| veil(rect.fill) && rect.rect.contains_rect(card.shrink(1.0)) && card.expand(1.0).contains_rect(rect.rect)),
"a veil of the scrim {scrim:?} covers the resting card {card:?}: {:?}",
rects.iter().filter(|rect| card.expand(1.0).contains_rect(rect.rect)).map(|rect| (rect.rect, rect.fill)).collect::<Vec<_>>()
);
assert!(rects.iter().any(|rect| rect.fill == egui::Color32::WHITE && card.contains_rect(rect.rect)), "the card's paper is on the tile");
for card in cards {
assert!(
rects.iter().any(|rect| veil(rect.fill) && rect.rect.contains_rect(card.shrink(1.0)) && card.expand(1.0).contains_rect(rect.rect)),
"a veil of the scrim {scrim:?} covers the resting card {card:?}: {:?}",
rects.iter().filter(|rect| card.expand(1.0).contains_rect(rect.rect)).map(|rect| (rect.rect, rect.fill)).collect::<Vec<_>>()
);
assert!(rects.iter().any(|rect| rect.fill == egui::Color32::WHITE && card.contains_rect(rect.rect)), "the card's paper is on the tile");
}
}
/// Recent shows each entry as it was made: a portrait and a landscape A3 are two documents, and