forked from microsoft/microsoft-ui-xaml
-
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.
Add ExpanderToggleButton Children to Peer (microsoft#6032)
* add expanderToggleButton children to peer * remove accessibilityView=Raw * fix CI build failures * add test * WIP * api test proj setup * revert changes * fix tests * add toggleswitch scenario * add integration test for automationpeer
- Loading branch information
Showing
10 changed files
with
198 additions
and
4 deletions.
There are no files selected for viewing
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
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,99 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
using Common; | ||
using Microsoft.UI.Xaml.Controls; | ||
using MUXControlsTestApp.Utilities; | ||
using Microsoft.UI.Xaml.Automation.Peers; | ||
using Windows.UI.Xaml.Automation.Provider; | ||
using Windows.UI.Xaml.Automation.Peers; | ||
using Windows.UI.Xaml.Media; | ||
using Windows.UI.Xaml.Automation; | ||
using Windows.UI.Xaml.Shapes; | ||
using Windows.UI.Xaml.Markup; | ||
using Windows.UI.Xaml.Controls; | ||
|
||
#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 | ||
|
||
namespace Windows.UI.Xaml.Tests.MUXControls.ApiTests | ||
{ | ||
[TestClass] | ||
public class ExpanderTests : ApiTestBase | ||
{ | ||
[TestMethod] | ||
public void ExpanderAutomationPeerTest() | ||
{ | ||
RunOnUIThread.Execute(() => | ||
{ | ||
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; | ||
|
||
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); | ||
}); | ||
} | ||
} | ||
} |
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,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' < '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> | ||
<HasSharedItems>true</HasSharedItems> | ||
<SharedGUID>0589A608-FB9C-49BF-9EA3-06CA805F3A9D</SharedGUID> | ||
</PropertyGroup> | ||
<PropertyGroup Label="Configuration"> | ||
<Import_RootNamespace>Expander_APITests</Import_RootNamespace> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildThisFileDirectory)ExpanderTests.cs" /> | ||
</ItemGroup> | ||
</Project> |
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,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>0589A608-FB9C-49BF-9EA3-06CA805F3A9D</ProjectGuid> | ||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion> | ||
</PropertyGroup> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" /> | ||
<PropertyGroup /> | ||
<Import Project="Expander_APITests.projitems" Label="Shared" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" /> | ||
</Project> |
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,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<TestSettings | ||
id="b924e60c-07ac-4b08-bf83-82852801b90b" | ||
name="Expander_APITests" | ||
enableDefaultDataCollectors="false" | ||
xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010"> | ||
<Description><!--_locID_text="Description1"-->These are default test settings for a local test run.</Description> | ||
<Deployment enabled="false" /> | ||
</TestSettings> |
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
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
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
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
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