diff --git a/dev/Repeater/APITests/FlowLayoutTests.cs b/dev/Repeater/APITests/FlowLayoutTests.cs index da31d7da9f..7ed6a53a01 100644 --- a/dev/Repeater/APITests/FlowLayoutTests.cs +++ b/dev/Repeater/APITests/FlowLayoutTests.cs @@ -44,7 +44,7 @@ namespace Windows.UI.Xaml.Tests.MUXControls.ApiTests.RepeaterTests { [TestClass] public class FlowLayoutTests : TestsBase - { + { [TestMethod] public void ValidateStackLayout() { @@ -68,17 +68,17 @@ public void ValidateStackLayout() Layout = new StackLayout() { Orientation = scrollOrientation.ToLayoutOrientation() } }; - SetPanelMinorSize(panel, om, panelMinorSize); - for (int i = 0; i < numItems; i++) - { - panel.Children.Add( - new Button() - { - Content = i, - Width = om.IsVerical ? itemMinorSize : itemMajorSize, - Height = om.IsVerical ? itemMajorSize : itemMinorSize - }); - } + SetPanelMinorSize(panel, om, panelMinorSize); + for (int i = 0; i < numItems; i++) + { + panel.Children.Add( + new Button() + { + Content = i, + Width = om.IsVerical ? itemMinorSize : itemMajorSize, + Height = om.IsVerical ? itemMajorSize : itemMinorSize + }); + } Content = panel; Content.UpdateLayout(); @@ -150,7 +150,7 @@ public void ValidateGridLayout() } }); } - + [TestMethod] public void ValidateResizingFirstItemResizesOtherItemsInGridLayout() { @@ -480,8 +480,8 @@ public void ValidateFlowLayout() { Log.Comment(string.Format("ScrollOrientation: {0}", scrollOrientation)); var om = new OrientationBasedMeasures(scrollOrientation); - int [] panelMinorSizeChoices = new int[] { 10, 50 }; - foreach(int panelMinorSize in panelMinorSizeChoices) + int[] panelMinorSizeChoices = new int[] { 10, 50 }; + foreach (int panelMinorSize in panelMinorSizeChoices) { const int numItems = 10; LayoutPanel panel = new LayoutPanel() @@ -493,11 +493,11 @@ public void ValidateFlowLayout() } }; - SetPanelMinorSize(panel, om, panelMinorSize); - for (int i = 0; i < numItems; i++) - { - panel.Children.Add(new Button() { Content = i }); - } + SetPanelMinorSize(panel, om, panelMinorSize); + for (int i = 0; i < numItems; i++) + { + panel.Children.Add(new Button() { Content = i }); + } Content = panel; @@ -513,7 +513,7 @@ public void ValidateFlowLayout() Content.UpdateLayout(); ValidateFlowLayoutChildrenLayoutBounds(om, (i) => panel.Children[i], minItemSpacing, lineSpacing, panel.Children.Count, panel.DesiredSize); } - } + } }); } @@ -527,8 +527,10 @@ public void ValidateFlowLayoutVaryingHeights() Log.Comment(string.Format("ScrollOrientation: {0}", scrollOrientation)); var om = new OrientationBasedMeasures(scrollOrientation); const int numItems = 10; - LayoutPanel panel = new LayoutPanel() { - Layout = new FlowLayout() { + LayoutPanel panel = new LayoutPanel() + { + Layout = new FlowLayout() + { Orientation = scrollOrientation.ToOrthogonalLayoutOrientation(), LineAlignment = FlowLayoutLineAlignment.Start } @@ -982,15 +984,15 @@ public void ValidateLayoutWithInfiniteMeasureSizeInNonVirtualizingDirection() Verify.AreEqual(expected.Height, scrollOrientation == ScrollOrientation.Vertical ? actual.Height : actual.Width); }); - foreach(var layout in layouts) + foreach (var layout in layouts) { Log.Comment("Layout is " + layout.GetType().Name); repeater.Layout = layout; Content.UpdateLayout(); - - if (layout is StackLayout) verifyDesiredSize(new Size(160, 430), repeater.DesiredSize); - if (layout is UniformGridLayout) verifyDesiredSize(new Size(190, 40), repeater.DesiredSize); - if (layout is FlowLayout) verifyDesiredSize(new Size(430, 160), repeater.DesiredSize); + + if (layout is StackLayout) verifyDesiredSize(new Size(160, 430), repeater.DesiredSize); + if (layout is UniformGridLayout) verifyDesiredSize(new Size(190, 40), repeater.DesiredSize); + if (layout is FlowLayout) verifyDesiredSize(new Size(430, 160), repeater.DesiredSize); } } }); @@ -1086,6 +1088,26 @@ public void ValidateIntersectionWithRealizationWindow() } } + [TestMethod] + public void ValidateUniformGridWithNoItems() + { + RunOnUIThread.Execute(() => + { + var repeater = new ItemsRepeater() + { + ItemsSource = new List(), // no items + Layout = new UniformGridLayout() { Orientation = Orientation.Vertical }, + }; + + Content = repeater; + Content.UpdateLayout(); + + // Ensure we do not crash and get zero size. + Verify.AreEqual(0, repeater.DesiredSize.Width); + Verify.AreEqual(0, repeater.DesiredSize.Height); + }); + } + [TestMethod] public void ValidateFlowLayoutWithOneItemHasNonZeroExtent() { @@ -1093,7 +1115,8 @@ public void ValidateFlowLayoutWithOneItemHasNonZeroExtent() { foreach (ScrollOrientation scrollOrientation in Enum.GetValues(typeof(ScrollOrientation))) { - var repeater = new ItemsRepeater() { + var repeater = new ItemsRepeater() + { ItemsSource = new List() { "single item" }, Layout = new FlowLayout() { Orientation = scrollOrientation.ToLayoutOrientation() }, }; @@ -1119,8 +1142,9 @@ public void ValidateGridLayoutWithSameOrientationAsScrolling() var firstRealizedIndex = int.MaxValue; RunOnUIThread.Execute(() => { - - var repeater = new ItemsRepeater() { + + var repeater = new ItemsRepeater() + { ItemsSource = Enumerable.Range(1, 1000), ItemTemplate = GetDataTemplate(@"