mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
reorg'd Toplevel tests
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using Terminal.Gui;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Terminal.Gui.ViewsTests;
|
||||
namespace TerminalGui.ViewsTests;
|
||||
|
||||
public class OverlappedTests {
|
||||
readonly ITestOutputHelper _output;
|
||||
@@ -16,7 +17,8 @@ public class OverlappedTests {
|
||||
#endif
|
||||
}
|
||||
|
||||
[Fact] [TestRespondersDisposed]
|
||||
[Fact]
|
||||
[TestRespondersDisposed]
|
||||
public void Dispose_Toplevel_IsOverlappedContainer_False_With_Begin_End ()
|
||||
{
|
||||
Application.Init (new FakeDriver ());
|
||||
@@ -35,7 +37,8 @@ public class OverlappedTests {
|
||||
#endif
|
||||
}
|
||||
|
||||
[Fact] [TestRespondersDisposed]
|
||||
[Fact]
|
||||
[TestRespondersDisposed]
|
||||
public void Dispose_Toplevel_IsOverlappedContainer_True_With_Begin ()
|
||||
{
|
||||
Application.Init (new FakeDriver ());
|
||||
@@ -47,7 +50,8 @@ public class OverlappedTests {
|
||||
Application.Shutdown ();
|
||||
}
|
||||
|
||||
[Fact] [AutoInitShutdown]
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void Application_RequestStop_With_Params_On_A_Not_OverlappedContainer_Always_Use_Application_Current ()
|
||||
{
|
||||
var top1 = new Toplevel ();
|
||||
@@ -683,7 +687,8 @@ public class OverlappedTests {
|
||||
[Fact]
|
||||
public void MoveToOverlappedChild_Throw_NullReferenceException_Passing_Null_Parameter () => Assert.Throws<NullReferenceException> (delegate { Application.MoveToOverlappedChild (null); });
|
||||
|
||||
[Fact] [AutoInitShutdown]
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void Visible_False_Does_Not_Clear ()
|
||||
{
|
||||
var overlapped = new Overlapped ();
|
||||
@@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using Terminal.Gui;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Terminal.Gui.ViewsTests;
|
||||
namespace TerminalGui.ViewsTests;
|
||||
|
||||
public class ToplevelTests {
|
||||
readonly ITestOutputHelper _output;
|
||||
@@ -16,8 +17,8 @@ public class ToplevelTests {
|
||||
var top = new Toplevel ();
|
||||
|
||||
Assert.Equal (Colors.TopLevel, top.ColorScheme);
|
||||
Assert.Equal ("Fill(0)", top.Width.ToString ());
|
||||
Assert.Equal ("Fill(0)", top.Height.ToString ());
|
||||
Assert.Equal ("Fill(0)", top.Width.ToString ());
|
||||
Assert.Equal ("Fill(0)", top.Height.ToString ());
|
||||
Assert.False (top.Running);
|
||||
Assert.False (top.Modal);
|
||||
Assert.Null (top.MenuBar);
|
||||
@@ -208,8 +209,8 @@ public class ToplevelTests {
|
||||
// Application.Top without menu and status bar.
|
||||
var supView = top.GetLocationThatFits (top, 2, 2, out var nx, out var ny, out var mb, out var sb);
|
||||
Assert.Equal (Application.Top, supView);
|
||||
Assert.Equal (0, nx);
|
||||
Assert.Equal (0, ny);
|
||||
Assert.Equal (0, nx);
|
||||
Assert.Equal (0, ny);
|
||||
Assert.Null (mb);
|
||||
Assert.Null (sb);
|
||||
|
||||
@@ -323,7 +324,7 @@ public class ToplevelTests {
|
||||
// Application.Top with a menu and status bar.
|
||||
top.GetLocationThatFits (win, 30, 20, out nx, out ny, out mb, out sb);
|
||||
Assert.Equal (20, nx); // 20+60=80
|
||||
Assert.Equal (9, ny); // 9+15+1(mb)=25
|
||||
Assert.Equal (9, ny); // 9+15+1(mb)=25
|
||||
Assert.NotNull (mb);
|
||||
Assert.NotNull (sb);
|
||||
|
||||
@@ -371,10 +372,10 @@ public class ToplevelTests {
|
||||
Application.Begin (top);
|
||||
top.Running = true;
|
||||
|
||||
Assert.Equal (new Rect (0, 0, 40, 25), win1.Frame);
|
||||
Assert.Equal (new Rect (0, 0, 40, 25), win1.Frame);
|
||||
Assert.Equal (new Rect (41, 0, 40, 25), win2.Frame);
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (tf1W1, top.MostFocused);
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (tf1W1, top.MostFocused);
|
||||
|
||||
Assert.True (isRunning);
|
||||
Assert.True (Application.OnKeyDown (Application.QuitKey));
|
||||
@@ -391,13 +392,13 @@ public class ToplevelTests {
|
||||
Assert.True (Application.OnKeyDown (new Key (KeyCode.Tab | KeyCode.ShiftMask)));
|
||||
Assert.Equal ($"First line Win1{Environment.NewLine}Second line Win1", tvW1.Text);
|
||||
Assert.True (Application.OnKeyDown (new Key (KeyCode.Tab | KeyCode.CtrlMask)));
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (tf2W1, top.MostFocused);
|
||||
Assert.True (Application.OnKeyDown (new Key (KeyCode.Tab)));
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (tf1W1, top.MostFocused);
|
||||
Assert.True (Application.OnKeyDown (new Key (KeyCode.CursorRight)));
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (tf1W1, top.MostFocused);
|
||||
Assert.True (Application.OnKeyDown (new Key (KeyCode.CursorDown)));
|
||||
Assert.Equal (win1, top.Focused);
|
||||
@@ -411,22 +412,22 @@ public class ToplevelTests {
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (tvW1, top.MostFocused);
|
||||
Assert.True (Application.OnKeyDown (new Key (KeyCode.CursorLeft)));
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (tf1W1, top.MostFocused);
|
||||
Assert.True (Application.OnKeyDown (new Key (KeyCode.CursorUp)));
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (tf2W1, top.MostFocused);
|
||||
Assert.True (Application.OnKeyDown (new Key (KeyCode.Tab | KeyCode.CtrlMask)));
|
||||
Assert.Equal (win2, top.Focused);
|
||||
Assert.Equal (win2, top.Focused);
|
||||
Assert.Equal (tf1W2, top.MostFocused);
|
||||
Assert.True (Application.OnKeyDown (new Key (KeyCode.Tab | KeyCode.CtrlMask | KeyCode.ShiftMask)));
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (tf2W1, top.MostFocused);
|
||||
Assert.True (Application.OnKeyDown (Application.AlternateForwardKey));
|
||||
Assert.Equal (win2, top.Focused);
|
||||
Assert.Equal (win2, top.Focused);
|
||||
Assert.Equal (tf1W2, top.MostFocused);
|
||||
Assert.True (Application.OnKeyDown (Application.AlternateBackwardKey));
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (tf2W1, top.MostFocused);
|
||||
Assert.True (Application.OnKeyDown (new Key (KeyCode.CursorUp)));
|
||||
Assert.Equal (win1, top.Focused);
|
||||
@@ -436,23 +437,23 @@ public class ToplevelTests {
|
||||
#else
|
||||
Assert.True (Application.OnKeyDown (new Key (KeyCode.CursorLeft)));
|
||||
#endif
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (tf1W1, top.MostFocused);
|
||||
|
||||
Assert.True (Application.OnKeyDown (new Key (KeyCode.CursorDown)));
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (tvW1, top.MostFocused);
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (tvW1, top.MostFocused);
|
||||
Assert.Equal (new Point (0, 0), tvW1.CursorPosition);
|
||||
Assert.True (Application.OnKeyDown (new Key (KeyCode.End | KeyCode.CtrlMask)));
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (tvW1, top.MostFocused);
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (tvW1, top.MostFocused);
|
||||
Assert.Equal (new Point (16, 1), tvW1.CursorPosition);
|
||||
#if UNIX_KEY_BINDINGS
|
||||
Assert.True (Application.OnKeyDown (new (Key.F | Key.CtrlMask)));
|
||||
#else
|
||||
Assert.True (Application.OnKeyDown (new Key (KeyCode.CursorRight)));
|
||||
#endif
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (win1, top.Focused);
|
||||
Assert.Equal (tf2W1, top.MostFocused);
|
||||
|
||||
#if UNIX_KEY_BINDINGS
|
||||
@@ -519,7 +520,7 @@ public class ToplevelTests {
|
||||
Assert.Null (top.Focused);
|
||||
Assert.Null (top.MostFocused);
|
||||
Assert.Equal (tf1W2, win2.MostFocused);
|
||||
Assert.Equal (2, Application.OverlappedChildren.Count);
|
||||
Assert.Equal (2, Application.OverlappedChildren.Count);
|
||||
|
||||
Application.MoveToOverlappedChild (win1);
|
||||
Assert.Equal (win1, Application.Current);
|
||||
@@ -541,13 +542,13 @@ public class ToplevelTests {
|
||||
Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.Tab | KeyCode.ShiftMask)));
|
||||
Assert.Equal ($"First line Win1{Environment.NewLine}Second line Win1", tvW1.Text);
|
||||
Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.Tab | KeyCode.CtrlMask)));
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (tf2W1, win1.MostFocused);
|
||||
Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.Tab)));
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (tf1W1, win1.MostFocused);
|
||||
Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.CursorRight)));
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (tf1W1, win1.MostFocused);
|
||||
Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.CursorDown)));
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
@@ -561,27 +562,27 @@ public class ToplevelTests {
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (tvW1, win1.MostFocused);
|
||||
Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.CursorLeft)));
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (tf1W1, win1.MostFocused);
|
||||
Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.CursorUp)));
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (tf2W1, win1.MostFocused);
|
||||
Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.Tab)));
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (tf1W1, win1.MostFocused);
|
||||
Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.Tab | KeyCode.CtrlMask)));
|
||||
Assert.Equal (win2, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (win2, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (tf1W2, win2.MostFocused);
|
||||
tf2W2.SetFocus ();
|
||||
Assert.True (tf2W2.HasFocus);
|
||||
Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.Tab | KeyCode.CtrlMask | KeyCode.ShiftMask)));
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (tf1W1, win1.MostFocused);
|
||||
Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (Application.AlternateForwardKey));
|
||||
Assert.Equal (win2, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (win2, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (tf2W2, win2.MostFocused);
|
||||
Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (Application.AlternateBackwardKey));
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (tf1W1, win1.MostFocused);
|
||||
Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.CursorDown)));
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
@@ -591,22 +592,22 @@ public class ToplevelTests {
|
||||
#else
|
||||
Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.CursorLeft)));
|
||||
#endif
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (tf1W1, win1.MostFocused);
|
||||
Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.CursorDown)));
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (tvW1, win1.MostFocused);
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (tvW1, win1.MostFocused);
|
||||
Assert.Equal (new Point (0, 0), tvW1.CursorPosition);
|
||||
Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.End | KeyCode.CtrlMask)));
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (tvW1, win1.MostFocused);
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (tvW1, win1.MostFocused);
|
||||
Assert.Equal (new Point (16, 1), tvW1.CursorPosition);
|
||||
#if UNIX_KEY_BINDINGS
|
||||
Assert.True (Application.OverlappedChildren [0].ProcessKeyDown (new (Key.F | Key.CtrlMask)));
|
||||
#else
|
||||
Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.CursorRight)));
|
||||
#endif
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (win1, Application.OverlappedChildren [0]);
|
||||
Assert.Equal (tf2W1, win1.MostFocused);
|
||||
|
||||
#if UNIX_KEY_BINDINGS
|
||||
@@ -675,16 +676,16 @@ public class ToplevelTests {
|
||||
Assert.Equal (KeyCode.Null, quitKey);
|
||||
|
||||
Assert.Equal (KeyCode.PageDown | KeyCode.CtrlMask, Application.AlternateForwardKey);
|
||||
Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask, Application.AlternateBackwardKey);
|
||||
Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, Application.QuitKey);
|
||||
Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask, Application.AlternateBackwardKey);
|
||||
Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, Application.QuitKey);
|
||||
|
||||
Application.AlternateForwardKey = KeyCode.A;
|
||||
Application.AlternateBackwardKey = KeyCode.B;
|
||||
Application.QuitKey = KeyCode.C;
|
||||
|
||||
Assert.Equal (KeyCode.PageDown | KeyCode.CtrlMask, alternateForwardKey);
|
||||
Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask, alternateBackwardKey);
|
||||
Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, quitKey);
|
||||
Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask, alternateBackwardKey);
|
||||
Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, quitKey);
|
||||
|
||||
Assert.Equal (KeyCode.A, Application.AlternateForwardKey);
|
||||
Assert.Equal (KeyCode.B, Application.AlternateBackwardKey);
|
||||
@@ -696,8 +697,8 @@ public class ToplevelTests {
|
||||
Application.QuitKey = KeyCode.Q | KeyCode.CtrlMask;
|
||||
|
||||
Assert.Equal (KeyCode.PageDown | KeyCode.CtrlMask, Application.AlternateForwardKey);
|
||||
Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask, Application.AlternateBackwardKey);
|
||||
Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, Application.QuitKey);
|
||||
Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask, Application.AlternateBackwardKey);
|
||||
Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, Application.QuitKey);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -743,7 +744,7 @@ public class ToplevelTests {
|
||||
Flags = MouseFlags.Button1Pressed
|
||||
}));
|
||||
|
||||
Assert.Equal (Application.Current, Application.MouseGrabView);
|
||||
Assert.Equal (Application.Current, Application.MouseGrabView);
|
||||
Assert.Equal (new Rect (2, 2, 10, 3), Application.MouseGrabView.Frame);
|
||||
|
||||
} else if (iterations == 3) {
|
||||
@@ -756,7 +757,7 @@ public class ToplevelTests {
|
||||
}));
|
||||
Application.Refresh ();
|
||||
|
||||
Assert.Equal (Application.Current, Application.MouseGrabView);
|
||||
Assert.Equal (Application.Current, Application.MouseGrabView);
|
||||
Assert.Equal (new Rect (1, 2, 10, 3), Application.MouseGrabView.Frame);
|
||||
|
||||
} else if (iterations == 4) {
|
||||
@@ -782,7 +783,7 @@ public class ToplevelTests {
|
||||
}));
|
||||
Application.Refresh ();
|
||||
|
||||
Assert.Equal (Application.Current, Application.MouseGrabView);
|
||||
Assert.Equal (Application.Current, Application.MouseGrabView);
|
||||
Assert.Equal (new Rect (1, 1, 10, 3), Application.MouseGrabView.Frame);
|
||||
|
||||
} else if (iterations == 6) {
|
||||
@@ -797,7 +798,7 @@ public class ToplevelTests {
|
||||
│ │
|
||||
└─────────────┘", _output);
|
||||
|
||||
Assert.Equal (Application.Current, Application.MouseGrabView);
|
||||
Assert.Equal (Application.Current, Application.MouseGrabView);
|
||||
Assert.Equal (new Rect (1, 1, 10, 3), Application.MouseGrabView.Frame);
|
||||
|
||||
} else if (iterations == 7) {
|
||||
@@ -857,7 +858,7 @@ public class ToplevelTests {
|
||||
Flags = MouseFlags.Button1Pressed
|
||||
}));
|
||||
|
||||
Assert.Equal (win, Application.MouseGrabView);
|
||||
Assert.Equal (win, Application.MouseGrabView);
|
||||
Assert.Equal (location, Application.MouseGrabView.Frame);
|
||||
} else if (iterations == 2) {
|
||||
Assert.Equal (win, Application.MouseGrabView);
|
||||
@@ -1150,10 +1151,10 @@ public class ToplevelTests {
|
||||
top.Add (scrollView);
|
||||
Application.Begin (top);
|
||||
|
||||
Assert.Equal (new Rect (0, 0, 80, 25), top.Frame);
|
||||
Assert.Equal (new Rect (3, 3, 40, 16), scrollView.Frame);
|
||||
Assert.Equal (new Rect (0, 0, 80, 25), top.Frame);
|
||||
Assert.Equal (new Rect (3, 3, 40, 16), scrollView.Frame);
|
||||
Assert.Equal (new Rect (0, 0, 200, 100), scrollView.Subviews [0].Frame);
|
||||
Assert.Equal (new Rect (3, 3, 194, 94), win.Frame);
|
||||
Assert.Equal (new Rect (3, 3, 194, 94), win.Frame);
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
▲
|
||||
┬
|
||||
@@ -1177,7 +1178,7 @@ public class ToplevelTests {
|
||||
Y = 6,
|
||||
Flags = MouseFlags.Button1Pressed
|
||||
}));
|
||||
Assert.Equal (win, Application.MouseGrabView);
|
||||
Assert.Equal (win, Application.MouseGrabView);
|
||||
Assert.Equal (new Rect (3, 3, 194, 94), win.Frame);
|
||||
|
||||
Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
|
||||
@@ -1262,7 +1263,7 @@ public class ToplevelTests {
|
||||
Application.Begin (window);
|
||||
Application.Refresh ();
|
||||
Assert.Equal (new Rect (0, 0, 40, 10), top.Frame);
|
||||
Assert.Equal (new Rect (0, 0, 20, 3), window.Frame);
|
||||
Assert.Equal (new Rect (0, 0, 20, 3), window.Frame);
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
┌──────────────────┐
|
||||
│ │
|
||||
@@ -1287,7 +1288,7 @@ public class ToplevelTests {
|
||||
|
||||
Application.Refresh ();
|
||||
Assert.Equal (new Rect (0, 0, 40, 10), top.Frame);
|
||||
Assert.Equal (new Rect (0, 0, 20, 3), window.Frame);
|
||||
Assert.Equal (new Rect (0, 0, 20, 3), window.Frame);
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
┌──────────────────┐
|
||||
│ │
|
||||
@@ -1320,7 +1321,7 @@ public class ToplevelTests {
|
||||
}));
|
||||
|
||||
Application.Refresh ();
|
||||
Assert.Equal (new Rect (0, 0, 19, 2), top.Frame);
|
||||
Assert.Equal (new Rect (0, 0, 19, 2), top.Frame);
|
||||
Assert.Equal (new Rect (-1, 0, 20, 3), window.Frame);
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
──────────────────┐
|
||||
@@ -1334,7 +1335,7 @@ public class ToplevelTests {
|
||||
}));
|
||||
|
||||
Application.Refresh ();
|
||||
Assert.Equal (new Rect (0, 0, 19, 2), top.Frame);
|
||||
Assert.Equal (new Rect (0, 0, 19, 2), top.Frame);
|
||||
Assert.Equal (new Rect (18, 1, 20, 3), window.Frame);
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
┌", _output);
|
||||
@@ -1347,7 +1348,7 @@ public class ToplevelTests {
|
||||
}));
|
||||
|
||||
Application.Refresh ();
|
||||
Assert.Equal (new Rect (0, 0, 19, 2), top.Frame);
|
||||
Assert.Equal (new Rect (0, 0, 19, 2), top.Frame);
|
||||
Assert.Equal (new Rect (19, 2, 20, 3), window.Frame);
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"", _output);
|
||||
}
|
||||
@@ -1402,7 +1403,7 @@ public class ToplevelTests {
|
||||
|
||||
firstIteration = false;
|
||||
Application.RunIteration (ref rs, ref firstIteration);
|
||||
Assert.Equal (window, Application.MouseGrabView);
|
||||
Assert.Equal (window, Application.MouseGrabView);
|
||||
Assert.Equal (new Rect (1, 1, 10, 3), window.Frame);
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
┌────────┐
|
||||
@@ -1,7 +1,8 @@
|
||||
using Xunit;
|
||||
using Terminal.Gui;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Terminal.Gui.ViewsTests;
|
||||
namespace TerminalGui.ViewsTests;
|
||||
|
||||
public class WindowTests {
|
||||
readonly ITestOutputHelper _output;
|
||||
@@ -14,9 +15,9 @@ public class WindowTests {
|
||||
// Parameterless
|
||||
var r = new Window ();
|
||||
Assert.NotNull (r);
|
||||
Assert.Equal (string.Empty, r.Title);
|
||||
Assert.Equal (string.Empty, r.Title);
|
||||
Assert.Equal (LayoutStyle.Computed, r.LayoutStyle);
|
||||
Assert.Equal ("Window()(0,0,0,0)", r.ToString ());
|
||||
Assert.Equal ("Window()(0,0,0,0)", r.ToString ());
|
||||
Assert.True (r.CanFocus);
|
||||
Assert.False (r.HasFocus);
|
||||
Assert.Equal (new Rect (0, 0, 0, 0), r.Bounds);
|
||||
@@ -38,8 +39,8 @@ public class WindowTests {
|
||||
// Empty Rect
|
||||
r = new Window (Rect.Empty) { Title = "title" };
|
||||
Assert.NotNull (r);
|
||||
Assert.Equal ("title", r.Title);
|
||||
Assert.Equal (LayoutStyle.Absolute, r.LayoutStyle);
|
||||
Assert.Equal ("title", r.Title);
|
||||
Assert.Equal (LayoutStyle.Absolute, r.LayoutStyle);
|
||||
Assert.Equal ("Window(title)(0,0,0,0)", r.ToString ());
|
||||
Assert.True (r.CanFocus);
|
||||
Assert.False (r.HasFocus);
|
||||
@@ -63,7 +64,7 @@ public class WindowTests {
|
||||
r = new Window (new Rect (1, 2, 3, 4)) { Title = "title" };
|
||||
Assert.Equal ("title", r.Title);
|
||||
Assert.NotNull (r);
|
||||
Assert.Equal (LayoutStyle.Absolute, r.LayoutStyle);
|
||||
Assert.Equal (LayoutStyle.Absolute, r.LayoutStyle);
|
||||
Assert.Equal ("Window(title)(1,2,3,4)", r.ToString ());
|
||||
Assert.True (r.CanFocus);
|
||||
Assert.False (r.HasFocus);
|
||||
@@ -85,7 +86,8 @@ public class WindowTests {
|
||||
r.Dispose ();
|
||||
}
|
||||
|
||||
[Fact] [AutoInitShutdown]
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void MenuBar_And_StatusBar_Inside_Window ()
|
||||
{
|
||||
var menu = new MenuBar (new MenuBarItem [] {
|
||||
@@ -167,7 +169,8 @@ public class WindowTests {
|
||||
└──────────────────┘", _output);
|
||||
}
|
||||
|
||||
[Fact] [AutoInitShutdown]
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void OnCanFocusChanged_Only_Must_ContentView_Forces_SetFocus_After_IsInitialized_Is_True ()
|
||||
{
|
||||
var win1 = new Window { Id = "win1", Width = 10, Height = 1 };
|
||||
@@ -185,7 +188,8 @@ public class WindowTests {
|
||||
Assert.False (view2.HasFocus);
|
||||
}
|
||||
|
||||
[Fact] [AutoInitShutdown]
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void Activating_MenuBar_By_Alt_Key_Does_Not_Throw ()
|
||||
{
|
||||
var menu = new MenuBar (new MenuBarItem [] {
|
||||
Reference in New Issue
Block a user