From 567be18a3020789cde0cf809c4dccbc8500e210f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 30 Jul 2025 15:19:08 +0000 Subject: [PATCH 1/4] Initial plan From 709e89b85d556bbfa3d546aff35b202ada05f2b3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 30 Jul 2025 15:29:04 +0000 Subject: [PATCH 2/4] Add LocalizedControlType to FlipView controls for accessibility Co-authored-by: niels9001 <9866362+niels9001@users.noreply.github.com> --- WinUIGallery/Samples/ControlPages/FlipViewPage.xaml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/WinUIGallery/Samples/ControlPages/FlipViewPage.xaml b/WinUIGallery/Samples/ControlPages/FlipViewPage.xaml index 9a61b19fb..257603747 100644 --- a/WinUIGallery/Samples/ControlPages/FlipViewPage.xaml +++ b/WinUIGallery/Samples/ControlPages/FlipViewPage.xaml @@ -22,7 +22,7 @@ ExampleHeight="Auto" HeaderText="A simple FlipView with items declared inline."> - + @@ -32,7 +32,7 @@ -<FlipView MaxWidth="400" Height="270"> +<FlipView MaxWidth="400" Height="270" AutomationProperties.LocalizedControlType="FlipView"> <Image Source="ms-appx:///Assets/SampleMedia/cliff.jpg" AutomationProperties.Name="Cliff"/> <Image Source="ms-appx:///Assets/SampleMedia/grapes.jpg" AutomationProperties.Name="Grapes"/> <Image Source="ms-appx:///Assets/SampleMedia/rainier.jpg" AutomationProperties.Name="Rainier"/> @@ -49,6 +49,7 @@ MaxWidth="400" BorderBrush="Black" BorderThickness="1" + AutomationProperties.LocalizedControlType="FlipView" ItemsSource="{x:Bind Items, Mode=OneWay}"> @@ -81,7 +82,7 @@ -<FlipView MaxWidth="400" Height="180" BorderBrush="Black" BorderThickness="1" ItemsSource="{x:Bind Items, Mode=OneWay}"> +<FlipView MaxWidth="400" Height="180" BorderBrush="Black" BorderThickness="1" AutomationProperties.LocalizedControlType="FlipView" ItemsSource="{x:Bind Items, Mode=OneWay}"> <FlipView.ItemTemplate> <DataTemplate x:DataType="data:ControlInfoDataItem"> <Grid> @@ -98,7 +99,7 @@ - + @@ -113,7 +114,7 @@ -<FlipView MaxWidth="400" Height="270"> +<FlipView MaxWidth="400" Height="270" AutomationProperties.LocalizedControlType="FlipView"> <Image Source="ms-appx:///Assets/SampleMedia/cliff.jpg" AutomationProperties.Name="Cliff"/> <Image Source="ms-appx:///Assets/SampleMedia/grapes.jpg" AutomationProperties.Name="Grapes"/> <Image Source="ms-appx:///Assets/SampleMedia/rainier.jpg" AutomationProperties.Name="Rainier"/> @@ -124,7 +125,7 @@ <VirtualizingStackPanel Orientation="Vertical"/> </ItemsPanelTemplate> </FlipView.ItemsPanel> -<FlipView> +</FlipView> From 3df03a821daa276044273a91e81889d103ba62a7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 30 Jul 2025 15:33:00 +0000 Subject: [PATCH 3/4] Add comprehensive tests for FlipView LocalizedControlType accessibility Co-authored-by: niels9001 <9866362+niels9001@users.noreply.github.com> --- tests/WinUIGallery.UITests/Tests/FlipView.cs | 73 ++++++++++++++++++++ tests/WinUIGallery.UnitTests/UnitTests.cs | 71 +++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 tests/WinUIGallery.UITests/Tests/FlipView.cs diff --git a/tests/WinUIGallery.UITests/Tests/FlipView.cs b/tests/WinUIGallery.UITests/Tests/FlipView.cs new file mode 100644 index 000000000..0beff8a05 --- /dev/null +++ b/tests/WinUIGallery.UITests/Tests/FlipView.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OpenQA.Selenium.Appium.Windows; + +namespace WinUIGallery.UITests.Tests; + +[TestClass] +public class FlipView : TestBase +{ + private static WindowsElement flipViewElement1 = null; + private static WindowsElement flipViewElement2 = null; + private static WindowsElement flipViewElement3 = null; + + [ClassInitialize] + public static void ClassInitialize(TestContext context) + { + OpenControlPage("FlipView"); + + // Wait for the page to load and find FlipView elements + System.Threading.Thread.Sleep(1000); + + // Find the FlipView controls - they should have LocalizedControlType set + var flipViews = Session.FindElementsByClassName("FlipView"); + Assert.IsTrue(flipViews.Count >= 3, "FlipViewPage should contain at least 3 FlipView controls"); + + flipViewElement1 = flipViews[0]; + flipViewElement2 = flipViews[1]; + flipViewElement3 = flipViews[2]; + + Assert.IsNotNull(flipViewElement1); + Assert.IsNotNull(flipViewElement2); + Assert.IsNotNull(flipViewElement3); + } + + [TestMethod] + public void VerifyFlipViewLocalizedControlType() + { + // Verify that FlipView controls have proper LocalizedControlType for accessibility + Assert.AreEqual("FlipView", flipViewElement1.GetAttribute("LocalizedControlType"), + "First FlipView should have LocalizedControlType set to 'FlipView'"); + Assert.AreEqual("FlipView", flipViewElement2.GetAttribute("LocalizedControlType"), + "Second FlipView should have LocalizedControlType set to 'FlipView'"); + Assert.AreEqual("FlipView", flipViewElement3.GetAttribute("LocalizedControlType"), + "Third FlipView should have LocalizedControlType set to 'FlipView'"); + } + + [TestMethod] + public void BasicFlipViewNavigation() + { + // Test basic FlipView navigation functionality + Assert.IsTrue(flipViewElement1.Displayed, "FlipView should be visible"); + + // Get the initial selected item + var selectedItem = flipViewElement1.GetAttribute("Selection.SelectedItem"); + Assert.IsNotNull(selectedItem, "FlipView should have a selected item"); + + // Try to navigate (this might require keyboard navigation or finding navigation buttons) + flipViewElement1.Click(); + System.Threading.Thread.Sleep(500); + + // Basic verification that the control is functional + Assert.IsTrue(flipViewElement1.Enabled, "FlipView should be enabled and functional"); + } + + [TestMethod] + public void VerifyAccessibilityCompliance() + { + // Run accessibility scan specifically for FlipView + AxeHelper.AssertNoAccessibilityErrors(); + } +} \ No newline at end of file diff --git a/tests/WinUIGallery.UnitTests/UnitTests.cs b/tests/WinUIGallery.UnitTests/UnitTests.cs index 2e20e6ab3..e20039453 100644 --- a/tests/WinUIGallery.UnitTests/UnitTests.cs +++ b/tests/WinUIGallery.UnitTests/UnitTests.cs @@ -17,6 +17,7 @@ using System.Threading.Tasks; using Windows.Foundation; using WinUIGallery.Helpers; +using WinUIGallery.ControlPages; namespace WinUIGallery.UnitTests; @@ -184,6 +185,76 @@ private void ExecuteOnUIThread(Action action) } } + [UITestMethod] + public void TestFlipViewAutomationProperties() + { + FlipView flipView = new() + { + Height = 270, + MaxWidth = 400 + }; + + // Set the LocalizedControlType as done in the FlipViewPage + Microsoft.UI.Xaml.Automation.AutomationProperties.SetLocalizedControlType(flipView, "FlipView"); + + // Add some test items + flipView.Items.Add(new Rectangle() { Fill = new SolidColorBrush(Colors.Red), Width = 100, Height = 100 }); + flipView.Items.Add(new Rectangle() { Fill = new SolidColorBrush(Colors.Blue), Width = 100, Height = 100 }); + + UnitTestApp.UnitTestAppWindow.AddToVisualTree(flipView); + flipView.UpdateLayout(); + + // Verify that the LocalizedControlType is set correctly + var localizedControlType = Microsoft.UI.Xaml.Automation.AutomationProperties.GetLocalizedControlType(flipView); + Assert.AreEqual("FlipView", localizedControlType, "FlipView should have LocalizedControlType set to 'FlipView'"); + + // Verify that the control is accessible + Assert.IsNotNull(flipView, "FlipView should be created successfully"); + Assert.AreEqual(2, flipView.Items.Count, "FlipView should contain 2 items"); + } + + [UITestMethod] + public void TestFlipViewPageAutomationProperties() + { + // Create an instance of FlipViewPage to test the actual implementation + FlipViewPage flipViewPage = new(); + + UnitTestApp.UnitTestAppWindow.AddToVisualTree(flipViewPage); + flipViewPage.UpdateLayout(); + + // Find FlipView controls in the page and verify their LocalizedControlType + var flipViews = FindVisualChildren(flipViewPage); + + Assert.IsTrue(flipViews.Count() >= 3, "FlipViewPage should contain at least 3 FlipView controls"); + + foreach (var flipView in flipViews) + { + var localizedControlType = Microsoft.UI.Xaml.Automation.AutomationProperties.GetLocalizedControlType(flipView); + Assert.AreEqual("FlipView", localizedControlType, + $"FlipView should have LocalizedControlType set to 'FlipView' for accessibility compliance"); + } + } + + private static IEnumerable FindVisualChildren(DependencyObject depObj) where T : DependencyObject + { + if (depObj != null) + { + for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++) + { + DependencyObject child = VisualTreeHelper.GetChild(depObj, i); + if (child != null && child is T) + { + yield return (T)child; + } + + foreach (T childOfChild in FindVisualChildren(child)) + { + yield return childOfChild; + } + } + } + } + [TestCleanup] public void Cleanup() { From 9bb8b0ff520bcbddd9beecba68247ae5b714b6b3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 30 Jul 2025 15:56:15 +0000 Subject: [PATCH 4/4] Remove tests and LocalizedControlType from XAML code snippets per feedback Co-authored-by: niels9001 <9866362+niels9001@users.noreply.github.com> --- .../Samples/ControlPages/FlipViewPage.xaml | 6 +- tests/WinUIGallery.UITests/Tests/FlipView.cs | 73 ------------------- tests/WinUIGallery.UnitTests/UnitTests.cs | 71 ------------------ 3 files changed, 3 insertions(+), 147 deletions(-) delete mode 100644 tests/WinUIGallery.UITests/Tests/FlipView.cs diff --git a/WinUIGallery/Samples/ControlPages/FlipViewPage.xaml b/WinUIGallery/Samples/ControlPages/FlipViewPage.xaml index 257603747..388bc4e8d 100644 --- a/WinUIGallery/Samples/ControlPages/FlipViewPage.xaml +++ b/WinUIGallery/Samples/ControlPages/FlipViewPage.xaml @@ -32,7 +32,7 @@ -<FlipView MaxWidth="400" Height="270" AutomationProperties.LocalizedControlType="FlipView"> +<FlipView MaxWidth="400" Height="270"> <Image Source="ms-appx:///Assets/SampleMedia/cliff.jpg" AutomationProperties.Name="Cliff"/> <Image Source="ms-appx:///Assets/SampleMedia/grapes.jpg" AutomationProperties.Name="Grapes"/> <Image Source="ms-appx:///Assets/SampleMedia/rainier.jpg" AutomationProperties.Name="Rainier"/> @@ -82,7 +82,7 @@ -<FlipView MaxWidth="400" Height="180" BorderBrush="Black" BorderThickness="1" AutomationProperties.LocalizedControlType="FlipView" ItemsSource="{x:Bind Items, Mode=OneWay}"> +<FlipView MaxWidth="400" Height="180" BorderBrush="Black" BorderThickness="1" ItemsSource="{x:Bind Items, Mode=OneWay}"> <FlipView.ItemTemplate> <DataTemplate x:DataType="data:ControlInfoDataItem"> <Grid> @@ -114,7 +114,7 @@ -<FlipView MaxWidth="400" Height="270" AutomationProperties.LocalizedControlType="FlipView"> +<FlipView MaxWidth="400" Height="270"> <Image Source="ms-appx:///Assets/SampleMedia/cliff.jpg" AutomationProperties.Name="Cliff"/> <Image Source="ms-appx:///Assets/SampleMedia/grapes.jpg" AutomationProperties.Name="Grapes"/> <Image Source="ms-appx:///Assets/SampleMedia/rainier.jpg" AutomationProperties.Name="Rainier"/> diff --git a/tests/WinUIGallery.UITests/Tests/FlipView.cs b/tests/WinUIGallery.UITests/Tests/FlipView.cs deleted file mode 100644 index 0beff8a05..000000000 --- a/tests/WinUIGallery.UITests/Tests/FlipView.cs +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -using Microsoft.VisualStudio.TestTools.UnitTesting; -using OpenQA.Selenium.Appium.Windows; - -namespace WinUIGallery.UITests.Tests; - -[TestClass] -public class FlipView : TestBase -{ - private static WindowsElement flipViewElement1 = null; - private static WindowsElement flipViewElement2 = null; - private static WindowsElement flipViewElement3 = null; - - [ClassInitialize] - public static void ClassInitialize(TestContext context) - { - OpenControlPage("FlipView"); - - // Wait for the page to load and find FlipView elements - System.Threading.Thread.Sleep(1000); - - // Find the FlipView controls - they should have LocalizedControlType set - var flipViews = Session.FindElementsByClassName("FlipView"); - Assert.IsTrue(flipViews.Count >= 3, "FlipViewPage should contain at least 3 FlipView controls"); - - flipViewElement1 = flipViews[0]; - flipViewElement2 = flipViews[1]; - flipViewElement3 = flipViews[2]; - - Assert.IsNotNull(flipViewElement1); - Assert.IsNotNull(flipViewElement2); - Assert.IsNotNull(flipViewElement3); - } - - [TestMethod] - public void VerifyFlipViewLocalizedControlType() - { - // Verify that FlipView controls have proper LocalizedControlType for accessibility - Assert.AreEqual("FlipView", flipViewElement1.GetAttribute("LocalizedControlType"), - "First FlipView should have LocalizedControlType set to 'FlipView'"); - Assert.AreEqual("FlipView", flipViewElement2.GetAttribute("LocalizedControlType"), - "Second FlipView should have LocalizedControlType set to 'FlipView'"); - Assert.AreEqual("FlipView", flipViewElement3.GetAttribute("LocalizedControlType"), - "Third FlipView should have LocalizedControlType set to 'FlipView'"); - } - - [TestMethod] - public void BasicFlipViewNavigation() - { - // Test basic FlipView navigation functionality - Assert.IsTrue(flipViewElement1.Displayed, "FlipView should be visible"); - - // Get the initial selected item - var selectedItem = flipViewElement1.GetAttribute("Selection.SelectedItem"); - Assert.IsNotNull(selectedItem, "FlipView should have a selected item"); - - // Try to navigate (this might require keyboard navigation or finding navigation buttons) - flipViewElement1.Click(); - System.Threading.Thread.Sleep(500); - - // Basic verification that the control is functional - Assert.IsTrue(flipViewElement1.Enabled, "FlipView should be enabled and functional"); - } - - [TestMethod] - public void VerifyAccessibilityCompliance() - { - // Run accessibility scan specifically for FlipView - AxeHelper.AssertNoAccessibilityErrors(); - } -} \ No newline at end of file diff --git a/tests/WinUIGallery.UnitTests/UnitTests.cs b/tests/WinUIGallery.UnitTests/UnitTests.cs index e20039453..2e20e6ab3 100644 --- a/tests/WinUIGallery.UnitTests/UnitTests.cs +++ b/tests/WinUIGallery.UnitTests/UnitTests.cs @@ -17,7 +17,6 @@ using System.Threading.Tasks; using Windows.Foundation; using WinUIGallery.Helpers; -using WinUIGallery.ControlPages; namespace WinUIGallery.UnitTests; @@ -185,76 +184,6 @@ private void ExecuteOnUIThread(Action action) } } - [UITestMethod] - public void TestFlipViewAutomationProperties() - { - FlipView flipView = new() - { - Height = 270, - MaxWidth = 400 - }; - - // Set the LocalizedControlType as done in the FlipViewPage - Microsoft.UI.Xaml.Automation.AutomationProperties.SetLocalizedControlType(flipView, "FlipView"); - - // Add some test items - flipView.Items.Add(new Rectangle() { Fill = new SolidColorBrush(Colors.Red), Width = 100, Height = 100 }); - flipView.Items.Add(new Rectangle() { Fill = new SolidColorBrush(Colors.Blue), Width = 100, Height = 100 }); - - UnitTestApp.UnitTestAppWindow.AddToVisualTree(flipView); - flipView.UpdateLayout(); - - // Verify that the LocalizedControlType is set correctly - var localizedControlType = Microsoft.UI.Xaml.Automation.AutomationProperties.GetLocalizedControlType(flipView); - Assert.AreEqual("FlipView", localizedControlType, "FlipView should have LocalizedControlType set to 'FlipView'"); - - // Verify that the control is accessible - Assert.IsNotNull(flipView, "FlipView should be created successfully"); - Assert.AreEqual(2, flipView.Items.Count, "FlipView should contain 2 items"); - } - - [UITestMethod] - public void TestFlipViewPageAutomationProperties() - { - // Create an instance of FlipViewPage to test the actual implementation - FlipViewPage flipViewPage = new(); - - UnitTestApp.UnitTestAppWindow.AddToVisualTree(flipViewPage); - flipViewPage.UpdateLayout(); - - // Find FlipView controls in the page and verify their LocalizedControlType - var flipViews = FindVisualChildren(flipViewPage); - - Assert.IsTrue(flipViews.Count() >= 3, "FlipViewPage should contain at least 3 FlipView controls"); - - foreach (var flipView in flipViews) - { - var localizedControlType = Microsoft.UI.Xaml.Automation.AutomationProperties.GetLocalizedControlType(flipView); - Assert.AreEqual("FlipView", localizedControlType, - $"FlipView should have LocalizedControlType set to 'FlipView' for accessibility compliance"); - } - } - - private static IEnumerable FindVisualChildren(DependencyObject depObj) where T : DependencyObject - { - if (depObj != null) - { - for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++) - { - DependencyObject child = VisualTreeHelper.GetChild(depObj, i); - if (child != null && child is T) - { - yield return (T)child; - } - - foreach (T childOfChild in FindVisualChildren(child)) - { - yield return childOfChild; - } - } - } - } - [TestCleanup] public void Cleanup() {