1- < File content after removing the line 'using CommunityToolkit . WinUI . Helpers ; '>
1+ // Licensed to the .NET Foundation under one or more agreements.
2+ // The .NET Foundation licenses this file to you under the MIT license.
3+ // See the LICENSE file in the project root for more information.
4+
5+ using CommunityToolkit . WinUI . Controls ;
6+ using CommunityToolkit . Tooling . TestGen ;
7+ using CommunityToolkit . Tests ;
8+ using CommunityToolkit . WinUI . Controls . Automation . Peers ;
9+
10+ namespace SizersTests ;
11+
12+ [ TestClass ]
13+ public partial class ExampleSizerBaseTestClass : VisualUITestBase
14+ {
15+ [ TestMethod ]
16+ public async Task ShouldConfigureGridSplitterAutomationPeer ( )
17+ {
18+ await EnqueueAsync ( ( ) =>
19+ {
20+ const string automationName = "MyCustomAutomationName" ;
21+ const string name = "Sizer" ;
22+
23+ var gridSplitter = new GridSplitter ( ) ;
24+ var gridSplitterAutomationPeer = FrameworkElementAutomationPeer . CreatePeerForElement ( gridSplitter ) as SizerAutomationPeer ;
25+
26+ Assert . IsNotNull ( gridSplitterAutomationPeer , "Verify that the AutomationPeer is SizerAutomationPeer." ) ;
27+
28+ gridSplitter . Name = name ;
29+ Assert . IsTrue ( gridSplitterAutomationPeer . GetName ( ) . Contains ( name ) , "Verify that the UIA name contains the given Name of the GridSplitter (Sizer)." ) ;
30+
31+ gridSplitter . SetValue ( AutomationProperties . NameProperty , automationName ) ;
32+ Assert . IsTrue ( gridSplitterAutomationPeer . GetName ( ) . Contains ( automationName ) , "Verify that the UIA name contains the customized AutomationProperties.Name of the GridSplitter." ) ;
33+ } ) ;
34+ }
35+
36+ [ UIThreadTestMethod ]
37+ public void PropertySizer_TestInitialBinding ( PropertySizerTestInitialBinding testControl )
38+ {
39+ var propertySizer = testControl . FindDescendant < PropertySizer > ( ) ;
40+
41+ Assert . IsNotNull ( propertySizer , "Could not find PropertySizer control." ) ;
42+
43+ // Set in XAML Page LINK: PropertySizerTestInitialBinding.xaml#L14
44+ Assert . AreEqual ( 300 , propertySizer . Binding , "Property Sizer not at expected initial value." ) ;
45+ }
46+
47+ [ UIThreadTestMethod ]
48+ public void PropertySizer_TestChangeBinding ( PropertySizerTestInitialBinding testControl )
49+ {
50+ var propertySizer = testControl . FindDescendant < PropertySizer > ( ) ;
51+ var navigationView = testControl . FindDescendant < MUXC . NavigationView > ( ) ;
52+
53+ Assert . IsNotNull ( propertySizer , "Could not find PropertySizer control." ) ;
54+ Assert . IsNotNull ( navigationView , "Could not find NavigationView control." ) ;
55+
56+ navigationView . OpenPaneLength = 200 ;
57+
58+ // Set in XAML Page LINK: PropertySizerTestInitialBinding.xaml#L14
59+ Assert . AreEqual ( 200 , propertySizer . Binding , "Property Sizer not at expected changed value." ) ;
60+ }
61+
62+ [ UIThreadTestMethod ]
63+ public void ContentSizer_TestAutoLayout_NonZeroAndNaN ( ContentSizerTestInitialLayout testControl )
64+ {
65+ var contentSizer = testControl . FindDescendant < ContentSizer > ( ) ;
66+ var textBlock = testControl . FindDescendant < TextBlock > ( ) ;
67+
68+ Assert . IsNotNull ( contentSizer , "Could not find ContentSizer control." ) ;
69+ Assert . IsNotNull ( textBlock , "Could not find TextBlock control." ) ;
70+
71+ Assert . IsTrue ( textBlock . DesiredSize . Width > 5 , "TextBlock desired size is too small." ) ;
72+ Assert . IsTrue ( double . IsNaN ( textBlock . Width ) , "TextBlock width should not be constrained and be NaN." ) ;
73+ }
74+ }
0 commit comments