mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
* touching publish.yml
* Fixed UICatalog bugs. Added fluent tests.
* marked v1 menu stuff as obsolte
* Tweaks.
Added View.GetSubMenus<type>().
* fixed unit tests
* general messing around
* general messing around
* Playing with Fluent
* ColorScheme tweaks
* WIP: ColorScheme tweaks
* Playing with Fluent
* Merged from laptop2
* Hacky-ish fixes to:
- #4016
- #4014
* Fixed Region bug preventing menus without borders from working
* Tweaks
* Fixed a bunch of CM issues
* Fixed OoptionSelector
* ip
* FixedCM issues
* Fixed CM issues2
* Revert "FixedCM issues"
This reverts commit dd6c6a70a3.
* Reverted stuff
* Found and fixed bug in AllViews_Center_Properly
* Fixed CM issues2
* removed menuv2 onapplied.
Changed how UICatalog Applys CM
* changed test time out to see if it helkps with ubuntu fails
* reset app on fail?
* back to 1500ms
* Made StatusBar nullable.
* Code Cleanup.
* HexEditor Code Cleanup.
* HexEditor Code Cleanup.
* Back to 3000ms. Sigh.
* Trying different logic
* Trying different logic2
* Fixed potential crash in runlop
* Fixed potential crash in runlop2
* Tweaked Spinner stuff
* Removed TabView from TextEffects scenario. Not needed and possible culprit.
* back to 2000ms
* WIP: Revamping menu scenarios
* Menu Scenario refinements.
Fixed a few bugs.
Code cleanup.
* fixed unit test
* Fixed warnings
* Fixed warnings2
* Fixed File.Exit
* WIP: Dealing with QuitKey struggles
* WIP: Dealing with QuitKey struggles 2
* WIP: Dealing with QuitKey struggles 3
* Fixed ListView collection nav bug
* Fixed a bunch of menu stuff.
Fixed Appv2 stuff.
* Lots of refactoring and fixing
* Lots of unit test issues
* Fixed DebugIDisposable issues
* Fixed release build issue
* Fixed release build issue 2
* DebugIDisposable -> EnableDebugIDisposableAsserts and more
* DebugIDisposable -> EnableDebugIDisposableAsserts and more 2
* Fixed Menus scenario - context menu
* Added @bdisp suggested assert. Commented it out as it breaks tests.
* Code cleanup
* Fixed disposed but
* Fixed UICatalog exit
* Fixed Unit test I broke.
Added 'Minimal' Theme that turns off all borders etc...
This commit is contained in:
@@ -45,6 +45,8 @@ public class AllViewsTests (ITestOutputHelper output) : TestsAllViews
|
||||
frame.BeginInit ();
|
||||
frame.EndInit ();
|
||||
frame.LayoutSubViews ();
|
||||
frame.Dispose ();
|
||||
Application.Shutdown ();
|
||||
|
||||
// What's the natural width/height?
|
||||
int expectedX = (frame.Frame.Width - view.Frame.Width) / 2;
|
||||
@@ -59,7 +61,6 @@ public class AllViewsTests (ITestOutputHelper output) : TestsAllViews
|
||||
view.Frame.Top == expectedY,
|
||||
$"{view} did not center vertically. Expected: {expectedY}. Actual: {view.Frame.Top}"
|
||||
);
|
||||
Application.Shutdown ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -169,6 +169,8 @@ public class CheckBoxTests (ITestOutputHelper output)
|
||||
|
||||
checkBox.AllowCheckStateNone = false;
|
||||
Assert.Equal (CheckState.UnChecked, checkBox.CheckedState);
|
||||
|
||||
Application.ResetState();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -4,13 +4,6 @@ namespace Terminal.Gui.ViewsTests;
|
||||
|
||||
public class ColorPickerTests
|
||||
{
|
||||
public ColorPickerTests ()
|
||||
{
|
||||
#if DEBUG_IDISPOSABLE
|
||||
View.DebugIDisposable = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[SetupFakeDriver]
|
||||
public void ColorPicker_ChangedEvent_Fires ()
|
||||
@@ -102,6 +95,7 @@ public class ColorPickerTests
|
||||
Assert.Equal ("#800000", hex.Text);
|
||||
|
||||
Application.Top?.Dispose ();
|
||||
Application.ResetState();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -136,6 +130,8 @@ public class ColorPickerTests
|
||||
Assert.Equal ("#FF0000", hex.Text);
|
||||
|
||||
Application.Top?.Dispose ();
|
||||
Application.ResetState ();
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -170,6 +166,8 @@ public class ColorPickerTests
|
||||
Assert.Equal ("#FF0000", hex.Text);
|
||||
|
||||
Application.Top?.Dispose ();
|
||||
Application.ResetState ();
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -223,6 +221,8 @@ public class ColorPickerTests
|
||||
Assert.IsAssignableFrom<BBar> (cp.Focused);
|
||||
|
||||
Application.Top?.Dispose ();
|
||||
Application.ResetState ();
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -447,6 +447,8 @@ public class ColorPickerTests
|
||||
Assert.Equal ("#000000", hex.Text);
|
||||
|
||||
Application.Top?.Dispose ();
|
||||
Application.ResetState (true);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -504,6 +506,8 @@ public class ColorPickerTests
|
||||
Assert.Equal ("#FF0000", hex.Text);
|
||||
|
||||
Application.Top.Dispose ();
|
||||
Application.ResetState (true);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -557,6 +561,8 @@ public class ColorPickerTests
|
||||
Assert.Equal ("#1E0000", hex.Text);
|
||||
|
||||
Application.Top?.Dispose ();
|
||||
Application.ResetState (true);
|
||||
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -592,6 +598,8 @@ public class ColorPickerTests
|
||||
Assert.Equal (expectedHex, hex.Text);
|
||||
|
||||
Application.Top.Dispose ();
|
||||
Application.ResetState (true);
|
||||
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -636,6 +644,8 @@ public class ColorPickerTests
|
||||
Assert.Equal (expectedHex, hex.Text);
|
||||
|
||||
Application.Top?.Dispose ();
|
||||
Application.ResetState (true);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -681,6 +691,8 @@ public class ColorPickerTests
|
||||
Assert.Equal ("#FF0000", hex.Text);
|
||||
|
||||
Application.Top!.Dispose ();
|
||||
Application.ResetState (true);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -717,6 +729,8 @@ public class ColorPickerTests
|
||||
Assert.Equal ("#800000", hex.Text);
|
||||
|
||||
Application.Top?.Dispose ();
|
||||
Application.ResetState (true);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -1157,4 +1157,34 @@ Item 6",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CollectionNavigatorMatcher_KeybindingsOverrideNavigator ()
|
||||
{
|
||||
Application.Top = new ();
|
||||
|
||||
ObservableCollection<string> source = new () { "apricot", "arm", "bat", "batman", "bates hotel", "candle" };
|
||||
ListView lv = new ListView { Source = new ListWrapper<string> (source) };
|
||||
|
||||
Application.Top.Add (lv);
|
||||
lv.SetFocus ();
|
||||
|
||||
lv.KeyBindings.Add (Key.B, Command.Down);
|
||||
|
||||
Assert.Equal (-1, lv.SelectedItem);
|
||||
|
||||
// Keys should be consumed to move down the navigation i.e. to apricot
|
||||
Assert.True (Application.RaiseKeyDownEvent (Key.B));
|
||||
Assert.Equal (0, lv.SelectedItem);
|
||||
|
||||
Assert.True (Application.RaiseKeyDownEvent (Key.B));
|
||||
Assert.Equal (1, lv.SelectedItem);
|
||||
|
||||
// There is no keybinding for Key.C so it hits collection navigator i.e. we jump to candle
|
||||
Assert.True (Application.RaiseKeyDownEvent (Key.C));
|
||||
Assert.Equal (5, lv.SelectedItem);
|
||||
|
||||
Application.Top.Dispose ();
|
||||
Application.ResetState ();
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ public class MenuBarTests ()
|
||||
{
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void DefaultKey_Activates ()
|
||||
public void DefaultKey_Activates_And_Opens ()
|
||||
{
|
||||
// Arrange
|
||||
var menuItem = new MenuItemv2 { Id = "menuItem", Title = "_Item" };
|
||||
@@ -23,11 +23,11 @@ public class MenuBarTests ()
|
||||
var top = new Toplevel ();
|
||||
top.Add (menuBar);
|
||||
RunState rs = Application.Begin (top);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
|
||||
// Act
|
||||
Application.RaiseKeyDownEvent (MenuBarv2.DefaultKey);
|
||||
Assert.True (menuBar.IsActive ());
|
||||
Assert.True (menuBar.Active);
|
||||
Assert.True (menuBar.IsOpen ());
|
||||
Assert.True (menuBar.HasFocus);
|
||||
Assert.True (menuBar.CanFocus);
|
||||
@@ -56,7 +56,7 @@ public class MenuBarTests ()
|
||||
var top = new Toplevel ();
|
||||
top.Add (menuBar);
|
||||
RunState rs = Application.Begin (top);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
|
||||
// Act
|
||||
Application.RaiseKeyDownEvent (MenuBarv2.DefaultKey);
|
||||
@@ -64,7 +64,7 @@ public class MenuBarTests ()
|
||||
Assert.True (menuBarItem.PopoverMenu.Visible);
|
||||
|
||||
Application.RaiseKeyDownEvent (MenuBarv2.DefaultKey);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
Assert.False (menuBar.IsOpen ());
|
||||
Assert.False (menuBar.HasFocus);
|
||||
Assert.False (menuBar.CanFocus);
|
||||
@@ -77,12 +77,12 @@ public class MenuBarTests ()
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void QuitKey_DeActivates ()
|
||||
public void QuitKey_Deactivates ()
|
||||
{
|
||||
// Arrange
|
||||
var menuItem = new MenuItemv2 { Id = "menuItem", Title = "_Item" };
|
||||
var menuItem = new MenuItemv2 { Id = "menuItem", Title = "Menu_Item" };
|
||||
var menu = new Menuv2 ([menuItem]) { Id = "menu" };
|
||||
var menuBarItem = new MenuBarItemv2 { Id = "menuBarItem", Title = "_New" };
|
||||
var menuBarItem = new MenuBarItemv2 { Id = "menuBarItem", Title = "_MenuBarItem" };
|
||||
var menuBarItemPopover = new PopoverMenu ();
|
||||
menuBarItem.PopoverMenu = menuBarItemPopover;
|
||||
menuBarItemPopover.Root = menu;
|
||||
@@ -93,16 +93,16 @@ public class MenuBarTests ()
|
||||
var top = new Toplevel ();
|
||||
top.Add (menuBar);
|
||||
RunState rs = Application.Begin (top);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
|
||||
// Act
|
||||
Application.RaiseKeyDownEvent (MenuBarv2.DefaultKey);
|
||||
Assert.True (menuBar.IsActive ());
|
||||
Assert.True (menuBar.Active);
|
||||
Assert.True (menuBar.IsOpen ());
|
||||
Assert.True (menuBarItem.PopoverMenu.Visible);
|
||||
|
||||
// Act
|
||||
|
||||
Application.RaiseKeyDownEvent (Application.QuitKey);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
Assert.False (menuBar.IsOpen ());
|
||||
Assert.False (menuBar.HasFocus);
|
||||
Assert.False (menuBar.CanFocus);
|
||||
@@ -115,7 +115,7 @@ public class MenuBarTests ()
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void MenuBarItem_HotKey_Activates ()
|
||||
public void MenuBarItem_HotKey_Activates_And_Opens ()
|
||||
{
|
||||
// Arrange
|
||||
var menuItem = new MenuItemv2 { Id = "menuItem", Title = "_Item" };
|
||||
@@ -131,10 +131,11 @@ public class MenuBarTests ()
|
||||
var top = new Toplevel ();
|
||||
top.Add (menuBar);
|
||||
RunState rs = Application.Begin (top);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
|
||||
// Act
|
||||
Application.RaiseKeyDownEvent (Key.N.WithAlt);
|
||||
Assert.True (menuBar.Active);
|
||||
Assert.True (menuBar.IsOpen ());
|
||||
Assert.True (menuBar.HasFocus);
|
||||
Assert.True (menuBarItem.PopoverMenu.Visible);
|
||||
@@ -162,16 +163,16 @@ public class MenuBarTests ()
|
||||
var top = new Toplevel ();
|
||||
top.Add (menuBar);
|
||||
RunState rs = Application.Begin (top);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
|
||||
// Act
|
||||
Application.RaiseKeyDownEvent (Key.N.WithAlt);
|
||||
Assert.True (menuBar.IsActive ());
|
||||
Assert.True (menuBar.Active);
|
||||
Assert.True (menuBar.IsOpen ());
|
||||
Assert.True (menuBarItem.PopoverMenu.Visible);
|
||||
|
||||
Application.RaiseKeyDownEvent (Key.N.WithAlt);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
Assert.False (menuBar.IsOpen ());
|
||||
Assert.False (menuBar.HasFocus);
|
||||
Assert.False (menuBar.CanFocus);
|
||||
@@ -182,16 +183,15 @@ public class MenuBarTests ()
|
||||
top.Dispose ();
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void MenuItem_HotKey_Deactivates ()
|
||||
public void MenuItems_HotKey_RaisesAction ()
|
||||
{
|
||||
// Arrange
|
||||
int action = 0;
|
||||
var menuItem = new MenuItemv2 { Id = "menuItem", Title = "_Item", Action = () => action++ };
|
||||
var menuItem = new MenuItemv2 { Id = "menuItem", Title = "Menu_Item", Action = () => action++ };
|
||||
var menu = new Menuv2 ([menuItem]) { Id = "menu" };
|
||||
var menuBarItem = new MenuBarItemv2 { Id = "menuBarItem", Title = "_New" };
|
||||
var menuBarItem = new MenuBarItemv2 { Id = "menuBarItem", Title = "_MenuBarItem" };
|
||||
var menuBarItemPopover = new PopoverMenu ();
|
||||
menuBarItem.PopoverMenu = menuBarItemPopover;
|
||||
menuBarItemPopover.Root = menu;
|
||||
@@ -202,16 +202,48 @@ public class MenuBarTests ()
|
||||
var top = new Toplevel ();
|
||||
top.Add (menuBar);
|
||||
RunState rs = Application.Begin (top);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
|
||||
// Act
|
||||
Application.RaiseKeyDownEvent (Key.N.WithAlt);
|
||||
Assert.True (menuBar.IsActive ());
|
||||
Application.RaiseKeyDownEvent (Key.M.WithAlt);
|
||||
Assert.True (menuBar.Active);
|
||||
Assert.True (menuBar.CanFocus);
|
||||
Assert.True (menuBarItem.PopoverMenu.Visible);
|
||||
|
||||
// Act
|
||||
Application.RaiseKeyDownEvent (Key.I);
|
||||
Assert.Equal (1, action);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
|
||||
Application.End (rs);
|
||||
top.Dispose ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void MenuItems_HotKey_Deactivates ()
|
||||
{
|
||||
// Arrange
|
||||
var menuItem = new MenuItemv2 { Id = "menuItem", Title = "Menu_Item" };
|
||||
var menu = new Menuv2 ([menuItem]) { Id = "menu" };
|
||||
var menuBarItem = new MenuBarItemv2 { Id = "menuBarItem", Title = "_MenuBarItem" };
|
||||
var menuBarItemPopover = new PopoverMenu ();
|
||||
menuBarItem.PopoverMenu = menuBarItemPopover;
|
||||
menuBarItemPopover.Root = menu;
|
||||
var menuBar = new MenuBarv2 () { Id = "menuBar" };
|
||||
menuBar.Add (menuBarItem);
|
||||
Assert.Single (menuBar.SubViews);
|
||||
Assert.Single (menuBarItem.SubViews);
|
||||
var top = new Toplevel ();
|
||||
top.Add (menuBar);
|
||||
RunState rs = Application.Begin (top);
|
||||
Assert.False (menuBar.Active);
|
||||
|
||||
Application.RaiseKeyDownEvent (Key.M.WithAlt);
|
||||
Assert.True (menuBar.Active);
|
||||
Assert.True (menuBarItem.PopoverMenu.Visible);
|
||||
|
||||
// Act
|
||||
Application.RaiseKeyDownEvent (Key.I);
|
||||
Assert.False (menuBar.Active);
|
||||
Assert.False (menuBar.IsOpen ());
|
||||
Assert.False (menuBar.HasFocus);
|
||||
Assert.False (menuBar.CanFocus);
|
||||
@@ -224,7 +256,7 @@ public class MenuBarTests ()
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void HotKey_Activates_Only_Once ()
|
||||
public void HotKey_Makes_PopoverMenu_Visible_Only_Once ()
|
||||
{
|
||||
// Arrange
|
||||
var menuItem = new MenuItemv2 { Id = "menuItem", Title = "_Item" };
|
||||
@@ -240,7 +272,7 @@ public class MenuBarTests ()
|
||||
var top = new Toplevel ();
|
||||
top.Add (menuBar);
|
||||
RunState rs = Application.Begin (top);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
|
||||
int visibleChangeCount = 0;
|
||||
menuBarItemPopover.VisibleChanged += (sender, args) =>
|
||||
@@ -261,7 +293,7 @@ public class MenuBarTests ()
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void WhenActive_Other_MenuBarItem_HotKey_Activates ()
|
||||
public void WhenOpen_Other_MenuBarItem_HotKey_Activates_And_Opens ()
|
||||
{
|
||||
// Arrange
|
||||
var menuItem = new MenuItemv2 { Id = "menuItem", Title = "_Item" };
|
||||
@@ -285,17 +317,17 @@ public class MenuBarTests ()
|
||||
var top = new Toplevel ();
|
||||
top.Add (menuBar);
|
||||
RunState rs = Application.Begin (top);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
|
||||
Assert.False (menuBar.Active);
|
||||
Assert.False (menuBar.IsOpen ());
|
||||
|
||||
// Act
|
||||
Application.RaiseKeyDownEvent (Key.N.WithAlt);
|
||||
Assert.True (menuBar.IsActive ());
|
||||
Assert.True (menuBar.Active);
|
||||
Assert.True (menuBar.IsOpen ());
|
||||
Assert.True (menuBarItem.PopoverMenu.Visible);
|
||||
|
||||
Application.RaiseKeyDownEvent (Key.E.WithAlt);
|
||||
Assert.True (menuBar.IsActive ());
|
||||
Assert.True (menuBar.Active);
|
||||
Assert.True (menuBar.IsOpen ());
|
||||
Assert.True (menuBarItem2.PopoverMenu.Visible);
|
||||
Assert.False (menuBarItem.PopoverMenu.Visible);
|
||||
@@ -306,7 +338,7 @@ public class MenuBarTests ()
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void Mouse_Enter_Sets_Can_Focus_But_Does_Not_Activate ()
|
||||
public void Mouse_Enter_Activates_But_Does_Not_Open ()
|
||||
{
|
||||
// Arrange
|
||||
var menuItem = new MenuItemv2 { Id = "menuItem", Title = "_Item" };
|
||||
@@ -322,14 +354,14 @@ public class MenuBarTests ()
|
||||
var top = new Toplevel ();
|
||||
top.Add (menuBar);
|
||||
RunState rs = Application.Begin (top);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
|
||||
// Act
|
||||
Application.RaiseMouseEvent (new ()
|
||||
{
|
||||
Flags = MouseFlags.ReportMousePosition
|
||||
});
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.True (menuBar.Active);
|
||||
Assert.False (menuBar.IsOpen ());
|
||||
Assert.True (menuBar.HasFocus);
|
||||
Assert.True (menuBar.CanFocus);
|
||||
@@ -342,7 +374,7 @@ public class MenuBarTests ()
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void Mouse_Click_Activates ()
|
||||
public void Mouse_Click_Activates_And_Opens ()
|
||||
{
|
||||
// Arrange
|
||||
var menuItem = new MenuItemv2 { Id = "menuItem", Title = "_Item" };
|
||||
@@ -358,14 +390,14 @@ public class MenuBarTests ()
|
||||
var top = new Toplevel ();
|
||||
top.Add (menuBar);
|
||||
RunState rs = Application.Begin (top);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
|
||||
// Act
|
||||
Application.RaiseMouseEvent (new ()
|
||||
{
|
||||
Flags = MouseFlags.Button1Clicked
|
||||
});
|
||||
Assert.True (menuBar.IsActive ());
|
||||
Assert.True (menuBar.Active);
|
||||
Assert.True (menuBar.IsOpen ());
|
||||
Assert.True (menuBar.HasFocus);
|
||||
Assert.True (menuBar.CanFocus);
|
||||
@@ -399,7 +431,7 @@ public class MenuBarTests ()
|
||||
var top = new Toplevel ();
|
||||
top.Add (menuBar);
|
||||
RunState rs = Application.Begin (top);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
|
||||
Application.RaiseMouseEvent (new ()
|
||||
{
|
||||
@@ -416,7 +448,7 @@ public class MenuBarTests ()
|
||||
{
|
||||
Flags = MouseFlags.Button1Clicked
|
||||
});
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
Assert.False (menuBar.IsOpen ());
|
||||
Assert.False (menuBar.HasFocus);
|
||||
Assert.False (menuBar.CanFocus);
|
||||
@@ -447,21 +479,21 @@ public class MenuBarTests ()
|
||||
top.Add (menuBar);
|
||||
RunState rs = Application.Begin (top);
|
||||
|
||||
Assert.False (menuBar.IsActive());
|
||||
Assert.False (menuBar.Active);
|
||||
Application.RaiseKeyDownEvent (Key.N.WithAlt);
|
||||
Assert.Equal (0, action);
|
||||
|
||||
Assert.Equal(Key.I, menuItem.HotKey);
|
||||
Application.RaiseKeyDownEvent (Key.I);
|
||||
Assert.Equal (1, action);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
|
||||
menuItem.Title = "_Foo";
|
||||
Application.RaiseKeyDownEvent (Key.N.WithAlt);
|
||||
Assert.True (menuBar.IsActive ());
|
||||
Assert.True (menuBar.Active);
|
||||
Application.RaiseKeyDownEvent (Key.I);
|
||||
Assert.Equal (1, action);
|
||||
Assert.True (menuBar.IsActive ());
|
||||
Assert.True (menuBar.Active);
|
||||
|
||||
Application.RaiseKeyDownEvent (Key.F);
|
||||
Assert.Equal (2, action);
|
||||
@@ -488,12 +520,12 @@ public class MenuBarTests ()
|
||||
var top = new Toplevel ();
|
||||
top.Add (menuBar);
|
||||
RunState rs = Application.Begin (top);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
|
||||
// Act
|
||||
menuBar.Enabled = false;
|
||||
Application.RaiseKeyDownEvent (Key.N.WithAlt);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
Assert.False (menuBar.IsOpen ());
|
||||
Assert.False (menuBarItem.PopoverMenu.Visible);
|
||||
|
||||
@@ -503,7 +535,7 @@ public class MenuBarTests ()
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown (configLocation: ConfigLocations.Default)]
|
||||
public void Disabled_MenuBarItem_Is_Not_Activated ()
|
||||
public void MenuBarItem_Disabled_MenuBarItem_HotKey_No_Activate_Or_Open ()
|
||||
{
|
||||
// Arrange
|
||||
var menuItem = new MenuItemv2 { Id = "menuItem", Title = "_Item" };
|
||||
@@ -519,12 +551,12 @@ public class MenuBarTests ()
|
||||
var top = new Toplevel ();
|
||||
top.Add (menuBar);
|
||||
RunState rs = Application.Begin (top);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
|
||||
// Act
|
||||
menuBarItem.Enabled = false;
|
||||
Application.RaiseKeyDownEvent (Key.N.WithAlt);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
Assert.False (menuBar.IsOpen ());
|
||||
Assert.False (menuBarItem.PopoverMenu.Visible);
|
||||
|
||||
@@ -535,7 +567,7 @@ public class MenuBarTests ()
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown (configLocation: ConfigLocations.Default)]
|
||||
public void Disabled_MenuBarItem_Popover_Is_Activated ()
|
||||
public void MenuBarItem_Disabled_Popover_Is_Activated ()
|
||||
{
|
||||
// Arrange
|
||||
var menuItem = new MenuItemv2 { Id = "menuItem", Title = "_Item" };
|
||||
@@ -551,12 +583,12 @@ public class MenuBarTests ()
|
||||
var top = new Toplevel ();
|
||||
top.Add (menuBar);
|
||||
RunState rs = Application.Begin (top);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
|
||||
// Act
|
||||
menuBarItem.PopoverMenu.Enabled = false;
|
||||
Application.RaiseKeyDownEvent (Key.N.WithAlt);
|
||||
Assert.True (menuBar.IsActive ());
|
||||
Assert.True (menuBar.Active);
|
||||
Assert.True (menuBar.IsOpen ());
|
||||
Assert.True (menuBarItem.PopoverMenu.Visible);
|
||||
|
||||
@@ -589,7 +621,7 @@ public class MenuBarTests ()
|
||||
var top = new Toplevel ();
|
||||
top.Add (menuBar);
|
||||
RunState rs = Application.Begin (top);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
|
||||
Application.RaiseKeyDownEvent (Key.N.WithAlt);
|
||||
Assert.True (menuBar.IsOpen ());
|
||||
@@ -609,7 +641,7 @@ public class MenuBarTests ()
|
||||
|
||||
// use new key
|
||||
Application.RaiseKeyDownEvent (Key.E.WithAlt);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
Assert.False (menuBar.IsOpen ());
|
||||
Assert.False (menuBar.HasFocus);
|
||||
Assert.False (menuBar.CanFocus);
|
||||
@@ -638,12 +670,12 @@ public class MenuBarTests ()
|
||||
var top = new Toplevel ();
|
||||
top.Add (menuBar);
|
||||
RunState rs = Application.Begin (top);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
|
||||
// Act
|
||||
menuBar.Visible = false;
|
||||
Application.RaiseKeyDownEvent (Key.N.WithAlt);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
Assert.False (menuBar.IsOpen ());
|
||||
Assert.False (menuBar.HasFocus);
|
||||
Assert.False (menuBar.CanFocus);
|
||||
@@ -679,7 +711,7 @@ public class MenuBarTests ()
|
||||
var top = new Toplevel ();
|
||||
top.Add (menuBar);
|
||||
RunState rs = Application.Begin (top);
|
||||
Assert.False (menuBar.IsActive ());
|
||||
Assert.False (menuBar.Active);
|
||||
|
||||
// Act
|
||||
menuBar.Visible = false;
|
||||
|
||||
@@ -3,6 +3,7 @@ using Xunit.Abstractions;
|
||||
|
||||
namespace Terminal.Gui.ViewsTests;
|
||||
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
public class MenuBarv1Tests (ITestOutputHelper output)
|
||||
{
|
||||
[Fact]
|
||||
@@ -3884,3 +3885,4 @@ Edit
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
namespace Terminal.Gui.ViewsTests;
|
||||
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
public class Menuv1Tests
|
||||
{
|
||||
private readonly ITestOutputHelper _output;
|
||||
|
||||
@@ -600,8 +600,8 @@ public class RadioGroupTests (ITestOutputHelper output)
|
||||
[Fact]
|
||||
public void SelectedItemChanged_Event ()
|
||||
{
|
||||
int previousSelectedItem = -1;
|
||||
int selectedItem = -1;
|
||||
int? previousSelectedItem = -1;
|
||||
int? selectedItem = -1;
|
||||
var rg = new RadioGroup { RadioLabels = ["Test", "New Test"] };
|
||||
|
||||
rg.SelectedItemChanged += (s, e) =>
|
||||
|
||||
@@ -466,7 +466,7 @@ public class ShortcutTests
|
||||
|
||||
shortcut.HasFocus = true;
|
||||
|
||||
Assert.NotNull (shortcut.ColorScheme);
|
||||
Assert.Null (shortcut.ColorScheme);
|
||||
|
||||
Application.Top.Dispose ();
|
||||
Application.ResetState ();
|
||||
|
||||
@@ -4,13 +4,6 @@ namespace Terminal.Gui.ViewsTests;
|
||||
|
||||
public class ToplevelTests
|
||||
{
|
||||
public ToplevelTests ()
|
||||
{
|
||||
#if DEBUG_IDISPOSABLE
|
||||
View.DebugIDisposable = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_Default ()
|
||||
{
|
||||
|
||||
@@ -161,9 +161,6 @@ public class WindowTests (ITestOutputHelper output)
|
||||
Assert.Equal (0, windowWithFrameRectEmpty.Width);
|
||||
Assert.Equal (0, windowWithFrameRectEmpty.Height);
|
||||
Assert.False (windowWithFrameRectEmpty.IsCurrentTop);
|
||||
#if DEBUG
|
||||
Assert.Equal (windowWithFrameRectEmpty.Title, windowWithFrameRectEmpty.Id);
|
||||
#endif
|
||||
Assert.False (windowWithFrameRectEmpty.WantContinuousButtonPressed);
|
||||
Assert.False (windowWithFrameRectEmpty.WantMousePositionReports);
|
||||
Assert.Null (windowWithFrameRectEmpty.SuperView);
|
||||
@@ -176,11 +173,7 @@ public class WindowTests (ITestOutputHelper output)
|
||||
windowWithFrame1234.Title = "title";
|
||||
Assert.Equal ("title", windowWithFrame1234.Title);
|
||||
Assert.NotNull (windowWithFrame1234);
|
||||
#if DEBUG
|
||||
Assert.Equal ($"Window(title){windowWithFrame1234.Frame}", windowWithFrame1234.ToString ());
|
||||
#else
|
||||
Assert.Equal ($"Window(){windowWithFrame1234.Frame}", windowWithFrame1234.ToString ());
|
||||
#endif
|
||||
Assert.True (windowWithFrame1234.CanFocus);
|
||||
Assert.False (windowWithFrame1234.HasFocus);
|
||||
Assert.Equal (new (0, 0, 1, 2), windowWithFrame1234.Viewport);
|
||||
@@ -192,9 +185,6 @@ public class WindowTests (ITestOutputHelper output)
|
||||
Assert.Equal (3, windowWithFrame1234.Width);
|
||||
Assert.Equal (4, windowWithFrame1234.Height);
|
||||
Assert.False (windowWithFrame1234.IsCurrentTop);
|
||||
#if DEBUG
|
||||
Assert.Equal (windowWithFrame1234.Title, windowWithFrame1234.Id);
|
||||
#endif
|
||||
Assert.False (windowWithFrame1234.WantContinuousButtonPressed);
|
||||
Assert.False (windowWithFrame1234.WantMousePositionReports);
|
||||
Assert.Null (windowWithFrame1234.SuperView);
|
||||
|
||||
Reference in New Issue
Block a user