|
|
@@ -65,5 +65,64 @@ namespace Perspex.LeakTests
|
|
|
dotMemory.Check(memory =>
|
|
|
Assert.Equal(0, memory.GetObjects(where => where.Type.Is<StyleActivator>()).ObjectsCount));
|
|
|
}
|
|
|
+
|
|
|
+ [Fact]
|
|
|
+ public void Changing_Carousel_SelectedIndex_Should_Not_Leak_StyleActivators()
|
|
|
+ {
|
|
|
+ Func<Window> run = () =>
|
|
|
+ {
|
|
|
+ Carousel target;
|
|
|
+
|
|
|
+ var window = new Window
|
|
|
+ {
|
|
|
+ Styles = new Styles
|
|
|
+ {
|
|
|
+ new Style(x => x.OfType<ContentControl>().Class("foo"))
|
|
|
+ {
|
|
|
+ Setters = new[]
|
|
|
+ {
|
|
|
+ new Setter(Visual.OpacityProperty, 0.5),
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ Content = target = new Carousel
|
|
|
+ {
|
|
|
+ Items = new[]
|
|
|
+ {
|
|
|
+ new ContentControl
|
|
|
+ {
|
|
|
+ Name = "item1",
|
|
|
+ Classes = new Classes("foo"),
|
|
|
+ Content = "item1",
|
|
|
+ },
|
|
|
+ new ContentControl
|
|
|
+ {
|
|
|
+ Name = "item2",
|
|
|
+ Classes = new Classes("foo"),
|
|
|
+ Content = "item2",
|
|
|
+ },
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // Do a layout and make sure that Carousel gets added to visual tree.
|
|
|
+ window.LayoutManager.ExecuteLayoutPass();
|
|
|
+ Assert.IsType<Carousel>(window.Presenter.Child);
|
|
|
+
|
|
|
+ target.SelectedIndex = 1;
|
|
|
+ window.LayoutManager.ExecuteLayoutPass();
|
|
|
+ target.SelectedIndex = 0;
|
|
|
+ window.LayoutManager.ExecuteLayoutPass();
|
|
|
+ target.SelectedIndex = 1;
|
|
|
+ window.LayoutManager.ExecuteLayoutPass();
|
|
|
+
|
|
|
+ return window;
|
|
|
+ };
|
|
|
+
|
|
|
+ var result = run();
|
|
|
+
|
|
|
+ dotMemory.Check(memory =>
|
|
|
+ Assert.Equal(1, memory.GetObjects(where => where.Type.Is<StyleActivator>()).ObjectsCount));
|
|
|
+ }
|
|
|
}
|
|
|
}
|