1
0
Andrey Kunchev 6 жил өмнө
parent
commit
f3bb98756f

+ 53 - 25
tests/Avalonia.Controls.UnitTests/WrapPanelTests.cs

@@ -12,14 +12,14 @@ namespace Avalonia.Controls.UnitTests
         public void Lays_Out_Horizontally_On_Separate_Lines()
         {
             var target = new WrapPanel()
-                         {
-                            Width = 100,
-                            Children =
+            {
+                Width = 100,
+                Children =
                             {
                                 new Border { Height = 50, Width = 100 },
                                 new Border { Height = 50, Width = 100 },
                             }
-                         };
+            };
 
             target.Measure(Size.Infinity);
             target.Arrange(new Rect(target.DesiredSize));
@@ -33,14 +33,14 @@ namespace Avalonia.Controls.UnitTests
         public void Lays_Out_Horizontally_On_A_Single_Line()
         {
             var target = new WrapPanel()
-                         {
-                            Width = 200,
-                            Children =
+            {
+                Width = 200,
+                Children =
                             {
                                 new Border { Height = 50, Width = 100 },
                                 new Border { Height = 50, Width = 100 },
                             }
-                         };
+            };
 
             target.Measure(Size.Infinity);
             target.Arrange(new Rect(target.DesiredSize));
@@ -54,15 +54,15 @@ namespace Avalonia.Controls.UnitTests
         public void Lays_Out_Vertically_Children_On_A_Single_Line()
         {
             var target = new WrapPanel()
-                         {
-                            Orientation = Orientation.Vertical,
-                            Height = 120,
-                            Children =
+            {
+                Orientation = Orientation.Vertical,
+                Height = 120,
+                Children =
                             {
                                 new Border { Height = 50, Width = 100 },
                                 new Border { Height = 50, Width = 100 },
                             }
-                         };
+            };
 
             target.Measure(Size.Infinity);
             target.Arrange(new Rect(target.DesiredSize));
@@ -76,15 +76,15 @@ namespace Avalonia.Controls.UnitTests
         public void Lays_Out_Vertically_On_Separate_Lines()
         {
             var target = new WrapPanel()
-                         {
-                            Orientation = Orientation.Vertical,
-                            Height = 60,
-                            Children =
+            {
+                Orientation = Orientation.Vertical,
+                Height = 60,
+                Children =
                             {
                                 new Border { Height = 50, Width = 100 },
                                 new Border { Height = 50, Width = 100 },
                             }
-                         };
+            };
 
             target.Measure(Size.Infinity);
             target.Arrange(new Rect(target.DesiredSize));
@@ -98,17 +98,17 @@ namespace Avalonia.Controls.UnitTests
         public void Applies_ItemWidth_And_ItemHeight_Properties()
         {
             var target = new WrapPanel()
-                        {
-                            Orientation = Orientation.Horizontal,
-                            Width = 50,
-                            ItemWidth = 20,
-                            ItemHeight = 15,
-                            Children =
+            {
+                Orientation = Orientation.Horizontal,
+                Width = 50,
+                ItemWidth = 20,
+                ItemHeight = 15,
+                Children =
                             {
                                 new Border(),
                                 new Border(),
                             }
-                        };
+            };
 
             target.Measure(Size.Infinity);
             target.Arrange(new Rect(target.DesiredSize));
@@ -117,5 +117,33 @@ namespace Avalonia.Controls.UnitTests
             Assert.Equal(new Rect(0, 0, 20, 15), target.Children[0].Bounds);
             Assert.Equal(new Rect(20, 0, 20, 15), target.Children[1].Bounds);
         }
+
+        [Fact]
+        void ItemWidth_Trigger_InvalidateMeasure()
+        {
+            var target = new WrapPanel();
+
+            target.Measure(new Size(10, 10));
+
+            Assert.True(target.IsMeasureValid);
+
+            target.ItemWidth = 1;
+
+            Assert.False(target.IsMeasureValid);
+        }
+
+        [Fact]
+        void ItemHeight_Trigger_InvalidateMeasure()
+        {
+            var target = new WrapPanel();
+
+            target.Measure(new Size(10, 10));
+
+            Assert.True(target.IsMeasureValid);
+
+            target.ItemHeight = 1;
+
+            Assert.False(target.IsMeasureValid);
+        }
     }
 }