|
|
@@ -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())
|
|
|
{
|