Browse Source

Removed leak tests and added failing test.

These were from a time when templates were applied when
attached/detached from visual tree. Template controls are now retained
until another template is applied.
pull/464/head
Steven Kirk 11 years ago
parent
commit
667c17af4b
  1. 67
      tests/Perspex.LeakTests/ControlTests.cs

67
tests/Perspex.LeakTests/ControlTests.cs

@ -9,6 +9,7 @@ using Perspex.Controls;
using Perspex.Controls.Primitives;
using Perspex.Controls.Templates;
using Perspex.Layout;
using Perspex.Styling;
using Perspex.UnitTests;
using Perspex.VisualTree;
using Xunit;
@ -90,39 +91,6 @@ namespace Perspex.LeakTests
}
}
[Fact]
public void Templated_Child_Is_Freed_When_Template_Cleared()
{
using (UnitTestApplication.Start(TestServices.StyledWindow))
{
Func<Window> run = () =>
{
var window = new Window
{
Content = new TestTemplatedControl()
};
// Do a layout and make sure that the control gets added to visual tree and its
// template applied.
LayoutManager.Instance.ExecuteInitialLayoutPass(window);
Assert.IsType<TestTemplatedControl>(window.Presenter.Child);
Assert.IsType<Canvas>(window.Presenter.Child.GetVisualChildren().SingleOrDefault());
// Clear the template and ensure the control template gets removed
((TestTemplatedControl)window.Content).Template = null;
LayoutManager.Instance.ExecuteLayoutPass();
Assert.Equal(0, window.Presenter.Child.GetVisualChildren().Count());
return window;
};
var result = run();
dotMemory.Check(memory =>
Assert.Equal(0, memory.GetObjects(where => where.Type.Is<Canvas>()).ObjectsCount));
}
}
[Fact]
public void ScrollViewer_With_Content_Is_Freed()
{
@ -239,39 +207,6 @@ namespace Perspex.LeakTests
}
}
[Fact]
public void TextBox_ScrollViewer_Is_Freed_When_Template_Cleared()
{
using (UnitTestApplication.Start(TestServices.StyledWindow))
{
Func<Window> run = () =>
{
var window = new Window
{
Content = new TextBox()
};
// Do a layout and make sure that TextBox gets added to visual tree and its
// template applied.
LayoutManager.Instance.ExecuteInitialLayoutPass(window);
Assert.IsType<TextBox>(window.Presenter.Child);
Assert.NotEqual(0, window.Presenter.Child.GetVisualChildren().Count());
// Clear the template and ensure the TextBox template gets removed
((TextBox)window.Content).Template = null;
LayoutManager.Instance.ExecuteLayoutPass();
Assert.Equal(0, window.Presenter.Child.GetVisualChildren().Count());
return window;
};
var result = run();
dotMemory.Check(memory =>
Assert.Equal(0, memory.GetObjects(where => where.Type.Is<ScrollViewer>()).ObjectsCount));
}
}
[Fact]
public void TreeView_Is_Freed()
{

Loading…
Cancel
Save