layout tests: bounds judged in device px, numbers share the length bound

This commit is contained in:
Meta Vens 2026-11-28 06:13:21 +01:00
commit db0e911f19

View file

@ -358,6 +358,7 @@ fn arm_table() {
assert_eq!(shrink.nodes, initial(&|s| s.shrink = 1.0));
// A slot is named once however many of its parts are wrong.
one(&probe(&|s| s.gap = size2(px(-1.0), px(-2.0))), "gap");
one(&probe(&|s| s.grow = 5e6), "grow");
let wide = probe(&|s| s.size.width = px(1e40));
one(&wide, "size");
assert_eq!(wide.nodes, initial(&|s| s.size.width = Dimension::Auto));
@ -646,6 +647,9 @@ fn invalid_image_measures_are_named_and_harmless() {
assert_eq!((sibling.2, sibling.3), (200.0, 16.0), "{size:?}");
assert!(laid.nodes.iter().all(|n| [n.rect.x, n.rect.y, n.rect.w, n.rect.h].iter().all(|v| v.is_finite())), "{size:?}");
}
// The bound is judged in device px: 1.5e6 logical px at scale 2 is past it.
let doubled = layout(&tree, &pixels(800.0, 600.0, 2.0), &mut Image((1.5e6, 1.5e6))).unwrap();
assert_eq!(doubled.diagnostics.len(), 1);
// No extent yet (0x0) is not a fault, and a sound ratio is kept.
assert!(run((0.0, 0.0)).diagnostics.is_empty());
let sound = run((40.0, 20.0));