|
| 1 | +using System.Reflection; |
| 2 | +using MaterialDesignColors; |
| 3 | + |
| 4 | +namespace MaterialDesignThemes.UITests; |
| 5 | + |
| 6 | +public class AllStyles : TestBase |
| 7 | +{ |
| 8 | + public AllStyles(ITestOutputHelper output) |
| 9 | + : base(output) |
| 10 | + { } |
| 11 | + |
| 12 | + [Theory] |
| 13 | + [InlineData("Button", "MaterialDesignRaisedButton")] |
| 14 | + [InlineData("Calendar", "MaterialDesignCalendarPortrait")] |
| 15 | + [InlineData("CheckBox", "MaterialDesignCheckBox")] |
| 16 | + [InlineData("ComboBox", "MaterialDesignComboBox")] |
| 17 | + [InlineData("DataGrid", "MaterialDesignDataGrid")] |
| 18 | + [InlineData("DatePicker", "MaterialDesignDatePicker")] |
| 19 | + [InlineData("Expander", "MaterialDesignExpander")] |
| 20 | + [InlineData("GridSplitter", "MaterialDesignGridSplitter")] |
| 21 | + [InlineData("GroupBox", "MaterialDesignGroupBox")] |
| 22 | + [InlineData("Label", "MaterialDesignLabel")] |
| 23 | + [InlineData("ListBox", "MaterialDesignListBox")] |
| 24 | + [InlineData("ListView", "MaterialDesignListView")] |
| 25 | + [InlineData("Menu", "MaterialDesignMenu")] |
| 26 | + [InlineData("PasswordBox", "MaterialDesignPasswordBox")] |
| 27 | + [InlineData("ProgressBar", "MaterialDesignLinearProgressBar")] |
| 28 | + [InlineData("RadioButton", "MaterialDesignRadioButton")] |
| 29 | + [InlineData("RichTextBox", "MaterialDesignRichTextBox")] |
| 30 | + [InlineData("ScrollBar", "MaterialDesignScrollBar")] |
| 31 | + [InlineData("ScrollViewer", "MaterialDesignScrollViewer")] |
| 32 | + [InlineData("Slider", "MaterialDesignSlider")] |
| 33 | + [InlineData("TabControl", "MaterialDesignTabControl")] |
| 34 | + [InlineData("TextBox", "MaterialDesignTextBox")] |
| 35 | + [InlineData("ToggleButton", "MaterialDesignSwitchToggleButton")] |
| 36 | + [InlineData("ToolBar", "MaterialDesignToolBar")] |
| 37 | + [InlineData("TreeView", "MaterialDesignTreeView")] |
| 38 | + public async Task LoadStyleInIsolation_CanBeLoaded(string controlName, string styleName) |
| 39 | + { |
| 40 | + await using var recorder = new TestRecorder(App); |
| 41 | + |
| 42 | + string applicationResourceXaml = $$""" |
| 43 | +<ResourceDictionary |
| 44 | + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| 45 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 46 | + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"> |
| 47 | + <ResourceDictionary.MergedDictionaries> |
| 48 | + <materialDesign:BundledTheme BaseTheme="{{BaseTheme.Inherit}}" PrimaryColor="{{PrimaryColor.Purple}}" SecondaryColor="{{SecondaryColor.Blue}}" /> |
| 49 | +
|
| 50 | + <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.{{controlName}}.xaml" /> |
| 51 | + </ResourceDictionary.MergedDictionaries> |
| 52 | +
|
| 53 | + <Style TargetType="{x:Type {{controlName}}}" BasedOn="{StaticResource {{styleName}}}" /> |
| 54 | +</ResourceDictionary> |
| 55 | +"""; |
| 56 | + |
| 57 | + await App.Initialize(applicationResourceXaml, |
| 58 | + Path.GetFullPath("MaterialDesignColors.dll"), |
| 59 | + Path.GetFullPath("MaterialDesignThemes.Wpf.dll"), |
| 60 | + Assembly.GetExecutingAssembly().Location); |
| 61 | + |
| 62 | + IWindow window = await App.CreateWindow($$""" |
| 63 | + <Window |
| 64 | + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| 65 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 66 | + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
| 67 | + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| 68 | + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" |
| 69 | + mc:Ignorable="d" |
| 70 | + Height="800" Width="1100" |
| 71 | + TextElement.Foreground="{DynamicResource MaterialDesignBody}" |
| 72 | + TextElement.FontWeight="Regular" |
| 73 | + TextElement.FontSize="13" |
| 74 | + TextOptions.TextFormattingMode="Ideal" |
| 75 | + TextOptions.TextRenderingMode="Auto" |
| 76 | + Background="{DynamicResource MaterialDesignPaper}" |
| 77 | + FontFamily="{materialDesign:MaterialDesignFont}" |
| 78 | + Title="Test Window" |
| 79 | + Topmost="True" |
| 80 | + WindowStartupLocation="CenterScreen"> |
| 81 | + <{{controlName}} /> |
| 82 | + </Window> |
| 83 | + """); |
| 84 | + |
| 85 | + Assert.True(await window.GetIsVisible()); |
| 86 | + } |
| 87 | +} |
0 commit comments