1 Commits

Author SHA1 Message Date
codex-bot 1fb6dc3b8f test: account for window chrome in viewport layout assertions 2026-10-30 03:45:21 +08:00
+28 -3
View File
@@ -207,8 +207,10 @@ page.render(Column(0,8,Column(0,8,paragraph,tail),Column(50,8,paragraph)))
}) })
.collect(); .collect();
assert_eq!(commands.len(), 2); assert_eq!(commands.len(), 2);
assert_eq!(commands[0][0], 240.0); // The 240px window reserves 56px for the rail and 8px for its inset.
assert_eq!(commands[1][0], 140.0); // The second occurrence additionally has 50px padding on each side.
assert_eq!(commands[0][0], 176.0);
assert_eq!(commands[1][0], 76.0);
assert!(commands[1][1] > commands[0][1]); assert!(commands[1][1] > commands[0][1]);
let tail = initial let tail = initial
.frame .frame
@@ -236,6 +238,20 @@ page.render(Column(0,8,Column(0,8,paragraph,tail),Column(50,8,paragraph)))
.map(|m| m.id) .map(|m| m.id)
.collect::<Vec<_>>() .collect::<Vec<_>>()
); );
let widths: Vec<_> = resized
.frame
.commands
.iter()
.filter_map(|command| match command {
RenderCommand::Text {
value,
wrap_bounds: Some(bounds),
..
} if value == &text => Some(bounds[0]),
_ => None,
})
.collect();
assert_eq!(widths, [336.0, 236.0]);
let heights: Vec<_> = resized let heights: Vec<_> = resized
.frame .frame
.commands .commands
@@ -1758,6 +1774,15 @@ fn viewport_resize_changes_constraints_and_preserves_mount_identity_without_sour
}), }),
) )
.unwrap(); .unwrap();
// Page content excludes the 56px rail, 8px inset and 24px root padding
// on each side, both initially and after resizing the outer window.
assert!(
initial
.frame
.mounts
.iter()
.any(|mount| mount.width == 688.0 && mount.height == 24.0)
);
let ids: Vec<_> = initial.frame.mounts.iter().map(|mount| mount.id).collect(); let ids: Vec<_> = initial.frame.mounts.iter().map(|mount| mount.id).collect();
let document = session let document = session
.resize(Some(crate::layout::Size { .resize(Some(crate::layout::Size {
@@ -1780,7 +1805,7 @@ fn viewport_resize_changes_constraints_and_preserves_mount_identity_without_sour
.frame .frame
.mounts .mounts
.iter() .iter()
.any(|mount| mount.width == 312.0 && mount.height == 24.0) .any(|mount| mount.width == 248.0 && mount.height == 24.0)
); );
assert_eq!(session.inputs, 0); assert_eq!(session.inputs, 0);
assert!( assert!(