Browse Source

Added failing test for #3487.

Steven Kirk 5 years ago
parent
commit
632c40340a
1 changed files with 24 additions and 0 deletions
  1. 24 0
      tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs

+ 24 - 0
tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs

@@ -575,6 +575,30 @@ namespace Avalonia.Controls.UnitTests
             };
         }
 
+        [Fact]
+        public void Detaching_Then_Reattaching_To_Logical_Tree_Twice_Does_Not_Throw()
+        {
+            // # Issue 3487
+            var target = new ItemsControl
+            {
+                Template = GetTemplate(),
+                Items = new[] { "foo", "bar" },
+                ItemTemplate = new FuncDataTemplate<string>((_, __) => new Canvas()),
+            };
+
+            var root = new TestRoot(target);
+            root.Measure(Size.Infinity);
+            root.Arrange(new Rect(root.DesiredSize));
+
+            root.Child = null;
+            root.Child = target;
+
+            target.Measure(Size.Infinity);
+
+            root.Child = null;
+            root.Child = target;
+        }
+
         private class Item
         {
             public Item(string value)