Browse Source

Added low-level unit tests; found latent bugs in View.Clear, Bounds, etc... Fixed.

Tig 1 year ago
parent
commit
745e2c21a2

+ 1 - 1
Terminal.Gui/Application.cs

@@ -807,7 +807,7 @@ public static partial class Application
                 || state.Toplevel.SubViewNeedsDisplay
                 || state.Toplevel.LayoutNeeded))
         {
-            state.Toplevel.Clear (Driver.Bounds);
+            Driver.ClearContents ();
         }
 
         if (state.Toplevel.NeedsDisplay || state.Toplevel.SubViewNeedsDisplay || state.Toplevel.LayoutNeeded || OverlappedChildNeedsDisplay ())

+ 31 - 12
Terminal.Gui/View/Adornment/Adornment.cs

@@ -30,10 +30,22 @@ public class Adornment : View
     /// <param name="parent"></param>
     public Adornment (View parent) { Parent = parent; }
 
-    /// <summary>Gets the rectangle that describes the inner area of the Adornment. The Location is always (0,0).</summary>
+    ///// <summary>
+    /////     Helper to get the X and Y offset of the Bounds from the Adornment Frame. This is the Left and Top properties
+    /////     of <see cref="Thickness"/>.
+    ///// </summary>
+    //public override Point GetBoundsOffset ()
+    //{
+    //    return new (Thickness.Left, Thickness.Top);
+    //}
+
+    /// <summary>
+    /// Gets the rectangle that describes the area of the Adornment. The Location is always (0,0).
+    /// The size is the size of the Frame 
+    /// </summary>
     public override Rectangle Bounds
     {
-        get => new Rectangle (Point.Empty, Thickness?.GetInside (new (Point.Empty, Frame.Size)).Size ?? Frame.Size);
+        get => new (Point.Empty, Frame.Size);
         // QUESTION: So why even have a setter then?
         set => throw new InvalidOperationException ("It makes no sense to set Bounds of a Thickness.");
     }
@@ -82,6 +94,18 @@ public class Adornment : View
         }
     }
 
+    ///// <inheritdoc/>
+    //public override Rectangle BoundsToScreen (Rectangle bounds)
+    //{
+    //    // Adornments are *Children* of a View, not SubViews. Thus View.BoundsToScreen will not work.
+    //    // To get the screen-relative coordinates of a Adornment, we need to know who
+    //    // the Parent is
+    //    Rectangle parentFrame = Parent?.Frame ?? Frame;
+    //    bounds.Offset (parentFrame.X, parentFrame.Y);
+
+    //    return Parent?.SuperView?.BoundsToScreen (bounds) ?? bounds;
+    //}
+
     /// <inheritdoc/>
     public override Rectangle FrameToScreen ()
     {
@@ -91,12 +115,9 @@ public class Adornment : View
         }
 
         // Adornments are *Children* of a View, not SubViews. Thus View.FrameToScreen will not work.
-        // To get the screen-relative coordinates of a Adornment, we need to know who
-        // the Parent is
+        // To get the screen-relative coordinates of a Adornment, we need get the parent's Frame
+        // in screen coords, and add our Frame location to it.
         Rectangle parent = Parent.FrameToScreen ();
-
-        // We now have coordinates relative to our View. If our View's SuperView has
-        // a SuperView, keep going...
         return new (new (parent.X + Frame.X, parent.Y + Frame.Y), Frame.Size);
     }
 
@@ -112,13 +133,11 @@ public class Adornment : View
             return;
         }
 
-        Rectangle screenBounds = BoundsToScreen (Frame);
-
+        Rectangle screenBounds = BoundsToScreen (contentArea);
         Attribute normalAttr = GetNormalColor ();
-
-        // This just draws/clears the thickness, not the insides.
         Driver.SetAttribute (normalAttr);
-        Thickness.Draw (screenBounds, (string)(Data ?? string.Empty));
+        // This just draws/clears the thickness, not the insides.
+        Thickness.Draw (screenBounds, ToString ());
 
         if (!string.IsNullOrEmpty (TextFormatter.Text))
         {

+ 1 - 1
Terminal.Gui/View/Adornment/Border.cs

@@ -204,7 +204,7 @@ public class Border : Adornment
         }
 
         //Driver.SetAttribute (Colors.ColorSchemes ["Error"].Normal);
-        Rectangle screenBounds = BoundsToScreen (Frame);
+        Rectangle screenBounds = BoundsToScreen (contentArea);
 
         //OnDrawSubviews (bounds); 
 

+ 27 - 21
Terminal.Gui/View/Layout/ViewLayout.cs

@@ -176,26 +176,31 @@ public partial class View
             }
 #endif // DEBUG
 
-            // BUGBUG: I think there's a bug here. This should be && not ||
             if (Margin is null || Border is null || Padding is null)
             {
                 return Rectangle.Empty with { Size = Frame.Size };
             }
 
-            int width = Math.Max (
-                                  0,
-                                  Frame.Size.Width
-                                  - Margin.Thickness.Horizontal
-                                  - Border.Thickness.Horizontal
-                                  - Padding.Thickness.Horizontal
-                                 );
-
-            int height = Math.Max (
-                                   0,
-                                   Frame.Size.Height - Margin.Thickness.Vertical - Border.Thickness.Vertical - Padding.Thickness.Vertical
-                                  );
+            //if (!IsInitialized)
+            //{
+                int width = Math.Max (
+                                      0,
+                                      Frame.Size.Width
+                                      - Margin.Thickness.Horizontal
+                                      - Border.Thickness.Horizontal
+                                      - Padding.Thickness.Horizontal
+                                     );
+
+                int height = Math.Max (
+                                       0,
+                                       Frame.Size.Height - Margin.Thickness.Vertical - Border.Thickness.Vertical - Padding.Thickness.Vertical
+                                      );
+
+                return Rectangle.Empty with { Size = new (width, height) };
+            //}
 
-            return Rectangle.Empty with { Size = new (width, height) };
+            //var totalThickness = Margin.Thickness + Border.Thickness + Padding.Thickness;
+            //return new (Point.Empty, totalThickness.GetInside (Frame).Size ?? Frame.Size);
         }
         set
         {
@@ -503,12 +508,11 @@ public partial class View
     {
         // Translate bounds to Frame (our SuperView's Bounds-relative coordinates)
         Point boundsOffset = GetBoundsOffset ();
-        bounds.Offset(Frame.X + boundsOffset.X, Frame.Y + boundsOffset.Y);
 
         Rectangle screen = FrameToScreen ();
         screen.Offset (boundsOffset.X + bounds.X, boundsOffset.Y + bounds.Y);
 
-        return screen;
+        return new Rectangle(screen.Location, bounds.Size);
     }
 
 #nullable enable
@@ -611,12 +615,14 @@ public partial class View
     ///     Helper to get the X and Y offset of the Bounds from the Frame. This is the sum of the Left and Top properties
     ///     of <see cref="Margin"/>, <see cref="Border"/> and <see cref="Padding"/>.
     /// </summary>
-    public Point GetBoundsOffset ()
+    public virtual Point GetBoundsOffset ()
     {
-        return new (
-                          Padding?.Thickness.GetInside (Padding.Frame).X ?? 0,
-                          Padding?.Thickness.GetInside (Padding.Frame).Y ?? 0
-                         );
+        if (Padding is null)
+        {
+            return Point.Empty;
+        }
+
+        return Padding.Thickness.GetInside (Padding.Frame).Location;
     }
 
     /// <summary>Fired after the View's <see cref="LayoutSubviews"/> method has completed.</summary>

+ 1 - 1
Terminal.Gui/View/View.cs

@@ -201,7 +201,7 @@ public partial class View : Responder, ISupportInitializeNotification
 
                     if (ClearOnVisibleFalse)
                     {
-                        Clear ();
+                        ClearFrame();
                     }
                 }
 

+ 24 - 11
Terminal.Gui/View/ViewDrawing.cs

@@ -80,25 +80,36 @@ public partial class View
         Driver.AddRune (ch);
     }
 
-    /// <summary>Clears the <see cref="Bounds"/> with the normal background color.</summary>
+    /// <summary>Clears the <see cref="Frame"/> with the normal background color.</summary>
     /// <remarks>
     ///     <para>This clears the Bounds used by this view.</para>
     /// </remarks>
-    public void Clear ()
+    public void ClearFrame ()
     {
         if (IsInitialized)
         {
-            Clear (BoundsToScreen (Bounds));
+            if (Driver is null)
+            {
+                return;
+            }
+
+            Attribute prev = Driver.SetAttribute (GetNormalColor ());
+            Driver.FillRect (FrameToScreen());
+            Driver.SetAttribute (prev);
         }
     }
 
-    // BUGBUG: This version of the Clear API should be removed. We should have a tenet that says 
-    // "View APIs only deal with View-relative coords". This is only used by ComboBox which can
-    // be refactored to use the View-relative version.
-    /// <summary>Clears the specified screen-relative rectangle with the normal background.</summary>
+    /// <summary>Clears <see cref="Bounds"/> with the normal background.</summary>
+    /// <remarks></remarks>
+    public void Clear ()
+    {
+        Clear (Bounds);
+    }
+
+    /// <summary>Clears the specified <see cref="Bounds"/>-relative rectangle with the normal background.</summary>
     /// <remarks></remarks>
-    /// <param name="regionScreen">The screen-relative rectangle to clear.</param>
-    public void Clear (Rectangle regionScreen)
+    /// <param name="contentArea">The Bounds-relative rectangle to clear.</param>
+    public void Clear (Rectangle contentArea)
     {
         if (Driver is null)
         {
@@ -106,7 +117,9 @@ public partial class View
         }
 
         Attribute prev = Driver.SetAttribute (GetNormalColor ());
-        Driver.FillRect (regionScreen);
+        // Clamp the region to the bounds of the view
+        contentArea = Rectangle.Intersect (contentArea, Bounds);
+        Driver.FillRect (BoundsToScreen(contentArea));
         Driver.SetAttribute (prev);
     }
 
@@ -373,7 +386,7 @@ public partial class View
         {
             if (SuperView is { })
             {
-                Clear (BoundsToScreen (contentArea));
+                Clear (contentArea);
             }
 
             if (!string.IsNullOrEmpty (TextFormatter.Text))

+ 3 - 3
Terminal.Gui/Views/ComboBox.cs

@@ -490,11 +490,11 @@ public class ComboBox : View
             OnOpenSelectedItem ();
         }
 
-        Rectangle rect = _listview.BoundsToScreen (_listview.IsInitialized ? _listview.Bounds : Rectangle.Empty);
         Reset (true);
-        _listview.Clear (rect);
+        _listview.Clear (_listview.IsInitialized ? _listview.Bounds : Rectangle.Empty);
         _listview.TabStop = false;
         SuperView?.SendSubviewToBack (this);
+        Rectangle rect = _listview.BoundsToScreen (_listview.IsInitialized ? _listview.Bounds : Rectangle.Empty);
         SuperView?.SetNeedsDisplay (rect);
         OnCollapsed ();
     }
@@ -761,7 +761,7 @@ public class ComboBox : View
     private void ShowList ()
     {
         _listview.SetSource (_searchset);
-        _listview.Clear (); // Ensure list shrinks in Dialog as you type
+        _listview.Clear (Bounds); // Ensure list shrinks in Dialog as you type
         _listview.Height = CalculatetHeight ();
         SuperView?.BringSubviewToFront (this);
     }

+ 1 - 1
Terminal.Gui/Views/ScrollView.cs

@@ -342,7 +342,7 @@ public class ScrollView : View
         Rectangle savedClip = ClipToBounds ();
 
         // TODO: It's bad practice for views to always clear a view. It negates clipping.
-        Clear ();
+        Clear (contentArea);
 
         if (!string.IsNullOrEmpty (_contentView.Text) || _contentView.Subviews.Count > 0)
         {

+ 1 - 1
Terminal.Gui/Views/Slider.cs

@@ -1073,7 +1073,7 @@ public class Slider<T> : View
     private void DrawSlider ()
     {
         // TODO: be more surgical on clear
-        Clear ();
+        Clear (Bounds);
 
         // Attributes
 

+ 1 - 1
Terminal.Gui/Views/TabView.cs

@@ -662,7 +662,7 @@ public class TabView : View
             _host._tabLocations = _host.CalculateViewport (Bounds).ToArray ();
 
             // clear any old text
-            Clear ();
+            Clear (contentArea);
 
             RenderTabLine ();
 

+ 1 - 1
Terminal.Gui/Views/TileView.cs

@@ -182,7 +182,7 @@ public class TileView : View
     public override void OnDrawContent (Rectangle contentArea)
     {
         Driver.SetAttribute (ColorScheme.Normal);
-        Clear ();
+        Clear (contentArea);
 
         base.OnDrawContent (contentArea);
 

+ 3 - 1
Terminal.Gui/Views/Toplevel.cs

@@ -1,3 +1,5 @@
+using System.Net.Mime;
+
 namespace Terminal.Gui;
 
 /// <summary>
@@ -358,7 +360,7 @@ public partial class Toplevel : View
         {
             //Driver.SetAttribute (GetNormalColor ());
             // TODO: It's bad practice for views to always clear. Defeats the purpose of clipping etc...
-            Clear ();
+            ClearFrame ();
             LayoutSubviews ();
             PositionToplevels ();
 

+ 1 - 1
UICatalog/Scenarios/AllViewsTester.cs

@@ -121,7 +121,7 @@ public class AllViewsTester : Scenario
                                                       _hostPane.Remove (_curView);
                                                       _curView.Dispose ();
                                                       _curView = null;
-                                                      _hostPane.Clear ();
+                                                      _hostPane.ClearFrame ();
                                                   }
 
                                                   _curView = CreateClass (_viewClasses.Values.ToArray () [_classListView.SelectedItem]);

+ 1 - 1
UICatalog/Scenarios/ColorPicker.cs

@@ -99,7 +99,7 @@ public class ColorPickers : Scenario
     /// <summary>Update a color label from his ColorPicker.</summary>
     private void UpdateColorLabel (Label label, ColorPicker colorPicker)
     {
-        label.Clear ();
+        label.ClearFrame ();
         var color = new Color (colorPicker.SelectedColor);
 
         label.Text =

+ 1 - 1
UICatalog/Scenarios/Snake.cs

@@ -314,7 +314,7 @@ public class Snake : Scenario
             base.OnDrawContent (contentArea);
 
             Driver.SetAttribute (white);
-            Clear ();
+            Clear (contentArea);
 
             var canvas = new LineCanvas ();
 

+ 1 - 1
UnitTests/Drawing/LineCanvasTests.cs

@@ -1312,7 +1312,7 @@ public class LineCanvasTests
 
         v.DrawContentComplete += (s, e) =>
                                  {
-                                     v.Clear ();
+                                     v.Clear (v.Bounds);
 
                                      foreach (KeyValuePair<Point, Rune> p in canvasCopy.GetMap ())
                                      {

+ 16 - 0
UnitTests/Drawing/ThicknessTests.cs

@@ -340,6 +340,22 @@ public class ThicknessTests
         Assert.Equal (t.GetHashCode (), t.GetHashCode ());
     }
 
+    // Test Thickness.GetInside(Rectangle)
+    [Theory]
+    [InlineData (0, 0, 10, 10, 1, 1, 8, 8)]
+    [InlineData (1, 0, 10, 10, 2, 1, 8, 8)]
+    [InlineData (0, 1, 10, 10, 1, 2, 8, 8)]
+    public void GetInside_Uniform (int x, int y, int width, int height, int expectedX, int expectedY, int expectedWidth, int expectedHeight)
+    {
+        var t = new Thickness (1, 1, 1, 1); // Uniform thickness for simplicity
+        var r = new Rectangle (x, y, width, height);
+        Rectangle inside = t.GetInside (r);
+        Assert.Equal (expectedX, inside.X);
+        Assert.Equal (expectedY, inside.Y);
+        Assert.Equal (expectedWidth, inside.Width);
+        Assert.Equal (expectedHeight, inside.Height);
+    }
+
     [Fact]
     public void GetInsideTests_Mixed_Pos_Neg_Thickness_Non_Empty_Size ()
     {

+ 1 - 1
UnitTests/UICatalog/ScenarioTests.cs

@@ -254,7 +254,7 @@ public class ScenarioTests
                                                       _hostPane.Remove (_curView);
                                                       _curView.Dispose ();
                                                       _curView = null;
-                                                      _hostPane.Clear ();
+                                                      _hostPane.Clear (_hostPane.Bounds);
                                                   }
 
                                                   _curView = CreateClass (_viewClasses.Values.ToArray () [_classListView.SelectedItem]);

+ 61 - 16
UnitTests/View/Adornment/AdornmentTests.cs

@@ -15,35 +15,80 @@ public class AdornmentTests
             X = 1,
             Y = 2,
             Width = 20,
-            Height = 31
+            Height = 20
         };
 
+        view.BeginInit ();
+        view.EndInit ();
+
+        Assert.Equal (new (1, 2, 20, 20), view.Frame);
+        Assert.Equal (new (0, 0, 20, 20), view.Bounds);
+
         var marginThickness = 1;
-        view.Margin.Thickness = new Thickness (marginThickness);
+        view.Margin.Thickness = new  (marginThickness);
+        Assert.Equal (new (0, 0, 18, 18), view.Bounds);
 
         var borderThickness = 2;
-        view.Border.Thickness = new Thickness (borderThickness);
+        view.Border.Thickness = new (borderThickness);
+        Assert.Equal (new (0, 0, 14, 14), view.Bounds);
 
         var paddingThickness = 3;
         view.Padding.Thickness = new Thickness (paddingThickness);
+        Assert.Equal (new (0, 0, 8, 8), view.Bounds);
 
-        view.BeginInit ();
-        view.EndInit ();
+        Assert.Equal (new (0, 0, view.Margin.Frame.Width, view.Margin.Frame.Height), view.Margin.Bounds);
 
-        Assert.Equal (new Rectangle (1, 2, 20, 31), view.Frame);
-        Assert.Equal (new Rectangle (0, 0, 8, 19), view.Bounds);
+        Assert.Equal (new (0, 0, view.Border.Frame.Width, view.Border.Frame.Height), view.Border.Bounds);
 
-        Assert.Equal (new Rectangle (0, 0, view.Margin.Frame.Width - marginThickness * 2, view.Margin.Frame.Height - marginThickness * 2), view.Margin.Bounds);
+        Assert.Equal (new (0, 0, view.Padding.Frame.Width , view.Padding.Frame.Height), view.Padding.Bounds);
+    }
 
-        Assert.Equal (new Rectangle (0, 0, view.Border.Frame.Width - borderThickness * 2, view.Border.Frame.Height - borderThickness * 2), view.Border.Bounds);
+    // Test that Adornment.Bounds_get override returns Frame.Size minus Thickness
+    [Theory]
+    [InlineData (0, 0, 0, 0, 0)]
+    [InlineData (0, 0, 0, 1, 1)]
+    [InlineData (0, 0, 0, 1, 0)]
+    [InlineData (0, 0, 0, 0, 1)]
+    [InlineData (1, 0, 0, 0, 0)]
+    [InlineData (1, 0, 0, 1, 1)]
+    [InlineData (1, 0, 0, 1, 0)]
+    [InlineData (1, 0, 0, 0, 1)]
+    [InlineData (1, 0, 0, 4, 4)]
+    [InlineData (1, 0, 0, 4, 0)]
+    [InlineData (1, 0, 0, 0, 4)]
+
+    [InlineData (0, 1, 0, 0, 0)]
+    [InlineData (0, 1, 0, 1, 1)]
+    [InlineData (0, 1, 0, 1, 0)]
+    [InlineData (0, 1, 0, 0, 1)]
+    [InlineData (1, 1, 0, 0, 0)]
+    [InlineData (1, 1, 0, 1, 1)]
+    [InlineData (1, 1, 0, 1, 0)]
+    [InlineData (1, 1, 0, 0, 1)]
+    [InlineData (1, 1, 0, 4, 4)]
+    [InlineData (1, 1, 0, 4, 0)]
+    [InlineData (1, 1, 0, 0, 4)]
+
+    [InlineData (0, 1, 1, 0, 0)]
+    [InlineData (0, 1, 1, 1, 1)]
+    [InlineData (0, 1, 1, 1, 0)]
+    [InlineData (0, 1, 1, 0, 1)]
+    [InlineData (1, 1, 1, 0, 0)]
+    [InlineData (1, 1, 1, 1, 1)]
+    [InlineData (1, 1, 1, 1, 0)]
+    [InlineData (1, 1, 1, 0, 1)]
+    [InlineData (1, 1, 1, 4, 4)]
+    [InlineData (1, 1, 1, 4, 0)]
+    [InlineData (1, 1, 1, 0, 4)]
+    public void Bounds_Width_Is_Frame_Width (int thickness, int x, int y, int w, int h)
+    {
+        var adornment = new Adornment (null);
+        adornment.Thickness = new Thickness (thickness);
+        adornment.Frame = new Rectangle (x, y, w, h);
+        Assert.Equal (new Rectangle (x, y, w, h), adornment.Frame);
 
-        Assert.Equal (
-                      new Rectangle (
-                                     0,
-                                     0,
-                                     view.Padding.Frame.Width - (marginThickness + borderThickness) * 2,
-                                     view.Padding.Frame.Height - (marginThickness + borderThickness) * 2),
-                      view.Padding.Bounds);
+        var expectedBounds = new Rectangle (0, 0, w, h);
+        Assert.Equal (expectedBounds, adornment.Bounds);
     }
 
     // Test that Adornment.Bounds_get override uses Parent not SuperView

+ 3 - 3
UnitTests/View/Adornment/MarginTests.cs

@@ -36,9 +36,9 @@ public class MarginTests
 
         TestHelpers.AssertDriverContentsAre (
                                              @"
-LTR
-L R
-BBB",
+MMM
+M M
+MMM",
                                              _output
                                             );
         TestHelpers.AssertDriverAttributesAre ("0", null, superView.GetNormalColor ());

+ 3 - 3
UnitTests/View/Adornment/PaddingTests.cs

@@ -31,9 +31,9 @@ public class PaddingTests
 
         TestHelpers.AssertDriverContentsAre (
                                              @"
-LTR
-L R
-BBB",
+PPP
+P P
+PPP",
                                              _output
                                             );
         TestHelpers.AssertDriverAttributesAre ("0", null, view.GetNormalColor ());

+ 50 - 37
UnitTests/View/Adornment/ToScreenTests.cs

@@ -32,8 +32,8 @@ public class AdornmentToScreenTests (ITestOutputHelper output)
 
         // Assert
         Assert.Equal(expectedX, marginScreen.X);
-        Assert.Equal (expectedX, borderScreen.X);
-        Assert.Equal (expectedX, paddingScreen.X);
+        Assert.Equal (expectedX + view.Margin.Thickness.Left, borderScreen.X);
+        Assert.Equal (expectedX + view.Margin.Thickness.Left + view.Border.Thickness.Left, paddingScreen.X);
     }
 
     [Theory]
@@ -59,7 +59,7 @@ public class AdornmentToScreenTests (ITestOutputHelper output)
         // Assert
         Assert.Equal (expectedX, marginScreen.X);
         Assert.Equal (expectedX + view.Margin.Thickness.Left, borderScreen.X);
-        Assert.Equal (expectedX + view.Border.Thickness.Left, paddingScreen.X);
+        Assert.Equal (expectedX + view.Margin.Thickness.Left + view.Border.Thickness.Left, paddingScreen.X);
     }
 
     [Theory]
@@ -95,14 +95,14 @@ public class AdornmentToScreenTests (ITestOutputHelper output)
         // Assert
         Assert.Equal (expectedX, marginScreen.X);
         Assert.Equal (expectedX + view.Margin.Thickness.Left, borderScreen.X);
-        Assert.Equal (expectedX + view.Border.Thickness.Left, paddingScreen.X);
+        Assert.Equal (expectedX + view.Margin.Thickness.Left + view.Border.Thickness.Left, paddingScreen.X);
     }
 
     [Theory]
-    [InlineData (0, 1)]
-    [InlineData (1, 2)]
-    [InlineData (-1, 0)]
-    [InlineData (11, 12)]
+    [InlineData (0, 3)]
+    [InlineData (1, 4)]
+    [InlineData (-1, 2)]
+    [InlineData (11, 14)]
     public void FrameToScreen_SuperView_WithAdornments (int x, int expectedX)
     {
         // We test with only X because Y is equivalent. Height/Width are irrelevant.
@@ -116,7 +116,9 @@ public class AdornmentToScreenTests (ITestOutputHelper output)
             Height = Dim.Fill (),
             Width = Dim.Fill ()
         };
+        superView.Margin.Thickness = new (1);
         superView.Border.Thickness = new (1);
+        superView.Padding.Thickness = new (1);
 
         var view = new View ();
         view.Frame = frame;
@@ -132,7 +134,7 @@ public class AdornmentToScreenTests (ITestOutputHelper output)
         // Assert
         Assert.Equal (expectedX, marginScreen.X);
         Assert.Equal (expectedX + view.Margin.Thickness.Left, borderScreen.X);
-        Assert.Equal (expectedX + view.Border.Thickness.Left, paddingScreen.X);
+        Assert.Equal (expectedX + view.Margin.Thickness.Left + view.Border.Thickness.Left, paddingScreen.X);
     }
 
     [Theory]
@@ -178,14 +180,14 @@ public class AdornmentToScreenTests (ITestOutputHelper output)
         // Assert
         Assert.Equal (expectedX, marginScreen.X);
         Assert.Equal (expectedX + view.Margin.Thickness.Left, borderScreen.X);
-        Assert.Equal (expectedX + view.Border.Thickness.Left, paddingScreen.X);
+        Assert.Equal (expectedX + view.Margin.Thickness.Left + view.Border.Thickness.Left, paddingScreen.X);
     }
 
     [Theory]
-    [InlineData (0, 2)]
-    [InlineData (1, 3)]
-    [InlineData (-1, 1)]
-    [InlineData (11, 13)]
+    [InlineData (0, 6)]
+    [InlineData (1, 7)]
+    [InlineData (-1, 5)]
+    [InlineData (11, 17)]
     public void FrameToScreen_NestedSuperView_WithAdornments (int x, int expectedX)
     {
         // We test with only X because Y is equivalent. Height/Width are irrelevant.
@@ -199,7 +201,9 @@ public class AdornmentToScreenTests (ITestOutputHelper output)
             Height = Dim.Fill (),
             Width = Dim.Fill ()
         };
+        superSuperView.Margin.Thickness = new (1);
         superSuperView.Border.Thickness = new (1);
+        superSuperView.Padding.Thickness = new (1);
 
         var superView = new View ()
         {
@@ -208,9 +212,10 @@ public class AdornmentToScreenTests (ITestOutputHelper output)
             Height = Dim.Fill (),
             Width = Dim.Fill ()
         };
-
-        superSuperView.Add (superView);
+        superView.Margin.Thickness = new (1);
         superView.Border.Thickness = new (1);
+        superView.Padding.Thickness = new (1);
+        superSuperView.Add (superView);
 
         var view = new View ();
         view.Frame = frame;
@@ -226,7 +231,7 @@ public class AdornmentToScreenTests (ITestOutputHelper output)
         // Assert
         Assert.Equal (expectedX, marginScreen.X);
         Assert.Equal (expectedX + view.Margin.Thickness.Left, borderScreen.X);
-        Assert.Equal (expectedX + view.Border.Thickness.Left, paddingScreen.X);
+        Assert.Equal (expectedX + view.Margin.Thickness.Left + view.Border.Thickness.Left, paddingScreen.X);
     }
 
 
@@ -253,7 +258,7 @@ public class AdornmentToScreenTests (ITestOutputHelper output)
         // Assert
         Assert.Equal (expectedX, marginScreen.X);
         Assert.Equal (expectedX + view.Margin.Thickness.Left, borderScreen.X);
-        Assert.Equal (expectedX + view.Border.Thickness.Left, paddingScreen.X);
+        Assert.Equal (expectedX + view.Margin.Thickness.Left + view.Border.Thickness.Left, paddingScreen.X);
     }
 
     [Theory]
@@ -278,9 +283,14 @@ public class AdornmentToScreenTests (ITestOutputHelper output)
         var frame = new Rectangle (frameX, 0, 10, 10);
 
         var view = new View ();
+        view.Margin.Thickness = new (1);
         view.Border.Thickness = new (1);
+        view.Padding.Thickness = new (1);
+        // Total thickness is 3 (view.Bounds will be Frame.Width - 6)
         view.Frame = frame;
 
+        Assert.Equal(4, view.Bounds.Width);
+
         // Act
         var marginScreen = view.Margin.BoundsToScreen (new (boundsX, 0, 0, 0));
         var borderScreen = view.Border.BoundsToScreen (new (boundsX, 0, 0, 0));
@@ -288,8 +298,8 @@ public class AdornmentToScreenTests (ITestOutputHelper output)
 
         // Assert
         Assert.Equal (expectedX, marginScreen.X);
-        Assert.Equal (expectedX, borderScreen.X);
-        Assert.Equal (expectedX, paddingScreen.X);
+        Assert.Equal (expectedX + view.Margin.Thickness.Left, borderScreen.X);
+        Assert.Equal (expectedX + view.Margin.Thickness.Left + view.Border.Thickness.Left, paddingScreen.X);
     }
 
     [Theory]
@@ -442,20 +452,20 @@ public class AdornmentToScreenTests (ITestOutputHelper output)
     }
 
     [Theory]
-    [InlineData (0, 0, 2)]
-    [InlineData (1, 0, 3)]
-    [InlineData (-1, 0, 1)]
-    [InlineData (11, 0, 13)]
-
-    [InlineData (0, 1, 3)]
-    [InlineData (1, 1, 4)]
-    [InlineData (-1, 1, 2)]
-    [InlineData (11, 1, 14)]
-
-    [InlineData (0, -1, 1)]
-    [InlineData (1, -1, 2)]
-    [InlineData (-1, -1, 0)]
-    [InlineData (11, -1, 12)]
+    [InlineData (0, 0, 6)]
+    [InlineData (1, 0, 7)]
+    [InlineData (-1, 0, 5)]
+    [InlineData (11, 0, 17)]
+
+    [InlineData (0, 1, 7)]
+    [InlineData (1, 1, 8)]
+    [InlineData (-1, 1, 6)]
+    [InlineData (11, 1, 18)]
+
+    [InlineData (0, -1, 5)]
+    [InlineData (1, -1, 6)]
+    [InlineData (-1, -1, 4)]
+    [InlineData (11, -1, 16)]
     public void BoundsToScreen_NestedSuperView_WithAdornments (int frameX, int boundsX, int expectedX)
     {
         // We test with only X because Y is equivalent. Height/Width are irrelevant.
@@ -469,7 +479,9 @@ public class AdornmentToScreenTests (ITestOutputHelper output)
             Height = Dim.Fill (),
             Width = Dim.Fill ()
         };
+        superSuperView.Margin.Thickness = new (1);
         superSuperView.Border.Thickness = new (1);
+        superSuperView.Padding.Thickness = new (1);
 
         var superView = new View ()
         {
@@ -478,9 +490,10 @@ public class AdornmentToScreenTests (ITestOutputHelper output)
             Height = Dim.Fill (),
             Width = Dim.Fill ()
         };
-
-        superSuperView.Add (superView);
+        superView.Margin.Thickness = new (1);
         superView.Border.Thickness = new (1);
+        superView.Padding.Thickness = new (1);
+        superSuperView.Add (superView);
 
         var view = new View ();
         view.Frame = frame;
@@ -496,7 +509,7 @@ public class AdornmentToScreenTests (ITestOutputHelper output)
         // Assert
         Assert.Equal (expectedX, marginScreen.X);
         Assert.Equal (expectedX + view.Margin.Thickness.Left, borderScreen.X);
-        Assert.Equal (expectedX + view.Border.Thickness.Left, paddingScreen.X);
+        Assert.Equal (expectedX + view.Margin.Thickness.Left + view.Border.Thickness.Left, paddingScreen.X);
     }
 
 }

+ 75 - 1
UnitTests/View/DrawTests.cs

@@ -2,7 +2,7 @@
 using System.Text;
 using Xunit.Abstractions;
 
-namespace Terminal.Gui.ViewsTests;
+namespace Terminal.Gui.ViewTests;
 
 [Trait("Category","Output")]
 public class DrawTests
@@ -10,6 +10,80 @@ public class DrawTests
     private readonly ITestOutputHelper _output;
     public DrawTests (ITestOutputHelper output) { _output = output; }
 
+    [Theory]
+    [InlineData (0, 0, 2, 2)]
+    [SetupFakeDriver]
+    public void ClearFrame_Clears_Frame (int x, int y, int width, int height)
+    {
+        var superView = new View { Width = Dim.Fill (), Height = Dim.Fill () };
+
+        var view = new View
+        {
+            X = x, Y = y,
+            Width = width, Height = height,
+            BorderStyle = LineStyle.Single
+        };
+        superView.Add (view);
+        superView.BeginInit ();
+        superView.EndInit ();
+        superView.LayoutSubviews ();
+
+        superView.Draw ();
+
+        TestHelpers.AssertDriverContentsWithFrameAre (
+                                                      @"
+┌┐
+└┘",
+                                                      _output);
+
+        view.ClearFrame ();
+        TestHelpers.AssertDriverContentsWithFrameAre (
+                                                      @"",
+                                                      _output);
+
+    }
+
+    [Theory]
+    [InlineData (0, 0, 1, 1)]
+    [InlineData (0, 0, 2, 2)]
+    [InlineData (-1, -1, 2, 2)]
+    [SetupFakeDriver]
+    public void Clear_Bounds_Clears_Only_Bounds (int x, int y, int width, int height)
+    {
+        var superView = new View { Width = Dim.Fill (), Height = Dim.Fill () };
+
+        var view = new View
+        {
+            Text = "X",
+            X = 1, Y = 1,
+            Width = 3, Height = 3,
+            BorderStyle = LineStyle.Single
+        };
+        superView.Add (view);
+        superView.BeginInit ();
+        superView.EndInit ();
+        superView.LayoutSubviews ();
+
+        superView.Draw ();
+
+        TestHelpers.AssertDriverContentsWithFrameAre (
+                                                      @"
+ ┌─┐
+ │X│
+ └─┘",
+                                                      _output);
+
+        Rectangle boundsToClear = new (x, y, width, height);
+        view.Clear (boundsToClear);
+        TestHelpers.AssertDriverContentsWithFrameAre (
+                                                      @"
+ ┌─┐
+ │ │
+ └─┘",
+                                                      _output);
+
+    }
+
     [Fact]
     [AutoInitShutdown]
     [Trait("Category","Unicode")]

+ 152 - 0
UnitTests/View/Layout/BoundsTests.cs

@@ -0,0 +1,152 @@
+using Xunit.Abstractions;
+
+namespace Terminal.Gui.ViewTests;
+
+/// <summary>
+/// Test the <see cref="View.Bounds"/>.
+/// DOES NOT TEST Adornment.Bounds methods. Those are in ./Adornment/BoundsTests.cs
+/// </summary>
+/// <param name="output"></param>
+public class BoundsTests (ITestOutputHelper output)
+{
+    private readonly ITestOutputHelper _output = output;
+
+    [Theory]
+    [InlineData (0, 10)]
+    [InlineData (1, 10)]
+    [InlineData (-1, 10)]
+    [InlineData (11, 10)]
+    public void Get_Bounds_NoSuperView_WithoutAdornments (int x, int expectedW)
+    {
+        // We test with only X because Y is equivalent. Height/Width are irrelevant.
+        // Arrange
+        var frame = new Rectangle (x, 0, 10, 10);
+
+        var view = new View ();
+        view.Frame = frame;
+        view.BeginInit();
+        view.EndInit();
+
+        // Act
+        var bounds = view.Bounds;
+
+        // Assert
+        Assert.Equal(expectedW, bounds.Width);
+    }
+    
+    [Theory]
+    [InlineData (0, 0, 10)]
+    [InlineData (1, 0, 9)]
+    [InlineData (-1, 0, 11)]
+    [InlineData (10, 0, 0)]
+    [InlineData (11, 0, 0)]
+
+    [InlineData (0, 1, 6)]
+    [InlineData (1, 1, 5)]
+    [InlineData (-1, 1, 7)]
+    [InlineData (10, 1, 0)]
+    [InlineData (11, 1, 0)]
+
+    public void Get_Bounds_NestedSuperView_WithAdornments (int frameX, int borderThickness, int expectedW)
+    {
+        // We test with only X because Y is equivalent. Height/Width are irrelevant.
+        // Arrange
+        var superSuperView = new View ()
+        {
+            X = 0,
+            Y = 0,
+            Height = 10,
+            Width = 10,
+        };
+        superSuperView.Border.Thickness = new Thickness (borderThickness);
+
+        var superView = new View ()
+        {
+            X = 0,
+            Y = 0,
+            Height = Dim.Fill (),
+            Width = Dim.Fill ()
+        };
+        superView.Border.Thickness = new Thickness (borderThickness);
+
+        superSuperView.Add (superView);
+
+        var view = new View ()
+        {
+            X = frameX,
+            Y = 0,
+            Height = Dim.Fill (),
+            Width = Dim.Fill ()
+        };
+
+        superView.Add (view);
+        superSuperView.BeginInit ();
+        superSuperView.EndInit ();
+        superSuperView.LayoutSubviews ();
+
+        // Act
+        var bounds = view.Bounds;
+
+        // Assert
+        Assert.Equal (expectedW, bounds.Width);
+    }
+
+
+
+    [Theory]
+    [InlineData (0, 0, 10)]
+    [InlineData (1, 0, 9)]
+    [InlineData (-1, 0, 11)]
+    [InlineData (10, 0, 0)]
+    [InlineData (11, 0, 0)]
+
+    [InlineData (0, 1, 4)]
+    [InlineData (1, 1, 3)]
+    [InlineData (-1, 1, 5)]
+    [InlineData (10, 1, 0)]
+    [InlineData (11, 1, 0)]
+    public void Get_Bounds_NestedSuperView_WithAdornments_WithBorder (int frameX, int borderThickness, int expectedW)
+    {
+        // We test with only X because Y is equivalent. Height/Width are irrelevant.
+        // Arrange
+        var superSuperView = new View ()
+        {
+            X = 0,
+            Y = 0,
+            Height = 10,
+            Width = 10,
+        };
+        superSuperView.Border.Thickness = new Thickness (borderThickness);
+
+        var superView = new View ()
+        {
+            X = 0,
+            Y = 0,
+            Height = Dim.Fill (),
+            Width = Dim.Fill ()
+        };
+        superView.Border.Thickness = new Thickness (borderThickness);
+
+        superSuperView.Add (superView);
+
+        var view = new View ()
+        {
+            X = frameX,
+            Y = 0,
+            Height = Dim.Fill (),
+            Width = Dim.Fill ()
+        };
+        view.Border.Thickness = new Thickness (borderThickness);
+
+        superView.Add (view);
+        superSuperView.BeginInit ();
+        superSuperView.EndInit ();
+        superSuperView.LayoutSubviews ();
+
+        // Act
+        var bounds = view.Bounds;
+
+        // Assert
+        Assert.Equal (expectedW, bounds.Width);
+    }
+}

+ 18 - 18
UnitTests/View/Layout/CoordinateTests.cs → UnitTests/View/Layout/ScreenToTests.cs

@@ -3,13 +3,13 @@
 namespace Terminal.Gui.ViewTests;
 
 /// <summary>Tests for view coordinate mapping (e.g. <see cref="View.ScreenToFrame"/> etc...).</summary>
-public class CoordinateTests
+public class ScreenToTests
 {
     private readonly ITestOutputHelper _output;
-    public CoordinateTests (ITestOutputHelper output) { _output = output; }
+    public ScreenToTests (ITestOutputHelper output) { _output = output; }
 
     /// <summary>
-    ///     Tests that screen to bounds mapping works correctly when the view has no superview and there ARE Frames on the
+    ///     Tests that screen to bounds mapping works correctly when the view has no superview and there ARE Adornments on the
     ///     view.
     /// </summary>
     [Theory]
@@ -21,7 +21,7 @@ public class CoordinateTests
     [InlineData (1, 1, 1, 1, -1, -1)]
     [InlineData (1, 1, 9, 9, 7, 7)]
     [InlineData (1, 1, 11, 11, 9, 9)]
-    public void ScreenToBounds_NoSuper_HasFrames (int viewX, int viewY, int x, int y, int expectedX, int expectedY)
+    public void ScreenToBounds_NoSuper_HasAdornments (int viewX, int viewY, int x, int y, int expectedX, int expectedY)
     {
         var view = new View
         {
@@ -38,7 +38,7 @@ public class CoordinateTests
     }
 
     /// <summary>
-    ///     Tests that screen to bounds mapping works correctly when the view has no superview and there are no Frames on
+    ///     Tests that screen to bounds mapping works correctly when the view has no superview and there are no Adornments on
     ///     the view.
     /// </summary>
     [Theory]
@@ -50,7 +50,7 @@ public class CoordinateTests
     [InlineData (1, 1, 1, 1, 0, 0)]
     [InlineData (1, 1, 9, 9, 8, 8)]
     [InlineData (1, 1, 11, 11, 10, 10)] // it's ok for the view to return coordinates outside of its bounds
-    public void ScreenToBounds_NoSuper_NoFrames (int viewX, int viewY, int x, int y, int expectedX, int expectedY)
+    public void ScreenToBounds_NoSuper_NoAdornments (int viewX, int viewY, int x, int y, int expectedX, int expectedY)
     {
         var view = new View { X = viewX, Y = viewY, Width = 10, Height = 10 };
 
@@ -59,7 +59,7 @@ public class CoordinateTests
         Assert.Equal (expectedY, actual.Y);
     }
 
-    /// <summary>Tests that screen to bounds mapping works correctly when the view has as superview it DOES have Frames</summary>
+    /// <summary>Tests that screen to bounds mapping works correctly when the view has as superview it DOES have Adornments</summary>
     [Theory]
     [InlineData (0, 0, 0, 0, -1, -1)] // it's ok for the view to return coordinates outside of its bounds
     [InlineData (0, 0, 1, 1, 0, 0)]
@@ -69,7 +69,7 @@ public class CoordinateTests
     [InlineData (1, 1, 1, 1, -1, -1)]
     [InlineData (1, 1, 9, 9, 7, 7)]
     [InlineData (1, 1, 11, 11, 9, 9)] // it's ok for the view to return coordinates outside of its bounds
-    public void ScreenToBounds_SuperHasFrames (int viewX, int viewY, int x, int y, int expectedX, int expectedY)
+    public void ScreenToBounds_SuperHasAdornments (int viewX, int viewY, int x, int y, int expectedX, int expectedY)
     {
         var super = new View
         {
@@ -87,7 +87,7 @@ public class CoordinateTests
         Assert.Equal (expectedY, actual.Y);
     }
 
-    /// <summary>Tests that screen to bounds mapping works correctly when the view has as superview it does not have Frames</summary>
+    /// <summary>Tests that screen to bounds mapping works correctly when the view has as superview it does not have Adornments</summary>
     [Theory]
     [InlineData (0, 0, 0, 0, 0, 0)]
     [InlineData (0, 0, 1, 1, 1, 1)]
@@ -97,7 +97,7 @@ public class CoordinateTests
     [InlineData (1, 1, 1, 1, 0, 0)]
     [InlineData (1, 1, 9, 9, 8, 8)]
     [InlineData (1, 1, 11, 11, 10, 10)] // it's ok for the view to return coordinates outside of its bounds
-    public void ScreenToBounds_SuperHasNoFrames (int viewX, int viewY, int x, int y, int expectedX, int expectedY)
+    public void ScreenToBounds_SuperHasNoAdornments (int viewX, int viewY, int x, int y, int expectedX, int expectedY)
     {
         var super = new View { X = 0, Y = 0, Width = 10, Height = 10 };
         var view = new View { X = viewX, Y = viewY, Width = 5, Height = 5 };
@@ -109,7 +109,7 @@ public class CoordinateTests
     }
 
     /// <summary>
-    ///     Tests that screen to view mapping works correctly when the view has no superview and there ARE Frames on the
+    ///     Tests that screen to view mapping works correctly when the view has no superview and there ARE Adornments on the
     ///     view.
     /// </summary>
     [Theory]
@@ -121,7 +121,7 @@ public class CoordinateTests
     [InlineData (1, 1, 1, 1, 0, 0)]
     [InlineData (1, 1, 9, 9, 8, 8)]
     [InlineData (1, 1, 11, 11, 10, 10)] // it's ok for the view to return coordinates outside of its bounds
-    public void ScreenToView_NoSuper_HasFrames (int viewX, int viewY, int x, int y, int expectedX, int expectedY)
+    public void ScreenToView_NoSuper_HasAdornments (int viewX, int viewY, int x, int y, int expectedX, int expectedY)
     {
         var view = new View
         {
@@ -138,7 +138,7 @@ public class CoordinateTests
     }
 
     /// <summary>
-    ///     Tests that screen to view mapping works correctly when the view has no superview and there are no Frames on
+    ///     Tests that screen to view mapping works correctly when the view has no superview and there are no Adornments on
     ///     the view.
     /// </summary>
     [Theory]
@@ -150,7 +150,7 @@ public class CoordinateTests
     [InlineData (1, 1, 1, 1, 0, 0)]
     [InlineData (1, 1, 9, 9, 8, 8)]
     [InlineData (1, 1, 11, 11, 10, 10)] // it's ok for the view to return coordinates outside of its bounds
-    public void ScreenToView_NoSuper_NoFrames (int viewX, int viewY, int x, int y, int expectedX, int expectedY)
+    public void ScreenToView_NoSuper_NoAdornments (int viewX, int viewY, int x, int y, int expectedX, int expectedY)
     {
         var view = new View { X = viewX, Y = viewY, Width = 10, Height = 10 };
 
@@ -159,7 +159,7 @@ public class CoordinateTests
         Assert.Equal (expectedY, actual.Y);
     }
 
-    /// <summary>Tests that screen to view mapping works correctly when the view has as superview it DOES have Frames</summary>
+    /// <summary>Tests that screen to view mapping works correctly when the view has as superview it DOES have Adornments</summary>
     [Theory]
     [InlineData (0, 0, 0, 0, -1, -1)] // it's ok for the view to return coordinates outside of its bounds
     [InlineData (0, 0, 1, 1, 0, 0)]
@@ -169,7 +169,7 @@ public class CoordinateTests
     [InlineData (1, 1, 1, 1, -1, -1)]
     [InlineData (1, 1, 9, 9, 7, 7)]
     [InlineData (1, 1, 11, 11, 9, 9)] // it's ok for the view to return coordinates outside of its bounds
-    public void ScreenToView_SuperHasFrames (int viewX, int viewY, int x, int y, int expectedX, int expectedY)
+    public void ScreenToView_SuperHasAdornments (int viewX, int viewY, int x, int y, int expectedX, int expectedY)
     {
         var super = new View
         {
@@ -187,7 +187,7 @@ public class CoordinateTests
         Assert.Equal (expectedY, actual.Y);
     }
 
-    /// <summary>Tests that screen to view mapping works correctly when the view has as superview it does not have Frames</summary>
+    /// <summary>Tests that screen to view mapping works correctly when the view has as superview it does not have Adornments</summary>
     [Theory]
     [InlineData (0, 0, 0, 0, 0, 0)]
     [InlineData (0, 0, 1, 1, 1, 1)]
@@ -197,7 +197,7 @@ public class CoordinateTests
     [InlineData (1, 1, 1, 1, 0, 0)]
     [InlineData (1, 1, 9, 9, 8, 8)]
     [InlineData (1, 1, 11, 11, 10, 10)] // it's ok for the view to return coordinates outside of its bounds
-    public void ScreenToView_SuperHasNoFrames (int viewX, int viewY, int x, int y, int expectedX, int expectedY)
+    public void ScreenToView_SuperHasNoAdornments (int viewX, int viewY, int x, int y, int expectedX, int expectedY)
     {
         var super = new View { X = 0, Y = 0, Width = 10, Height = 10 };
         var view = new View { X = viewX, Y = viewY, Width = 5, Height = 5 };

+ 4 - 4
UnitTests/View/NavigationTests.cs

@@ -848,8 +848,8 @@ public class NavigationTests
         Assert.Equal (0, screen.X);
         Assert.Equal (0, screen.Y);
         screen = top.Padding.BoundsToScreen (new (0, 0, 0, 0));
-        Assert.Equal (0, screen.X);
-        Assert.Equal (0, screen.Y);
+        Assert.Equal (1, screen.X);
+        Assert.Equal (1, screen.Y);
         screen = top.BoundsToScreen (new (0, 0, 0, 0));
         Assert.Equal (1, screen.X);
         Assert.Equal (1, screen.Y);
@@ -1007,8 +1007,8 @@ public class NavigationTests
         Assert.Equal (0, screen.X);
         Assert.Equal (0, screen.Y);
         screen = top.Padding.BoundsToScreen (new (-3, -2, 0, 0));
-        Assert.Equal (0, screen.X);
-        Assert.Equal (0, screen.Y);
+        Assert.Equal (1, screen.X);
+        Assert.Equal (1, screen.Y);
         screen = top.BoundsToScreen (new (-3, -2, 0, 0));
         Assert.Equal (1, screen.X);
         Assert.Equal (1, screen.Y);

+ 22 - 4
UnitTests/View/ViewTests.cs

@@ -53,13 +53,22 @@ public class ViewTests
         Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
         Assert.Equal (new Rectangle (0, 0, 20, 10), pos);
 
-        view.Clear (view.Frame);
+        view.Clear (view.Bounds);
 
         expected = @"
+┌──────────────────┐
+│                  │
+│                  │
+│                  │
+│                  │
+│                  │
+│                  │
+│                  │
+│                  │
+└──────────────────┘
 ";
 
         pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-        Assert.Equal (Rectangle.Empty, pos);
     }
 
     [Fact]
@@ -106,13 +115,22 @@ public class ViewTests
         Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
         Assert.Equal (new Rectangle (0, 0, 20, 10), pos);
 
-        view.Clear (view.Frame);
+        view.Clear (view.Bounds);
 
         expected = @"
+┌──────────────────┐
+│                  │
+│                  │
+│                  │
+│                  │
+│                  │
+│                  │
+│                  │
+│                  │
+└──────────────────┘
 ";
 
         pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-        Assert.Equal (Rectangle.Empty, pos);
     }
 
     [Theory]