浏览代码

Fixed post merge errors.

Tig 1 年之前
父节点
当前提交
78f527e4a1
共有 2 个文件被更改,包括 13 次插入5 次删除
  1. 8 0
      Terminal.Gui/Application/Application .Screen.cs
  2. 5 5
      UnitTests/View/DrawTests.cs

+ 8 - 0
Terminal.Gui/Application/Application .Screen.cs

@@ -3,6 +3,14 @@ namespace Terminal.Gui;
 
 public static partial class Application // Screen related stuff
 {
+    /// <summary>
+    ///     Gets the size of the screen. This is the size of the screen as reported by the <see cref="ConsoleDriver"/>.
+    /// </summary>
+    /// <remarks>
+    ///     If the <see cref="ConsoleDriver"/> has not been initialized, this will return a default size of 2048x2048; useful for unit tests.
+    /// </remarks>
+    public static Rectangle Screen => Driver?.Screen ?? new (0, 0, 2048, 2048);
+
     /// <summary>Invoked when the terminal's size changed. The new size of the terminal is provided.</summary>
     /// <remarks>
     ///     Event handlers can set <see cref="SizeChangedEventArgs.Cancel"/> to <see langword="true"/> to prevent

+ 5 - 5
UnitTests/View/DrawTests.cs

@@ -393,7 +393,7 @@ public class DrawTests (ITestOutputHelper _output)
         var view = new View { Width = 2, Height = 2, BorderStyle = LineStyle.Single };
         view.BeginInit ();
         view.EndInit ();
-        view.SetRelativeLayout (Application!.Screen.Size);
+        view.SetRelativeLayout (Application.Screen.Size);
 
         Assert.Equal (new (0, 0, 2, 2), view.Frame);
         Assert.Equal (Rectangle.Empty, view.Viewport);
@@ -418,7 +418,7 @@ public class DrawTests (ITestOutputHelper _output)
         view.Border.Thickness = new Thickness (1, 1, 1, 0);
         view.BeginInit ();
         view.EndInit ();
-        view.SetRelativeLayout (Application!.Screen.Size);
+        view.SetRelativeLayout (Application.Screen.Size);
 
         Assert.Equal (new (0, 0, 2, 1), view.Frame);
         Assert.Equal (Rectangle.Empty, view.Viewport);
@@ -436,7 +436,7 @@ public class DrawTests (ITestOutputHelper _output)
         view.Border.Thickness = new Thickness (0, 1, 1, 1);
         view.BeginInit ();
         view.EndInit ();
-        view.SetRelativeLayout (Application!.Screen.Size);
+        view.SetRelativeLayout (Application.Screen.Size);
 
         Assert.Equal (new (0, 0, 1, 2), view.Frame);
         Assert.Equal (Rectangle.Empty, view.Viewport);
@@ -461,7 +461,7 @@ public class DrawTests (ITestOutputHelper _output)
         view.Border.Thickness = new Thickness (1, 1, 0, 1);
         view.BeginInit ();
         view.EndInit ();
-        view.SetRelativeLayout (Application!.Screen.Size);
+        view.SetRelativeLayout (Application.Screen.Size);
 
         Assert.Equal (new (0, 0, 1, 2), view.Frame);
         Assert.Equal (Rectangle.Empty, view.Viewport);
@@ -487,7 +487,7 @@ public class DrawTests (ITestOutputHelper _output)
 
         view.BeginInit ();
         view.EndInit ();
-        view.SetRelativeLayout (Application!.Screen.Size);
+        view.SetRelativeLayout (Application.Screen.Size);
 
         Assert.Equal (new (0, 0, 2, 1), view.Frame);
         Assert.Equal (Rectangle.Empty, view.Viewport);