From 9dae693bd4f3c89a6b797699ff0b66d554f23e56 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Tue, 31 Aug 2021 23:15:51 +0200 Subject: [PATCH 1/3] fix: Use SymbolThemeFontFamily instead of hard-coded Segoe MDL2 Assets --- .../Resources/.editorconfig | 9 +++++ .../Priority02/MenuFlyout_themeresources.xaml | 6 ++-- .../RevealBrush_themeresources.xaml | 4 +-- .../PriorityDefault/DropDownButton.xaml | 2 +- .../PriorityDefault/RatingControl.xaml | 2 +- .../RatingControl_themeresources.xaml | 4 +-- .../PriorityDefault/SplitButton.xaml | 2 +- src/Uno.UI.FluentTheme/themeresources.xaml | 20 +++++------ .../SplitButton/SplitButtonTests.cs | 22 ++++++++++++ .../ToggleSplitButtonTests.cs | 33 ++++++++++++++++++ .../DropDownButtonTests.cs | 34 +++++++++++++++++++ .../MenuFlyout_19h1_themeresources.xaml | 6 ++-- 12 files changed, 121 insertions(+), 23 deletions(-) create mode 100644 src/Uno.UI.FluentTheme/Resources/.editorconfig create mode 100644 src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/ToggleSplitButton/ToggleSplitButtonTests.cs create mode 100644 src/Uno.UI.RuntimeTests/MUX/Windows_UI_Xaml_Controls/DropDownButtonTests.cs diff --git a/src/Uno.UI.FluentTheme/Resources/.editorconfig b/src/Uno.UI.FluentTheme/Resources/.editorconfig new file mode 100644 index 000000000000..dbda9ec6da8a --- /dev/null +++ b/src/Uno.UI.FluentTheme/Resources/.editorconfig @@ -0,0 +1,9 @@ +# Overrides our root .editorconfig to match https://github.com/microsoft/microsoft-ui-xaml/blob/fd22d7ff96871f58fec5d9b284eba02fe762c60e/.editorconfig#L120-L126 + +[**.{xaml,xml}] +indent_style = space +indent_size = 4 +charset = utf-8-bom +insert_final_newline = true +trim_trailing_whitespace = true +end_of_line = crlf diff --git a/src/Uno.UI.FluentTheme/Resources/Priority02/MenuFlyout_themeresources.xaml b/src/Uno.UI.FluentTheme/Resources/Priority02/MenuFlyout_themeresources.xaml index 91badc8ba77f..4e868cd9c07c 100644 --- a/src/Uno.UI.FluentTheme/Resources/Priority02/MenuFlyout_themeresources.xaml +++ b/src/Uno.UI.FluentTheme/Resources/Priority02/MenuFlyout_themeresources.xaml @@ -639,21 +639,21 @@ Grid.Column="0" HorizontalAlignment="Left" Margin="0"> - + diff --git a/src/Uno.UI.FluentTheme/Resources/Priority06/RevealBrush_themeresources.xaml b/src/Uno.UI.FluentTheme/Resources/Priority06/RevealBrush_themeresources.xaml index 75d978287c8b..30c1e38686c4 100644 --- a/src/Uno.UI.FluentTheme/Resources/Priority06/RevealBrush_themeresources.xaml +++ b/src/Uno.UI.FluentTheme/Resources/Priority06/RevealBrush_themeresources.xaml @@ -2615,7 +2615,7 @@ - + @@ -2844,7 +2844,7 @@ diff --git a/src/Uno.UI.FluentTheme/Resources/PriorityDefault/DropDownButton.xaml b/src/Uno.UI.FluentTheme/Resources/PriorityDefault/DropDownButton.xaml index 2c5a010abc98..e81484194569 100644 --- a/src/Uno.UI.FluentTheme/Resources/PriorityDefault/DropDownButton.xaml +++ b/src/Uno.UI.FluentTheme/Resources/PriorityDefault/DropDownButton.xaml @@ -107,7 +107,7 @@ - + diff --git a/src/Uno.UI.FluentTheme/Resources/PriorityDefault/RatingControl_themeresources.xaml b/src/Uno.UI.FluentTheme/Resources/PriorityDefault/RatingControl_themeresources.xaml index 4c3600302d7f..6302d5a47881 100644 --- a/src/Uno.UI.FluentTheme/Resources/PriorityDefault/RatingControl_themeresources.xaml +++ b/src/Uno.UI.FluentTheme/Resources/PriorityDefault/RatingControl_themeresources.xaml @@ -49,7 +49,7 @@ FontSize="32" Text="" AutomationProperties.AccessibilityView="Raw" - FontFamily="Segoe MDL2 Assets"/> + FontFamily="{ThemeResource SymbolThemeFontFamily}"/> @@ -58,7 +58,7 @@ FontSize="32" Text="" AutomationProperties.AccessibilityView="Raw" - FontFamily="Segoe MDL2 Assets"/> + FontFamily="{ThemeResource SymbolThemeFontFamily}"/> diff --git a/src/Uno.UI.FluentTheme/Resources/PriorityDefault/SplitButton.xaml b/src/Uno.UI.FluentTheme/Resources/PriorityDefault/SplitButton.xaml index 9ea6511b5049..5044a457cd1f 100644 --- a/src/Uno.UI.FluentTheme/Resources/PriorityDefault/SplitButton.xaml +++ b/src/Uno.UI.FluentTheme/Resources/PriorityDefault/SplitButton.xaml @@ -195,7 +195,7 @@ diff --git a/src/Uno.UI.FluentTheme/themeresources.xaml b/src/Uno.UI.FluentTheme/themeresources.xaml index 479e4a6ce3fa..e2ff62da0ff3 100644 --- a/src/Uno.UI.FluentTheme/themeresources.xaml +++ b/src/Uno.UI.FluentTheme/themeresources.xaml @@ -5320,13 +5320,13 @@ @@ -8493,7 +8493,7 @@ - + @@ -8722,7 +8722,7 @@ @@ -14896,7 +14896,7 @@ - + @@ -19388,7 +19388,7 @@ - + @@ -19459,11 +19459,11 @@ - + - + @@ -20521,7 +20521,7 @@ diff --git a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/SplitButton/SplitButtonTests.cs b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/SplitButton/SplitButtonTests.cs index 6a11b5f5e42a..78d76260c59e 100644 --- a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/SplitButton/SplitButtonTests.cs +++ b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/SplitButton/SplitButtonTests.cs @@ -24,6 +24,9 @@ using SplitButton = Microsoft.UI.Xaml.Controls.SplitButton; using ToggleSplitButton = Microsoft.UI.Xaml.Controls.ToggleSplitButton; +using Uno.UI.RuntimeTests.Helpers; +using Windows.UI.Xaml.Media; +using Private.Infrastructure; namespace Windows.UI.Xaml.Tests.MUXControls.ApiTests { @@ -82,6 +85,25 @@ public void VerifyIsCheckedProperty() Verify.IsTrue(isChecked, "ToggleSplitButton is not checked"); }); } + + [TestMethod] + [Description("Verifies that the TextBlock representing the Chevron glyph uses the correct font")] + public void VerifyFontFamilyForChevron() + { + SplitButton splitButton = null; + using (StyleHelper.UseFluentStyles()) + { + RunOnUIThread.Execute(() => + { + splitButton = new SplitButton(); + TestServices.WindowHelper.WindowContent = splitButton; + + var secondayButton = splitButton.GetTemplateChild("SecondaryButton"); + var font = ((secondayButton as Button).Content as TextBlock).FontFamily; + Verify.AreEqual((FontFamily)Application.Current.Resources["SymbolThemeFontFamily"], font); + }); + } + } } // CanExecuteChanged is never used -- that's ok, disable the compiler warning. diff --git a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/ToggleSplitButton/ToggleSplitButtonTests.cs b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/ToggleSplitButton/ToggleSplitButtonTests.cs new file mode 100644 index 000000000000..90dcfe524cf2 --- /dev/null +++ b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/ToggleSplitButton/ToggleSplitButtonTests.cs @@ -0,0 +1,33 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Uno.UI.RuntimeTests.Helpers; +using MUXControlsTestApp.Utilities; +using Private.Infrastructure; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Media; +using Common; + +namespace Windows.UI.Xaml.Tests.MUXControls.ApiTests +{ + [TestClass] + public class ToggleSplitButtonTests + { + [TestMethod] + [Description("Verifies that the TextBlock representing the Chevron glyph uses the correct font")] + public void VerifyFontFamilyForChevron() + { + Microsoft.UI.Xaml.Controls.ToggleSplitButton toggleSplitButton = null; + using (StyleHelper.UseFluentStyles()) + { + RunOnUIThread.Execute(() => + { + toggleSplitButton = new Microsoft.UI.Xaml.Controls.ToggleSplitButton(); + TestServices.WindowHelper.WindowContent = toggleSplitButton; + + var secondayButton = toggleSplitButton.GetTemplateChild("SecondaryButton"); + var font = ((secondayButton as Button).Content as TextBlock).FontFamily; + Verify.AreEqual((FontFamily)Application.Current.Resources["SymbolThemeFontFamily"], font); + }); + } + } + } +} diff --git a/src/Uno.UI.RuntimeTests/MUX/Windows_UI_Xaml_Controls/DropDownButtonTests.cs b/src/Uno.UI.RuntimeTests/MUX/Windows_UI_Xaml_Controls/DropDownButtonTests.cs new file mode 100644 index 000000000000..4116c7bfae51 --- /dev/null +++ b/src/Uno.UI.RuntimeTests/MUX/Windows_UI_Xaml_Controls/DropDownButtonTests.cs @@ -0,0 +1,34 @@ +using Common; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using MUXControlsTestApp.Utilities; +using Private.Infrastructure; +using Uno.UI.RuntimeTests.Helpers; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Media; + +namespace Windows.UI.Xaml.Tests.MUXControls.ApiTests +{ + [TestClass] + public class DropDownButtonTests + { + [TestMethod] + [Description("Verifies that the TextBlock representing the Chevron glyph uses the correct font")] + public void VerifyFontFamilyForChevron() + { + DropDownButton dropDownButton = null; + using (StyleHelper.UseFluentStyles()) + { + RunOnUIThread.Execute(() => + { + dropDownButton = new DropDownButton(); + TestServices.WindowHelper.WindowContent = dropDownButton; + + var chevronTextBlock = dropDownButton.GetTemplateChild("ChevronTextBlock") as TextBlock; + var font = chevronTextBlock.FontFamily; + Verify.AreEqual((FontFamily)Application.Current.Resources["SymbolThemeFontFamily"], font); + }); + } + } + + } +} diff --git a/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout_19h1_themeresources.xaml b/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout_19h1_themeresources.xaml index a55c0fa16c8f..afb04f3339ef 100644 --- a/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout_19h1_themeresources.xaml +++ b/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout_19h1_themeresources.xaml @@ -102,21 +102,21 @@ Grid.Column="0" HorizontalAlignment="Left" Margin="0"> - + From 2e149955420277d39b889ac785bd88f1ed73c006 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Wed, 1 Sep 2021 11:13:23 +0200 Subject: [PATCH 2/3] chore: Fix UWP build --- .../MUX/Windows_UI_Xaml_Controls/DropDownButtonTests.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Uno.UI.RuntimeTests/MUX/Windows_UI_Xaml_Controls/DropDownButtonTests.cs b/src/Uno.UI.RuntimeTests/MUX/Windows_UI_Xaml_Controls/DropDownButtonTests.cs index 4116c7bfae51..a96dc4fc58a6 100644 --- a/src/Uno.UI.RuntimeTests/MUX/Windows_UI_Xaml_Controls/DropDownButtonTests.cs +++ b/src/Uno.UI.RuntimeTests/MUX/Windows_UI_Xaml_Controls/DropDownButtonTests.cs @@ -11,6 +11,7 @@ namespace Windows.UI.Xaml.Tests.MUXControls.ApiTests [TestClass] public class DropDownButtonTests { +#if !WINDOWS_UWP // GetTemplateChild is protected in UWP while public in Uno. [TestMethod] [Description("Verifies that the TextBlock representing the Chevron glyph uses the correct font")] public void VerifyFontFamilyForChevron() @@ -29,6 +30,6 @@ public void VerifyFontFamilyForChevron() }); } } - +#endif } } From 451883b33d4a603aaa98da0b978f5950b7d54f86 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Thu, 2 Sep 2021 21:29:29 +0200 Subject: [PATCH 3/3] test: Use RunsOnUIThread attribute --- .../SplitButton/SplitButtonTests.cs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/SplitButton/SplitButtonTests.cs b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/SplitButton/SplitButtonTests.cs index 78d76260c59e..4be7dd31d878 100644 --- a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/SplitButton/SplitButtonTests.cs +++ b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/SplitButton/SplitButtonTests.cs @@ -27,6 +27,7 @@ using Uno.UI.RuntimeTests.Helpers; using Windows.UI.Xaml.Media; using Private.Infrastructure; +using Uno.UI.RuntimeTests; namespace Windows.UI.Xaml.Tests.MUXControls.ApiTests { @@ -87,21 +88,18 @@ public void VerifyIsCheckedProperty() } [TestMethod] + [RunsOnUIThread] [Description("Verifies that the TextBlock representing the Chevron glyph uses the correct font")] public void VerifyFontFamilyForChevron() { - SplitButton splitButton = null; using (StyleHelper.UseFluentStyles()) { - RunOnUIThread.Execute(() => - { - splitButton = new SplitButton(); - TestServices.WindowHelper.WindowContent = splitButton; - - var secondayButton = splitButton.GetTemplateChild("SecondaryButton"); - var font = ((secondayButton as Button).Content as TextBlock).FontFamily; - Verify.AreEqual((FontFamily)Application.Current.Resources["SymbolThemeFontFamily"], font); - }); + var splitButton = new SplitButton(); + TestServices.WindowHelper.WindowContent = splitButton; + + var secondayButton = splitButton.GetTemplateChild("SecondaryButton"); + var font = ((secondayButton as Button).Content as TextBlock).FontFamily; + Verify.AreEqual((FontFamily)Application.Current.Resources["SymbolThemeFontFamily"], font); } } }