@@ -91,6 +91,46 @@ await App.DispatcherQueue.EnqueueAsync(async () =>
9191 } ) ;
9292 }
9393
94+ [ TestCategory ( "ConstrainedBox" ) ]
95+ [ TestMethod ]
96+ public async Task Test_ConstrainedBox_Normal_IntegerWidth ( )
97+ {
98+ await App . DispatcherQueue . EnqueueAsync ( async ( ) =>
99+ {
100+ var treeRoot = XamlReader . Load ( @"<Page
101+ xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
102+ xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
103+ xmlns:controls=""using:Microsoft.Toolkit.Uwp.UI.Controls"">
104+ <controls:ConstrainedBox x:Name=""ConstrainedBox"" AspectRatio=""2"" Height=""100"">
105+ <Border HorizontalAlignment=""Stretch"" VerticalAlignment=""Stretch"" Background=""Red""/>
106+ </controls:ConstrainedBox>
107+ </Page>" ) as FrameworkElement ;
108+
109+ Assert . IsNotNull ( treeRoot , "Could not load XAML tree." ) ;
110+
111+ // Initialize Visual Tree
112+ await SetTestContentAsync ( treeRoot ) ;
113+
114+ var panel = treeRoot . FindChild ( "ConstrainedBox" ) as ConstrainedBox ;
115+
116+ Assert . IsNotNull ( panel , "Could not find ConstrainedBox in tree." ) ;
117+
118+ // Check Size
119+ Assert . AreEqual ( 2.0 , panel . AspectRatio , 0.01 , "ApectRatio does not meet expected value of 2.0" ) ;
120+
121+ // Force Layout calculations
122+ panel . UpdateLayout ( ) ;
123+
124+ var child = panel . Content as Border ;
125+
126+ Assert . IsNotNull ( child , "Could not find inner Border" ) ;
127+
128+ // Check Size
129+ Assert . AreEqual ( 200 , child . ActualWidth , 0.01 , "Actual width does not meet expected value of 200" ) ;
130+ Assert . AreEqual ( 100 , child . ActualHeight , 0.01 , "Actual height does not meet expected value of 100" ) ;
131+ } ) ;
132+ }
133+
94134 [ TestCategory ( "ConstrainedBox" ) ]
95135 [ TestMethod ]
96136 public void Test_ConstrainedBox_AspectRatioParsing_WidthAndHeight ( )
0 commit comments