Browse Source

reorg'd Toplevel tests

Tig Kindel 1 year ago
parent
commit
e0e9413283

+ 24 - 20
Terminal.Gui/Views/Toplevel.cs

@@ -11,7 +11,7 @@ namespace Terminal.Gui;
 /// </summary>
 /// <remarks>
 ///         <para>
-///         Toplevels can be modally executing views, started by calling
+///         Toplevels can run as modal (popup) views, started by calling
 ///         <see cref="Application.Run(Toplevel, System.Func{System.Exception,bool}(System.Exception))"/>.
 ///         They return control to the caller when <see cref="Application.RequestStop(Toplevel)"/> has
 ///         been called (which sets the <see cref="Toplevel.Running"/> property to <c>false</c>).
@@ -22,14 +22,14 @@ namespace Terminal.Gui;
 ///         The application Toplevel can be accessed via <see cref="Application.Top"/>. Additional
 ///         Toplevels can be created
 ///         and run (e.g. <see cref="Dialog"/>s. To run a Toplevel, create the <see cref="Toplevel"/> and
-///         call
-///         <see cref="Application.Run(Toplevel, System.Func{System.Exception,bool}(System.Exception))"/>.
+///         call <see cref="Application.Run(Toplevel, System.Func{System.Exception,bool}(System.Exception))"/>.
 ///         </para>
 /// </remarks>
 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.
@@ -42,8 +42,8 @@ public partial class Toplevel : View {
 
 	/// <summary>
 	/// Initializes a new instance of the <see cref="Toplevel"/> class with
-	/// <see cref="LayoutStyle.Computed"/> layout,
-	/// defaulting to full screen.
+	/// <see cref="LayoutStyle.Computed"/> layout, defaulting to full screen. The <see cref="View.Width"/> and <see cref="View.Height"/> properties
+	/// will be set to the dimensions of the terminal using <see cref="Dim.Fill"/>.
 	/// </summary>
 	public Toplevel ()
 	{
@@ -52,6 +52,16 @@ public partial class Toplevel : View {
 		Height = Dim.Fill ();
 	}
 
+	/// <summary>
+	/// Convenience factory method that creates a new Toplevel.
+	/// </summary>
+	/// <remarks>
+	/// The <see cref="View.Width"/> and <see cref="View.Height"/> properties
+	/// will be set to the dimensions of the terminal using <see cref="Dim.Fill"/>.
+	/// </remarks>
+	/// <returns>The created Toplevel.</returns>
+	public static Toplevel Create () => new (new Rect (0, 0, Driver.Cols, Driver.Rows)); // BUGBUG: Should be ComputedLayout
+
 	/// <summary>
 	/// Gets or sets whether the main loop for this <see cref="Toplevel"/> is running or not.
 	/// </summary>
@@ -306,17 +316,17 @@ public partial class Toplevel : View {
 		KeyBindings.Add ((KeyCode)Application.QuitKey, Command.QuitToplevel);
 
 		KeyBindings.Add (KeyCode.CursorRight, Command.NextView);
-		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
 
 #if UNIX_KEY_BINDINGS
@@ -389,12 +399,6 @@ 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) {
@@ -682,7 +686,7 @@ public partial class Toplevel : View {
 	public virtual void PositionToplevel (Toplevel top)
 	{
 		var superView = GetLocationThatFits (top, top.Frame.X, top.Frame.Y,
-			out var nx,                       out var ny,  out _, out var sb);
+			out var nx, out var ny, out _, out var sb);
 		var layoutSubviews = false;
 		var maxWidth = 0;
 		if (superView.Margin != null && superView == top.SuperView) {

+ 10 - 5
UnitTests/Views/OverlappedTests.cs → UnitTests/Views/Toplevel/OverlappedTests.cs

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

+ 63 - 62
UnitTests/Views/ToplevelTests.cs → UnitTests/Views/Toplevel/ToplevelTests.cs

@@ -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 (@"
  ┌────────┐

+ 14 - 10
UnitTests/Views/WindowTests.cs → UnitTests/Views/Toplevel/WindowTests.cs

@@ -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 [] {