mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
Fixes #2228. Crash when attempting to open menu bar item with action but no menu items assigned.
This commit is contained in:
@@ -1498,7 +1498,7 @@ Edit
|
||||
Assert.True (menu.IsMenuOpen);
|
||||
Assert.False (tf.HasFocus);
|
||||
Application.Top.Redraw (Application.Top.Bounds);
|
||||
TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen(0), output);
|
||||
TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output);
|
||||
|
||||
// Right - Edit has no sub menu; this tests that no sub menu shows
|
||||
Assert.True (menu.openMenu.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ())));
|
||||
@@ -1636,5 +1636,23 @@ Edit
|
||||
00000000000000
|
||||
00000000000000", attributes);
|
||||
}
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void MenuBar_With_Action_But_Without_MenuItems_Not_Throw ()
|
||||
{
|
||||
var menu = new MenuBar (
|
||||
menus: new []
|
||||
{
|
||||
new MenuBarItem { Title = "Test 1", Action = () => { } },
|
||||
new MenuBarItem { Title = "Test 2", Action = () => { } },
|
||||
});
|
||||
|
||||
Application.Top.Add (menu);
|
||||
Application.Begin (Application.Top);
|
||||
|
||||
Assert.False (Application.Top.OnKeyDown (new KeyEvent (Key.AltMask, new KeyModifiers { Alt = true })));
|
||||
Assert.True (menu.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ())));
|
||||
Assert.True (menu.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user