Skip to content

Commit ec72f70

Browse files
Add Infinite in Both directions for ConstrainedBox
1 parent 7698e7e commit ec72f70

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

UnitTests/UnitTests.UWP/UI/Controls/Test_ConstrainedBox.Infinity.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,52 @@ await App.DispatcherQueue.EnqueueAsync(async () =>
106106
Assert.AreEqual(200, child.ActualHeight, 0.01, "Actual height does not meet expected value of 200");
107107
});
108108
}
109+
110+
[TestCategory("ConstrainedBox")]
111+
[TestMethod]
112+
public async Task Test_ConstrainedBox_AllInfinite_AspectBothFallback()
113+
{
114+
await App.DispatcherQueue.EnqueueAsync(async () =>
115+
{
116+
var treeRoot = XamlReader.Load(@"<Page
117+
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
118+
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
119+
xmlns:controls=""using:Microsoft.Toolkit.Uwp.UI.Controls"">
120+
<ScrollViewer x:Name=""ScrollArea""
121+
HorizontalScrollMode=""Enabled"" HorizontalScrollBarVisibility=""Visible""
122+
VerticalScrollMode=""Enabled"" VerticalScrollBarVisibility=""Visible"">
123+
<controls:ConstrainedBox x:Name=""ConstrainedBox"" AspectRatio=""1:2"">
124+
<Border HorizontalAlignment=""Stretch"" VerticalAlignment=""Stretch"" Background=""Red""/>
125+
</controls:ConstrainedBox>
126+
</ScrollViewer>
127+
</Page>") as FrameworkElement;
128+
129+
Assert.IsNotNull(treeRoot, "Could not load XAML tree.");
130+
131+
// Initialize Visual Tree
132+
await SetTestContentAsync(treeRoot);
133+
134+
var scroll = treeRoot.FindChild("ScrollArea") as ScrollViewer;
135+
136+
Assert.IsNotNull(scroll, "Could not find ScrollViewer in tree.");
137+
138+
var panel = treeRoot.FindChild("ConstrainedBox") as ConstrainedBox;
139+
140+
Assert.IsNotNull(panel, "Could not find ConstrainedBox in tree.");
141+
142+
// Force Layout calculations
143+
panel.UpdateLayout();
144+
145+
var child = panel.Content as Border;
146+
147+
Assert.IsNotNull(child, "Could not find inner Border");
148+
149+
var width = scroll.ActualHeight / 2;
150+
151+
// Check Size
152+
Assert.AreEqual(width, child.ActualWidth, 0.01, "Actual width does not meet expected value of " + width);
153+
Assert.AreEqual(scroll.ActualHeight, child.ActualHeight, 0.01, "Actual height does not meet expected value of " + scroll.ActualHeight);
154+
});
155+
}
109156
}
110157
}

0 commit comments

Comments
 (0)