git.lucas.co / cce-ui
GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git

commit96e1010480402d0b9d39806bbac3d65d2ce27f4b
parent25f369d01e
authorLucas Galante <[email protected]>
date2026-09-10 10:16
test(layout): let the vstack flow read the live style, never pin it

test_vstack_flow pinned the label margin, the control label font, the
detached control label font and the section padding — all process-global,
all visible to every other test while it ran, and the section padding was
never put back at all.

The detached font was the one that cost us: the group test measures a
member's label twice, once through detached_label_rect and once through
the hull inside Group::frame, and both resolve the font at call time. With
the font flipped between the two calls the hull's right edge disagreed with
the label's by 22px — a_members_wide_label_is_in_the_hull failed in 3 of 5
parallel runs, and passed alone every time.

None of the pinning was load-bearing: the label offset was already read live
off the widget, so it was self-consistent under any font. The one expectation
that did depend on a pinned global — the first column's x — is derived from
section_padding() now. 12 consecutive full parallel runs are clean.

Co-Authored-By: Claude Opus 5 <[email protected]>

 src/layout.rs | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/layout.rs b/src/layout.rs
index 8e9ccf4..b0745d8 100644
--- a/src/layout.rs
+++ b/src/layout.rs
@@ -6580,16 +6580,16 @@ mod tests {
         }
     }
 
+    /// The vstack flow is checked against the LIVE style — the label margin, the
+    /// detached-label font and the section padding are process-global and the suite
+    /// runs in parallel, so pinning them here would be a window every other test
+    /// could see (a label measured in one font by its own call and in another by the
+    /// group hull's is exactly the flake this cost us). Every expectation below is
+    /// derived from the getters instead, so the flow holds under any config.
     #[test]
     fn test_vstack_flow() {
-        let orig_margin = label_margin();
-        set_label_margin(6.0);
-        let orig_font = control_label_font();
-        set_control_label_font("Berkeley Mono 12");
-        let orig_font_detached = control_label_font_detached();
-        set_control_label_font_detached("Berkeley Mono 12");
-        let _ = section_padding();
-        set_section_padding(8.0);
+        // `Section` seats its first column one `margin_x` in from its left edge.
+        let first_col_x = 10.0 + 2.0 * section_padding() + Section::DEFAULT_MARGIN_X;
         let mut mock_pc = MockRenderTarget { rects: Vec::new() };
         let mut sec = Section::new(&mut mock_pc, 10.0, 20.0, 200.0, "Test Section");
         
@@ -6601,7 +6601,7 @@ mod tests {
         stack.add_widget(&mut w1, 50.0, 30.0, &mut dummy);
 
         // Standard margin should be applied
-        assert_eq!(w1.x, 38.0);
+        assert_eq!(w1.x, first_col_x);
         assert_eq!(w1.y, start_y);
 
         let mut w2 = MockWidget { base: crate::widget::Widget::new(), x: 0.0, y: 0.0, w: 0.0, h: 0.0 };
@@ -6618,10 +6618,8 @@ mod tests {
         let offset = w3.base.label_offset();
         
         // Third widget has label, so its y should be shifted by offset
+        assert!(offset > 0.0, "a labelled widget has a strip");
         assert_eq!(w3.base.y, start_y + 30.0 + 10.0 + 40.0 + 10.0 + offset);
-        set_label_margin(orig_margin);
-        set_control_label_font(&orig_font);
-        set_control_label_font_detached(&orig_font_detached);
     }
 
     #[test]