From b1a5349e9f74f101a59436d4ce5e95ae292d70ea Mon Sep 17 00:00:00 2001 From: Andres Pineda Date: Fri, 9 Aug 2024 14:27:19 -0400 Subject: [PATCH 1/3] test: add UI sample for Expander and bindings --- .../Expander_Bindings_TemplatedControl.xaml | 99 +++++++++++++++++++ ...Expander_Bindings_TemplatedControl.xaml.cs | 53 ++++++++++ .../UITests.Shared/UITests.Shared.projitems | 7 ++ 3 files changed, 159 insertions(+) create mode 100644 src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/ExpanderTests/Expander_Bindings_TemplatedControl.xaml create mode 100644 src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/ExpanderTests/Expander_Bindings_TemplatedControl.xaml.cs diff --git a/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/ExpanderTests/Expander_Bindings_TemplatedControl.xaml b/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/ExpanderTests/Expander_Bindings_TemplatedControl.xaml new file mode 100644 index 000000000000..a5b63e36ea6c --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/ExpanderTests/Expander_Bindings_TemplatedControl.xaml @@ -0,0 +1,99 @@ + + + + + + + + + + diff --git a/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/ExpanderTests/Expander_Bindings_TemplatedControl.xaml.cs b/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/ExpanderTests/Expander_Bindings_TemplatedControl.xaml.cs new file mode 100644 index 000000000000..1f820df6b935 --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/ExpanderTests/Expander_Bindings_TemplatedControl.xaml.cs @@ -0,0 +1,53 @@ +#nullable enable +using Uno.UI.Samples.Controls; +using Microsoft.UI.Xaml.Automation.Peers; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml; +using Microsoft.Graph.Models; +using System; + +// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 + +namespace UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests; + +[Sample("Expander", "MUX", Name = "Expander_Bindings_TemplatedControl", isManualTest: true)] +public sealed partial class Expander_Bindings_TemplatedControl : UserControl +{ + public Expander_Bindings_TemplatedControl() + { + this.InitializeComponent(); + } +} + +public partial class SettingsExpander : Control +{ + public SettingsExpander() { } + + public object Header + { + get => (object)GetValue(HeaderProperty); + set => SetValue(HeaderProperty, value); + } + + public bool IsExpanded + { + get => (bool)GetValue(IsExpandedProperty); + set => SetValue(IsExpandedProperty, value); + } + protected virtual void OnIsExpandedPropertyChanged(bool oldValue, bool newValue) + { + } + + public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register( + nameof(Header), + typeof(object), + typeof(SettingsExpander), + new PropertyMetadata(defaultValue: null)); + + public static readonly DependencyProperty IsExpandedProperty = DependencyProperty.Register( + nameof(IsExpanded), + typeof(bool), + typeof(SettingsExpander), + new PropertyMetadata(defaultValue: false, (d, e) => ((SettingsExpander)d).OnIsExpandedPropertyChanged((bool)e.OldValue, (bool)e.NewValue))); +} diff --git a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems index be9dd1c0e399..f6f52e05a8ff 100644 --- a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems +++ b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems @@ -70,6 +70,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -5476,6 +5480,9 @@ + + Expander_Bindings_TemplatedControl.xaml + From 949314254c4ff9bd5d3ff6d0cbc7eccf2b593bec Mon Sep 17 00:00:00 2001 From: Andres Pineda Date: Thu, 26 Sep 2024 14:29:26 -0400 Subject: [PATCH 2/3] chore: fix typo --- .../ExpanderTests/Expander_Bindings_TemplatedControl.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/ExpanderTests/Expander_Bindings_TemplatedControl.xaml.cs b/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/ExpanderTests/Expander_Bindings_TemplatedControl.xaml.cs index 1f820df6b935..62c899a95829 100644 --- a/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/ExpanderTests/Expander_Bindings_TemplatedControl.xaml.cs +++ b/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/ExpanderTests/Expander_Bindings_TemplatedControl.xaml.cs @@ -11,7 +11,7 @@ namespace UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests; -[Sample("Expander", "MUX", Name = "Expander_Bindings_TemplatedControl", isManualTest: true)] +[Sample("Expander", "MUX", Name = "Expander_Bindings_TemplatedControl", IsManualTest = true)] public sealed partial class Expander_Bindings_TemplatedControl : UserControl { public Expander_Bindings_TemplatedControl() From 6486ba35ba2f020b9f49c758649c4144e0cd83a7 Mon Sep 17 00:00:00 2001 From: Andres Pineda Date: Wed, 2 Oct 2024 21:54:00 -0400 Subject: [PATCH 3/3] test: add sample description --- .../Expander_Bindings_TemplatedControl.xaml.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/ExpanderTests/Expander_Bindings_TemplatedControl.xaml.cs b/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/ExpanderTests/Expander_Bindings_TemplatedControl.xaml.cs index 62c899a95829..8433bf251eb2 100644 --- a/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/ExpanderTests/Expander_Bindings_TemplatedControl.xaml.cs +++ b/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/ExpanderTests/Expander_Bindings_TemplatedControl.xaml.cs @@ -11,7 +11,14 @@ namespace UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests; -[Sample("Expander", "MUX", Name = "Expander_Bindings_TemplatedControl", IsManualTest = true)] +[Sample("Expander", "MUX", + Name = "Expander_Bindings_TemplatedControl", + IsManualTest = true, + Description = + "Validates that the Expander control can be templated and that bindings work correctly. \r\n" + + "When the Content property is bound to a templated control, the control should be displayed correctly. \r\n" + + "When expanded the control should display two TextBlocks with the text 'Hello From Header in Custom Control' and 'On the Content'." + )] public sealed partial class Expander_Bindings_TemplatedControl : UserControl { public Expander_Bindings_TemplatedControl()