forked from unoplatform/uno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request unoplatform#14257 from ramezgerges/expander_align_…
…winui chore: align Expander with WinUI
- Loading branch information
Showing
4 changed files
with
369 additions
and
46 deletions.
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Expander/ExpanderTests_APITests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
// MUX Reference Expander/APITests/ExpanderTests.cpp, tag winui3/release/1.4.2 | ||
|
||
using Windows.UI.Xaml.Automation; | ||
using Windows.UI.Xaml.Automation.Peers; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Markup; | ||
using Windows.UI.Xaml.Media; | ||
using Common; | ||
#if !HAS_UNO_WINUI | ||
using Microsoft.UI.Xaml.Controls; | ||
#endif | ||
using MUXControlsTestApp.Utilities; | ||
using Uno.UI.RuntimeTests.Helpers; | ||
|
||
namespace Microsoft.UI.Xaml.Tests.MUXControls.ApiTests | ||
{ | ||
[TestClass] | ||
public class ExpanderTests : MUXApiTestBase | ||
{ | ||
[TestMethod] | ||
public void ExpanderAutomationPeerTest() | ||
{ | ||
RunOnUIThread.Execute(() => | ||
{ | ||
// Uno specific: the control is fluent only | ||
using var _ = StyleHelper.UseFluentStyles(); | ||
var root = (StackPanel)XamlReader.Load( | ||
@"<StackPanel xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' | ||
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' | ||
xmlns:primitives='using:Microsoft.UI.Xaml.Controls.Primitives' | ||
xmlns:controls='using:Microsoft.UI.Xaml.Controls'> | ||
<controls:Expander x:Name ='ExpandedExpander' AutomationProperties.Name='ExpandedExpander' IsExpanded='True' Margin='12' HorizontalAlignment='Left'> | ||
<controls:Expander.Header> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition /> | ||
<ColumnDefinition Width='80'/> | ||
</Grid.ColumnDefinitions> | ||
<StackPanel Margin='0,14,0,16'> | ||
<TextBlock AutomationProperties.Name='test' Text='This expander is expanded by default.' Margin='0,0,0,4' /> | ||
<TextBlock Text='This is the second line of text.' /> | ||
</StackPanel> | ||
<ToggleSwitch Grid.Column='1'/> | ||
</Grid> | ||
</controls:Expander.Header> | ||
<Button AutomationProperties.AutomationId = 'ExpandedExpanderContent'> Content </Button> | ||
</controls:Expander> | ||
</StackPanel>"); | ||
Content = root; | ||
Content.UpdateLayout(); | ||
var expander = VisualTreeHelper.GetChild(root, 0) as Expander; | ||
expander.IsExpanded = true; | ||
Content.UpdateLayout(); | ||
var grid = VisualTreeHelper.GetChild(expander, 0); | ||
var toggleButton = VisualTreeHelper.GetChild(grid, 0); | ||
var toggleButtonGrid = VisualTreeHelper.GetChild(toggleButton, 0); | ||
var contentPresenter = VisualTreeHelper.GetChild(toggleButtonGrid, 0); | ||
var grid2 = VisualTreeHelper.GetChild(contentPresenter, 0); | ||
var stackPanel = VisualTreeHelper.GetChild(grid2, 0); | ||
var textBlock1 = VisualTreeHelper.GetChild(stackPanel, 0) as TextBlock; | ||
var textBlock2 = VisualTreeHelper.GetChild(stackPanel, 1) as TextBlock; | ||
var toggleSwitch = VisualTreeHelper.GetChild(grid2, 1) as ToggleSwitch; | ||
var border = VisualTreeHelper.GetChild(grid, 1); | ||
var expanderContentBorder = VisualTreeHelper.GetChild(border, 0); | ||
var expanderContentContentPresenter = VisualTreeHelper.GetChild(expanderContentBorder, 0); | ||
var button = VisualTreeHelper.GetChild(expanderContentContentPresenter, 0) as Button; | ||
// https://github.com/unoplatform/uno/issues/14256 | ||
// Verify.AreEqual("ExpandedExpander", AutomationProperties.GetName(expander)); | ||
// Verify ExpandedExpander header content are included in the accessibility tree | ||
Verify.AreEqual(AutomationProperties.GetAccessibilityView(textBlock1), AccessibilityView.Content); | ||
Verify.AreEqual(AutomationProperties.GetAccessibilityView(textBlock2), AccessibilityView.Content); | ||
Verify.AreEqual(AutomationProperties.GetAccessibilityView(toggleSwitch), AccessibilityView.Content); | ||
// Verify ExpandedExpander content is included in the accessibility tree | ||
Verify.AreEqual(AutomationProperties.GetAccessibilityView(button), AccessibilityView.Content); | ||
expander.IsExpanded = false; | ||
Content.UpdateLayout(); | ||
// Verify ExpandedExpander content is not included in the accessibility tree and not readable once collapsed | ||
Verify.AreNotEqual(AutomationProperties.GetAccessibilityView(button), AccessibilityView.Raw); | ||
}); | ||
} | ||
} | ||
} |
202 changes: 202 additions & 0 deletions
202
...UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Expander/ExpanderTests_InteractionTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
// // Copyright (c) Microsoft Corporation. All rights reserved. | ||
// // Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
// MUX Reference Expander/InteractionTests/ExpanderTests.cpp, tag winui3/release/1.4.2 | ||
|
||
// using System; | ||
// using Common; | ||
// using Windows.UI.Xaml.Tests.MUXControls.InteractionTests.Infra; | ||
// using Windows.UI.Xaml.Tests.MUXControls.InteractionTests.Common; | ||
// using System.Collections.Generic; | ||
// using Windows.Foundation.Metadata; | ||
// | ||
// #if USING_TAEF | ||
// using WEX.TestExecution; | ||
// using WEX.TestExecution.Markup; | ||
// using WEX.Logging.Interop; | ||
// #else | ||
// using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
// using Microsoft.VisualStudio.TestTools.UnitTesting.Logging; | ||
// #endif | ||
// | ||
// using Microsoft.Windows.Apps.Test.Automation; | ||
// using Microsoft.Windows.Apps.Test.Foundation; | ||
// using Microsoft.Windows.Apps.Test.Foundation.Controls; | ||
// using Microsoft.Windows.Apps.Test.Foundation.Patterns; | ||
// using Microsoft.Windows.Apps.Test.Foundation.Waiters; | ||
// using MUXTestInfra.Shared.Infra; | ||
// | ||
// namespace Windows.UI.Xaml.Tests.MUXControls.InteractionTests | ||
// { | ||
// public class Expander : UIObject, IExpandCollapse | ||
// { | ||
// public Expander(UIObject uiObject) | ||
// : base(uiObject) | ||
// { | ||
// this.Initialize(); | ||
// } | ||
// | ||
// private void Initialize() | ||
// { | ||
// _expandCollapsePattern = new ExpandCollapseImplementation(this); | ||
// } | ||
// | ||
// public void ExpandAndWait() | ||
// { | ||
// using (var waiter = GetExpandedWaiter()) | ||
// { | ||
// Expand(); | ||
// waiter.Wait(); | ||
// } | ||
// | ||
// Wait.ForIdle(); | ||
// } | ||
// | ||
// public void CollapseAndWait() | ||
// { | ||
// using (var waiter = GetCollapsedWaiter()) | ||
// { | ||
// Collapse(); | ||
// waiter.Wait(); | ||
// } | ||
// | ||
// Wait.ForIdle(); | ||
// } | ||
// | ||
// public void Expand() | ||
// { | ||
// _expandCollapsePattern.Expand(); | ||
// } | ||
// | ||
// public void Collapse() | ||
// { | ||
// _expandCollapsePattern.Collapse(); | ||
// } | ||
// | ||
// public UIEventWaiter GetExpandedWaiter() | ||
// { | ||
// return _expandCollapsePattern.GetExpandedWaiter(); | ||
// } | ||
// | ||
// public UIEventWaiter GetCollapsedWaiter() | ||
// { | ||
// return _expandCollapsePattern.GetCollapsedWaiter(); | ||
// } | ||
// | ||
// public ExpandCollapseState ExpandCollapseState | ||
// { | ||
// get { return _expandCollapsePattern.ExpandCollapseState; } | ||
// } | ||
// | ||
// new public static IFactory<Expander> Factory | ||
// { | ||
// get | ||
// { | ||
// if (null == Expander._factory) | ||
// { | ||
// Expander._factory = new ExpanderFactory(); | ||
// } | ||
// return Expander._factory; | ||
// } | ||
// } | ||
// | ||
// private IExpandCollapse _expandCollapsePattern; | ||
// private static IFactory<Expander> _factory = null; | ||
// private class ExpanderFactory : IFactory<Expander> | ||
// { | ||
// public Expander Create(UIObject element) | ||
// { | ||
// return new Expander(element); | ||
// } | ||
// } | ||
// } | ||
// | ||
// [TestClass] | ||
// public class ExpanderTests | ||
// { | ||
// [ClassInitialize] | ||
// [TestProperty("RunAs", "User")] | ||
// [TestProperty("Classification", "Integration")] | ||
// [TestProperty("Platform", "Any")] | ||
// [TestProperty("MUXControlsTestSuite", "SuiteB")] | ||
// public static void ClassInitialize(TestContext testContext) | ||
// { | ||
// TestEnvironment.Initialize(testContext); | ||
// } | ||
// | ||
// public void TestCleanup() | ||
// { | ||
// TestCleanupHelper.Cleanup(); | ||
// } | ||
// | ||
// [TestMethod] | ||
// public void VerifyAxeScanPasses() | ||
// { | ||
// using (var setup = new TestSetupHelper("Expander-Axe")) | ||
// { | ||
// AxeTestHelper.TestForAxeIssues(); | ||
// } | ||
// } | ||
// | ||
// [TestMethod] | ||
// public void ExpandCollapseAutomationTests() | ||
// { | ||
// using (var setup = new TestSetupHelper("Expander Tests")) | ||
// { | ||
// Expander expander = FindElement.ByName<Expander>("ExpandedExpander"); | ||
// expander.SetFocus(); | ||
// Wait.ForIdle(); | ||
// | ||
// Log.Comment("Collapse using keyboard space key."); | ||
// KeyboardHelper.PressKey(Key.Space); | ||
// Verify.AreEqual(expander.ExpandCollapseState, ExpandCollapseState.Collapsed); | ||
// | ||
// Log.Comment("Expand using keyboard space key."); | ||
// KeyboardHelper.PressKey(Key.Space); | ||
// Verify.AreEqual(expander.ExpandCollapseState, ExpandCollapseState.Expanded); | ||
// | ||
// Log.Comment("Collapse by clicking."); | ||
// expander.Click(); | ||
// Verify.AreEqual(expander.ExpandCollapseState, ExpandCollapseState.Collapsed); | ||
// | ||
// Log.Comment("Expand by clicking."); | ||
// expander.Click(); | ||
// Verify.AreEqual(expander.ExpandCollapseState, ExpandCollapseState.Expanded); | ||
// | ||
// Log.Comment("Collapse using UIA ExpandCollapse pattern"); | ||
// expander.CollapseAndWait(); | ||
// Verify.AreEqual(expander.ExpandCollapseState, ExpandCollapseState.Collapsed); | ||
// | ||
// Log.Comment("Expand using UIA ExpandCollapse pattern"); | ||
// expander.ExpandAndWait(); | ||
// Verify.AreEqual(expander.ExpandCollapseState, ExpandCollapseState.Expanded); | ||
// } | ||
// } | ||
// | ||
// [TestMethod] | ||
// public void AutomationPeerTest() | ||
// { | ||
// using (var setup = new TestSetupHelper("Expander Tests")) | ||
// { | ||
// Expander expander = FindElement.ByName<Expander>("ExpanderWithToggleSwitch"); | ||
// expander.SetFocus(); | ||
// Wait.ForIdle(); | ||
// | ||
// // Verify ExpandedExpander header content AutomationProperties.Name properties are set | ||
// VerifyElement.Found("This expander with ToggleSwitch is expanded by default.", FindBy.Name); | ||
// VerifyElement.Found("This is the second line of text.", FindBy.Name); | ||
// VerifyElement.Found("SettingsToggleSwitch", FindBy.Name); | ||
// | ||
// // Verify ExpandedExpander content AutomationProperties.Name property is set | ||
// VerifyElement.Found("ExpanderWithToggleSwitch Content", FindBy.Name); | ||
// | ||
// Log.Comment("Collapse using keyboard space key."); | ||
// KeyboardHelper.PressKey(Key.Space); | ||
// Verify.AreEqual(expander.ExpandCollapseState, ExpandCollapseState.Collapsed); | ||
// | ||
// // Verify ExpandedExpander content AutomationProperties.Name property is not visible once collapsed | ||
// VerifyElement.NotFound("ExpanderWithToggleSwitch Content", FindBy.Name); | ||
// } | ||
// } | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.