Browse Source

Created new test

Created new test to determine if StackPanels with gaps add gaps for invisible children.
Luis Silva 7 years ago
parent
commit
e1ddeee321
1 changed files with 39 additions and 0 deletions
  1. 39 0
      tests/Avalonia.Controls.UnitTests/StackPanelTests.cs

+ 39 - 0
tests/Avalonia.Controls.UnitTests/StackPanelTests.cs

@@ -146,5 +146,44 @@ namespace Avalonia.Controls.UnitTests
             Assert.Equal(new Rect(20, 0, 30, 120), target.Children[1].Bounds);
             Assert.Equal(new Rect(50, 0, 50, 120), target.Children[2].Bounds);
         }
+
+        [Theory]
+        [InlineData(Orientation.Horizontal)]
+        [InlineData(Orientation.Vertical)]
+        public void Gap_Not_Added_For_Invisible_Children(Orientation orientation)
+        {
+            var targetThreeChildrenOneInvisble = new StackPanel
+            {
+                Gap = 40,
+                Orientation = orientation,
+                Children =
+                {
+                    new StackPanel { Width = 10, Height= 10, IsVisible = false },
+                    new StackPanel { Width = 10, Height= 10 },
+                    new StackPanel { Width = 10, Height= 10 },
+                }
+            };
+            var targetTwoChildrenNoneInvisible = new StackPanel
+            {
+                Gap = 40,
+                Orientation = orientation,
+                Children =
+                {
+                    new StackPanel { Width = 10, Height= 10 },
+                    new StackPanel { Width = 10, Height= 10 }
+                }
+            };
+
+            targetThreeChildrenOneInvisble.Measure(Size.Infinity);
+            targetThreeChildrenOneInvisble.Arrange(new Rect(targetThreeChildrenOneInvisble.DesiredSize));
+
+            targetTwoChildrenNoneInvisible.Measure(Size.Infinity);
+            targetTwoChildrenNoneInvisible.Arrange(new Rect(targetTwoChildrenNoneInvisible.DesiredSize));
+
+            Size sizeWithTwoChildren = targetTwoChildrenNoneInvisible.Bounds.Size;
+            Size sizeWithThreeChildren = targetThreeChildrenOneInvisble.Bounds.Size;
+
+            Assert.Equal(sizeWithTwoChildren, sizeWithThreeChildren);
+        }
     }
 }