Browse Source

Added failing test for Viewbox layout.

Steven Kirk 3 years ago
parent
commit
33f6974df1
1 changed files with 26 additions and 0 deletions
  1. 26 0
      tests/Avalonia.Controls.UnitTests/ViewboxTests.cs

+ 26 - 0
tests/Avalonia.Controls.UnitTests/ViewboxTests.cs

@@ -181,6 +181,32 @@ namespace Avalonia.Controls.UnitTests
             Assert.Null(child.GetLogicalParent());
         }
 
+        [Fact]
+        public void Changing_Child_Should_Invalidate_Layout()
+        {
+            var target = new Viewbox();
+
+            target.Child = new Canvas
+            {
+                Width = 100,
+                Height = 100,
+            };
+
+            target.Measure(Size.Infinity);
+            target.Arrange(new Rect(target.DesiredSize));
+            Assert.Equal(new Size(100, 100), target.DesiredSize);
+
+            target.Child = new Canvas
+            {
+                Width = 200,
+                Height = 200,
+            };
+
+            target.Measure(Size.Infinity);
+            target.Arrange(new Rect(target.DesiredSize));
+            Assert.Equal(new Size(200, 200), target.DesiredSize);
+        }
+
         private bool TryGetScale(Viewbox viewbox, out Vector scale)
         {
             if (viewbox.InternalTransform is null)