From 2831732eb7271b2a3af86354a31bfb08501f168d Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 28 Nov 2026 14:14:11 +0100 Subject: [PATCH] thing-core test: pin the half-a-side cap of the control inset Mutation survivors of Device::inset (`w / 2.0` and `h / 2.0` replaced by a product): a control narrower than twice its inset keeps the content box inside the border box. Co-Authored-By: Claude Sonnet 5.5 --- crates/thing-core/tests/layout.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/thing-core/tests/layout.rs b/crates/thing-core/tests/layout.rs index 41d399c..b859223 100644 --- a/crates/thing-core/tests/layout.rs +++ b/crates/thing-core/tests/layout.rs @@ -1374,3 +1374,14 @@ fn a_pixels_control_inset_is_two_logical_px_and_a_pixels_button_has_none() { assert_eq!(inside(&button, "button"), None, "Pixels lays a Button's content without an inset"); assert_eq!(inside(&button, "label"), None, "and a node that is no control has no content box"); } + +#[test] +fn a_control_smaller_than_its_inset_gives_up_half_of_each_side_at_most() { + // A 2x2 px grid track holds an input whose 2 px chrome on each side would eat the box twice: + // the inset is capped at half a side, so the content box is empty and in the middle. + let grid = BoxStyle { display: Display::Grid, grid_columns: vec![px(2.0)], grid_rows: vec![px(2.0)], ..sized(10.0, 10.0) }; + let tree = bind(&mut MemState::new(), &surface_of(bx("root", grid, vec![bordered("input")]))).expect("resolves"); + let laid = layout(&tree, &pixels(100.0, 100.0, 1.0), &mut FixedMeasure::pixels()).unwrap(); + assert_eq!(rect(&laid, "input"), (0.0, 0.0, 2.0, 2.0)); + assert_eq!(inside(&laid, "input"), Some((1.0, 1.0, 0.0, 0.0))); +}