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))); +}