Sitelet https://github.com/unoplatform/uno/issues/25013
Skip to content

Given_TextBlock.When_Inlines_Transitively_Change fails when Windows is in dark mode (expects OS-theme default brush) #25013

Description

@MartinZikmund

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:

Expected 'FFFFFFFF' in rectangle '{X=0,Y=0,Width=88,Height=19}', but no pixel has this color.
The closest pixel found is '00000000' at '0,0' with a (exclusive) difference of 255.

The text is rendered, but in the theme the test host uses (Light, dark-grey #E4000000 glyph pixels), not in the color the test expects. The test asserts against Uno.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):

DefaultBrushes.TextForegroundBrush = #FFFFFFFF
SUT.ActualTheme                    = Light
SUT.Foreground                     = #E4000000
bitmap colors                      = #00000000 (1329 px), #E4000000 (197 px), plus anti-aliasing shades of #xx000000

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-derived DefaultBrushes.TextForegroundBrush.

How to reproduce it (as minimally and precisely as possible) 🔬

  1. On Windows, set Settings > Personalization > Colors > Choose your mode to Dark.
  2. Build the SamplesApp (dotnet build src/SamplesApp/SamplesApp/SamplesApp.csproj -c Release -f net10.0-desktop -p:UnoFastDevBuild=true -p:UnoTargetFrameworkOverride=net10.0).
  3. Set UITEST_RUNTIME_TESTS_FILTER to the base64 of Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Controls.Given_TextBlock.When_Inlines_Transitively_Change.
  4. From bin/Release/net10.0-desktop run dotnet SamplesApp.dll --runtime-tests=test-results.xml.
  5. The test fails with the message above. With the OS in light mode it passes.

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 for net10.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.

  • Test: Given_TextBlock.cs#L735-L753 uses DefaultBrushes.TextForegroundBrush as the expected color and never sets a theme.
  • DefaultBrushes.cs caches an application-level brush (with a CoreApplication.RequestedTheme fallback), which is not necessarily what an individual element renders with.
  • Another assertion at line 266 of the same file uses the same helper and may be affected the same way (not checked).

Suggested fix: compare against ((SolidColorBrush)SUT.Foreground).Color, or set SUT.RequestedTheme explicitly before taking the screenshot.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/skia ✏️Categorizes an issue or PR as relevant to Skiaarea/tests 🧪Categorizes an issue or PR as relevant to testsdifficulty/starter 🚀Categorizes 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.kind/bugSomething isn't workingplatform/win32 🪟Categorizes an issue or PR as relevant to Win32triage/untriagedIndicates an issue requires triaging or verification

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions