Browse Source

Manually manage the name scope for control leak tests

pull/2705/head
Nikita Tsukanov 7 years ago
parent
commit
4df55f733d
  1. 6
      tests/Avalonia.LeakTests/ControlTests.cs

6
tests/Avalonia.LeakTests/ControlTests.cs

@ -67,13 +67,14 @@ namespace Avalonia.LeakTests
{ {
Func<Window> run = () => Func<Window> run = () =>
{ {
var scope = new NameScope();
var window = new Window var window = new Window
{ {
Content = new Canvas Content = new Canvas
{ {
Name = "foo" Name = "foo"
} }.RegisterInNameScope(scope)
}; }.WithNameScope(scope);
window.Show(); window.Show();
@ -84,6 +85,7 @@ namespace Avalonia.LeakTests
// Clear the content and ensure the Canvas is removed. // Clear the content and ensure the Canvas is removed.
window.Content = null; window.Content = null;
scope.Unregister("foo");
window.LayoutManager.ExecuteLayoutPass(); window.LayoutManager.ExecuteLayoutPass();
Assert.Null(window.Presenter.Child); Assert.Null(window.Presenter.Child);

Loading…
Cancel
Save