diff --git a/UnitTests/View/Layout/Dim.Tests.cs b/UnitTests/View/Layout/Dim.Tests.cs
index 8f57602dd..95f4f994d 100644
--- a/UnitTests/View/Layout/Dim.Tests.cs
+++ b/UnitTests/View/Layout/Dim.Tests.cs
@@ -580,7 +580,8 @@ public class DimTests
Assert.Equal (19, v3.Frame.Height);
v4.Text = "Button4";
- v4.AutoSize = true;
+ v4.Width = Auto(DimAutoStyle.Text);
+ v4.Height = Auto (DimAutoStyle.Text);
Assert.Equal (Dim.Auto (DimAutoStyle.Text), v4.Width);
Assert.Equal (Dim.Auto (DimAutoStyle.Text), v4.Height);
Assert.Equal (11, v4.Frame.Width); // 11 is the text length and because is Dim.DimAbsolute
diff --git a/UnitTests/View/Layout/Pos.Tests.cs b/UnitTests/View/Layout/Pos.Tests.cs
index 68f3db829..bf82c4c0e 100644
--- a/UnitTests/View/Layout/Pos.Tests.cs
+++ b/UnitTests/View/Layout/Pos.Tests.cs
@@ -881,7 +881,13 @@ public class PosTests (ITestOutputHelper output)
var clicked = false;
Toplevel top = new Toplevel () { Width = 80, Height = 25 };
var win1 = new Window { Id = "win1", Width = 20, Height = 10 };
- var view1 = new View { Text = "view1", AutoSize = true }; // BUGBUG: AutoSize or Width must be set
+ var view1 = new View
+ {
+ Text = "view1",
+ Width = Auto (DimAutoStyle.Text),
+ Height = Auto (DimAutoStyle.Text)
+
+ };
var win2 = new Window { Id = "win2", Y = Pos.Bottom (view1) + 1, Width = 10, Height = 3 };
var view2 = new View { Id = "view2", Width = Dim.Fill (), Height = 1, CanFocus = true };
view2.MouseClick += (sender, e) => clicked = true;
diff --git a/UnitTests/View/Layout/SetRelativeLayoutTests.cs b/UnitTests/View/Layout/SetRelativeLayoutTests.cs
index 59ca745ae..ddba936b7 100644
--- a/UnitTests/View/Layout/SetRelativeLayoutTests.cs
+++ b/UnitTests/View/Layout/SetRelativeLayoutTests.cs
@@ -48,7 +48,7 @@ public class SetRelativeLayoutTests
{
var view = new View { X = 1, Y = 1, Width = Dim.Fill (), Height = Dim.Fill () };
- view.SetRelativeLayout (new Size ( 80, 25));
+ view.SetRelativeLayout (new Size (80, 25));
Assert.Equal ("Fill(0)", view.Width.ToString ());
Assert.Equal (1, view.Frame.X);
Assert.Equal (1, view.Frame.Y);
@@ -63,7 +63,7 @@ public class SetRelativeLayoutTests
view.Y = 0;
Assert.Equal ("Absolute(0)", view.X.ToString ());
Assert.Equal ("Fill(0)", view.Width.ToString ());
- view.SetRelativeLayout (new Size ( 80, 25));
+ view.SetRelativeLayout (new Size (80, 25));
Assert.Equal (0, view.Frame.X);
Assert.Equal (0, view.Frame.Y);
Assert.Equal (80, view.Frame.Width);
@@ -235,11 +235,10 @@ public class SetRelativeLayoutTests
[TestRespondersDisposed]
public void PosCombine_Plus_Absolute ()
{
- var superView = new View { AutoSize = false, Width = 10, Height = 10 };
+ var superView = new View { Width = 10, Height = 10 };
var testView = new View
{
- AutoSize = false,
X = Pos.Center (),
Y = Pos.Center (),
Width = 1,
@@ -250,9 +249,8 @@ public class SetRelativeLayoutTests
Assert.Equal (4, testView.Frame.X);
Assert.Equal (4, testView.Frame.Y);
- testView = new View
+ testView = new()
{
- AutoSize = false,
X = Pos.Center () + 1, // ((10 / 2) - (1 / 2)) + 1 = 5 - 1 + 1 = 5
Y = Pos.Center () + 1,
Width = 1,
@@ -263,9 +261,8 @@ public class SetRelativeLayoutTests
Assert.Equal (5, testView.Frame.X);
Assert.Equal (5, testView.Frame.Y);
- testView = new View
+ testView = new()
{
- AutoSize = false,
X = 1 + Pos.Center (),
Y = 1 + Pos.Center (),
Width = 1,
@@ -276,9 +273,8 @@ public class SetRelativeLayoutTests
Assert.Equal (5, testView.Frame.X);
Assert.Equal (5, testView.Frame.Y);
- testView = new View
+ testView = new()
{
- AutoSize = false,
X = 1 + Pos.Percent (50),
Y = Pos.Percent (50) + 1,
Width = 1,
@@ -289,9 +285,8 @@ public class SetRelativeLayoutTests
Assert.Equal (6, testView.Frame.X);
Assert.Equal (6, testView.Frame.Y);
- testView = new View
+ testView = new()
{
- AutoSize = false,
X = Pos.Percent (10) + Pos.Percent (40),
Y = Pos.Percent (10) + Pos.Percent (40),
Width = 1,
@@ -302,9 +297,8 @@ public class SetRelativeLayoutTests
Assert.Equal (5, testView.Frame.X);
Assert.Equal (5, testView.Frame.Y);
- testView = new View
+ testView = new()
{
- AutoSize = false,
X = 1 + Pos.Percent (10) + Pos.Percent (40) - 1,
Y = 5 + Pos.Percent (10) + Pos.Percent (40) - 5,
Width = 1,
@@ -315,9 +309,8 @@ public class SetRelativeLayoutTests
Assert.Equal (5, testView.Frame.X);
Assert.Equal (5, testView.Frame.Y);
- testView = new View
+ testView = new()
{
- AutoSize = false,
X = Pos.Left (testView),
Y = Pos.Left (testView),
Width = 1,
@@ -328,9 +321,8 @@ public class SetRelativeLayoutTests
Assert.Equal (5, testView.Frame.X);
Assert.Equal (5, testView.Frame.Y);
- testView = new View
+ testView = new()
{
- AutoSize = false,
X = 1 + Pos.Left (testView),
Y = Pos.Top (testView) + 1,
Width = 1,
diff --git a/UnitTests/View/MouseTests.cs b/UnitTests/View/MouseTests.cs
index 6c798b8cd..e7e0fc5d9 100644
--- a/UnitTests/View/MouseTests.cs
+++ b/UnitTests/View/MouseTests.cs
@@ -136,7 +136,6 @@ public class MouseTests (ITestOutputHelper output) : TestsAllViews
CanFocus = true,
};
- view.AutoSize = false;
view.X = Pos.Right (otherView);
view.Y = 0;
view.Width = 10;
@@ -231,7 +230,6 @@ public class MouseTests (ITestOutputHelper output) : TestsAllViews
};
view.Visible = false;
- view.AutoSize = false;
view.X = Pos.Right (otherView);
view.Y = 0;
view.Width = 10;
diff --git a/UnitTests/View/Text/AutoSizeFalseTests.cs b/UnitTests/View/Text/AutoSizeFalseTests.cs
index c6d1e1034..a1a23d785 100644
--- a/UnitTests/View/Text/AutoSizeFalseTests.cs
+++ b/UnitTests/View/Text/AutoSizeFalseTests.cs
@@ -1,159 +1,14 @@
using Xunit.Abstractions;
-using static Terminal.Gui.Pos;
namespace Terminal.Gui.ViewTests;
/// Tests of the property with set to false.
-public class AutoSizeFalseTests
+public class AutoSizeFalseTests (ITestOutputHelper output)
{
- private readonly ITestOutputHelper _output;
- public AutoSizeFalseTests (ITestOutputHelper output) { _output = output; }
-
- [Fact]
- public void AutoSize_False_Equal_Before_And_After_IsInitialized_With_Different_Orders ()
- {
- var top = new View { Height = 25, Width = 80 };
- var view1 = new View { Text = "Say Hello view1 你", AutoSize = false, Width = 10, Height = 5 };
- var view2 = new View { Text = "Say Hello view2 你", AutoSize = false, Width = 10, Height = 5 };
- var view3 = new View { AutoSize = false, Width = 10, Height = 5, Text = "Say Hello view3 你" };
-
- var view4 = new View
- {
- Text = "Say Hello view4 你",
- AutoSize = false,
- Width = 10,
- Height = 5,
- TextDirection = TextDirection.TopBottom_LeftRight
- };
-
- var view5 = new View
- {
- Text = "Say Hello view5 你",
- AutoSize = false,
- Width = 10,
- Height = 5,
- TextDirection = TextDirection.TopBottom_LeftRight
- };
-
- var view6 = new View
- {
- AutoSize = false,
- Width = 10,
- Height = 5,
- TextDirection = TextDirection.TopBottom_LeftRight,
- Text = "Say Hello view6 你"
- };
- top.Add (view1, view2, view3, view4, view5, view6);
-
- Assert.False (view1.IsInitialized);
- Assert.False (view2.IsInitialized);
- Assert.False (view3.IsInitialized);
- Assert.False (view4.IsInitialized);
- Assert.False (view5.IsInitialized);
- Assert.False (view1.AutoSize);
- Assert.Equal (new Rectangle (0, 0, 10, 5), view1.Frame);
- Assert.Equal ("Absolute(10)", view1.Width.ToString ());
- Assert.Equal ("Absolute(5)", view1.Height.ToString ());
- Assert.False (view2.AutoSize);
- Assert.Equal (new Rectangle (0, 0, 10, 5), view2.Frame);
- Assert.Equal ("Absolute(10)", view2.Width.ToString ());
- Assert.Equal ("Absolute(5)", view2.Height.ToString ());
- Assert.False (view3.AutoSize);
- Assert.Equal (new Rectangle (0, 0, 10, 5), view3.Frame);
- Assert.Equal ("Absolute(10)", view3.Width.ToString ());
- Assert.Equal ("Absolute(5)", view3.Height.ToString ());
- Assert.False (view4.AutoSize);
- Assert.Equal (new Rectangle (0, 0, 10, 5), view4.Frame);
- Assert.Equal ("Absolute(10)", view4.Width.ToString ());
- Assert.Equal ("Absolute(5)", view4.Height.ToString ());
- Assert.False (view5.AutoSize);
- Assert.Equal (new Rectangle (0, 0, 10, 5), view5.Frame);
- Assert.Equal ("Absolute(10)", view5.Width.ToString ());
- Assert.Equal ("Absolute(5)", view5.Height.ToString ());
- Assert.False (view6.AutoSize);
- Assert.Equal (new Rectangle (0, 0, 10, 5), view6.Frame);
- Assert.Equal ("Absolute(10)", view6.Width.ToString ());
- Assert.Equal ("Absolute(5)", view6.Height.ToString ());
-
- top.BeginInit ();
- top.EndInit ();
-
- Assert.True (view1.IsInitialized);
- Assert.True (view2.IsInitialized);
- Assert.True (view3.IsInitialized);
- Assert.True (view4.IsInitialized);
- Assert.True (view5.IsInitialized);
- Assert.False (view1.AutoSize);
- Assert.Equal (new Rectangle (0, 0, 10, 5), view1.Frame);
- Assert.Equal ("Absolute(10)", view1.Width.ToString ());
- Assert.Equal ("Absolute(5)", view1.Height.ToString ());
- Assert.False (view2.AutoSize);
- Assert.Equal (new Rectangle (0, 0, 10, 5), view2.Frame);
- Assert.Equal ("Absolute(10)", view2.Width.ToString ());
- Assert.Equal ("Absolute(5)", view2.Height.ToString ());
- Assert.False (view3.AutoSize);
- Assert.Equal (new Rectangle (0, 0, 10, 5), view3.Frame);
- Assert.Equal ("Absolute(10)", view3.Width.ToString ());
- Assert.Equal ("Absolute(5)", view3.Height.ToString ());
- Assert.False (view4.AutoSize);
- Assert.Equal (new Rectangle (0, 0, 10, 5), view4.Frame);
- Assert.Equal ("Absolute(10)", view4.Width.ToString ());
- Assert.Equal ("Absolute(5)", view4.Height.ToString ());
- Assert.False (view5.AutoSize);
- Assert.Equal (new Rectangle (0, 0, 10, 5), view5.Frame);
- Assert.Equal ("Absolute(10)", view5.Width.ToString ());
- Assert.Equal ("Absolute(5)", view5.Height.ToString ());
- Assert.False (view6.AutoSize);
- Assert.Equal (new Rectangle (0, 0, 10, 5), view6.Frame);
- Assert.Equal ("Absolute(10)", view6.Width.ToString ());
- Assert.Equal ("Absolute(5)", view6.Height.ToString ());
- }
-
- [Fact]
- public void AutoSize_False_If_Text_Empty ()
- {
- var view1 = new View ();
- var view3 = new View { Text = "" };
-
- Assert.False (view1.AutoSize);
- Assert.False (view3.AutoSize);
- view1.Dispose ();
- view3.Dispose ();
- }
-
- [Fact]
- public void AutoSize_False_If_Text_Is_Not_Empty ()
- {
- var view1 = new View ();
- view1.Text = "Hello World";
- var view3 = new View { Text = "Hello World" };
-
- Assert.False (view1.AutoSize);
- Assert.False (view3.AutoSize);
- view1.Dispose ();
- view3.Dispose ();
- }
-
- [Fact]
- public void AutoSize_False_ResizeView_Is_Always_False ()
- {
- var super = new View ();
- var view = new View ();
- super.Add (view);
-
- view.Text = "New text";
- super.LayoutSubviews ();
- Rectangle expectedViewBounds = new (0, 0, 0, 0);
-
- Assert.False (view.AutoSize);
- Assert.Equal (expectedViewBounds, view.Viewport);
- super.Dispose ();
- }
-
[Fact]
public void AutoSize_False_ResizeView_With_Dim_Fill_After_IsInitialized ()
{
- var super = new View { Frame = new Rectangle (0, 0, 30, 80) };
+ var super = new View { Frame = new (0, 0, 30, 80) };
var view = new View { Width = Dim.Fill (), Height = Dim.Fill () };
super.Add (view);
Assert.False (view.AutoSize);
@@ -174,43 +29,6 @@ public class AutoSizeFalseTests
Assert.Equal (expectedViewBounds, view.Viewport);
}
- [Fact]
- [SetupFakeDriver]
- public void AutoSize_False_Setting_AutoSize_False_Keeps_Dims ()
- {
- var super = new View { Width = 10, Height = 10 };
- var view = new View ();
- view.Width = 2;
- view.Height = 1;
- Assert.Equal ("Absolute(2)", view.Width.ToString ());
- Assert.Equal ("Absolute(1)", view.Height.ToString ());
-
- super.Add (view);
- super.BeginInit ();
- super.EndInit ();
- super.LayoutSubviews ();
- Assert.Equal ("Absolute(2)", view.Width.ToString ());
- Assert.Equal ("Absolute(1)", view.Height.ToString ());
-
- view.AutoSize = true;
- Assert.Equal (Dim.Auto(Dim.DimAutoStyle.Text), view.Width);
- Assert.Equal (Dim.Auto (Dim.DimAutoStyle.Text), view.Height);
-
- view.AutoSize = false;
- Assert.Equal ("Absolute(0)", view.Width.ToString ());
- Assert.Equal ("Absolute(0)", view.Height.ToString ());
-
- view.Width = 2;
- view.Height = 1;
- Assert.Equal ("Absolute(2)", view.Width.ToString ());
- Assert.Equal ("Absolute(1)", view.Height.ToString ());
-
- view.AutoSize = false;
- Assert.Equal ("Absolute(2)", view.Width.ToString ());
- Assert.Equal ("Absolute(1)", view.Height.ToString ());
- }
-
-
[Fact]
[SetupFakeDriver]
public void AutoSize_False_View_IsEmpty_False_Return_Null_Lines ()
@@ -229,7 +47,7 @@ public class AutoSizeFalseTests
Assert.False (view.AutoSize);
Assert.Equal (new (0, 0, 3, 1), view.Frame);
Assert.Equal (new (3, 1), view.TextFormatter.Size);
- Assert.Equal (new List { "Vie" }, view.TextFormatter.GetLines ());
+ Assert.Equal (new() { "Vie" }, view.TextFormatter.GetLines ());
Assert.Equal (new (0, 0, 10, 4), frame.Frame);
frame.LayoutSubviews ();
@@ -243,7 +61,7 @@ public class AutoSizeFalseTests
└────────┘
";
- Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+ Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new (0, 0, 10, 4), pos);
text = "0123456789";
@@ -256,7 +74,7 @@ public class AutoSizeFalseTests
Assert.Equal (new (0, 0, 0, 1), view.Frame);
Assert.Equal (new (0, 1), view.TextFormatter.Size);
- Assert.Equal (new List { string.Empty }, view.TextFormatter.GetLines ());
+ Assert.Equal (new() { string.Empty }, view.TextFormatter.GetLines ());
expected = @"
┌────────┐
@@ -265,7 +83,7 @@ public class AutoSizeFalseTests
└────────┘
";
- pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+ pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new (0, 0, 10, 4), pos);
}
@@ -342,7 +160,7 @@ public class AutoSizeFalseTests
└──────────────────────────────┘
";
- Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+ Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
verticalView.Text = $"最初の行{Environment.NewLine}二行目";
Assert.True (verticalView.TextFormatter.NeedsFormat);
@@ -391,6 +209,6 @@ public class AutoSizeFalseTests
└──────────────────────────────┘
";
- pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+ pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
}
}