mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +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...
244 lines
13 KiB
C#
244 lines
13 KiB
C#
using System.Reflection;
|
|
using Terminal.Gui;
|
|
using TerminalGuiFluentTesting;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace IntegrationTests.FluentTests;
|
|
|
|
/// <summary>
|
|
/// Tests for the PopoverMenu class
|
|
/// </summary>
|
|
public class PopoverMenuTests (ITestOutputHelper outputHelper)
|
|
{
|
|
private readonly TextWriter _out = new TestOutputWriter (outputHelper);
|
|
|
|
[Theory]
|
|
[ClassData (typeof (V2TestDrivers))]
|
|
public void EnableForDesign_CreatesMenuItems (V2TestDriver d)
|
|
{
|
|
using GuiTestContext c = With.A<Window> (80, 25, d)
|
|
.Then (
|
|
() =>
|
|
{
|
|
var popoverMenu = new PopoverMenu ();
|
|
Application.Top!.Add (popoverMenu);
|
|
|
|
// Call EnableForDesign
|
|
Toplevel top = Application.Top;
|
|
bool result = popoverMenu.EnableForDesign (ref top);
|
|
|
|
// Should return true
|
|
Assert.True (result);
|
|
|
|
// Should have created menu items
|
|
Assert.NotNull (popoverMenu.Root);
|
|
Assert.Equal (7, popoverMenu.Root.SubViews.Count);
|
|
|
|
// Should have Cut menu item
|
|
View? cutMenuItem = popoverMenu.GetMenuItemsOfAllSubMenus ().FirstOrDefault (v => v?.Title == "Cu_t");
|
|
|
|
Assert.NotNull (cutMenuItem);
|
|
})
|
|
.Stop ();
|
|
}
|
|
|
|
|
|
[Theory]
|
|
[ClassData (typeof (V2TestDrivers))]
|
|
public void Activate_Sets_Application_Navigation_Correctly (V2TestDriver d)
|
|
{
|
|
MenuBarv2? menuBar = null;
|
|
|
|
using GuiTestContext c = With.A<Window> (50, 20, d)
|
|
.Then (
|
|
() =>
|
|
{
|
|
var popoverMenu = new PopoverMenu ();
|
|
|
|
// Call EnableForDesign
|
|
Toplevel top = Application.Top!;
|
|
popoverMenu.EnableForDesign (ref top);
|
|
|
|
View? view = new View ()
|
|
{
|
|
CanFocus = true,
|
|
Height = Dim.Auto (),
|
|
Width = Dim.Auto (),
|
|
Id = "focusableView",
|
|
Text = "View",
|
|
};
|
|
Application.Top!.Add (view);
|
|
|
|
// EnableForDesign sets to true; undo that
|
|
popoverMenu.Visible = false;
|
|
|
|
Application.Popover!.Register (popoverMenu);
|
|
|
|
view.SetFocus ();
|
|
})
|
|
.WaitIteration ()
|
|
.Then (() => Assert.False (Application.Popover?.GetActivePopover () is PopoverMenu))
|
|
.Then (() => Assert.IsNotType<MenuItemv2> (Application.Navigation!.GetFocused ()))
|
|
.ScreenShot ("PopoverMenu initial state", _out)
|
|
.Then (() => Application.Popover!.Show (Application.Popover.Popovers.First ()))
|
|
.WaitIteration ()
|
|
.ScreenShot ($"After Show", _out)
|
|
.Then (() => Assert.True (Application.Popover?.GetActivePopover () is PopoverMenu))
|
|
.Then (() => Assert.Equal ("Cu_t", Application.Navigation!.GetFocused ()!.Title))
|
|
.WriteOutLogs (_out)
|
|
.Stop ();
|
|
}
|
|
|
|
[Theory]
|
|
[ClassData (typeof (V2TestDrivers))]
|
|
public void QuitKey_Hides (V2TestDriver d)
|
|
{
|
|
MenuBarv2? menuBar = null;
|
|
|
|
using GuiTestContext c = With.A<Window> (50, 20, d)
|
|
.Then (
|
|
() =>
|
|
{
|
|
var popoverMenu = new PopoverMenu ();
|
|
|
|
// Call EnableForDesign
|
|
Toplevel top = Application.Top!;
|
|
bool result = popoverMenu.EnableForDesign (ref top);
|
|
|
|
View? view = new View ()
|
|
{
|
|
CanFocus = true,
|
|
Height = Dim.Auto (),
|
|
Width = Dim.Auto (),
|
|
Id = "focusableView",
|
|
Text = "View",
|
|
};
|
|
Application.Top!.Add (view);
|
|
|
|
// EnableForDesign sets to true; undo that
|
|
popoverMenu.Visible = false;
|
|
|
|
Application.Popover!.Register (popoverMenu);
|
|
|
|
view.SetFocus ();
|
|
})
|
|
.WaitIteration ()
|
|
.ScreenShot ("PopoverMenu initial state", _out)
|
|
.Then (() => Assert.False (Application.Popover?.GetActivePopover () is PopoverMenu))
|
|
.Then (() => Application.Popover!.Show (Application.Popover.Popovers.First ()))
|
|
.WaitIteration ()
|
|
.ScreenShot ($"After Show", _out)
|
|
.Then (() => Assert.True (Application.Popover?.GetActivePopover () is PopoverMenu))
|
|
.RaiseKeyDownEvent (Application.QuitKey)
|
|
.Then (() => Application.LayoutAndDraw (true))
|
|
.WaitIteration ()
|
|
.WriteOutLogs (_out)
|
|
.ScreenShot ($"After {Application.QuitKey}", _out)
|
|
.Then (() => Assert.False (Application.Popover!.Popovers.Cast<PopoverMenu> ().FirstOrDefault()!.Visible))
|
|
.Then (() => Assert.Null (Application.Popover!.GetActivePopover()))
|
|
.Then (() => Assert.True (Application.Top!.Running))
|
|
.WriteOutLogs (_out)
|
|
.Stop ();
|
|
}
|
|
|
|
[Theory]
|
|
[ClassData (typeof (V2TestDrivers))]
|
|
public void QuitKey_Restores_Focus_Correctly (V2TestDriver d)
|
|
{
|
|
MenuBarv2? menuBar = null;
|
|
|
|
using GuiTestContext c = With.A<Window> (50, 20, d)
|
|
.Then (
|
|
() =>
|
|
{
|
|
var popoverMenu = new PopoverMenu ();
|
|
|
|
// Call EnableForDesign
|
|
Toplevel top = Application.Top!;
|
|
bool result = popoverMenu.EnableForDesign (ref top);
|
|
|
|
View? view = new View ()
|
|
{
|
|
CanFocus = true,
|
|
Height = Dim.Auto (),
|
|
Width = Dim.Auto (),
|
|
Id = "focusableView",
|
|
Text = "View",
|
|
};
|
|
Application.Top!.Add (view);
|
|
|
|
// EnableForDesign sets to true; undo that
|
|
popoverMenu.Visible = false;
|
|
|
|
Application.Popover!.Register (popoverMenu);
|
|
|
|
view.SetFocus ();
|
|
})
|
|
.WaitIteration ()
|
|
.ScreenShot ("PopoverMenu initial state", _out)
|
|
.Then (() => Assert.False (Application.Popover?.GetActivePopover () is PopoverMenu))
|
|
.Then (() => Assert.IsNotType<MenuItemv2>(Application.Navigation!.GetFocused()))
|
|
.Then (() => Application.Popover!.Show (Application.Popover.Popovers.First ()))
|
|
.WaitIteration ()
|
|
.ScreenShot ($"After Show", _out)
|
|
.Then (() => Assert.True (Application.Popover?.GetActivePopover () is PopoverMenu))
|
|
.Then (() => Assert.IsType<MenuItemv2>(Application.Navigation!.GetFocused()))
|
|
.RaiseKeyDownEvent (Application.QuitKey)
|
|
.ScreenShot ($"After {Application.QuitKey}", _out)
|
|
.Then (() => Assert.False (Application.Popover?.GetActivePopover () is PopoverMenu))
|
|
.Then (() => Assert.IsNotType<MenuItemv2>(Application.Navigation!.GetFocused()))
|
|
.WriteOutLogs (_out)
|
|
.Stop ();
|
|
}
|
|
|
|
[Theory]
|
|
[ClassData (typeof (V2TestDrivers))]
|
|
public void MenuBarItem_With_QuitKey_Open_QuitKey_Does_Not_Quit_App (V2TestDriver d)
|
|
{
|
|
MenuBarv2? menuBar = null;
|
|
|
|
using GuiTestContext c = With.A<Window> (50, 20, d)
|
|
.Then (
|
|
() =>
|
|
{
|
|
var popoverMenu = new PopoverMenu ();
|
|
|
|
// Call EnableForDesign
|
|
Toplevel top = Application.Top!;
|
|
bool result = popoverMenu.EnableForDesign (ref top);
|
|
|
|
View? view = new View ()
|
|
{
|
|
CanFocus = true,
|
|
Height = Dim.Auto (),
|
|
Width = Dim.Auto (),
|
|
Id = "focusableView",
|
|
Text = "View",
|
|
};
|
|
Application.Top!.Add (view);
|
|
|
|
// EnableForDesign sets to true; undo that
|
|
popoverMenu.Visible = false;
|
|
|
|
Application.Popover!.Register (popoverMenu);
|
|
|
|
view.SetFocus ();
|
|
})
|
|
.WaitIteration ()
|
|
.Then (() => Assert.IsNotType<MenuItemv2>(Application.Navigation!.GetFocused()))
|
|
.ScreenShot ("PopoverMenu initial state", _out)
|
|
.Then (() => Application.Popover!.Show (Application.Popover.Popovers.First ()))
|
|
.WaitIteration ()
|
|
.ScreenShot ("PopoverMenu after Show", _out)
|
|
.Then (() => Assert.Equal ("Cu_t", Application.Navigation!.GetFocused ()!.Title))
|
|
.Then (() => Assert.True (Application.Top!.Running))
|
|
.RaiseKeyDownEvent (Application.QuitKey)
|
|
.Then (() => Application.LayoutAndDraw ())
|
|
.ScreenShot ($"After {Application.QuitKey}", _out)
|
|
.Then (() => Assert.False (Application.Popover?.GetActivePopover () is PopoverMenu))
|
|
.Then (() => Assert.True (Application.Top!.Running))
|
|
.WriteOutLogs (_out)
|
|
.Stop ();
|
|
}
|
|
}
|