restructure

This commit is contained in:
Tig
2024-06-16 16:07:40 -07:00
parent f99a744ef8
commit f43596c878
7 changed files with 304 additions and 414 deletions

View File

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