From 34b3e76ac17eefe6604531caac5bbf7291b30d16 Mon Sep 17 00:00:00 2001 From: yamabush1 Date: Mon, 1 Jun 2026 11:33:35 +0200 Subject: [PATCH] test: make button-paints-content render check theme-robust MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The render_pixels button test rendered on a black canvas and asserted some pixel differed from black. With no theme dir configured the active theme is the embedded B/W fallback, whose Light mode defines accent (the button fill) and text-primary as pure black on a white page — so a fallback button is black-on-black and the assertion spuriously failed. Render on white instead: the black fallback button stands out, and a real theme's saturated accent also differs from white, keeping the structural check theme-independent. --- tests/render_pixels.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/render_pixels.rs b/tests/render_pixels.rs index d373147..13bef02 100644 --- a/tests/render_pixels.rs +++ b/tests/render_pixels.rs @@ -148,8 +148,16 @@ fn render_hash_is_stable_across_two_back_to_back_passes() #[ test ] fn rendering_a_button_produces_pixels_that_differ_from_the_background() { + // Render on a WHITE canvas, not black: with no theme dir configured the + // active theme is the embedded B/W fallback, whose Light mode defines + // `accent` (the default button fill) and `text-primary` as pure BLACK on + // a white page. A black canvas would therefore hide a fallback button + // entirely (black-on-black) and this structural "button paints content" + // check would spuriously fail. White matches the fallback's page colour, + // so the black button stands out — and a real theme's saturated accent + // (e.g. teal) differs from white too, keeping the test theme-robust. let mut surface = UiSurface::<()>::new( 240, 120 ); - let bg = Color::rgb( 0.0, 0.0, 0.0 ); + let bg = Color::WHITE; let view: Element<()> = column::<()>().push( button( "tap" ) ).into(); let _ = surface.render( &view, @@ -158,7 +166,7 @@ fn rendering_a_button_produces_pixels_that_differ_from_the_background() let buf = extract_pixels( &surface, 240, 120 ); let differs = buf.chunks_exact( 4 ).any( |chunk| - !( chunk[ 0 ] == 0 && chunk[ 1 ] == 0 && chunk[ 2 ] == 0 && chunk[ 3 ] == 255 ) + !( chunk[ 0 ] == 255 && chunk[ 1 ] == 255 && chunk[ 2 ] == 255 && chunk[ 3 ] == 255 ) ); assert!( differs, "a button must paint at least one non-background pixel" ); }