mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-30 09:47:58 +01:00
merged
This commit is contained in:
@@ -29,7 +29,6 @@ public partial class Toplevel : View {
|
||||
internal static Point? _dragPosition;
|
||||
Point _startGrabPoint;
|
||||
|
||||
// BUGBUG: Remove; Toplevel should be ComputedLayout
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Toplevel"/> class with the specified
|
||||
/// <see cref="LayoutStyle.Absolute"/> layout.
|
||||
@@ -310,12 +309,20 @@ public partial class Toplevel : View {
|
||||
KeyBindings.Add (KeyCode.CursorDown, Command.NextView);
|
||||
KeyBindings.Add (KeyCode.CursorLeft, Command.PreviousView);
|
||||
KeyBindings.Add (KeyCode.CursorUp, Command.PreviousView);
|
||||
KeyBindings.Add (KeyCode.CursorDown, Command.NextView);
|
||||
KeyBindings.Add (KeyCode.CursorLeft, Command.PreviousView);
|
||||
KeyBindings.Add (KeyCode.CursorUp, Command.PreviousView);
|
||||
|
||||
KeyBindings.Add (KeyCode.Tab, Command.NextView);
|
||||
KeyBindings.Add (KeyCode.Tab | KeyCode.ShiftMask, Command.PreviousView);
|
||||
KeyBindings.Add (KeyCode.Tab | KeyCode.CtrlMask, Command.NextViewOrTop);
|
||||
KeyBindings.Add (KeyCode.Tab, Command.NextView);
|
||||
KeyBindings.Add (KeyCode.Tab | KeyCode.ShiftMask, Command.PreviousView);
|
||||
KeyBindings.Add (KeyCode.Tab | KeyCode.CtrlMask, Command.NextViewOrTop);
|
||||
KeyBindings.Add (KeyCode.Tab | KeyCode.ShiftMask | KeyCode.CtrlMask, Command.PreviousViewOrTop);
|
||||
|
||||
KeyBindings.Add (KeyCode.F5, Command.Refresh);
|
||||
KeyBindings.Add ((KeyCode)Application.AlternateForwardKey, Command.NextViewOrTop); // Needed on Unix
|
||||
KeyBindings.Add (KeyCode.F5, Command.Refresh);
|
||||
KeyBindings.Add ((KeyCode)Application.AlternateForwardKey, Command.NextViewOrTop); // Needed on Unix
|
||||
KeyBindings.Add ((KeyCode)Application.AlternateBackwardKey, Command.PreviousViewOrTop); // Needed on Unix
|
||||
@@ -390,6 +397,12 @@ public partial class Toplevel : View {
|
||||
QuitKeyChanged?.Invoke (this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convenience factory method that creates a new Toplevel with the current terminal dimensions.
|
||||
/// </summary>
|
||||
/// <returns>The created Toplevel.</returns>
|
||||
public static Toplevel Create () => new (new Rect (0, 0, Driver.Cols, Driver.Rows));
|
||||
|
||||
void MovePreviousViewOrTop ()
|
||||
{
|
||||
if (Application.OverlappedTop == null) {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
using System;
|
||||
using Terminal.Gui;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace TerminalGui.ViewsTests;
|
||||
namespace Terminal.Gui.ViewsTests;
|
||||
|
||||
public class OverlappedTests {
|
||||
readonly ITestOutputHelper _output;
|
||||
@@ -17,8 +16,7 @@ public class OverlappedTests {
|
||||
#endif
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[TestRespondersDisposed]
|
||||
[Fact] [TestRespondersDisposed]
|
||||
public void Dispose_Toplevel_IsOverlappedContainer_False_With_Begin_End ()
|
||||
{
|
||||
Application.Init (new FakeDriver ());
|
||||
@@ -37,8 +35,7 @@ public class OverlappedTests {
|
||||
#endif
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[TestRespondersDisposed]
|
||||
[Fact] [TestRespondersDisposed]
|
||||
public void Dispose_Toplevel_IsOverlappedContainer_True_With_Begin ()
|
||||
{
|
||||
Application.Init (new FakeDriver ());
|
||||
@@ -50,8 +47,7 @@ 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 ();
|
||||
@@ -687,8 +683,7 @@ 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,9 +1,8 @@
|
||||
using System;
|
||||
using Terminal.Gui;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace TerminalGui.ViewsTests;
|
||||
namespace Terminal.Gui.ViewsTests;
|
||||
|
||||
public class ToplevelTests {
|
||||
readonly ITestOutputHelper _output;
|
||||
@@ -17,8 +16,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);
|
||||
@@ -200,8 +199,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);
|
||||
|
||||
@@ -315,7 +314,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);
|
||||
|
||||
@@ -363,10 +362,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));
|
||||
@@ -383,13 +382,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);
|
||||
@@ -403,22 +402,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);
|
||||
@@ -428,23 +427,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
|
||||
@@ -511,7 +510,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);
|
||||
@@ -533,13 +532,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]);
|
||||
@@ -553,27 +552,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]);
|
||||
@@ -583,22 +582,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
|
||||
@@ -667,16 +666,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);
|
||||
@@ -688,8 +687,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]
|
||||
@@ -735,7 +734,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) {
|
||||
@@ -748,7 +747,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) {
|
||||
@@ -774,7 +773,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) {
|
||||
@@ -789,7 +788,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) {
|
||||
@@ -849,7 +848,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);
|
||||
@@ -1142,10 +1141,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 (@"
|
||||
▲
|
||||
┬
|
||||
@@ -1169,7 +1168,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 {
|
||||
@@ -1254,7 +1253,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 (@"
|
||||
┌──────────────────┐
|
||||
│ │
|
||||
@@ -1279,7 +1278,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 (@"
|
||||
┌──────────────────┐
|
||||
│ │
|
||||
@@ -1312,7 +1311,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 (@"
|
||||
──────────────────┐
|
||||
@@ -1326,7 +1325,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);
|
||||
@@ -1339,7 +1338,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);
|
||||
}
|
||||
@@ -1394,7 +1393,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,8 +1,7 @@
|
||||
using Terminal.Gui;
|
||||
using Xunit;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace TerminalGui.ViewsTests;
|
||||
namespace Terminal.Gui.ViewsTests;
|
||||
|
||||
public class WindowTests {
|
||||
readonly ITestOutputHelper _output;
|
||||
@@ -43,6 +42,8 @@ public class WindowTests {
|
||||
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);
|
||||
@@ -67,6 +68,7 @@ public class WindowTests {
|
||||
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);
|
||||
@@ -88,8 +90,7 @@ public class WindowTests {
|
||||
r.Dispose ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
[Fact] [AutoInitShutdown]
|
||||
public void MenuBar_And_StatusBar_Inside_Window ()
|
||||
{
|
||||
var menu = new MenuBar (new MenuBarItem [] {
|
||||
@@ -171,8 +172,7 @@ 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 };
|
||||
@@ -190,8 +190,7 @@ 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