-
Notifications
You must be signed in to change notification settings - Fork 894
Given_TextBlock.When_Inlines_Transitively_Change fails when Windows is in dark mode (expects OS-theme default brush) #25013
Copy link
Copy link
Open
Labels
area/skia ✏️Categorizes an issue or PR as relevant to SkiaCategorizes an issue or PR as relevant to Skiaarea/tests 🧪Categorizes an issue or PR as relevant to testsCategorizes an issue or PR as relevant to testsdifficulty/starter 🚀Categorizes an issue for which the difficulty level is reachable by newcomersCategorizes an issue for which the difficulty level is reachable by newcomersgood first issueDenotes an issue ready for a new contributor, according to the "help wanted" guidelines.Denotes an issue ready for a new contributor, according to the "help wanted" guidelines.kind/bugSomething isn't workingSomething isn't workingplatform/win32 🪟Categorizes an issue or PR as relevant to Win32Categorizes an issue or PR as relevant to Win32triage/untriagedIndicates an issue requires triaging or verificationIndicates an issue requires triaging or verification
Description
Activity
Metadata
Metadata
Assignees
Labels
area/skia ✏️Categorizes an issue or PR as relevant to SkiaCategorizes an issue or PR as relevant to Skiaarea/tests 🧪Categorizes an issue or PR as relevant to testsCategorizes an issue or PR as relevant to testsdifficulty/starter 🚀Categorizes an issue for which the difficulty level is reachable by newcomersCategorizes an issue for which the difficulty level is reachable by newcomersgood first issueDenotes an issue ready for a new contributor, according to the "help wanted" guidelines.Denotes an issue ready for a new contributor, according to the "help wanted" guidelines.kind/bugSomething isn't workingSomething isn't workingplatform/win32 🪟Categorizes an issue or PR as relevant to Win32Categorizes an issue or PR as relevant to Win32triage/untriagedIndicates an issue requires triaging or verificationIndicates an issue requires triaging or verification
Current behavior 🐛
Given_TextBlock.When_Inlines_Transitively_Change(runtime test, Skia Desktop) fails deterministically on a Windows machine whose app mode is dark (AppsUseLightTheme = 0). CI agents use the light theme, so CI passes and the failure is only seen locally:The text is rendered, but in the theme the test host uses (Light, dark-grey
#E4000000glyph pixels), not in the color the test expects. The test asserts againstUno.UI.Xaml.Media.DefaultBrushes.TextForegroundBrush, which resolves to the OS theme (white on a dark OS), while the TextBlock's real foreground follows the app/element theme (Light).Diagnostic output from the failing run (temporary logging added to the test):
Expected behavior 🎯
The test should pass regardless of the developer machine's OS theme. It should either force a theme on the
TextBlock(RequestedTheme) or compare against the foreground the control actually resolved (SUT.Foreground) instead of the OS-theme-derivedDefaultBrushes.TextForegroundBrush.How to reproduce it (as minimally and precisely as possible) 🔬
dotnet build src/SamplesApp/SamplesApp/SamplesApp.csproj -c Release -f net10.0-desktop -p:UnoFastDevBuild=true -p:UnoTargetFrameworkOverride=net10.0).UITEST_RUNTIME_TESTS_FILTERto the base64 ofUno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Controls.Given_TextBlock.When_Inlines_Transitively_Change.bin/Release/net10.0-desktoprundotnet SamplesApp.dll --runtime-tests=test-results.xml.Workaround 🛠️
Switch Windows to light app mode before running the runtime tests locally.
Works on UWP/WinUI
Not applicable (Uno-only runtime test and internal helper).
Renderer 🎨
Skia
Affected platforms 📱💻🖥️
Skia Desktop (Win32). Likely any desktop head where the OS reports a dark theme. Not tested elsewhere.
Uno.Sdk version (and other relevant versions) 📦
master
bfc8dffd7fe9062160edbc7562f34955e88f57b2, built fornet10.0-desktop, Windows 11.IDE version 🧑💻
N/A (command line)
Anything else we need to know? 💬
Confirmed by a real runtime run (see diagnostics above), not just by inspection.
Given_TextBlock.cs#L735-L753usesDefaultBrushes.TextForegroundBrushas the expected color and never sets a theme.DefaultBrushes.cscaches an application-level brush (with aCoreApplication.RequestedThemefallback), which is not necessarily what an individual element renders with.Suggested fix: compare against
((SolidColorBrush)SUT.Foreground).Color, or setSUT.RequestedThemeexplicitly before taking the screenshot.