mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-31 02:08:03 +01:00
restructure
This commit is contained in:
@@ -113,142 +113,6 @@ public class ContextMenuTests (ITestOutputHelper output)
|
||||
top.Dispose ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void ContextMenu_On_Toplevel_With_A_MenuBar_TextField_StatusBar ()
|
||||
{
|
||||
Thread.CurrentThread.CurrentUICulture = new CultureInfo ("en-US");
|
||||
|
||||
var menu = new MenuBar
|
||||
{
|
||||
Menus =
|
||||
[
|
||||
new MenuBarItem ("File", "", null),
|
||||
new MenuBarItem ("Edit", "", null)
|
||||
]
|
||||
};
|
||||
|
||||
var label = new Label { X = 2, Y = 3, Text = "Label:" };
|
||||
|
||||
var tf = new TextField { X = Pos.Right (label) + 1, Y = Pos.Top (label), Width = 20, Text = "TextField" };
|
||||
|
||||
var statusBar = new StatusBar (
|
||||
#if V2_STATUSBAR
|
||||
[
|
||||
new StatusItem (KeyCode.F1, "~F1~ Help", null),
|
||||
new StatusItem (KeyCode.CtrlMask | KeyCode.Q, "~^Q~ Quit", null)
|
||||
]
|
||||
#endif
|
||||
);
|
||||
|
||||
var top = new Toplevel ();
|
||||
top.Add (menu, label, tf, statusBar);
|
||||
((FakeDriver)Application.Driver).SetBufferSize (45, 17);
|
||||
Application.Begin (top);
|
||||
|
||||
Assert.Equal (new Rectangle (9, 3, 20, 1), tf.Frame);
|
||||
Assert.True (tf.HasFocus);
|
||||
|
||||
tf.ContextMenu.Show ();
|
||||
Assert.True (ContextMenu.IsShow);
|
||||
Assert.Equal (new Point (9, 3), tf.ContextMenu.Position);
|
||||
Application.Top.Draw ();
|
||||
|
||||
var expected = @"
|
||||
File Edit
|
||||
|
||||
|
||||
Label: TextField
|
||||
┌─────────────────────┐
|
||||
│ Select All Ctrl+T │
|
||||
│ Delete All Ctrl+R │
|
||||
│ Copy Ctrl+C │
|
||||
│ Cut Ctrl+X │
|
||||
│ Paste Ctrl+V │
|
||||
│ Undo Ctrl+Z │
|
||||
│ Redo Ctrl+Y │
|
||||
└─────────────────────┘
|
||||
|
||||
|
||||
|
||||
F1 Help │ ^Q Quit
|
||||
";
|
||||
|
||||
Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
|
||||
Assert.Equal (new Rectangle (1, 0, 32, 17), pos);
|
||||
top.Dispose ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void ContextMenu_On_Toplevel_With_A_MenuBar_Window_TextField_StatusBar ()
|
||||
{
|
||||
Thread.CurrentThread.CurrentUICulture = new CultureInfo ("en-US");
|
||||
|
||||
var menu = new MenuBar
|
||||
{
|
||||
Menus =
|
||||
[
|
||||
new MenuBarItem ("File", "", null),
|
||||
new MenuBarItem ("Edit", "", null)
|
||||
]
|
||||
};
|
||||
|
||||
var label = new Label { X = 2, Y = 3, Text = "Label:" };
|
||||
|
||||
var tf = new TextField { X = Pos.Right (label) + 1, Y = Pos.Top (label), Width = 20, Text = "TextField" };
|
||||
|
||||
var win = new Window ();
|
||||
win.Add (label, tf);
|
||||
|
||||
var statusBar = new StatusBar (
|
||||
#if V2_STATUSBAR
|
||||
new []
|
||||
{
|
||||
new StatusItem (KeyCode.F1, "~F1~ Help", null),
|
||||
new StatusItem (KeyCode.CtrlMask | KeyCode.Q, "~^Q~ Quit", null)
|
||||
}
|
||||
#endif
|
||||
);
|
||||
|
||||
var top = new Toplevel ();
|
||||
top.Add (menu, win, statusBar);
|
||||
Application.Begin (top);
|
||||
((FakeDriver)Application.Driver).SetBufferSize (44, 17);
|
||||
|
||||
Assert.Equal (new Rectangle (9, 3, 20, 1), tf.Frame);
|
||||
Assert.True (tf.HasFocus);
|
||||
|
||||
tf.ContextMenu.Show ();
|
||||
Assert.True (ContextMenu.IsShow);
|
||||
Assert.Equal (new Point (10, 5), tf.ContextMenu.Position);
|
||||
Application.Top.Draw ();
|
||||
|
||||
var expected = @"
|
||||
File Edit
|
||||
┌──────────────────────────────────────────┐
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ Label: TextField │
|
||||
│ ┌─────────────────────┐ │
|
||||
│ │ Select All Ctrl+T │ │
|
||||
│ │ Delete All Ctrl+R │ │
|
||||
│ │ Copy Ctrl+C │ │
|
||||
│ │ Cut Ctrl+X │ │
|
||||
│ │ Paste Ctrl+V │ │
|
||||
│ │ Undo Ctrl+Z │ │
|
||||
│ │ Redo Ctrl+Y │ │
|
||||
│ └─────────────────────┘ │
|
||||
└──────────────────────────────────────────┘
|
||||
F1 Help │ ^Q Quit
|
||||
";
|
||||
|
||||
Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
|
||||
Assert.Equal (new Rectangle (1, 0, 44, 17), pos);
|
||||
top.Dispose ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void Draw_A_ContextMenu_Over_A_Borderless_Top ()
|
||||
|
||||
Reference in New Issue
Block a user