Browse Source

Added another failing ContextMenu leak test.

pull/3745/head
Steven Kirk 6 years ago
parent
commit
c4da0f75b8
  1. 38
      tests/Avalonia.LeakTests/ControlTests.cs

38
tests/Avalonia.LeakTests/ControlTests.cs

@ -422,7 +422,43 @@ namespace Avalonia.LeakTests
}
[Fact]
public void Context_MenuItems_Are_Freed()
public void Attached_ContextMenu_Is_Freed()
{
using (Start())
{
void AttachShowAndDetachContextMenu(Control control)
{
var contextMenu = new ContextMenu
{
Items = new[]
{
new MenuItem { Header = "Foo" },
new MenuItem { Header = "Foo" },
}
};
control.ContextMenu = contextMenu;
contextMenu.Open(control);
contextMenu.Close();
control.ContextMenu = null;
}
var window = new Window();
window.Show();
Assert.Same(window, FocusManager.Instance.Current);
AttachShowAndDetachContextMenu(window);
dotMemory.Check(memory =>
Assert.Equal(0, memory.GetObjects(where => where.Type.Is<ContextMenu>()).ObjectsCount));
dotMemory.Check(memory =>
Assert.Equal(0, memory.GetObjects(where => where.Type.Is<MenuItem>()).ObjectsCount));
}
}
[Fact]
public void Standalone_ContextMenu_Is_Freed()
{
using (Start())
{

Loading…
Cancel
Save