|
|
@@ -313,7 +313,6 @@ namespace Avalonia.LeakTests
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
[Fact]
|
|
|
public void Slider_Is_Freed()
|
|
|
{
|
|
|
@@ -347,6 +346,43 @@ namespace Avalonia.LeakTests
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ [Fact]
|
|
|
+ public void TabItem_Is_Freed()
|
|
|
+ {
|
|
|
+ using (Start())
|
|
|
+ {
|
|
|
+ Func<Window> run = () =>
|
|
|
+ {
|
|
|
+ var window = new Window
|
|
|
+ {
|
|
|
+ Content = new TabControl
|
|
|
+ {
|
|
|
+ Items = new[] { new TabItem() }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ window.Show();
|
|
|
+
|
|
|
+ // Do a layout and make sure that TabControl and TabItem gets added to visual tree.
|
|
|
+ window.LayoutManager.ExecuteInitialLayoutPass();
|
|
|
+ var tabControl = Assert.IsType<TabControl>(window.Presenter.Child);
|
|
|
+ Assert.IsType<TabItem>(tabControl.Presenter.Panel.Children[0]);
|
|
|
+
|
|
|
+ // Clear the items and ensure the TabItem is removed.
|
|
|
+ tabControl.Items = null;
|
|
|
+ window.LayoutManager.ExecuteLayoutPass();
|
|
|
+ Assert.Empty(tabControl.Presenter.Panel.Children);
|
|
|
+
|
|
|
+ return window;
|
|
|
+ };
|
|
|
+
|
|
|
+ var result = run();
|
|
|
+
|
|
|
+ dotMemory.Check(memory =>
|
|
|
+ Assert.Equal(0, memory.GetObjects(where => where.Type.Is<TabItem>()).ObjectsCount));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
[Fact]
|
|
|
public void RendererIsDisposed()
|
|
|
{
|