From e1332321a5568cfc53ceac55a188cec981dcaca3 Mon Sep 17 00:00:00 2001 From: Nicolai Henriksen Date: Wed, 17 Aug 2022 02:49:49 +0200 Subject: [PATCH] Added BorderThickness attached DP for outlined date/time pickers (#2805) * Added BorderThickness attached DP for outlined date/time pickers * Added UI tests * Fixed typos in code comment * Increased delay in tests Tests are running green locally, so I presume it has something to do with the delay being too short * Fixed UI tests Initial mouse position was on the pickers, so I added a dummy button to initially move the mouse position away from the pickers. * Updated UI tests to test validation error scenario Ideally I would like XAMLTest to allow me to set a ValidationError "on the fly" if possible. For now, tests are updated with a real ValidationRule and invalid values are set to provoke the validation error. --- MainDemo.Wpf/Pickers.xaml | 54 ++++++++++++++ MaterialDesignThemes.UITests/TestBase.cs | 4 +- .../WPF/DatePickers/DatePickerTests.cs | 72 ++++++++++++++++++- .../WPF/TimePickers/TimePickerTests.cs | 61 ++++++++++++++++ .../XamlTestMixins.cs | 10 ++- ...imePickerActiveBorderThicknessConverter.cs | 24 +++++++ MaterialDesignThemes.Wpf/DatePickerAssist.cs | 33 +++++++++ .../MaterialDesignTheme.DatePicker.xaml | 36 ++++++++-- .../MaterialDesignTheme.TimePicker.xaml | 38 +++++++--- MaterialDesignThemes.Wpf/TimePickerAssist.cs | 33 +++++++++ 10 files changed, 346 insertions(+), 19 deletions(-) create mode 100644 MaterialDesignThemes.Wpf/Converters/OutlinedDateTimePickerActiveBorderThicknessConverter.cs create mode 100644 MaterialDesignThemes.Wpf/DatePickerAssist.cs create mode 100644 MaterialDesignThemes.Wpf/TimePickerAssist.cs diff --git a/MainDemo.Wpf/Pickers.xaml b/MainDemo.Wpf/Pickers.xaml index eb718f0f84..ada98ecbd5 100644 --- a/MainDemo.Wpf/Pickers.xaml +++ b/MainDemo.Wpf/Pickers.xaml @@ -198,6 +198,60 @@ materialDesign:HintAssist.HelperText="Helper text" Style="{StaticResource MaterialDesignOutlinedDatePicker}"/> + + + + + + + + + + + + + + + + GetThemeColor(string name) return resource.GetAs() ?? throw new Exception($"Failed to convert resource '{name}' to color"); } - protected async Task> LoadXaml(string xaml) + protected async Task> LoadXaml(string xaml, params (string namespacePrefix, Type type)[] additionalNamespaceDeclarations) { await App.InitializeWithMaterialDesign(); - return await App.CreateWindowWith(xaml); + return await App.CreateWindowWith(xaml, additionalNamespaceDeclarations); } protected async Task LoadUserControl() diff --git a/MaterialDesignThemes.UITests/WPF/DatePickers/DatePickerTests.cs b/MaterialDesignThemes.UITests/WPF/DatePickers/DatePickerTests.cs index 4a2331be03..1a9bf08708 100644 --- a/MaterialDesignThemes.UITests/WPF/DatePickers/DatePickerTests.cs +++ b/MaterialDesignThemes.UITests/WPF/DatePickers/DatePickerTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.ComponentModel; using System.Globalization; using System.Threading.Tasks; @@ -64,5 +64,75 @@ await Wait.For(async () => recorder.Success(); } + + [Fact] + [Description("Issue 2737")] + public async Task OutlinedDatePicker_RespectsActiveAndInactiveBorderThickness_WhenAttachedPropertiesAreSet() + { + await using var recorder = new TestRecorder(App); + + // Arrange + var expectedInactiveBorderThickness = new Thickness(4, 3, 2, 1); + var expectedActiveBorderThickness = new Thickness(1, 2, 3, 4); + var stackPanel = await LoadXaml($@" + + + + + + + + + + +