public async Task When_Theme_Changed_Static() { var app = UnitTestsApp.App.EnsureApplication(); var control = new Theme_Changed_Control(); app.HostView.Children.Add(control); control.Measure(new Size(1000, 1000)); var textLightStaticMarkup = control.TemplateFromResourceControl.TextBlock5.Text; Assert.AreEqual("ApplicationLevelLight", textLightStaticMarkup); try { if (await ThemeHelper.SwapSystemTheme()) { var textDarkStaticMarkup = control.TemplateFromResourceControl.TextBlock5.Text; Assert.AreEqual("ApplicationLevelLight", textDarkStaticMarkup); //StaticResource markup doesn't change ; } } finally { await ThemeHelper.SwapSystemTheme(); } }
public async Task When_Theme_Changed() { var app = UnitTestsApp.App.EnsureApplication(); var control = new Theme_Changed_Control(); app.HostView.Children.Add(control); control.Measure(new Size(1000, 1000)); var textLightThemeMarkup = control.TemplateFromResourceControl.TextBlock6.Text; Assert.AreEqual("LocalVisualTreeLight", textLightThemeMarkup); try { if (await ThemeHelper.SwapSystemTheme()) { if (control.Parent == null) { app.HostView.Children.Add(control); // On UWP the control may have been removed by another test after the async swap } var textDarkThemeMarkup = control.TemplateFromResourceControl.TextBlock6.Text; Assert.AreEqual("LocalVisualTreeDark", textDarkThemeMarkup); //ThemeResource markup change lookup uses the visual tree (rather than original XAML namescope) } } finally { await ThemeHelper.SwapSystemTheme(); } }