From bd57b1df116301a7b7b06d2a8ef911e49a2c351e Mon Sep 17 00:00:00 2001 From: Tig Date: Fri, 3 May 2024 13:46:33 -0600 Subject: [PATCH] Removed un-needed AutoSize tests --- .../View/Layout/SetRelativeLayoutTests.cs | 22 +- UnitTests/View/Text/AutoSizeFalseTests.cs | 6 - UnitTests/View/Text/AutoSizeTrueTests.cs | 1119 +---------------- 3 files changed, 72 insertions(+), 1075 deletions(-) diff --git a/UnitTests/View/Layout/SetRelativeLayoutTests.cs b/UnitTests/View/Layout/SetRelativeLayoutTests.cs index ddba936b7..7efbf1fba 100644 --- a/UnitTests/View/Layout/SetRelativeLayoutTests.cs +++ b/UnitTests/View/Layout/SetRelativeLayoutTests.cs @@ -1,4 +1,5 @@ using Xunit.Abstractions; +using static Terminal.Gui.Dim; namespace Terminal.Gui.LayoutTests; @@ -249,7 +250,7 @@ public class SetRelativeLayoutTests Assert.Equal (4, testView.Frame.X); Assert.Equal (4, testView.Frame.Y); - testView = new() + testView = new () { X = Pos.Center () + 1, // ((10 / 2) - (1 / 2)) + 1 = 5 - 1 + 1 = 5 Y = Pos.Center () + 1, @@ -261,7 +262,7 @@ public class SetRelativeLayoutTests Assert.Equal (5, testView.Frame.X); Assert.Equal (5, testView.Frame.Y); - testView = new() + testView = new () { X = 1 + Pos.Center (), Y = 1 + Pos.Center (), @@ -273,7 +274,7 @@ public class SetRelativeLayoutTests Assert.Equal (5, testView.Frame.X); Assert.Equal (5, testView.Frame.Y); - testView = new() + testView = new () { X = 1 + Pos.Percent (50), Y = Pos.Percent (50) + 1, @@ -285,7 +286,7 @@ public class SetRelativeLayoutTests Assert.Equal (6, testView.Frame.X); Assert.Equal (6, testView.Frame.Y); - testView = new() + testView = new () { X = Pos.Percent (10) + Pos.Percent (40), Y = Pos.Percent (10) + Pos.Percent (40), @@ -297,7 +298,7 @@ public class SetRelativeLayoutTests Assert.Equal (5, testView.Frame.X); Assert.Equal (5, testView.Frame.Y); - testView = new() + testView = new () { X = 1 + Pos.Percent (10) + Pos.Percent (40) - 1, Y = 5 + Pos.Percent (10) + Pos.Percent (40) - 5, @@ -309,7 +310,7 @@ public class SetRelativeLayoutTests Assert.Equal (5, testView.Frame.X); Assert.Equal (5, testView.Frame.Y); - testView = new() + testView = new () { X = Pos.Left (testView), Y = Pos.Left (testView), @@ -321,7 +322,7 @@ public class SetRelativeLayoutTests Assert.Equal (5, testView.Frame.X); Assert.Equal (5, testView.Frame.Y); - testView = new() + testView = new () { X = 1 + Pos.Left (testView), Y = Pos.Top (testView) + 1, @@ -396,7 +397,12 @@ public class SetRelativeLayoutTests public void PosDimFunction () { var screen = new Size (30, 1); - var view = new View { Text = "abc", AutoSize = true }; // BUGBUG: AutoSize or Width must be set + var view = new View + { + Text = "abc", + Width = Auto (DimAutoStyle.Text), + Height = Auto (DimAutoStyle.Text) + }; view.X = Pos.AnchorEnd (0) - Pos.Function (GetViewWidth); int GetViewWidth () { return view.Frame.Width; } diff --git a/UnitTests/View/Text/AutoSizeFalseTests.cs b/UnitTests/View/Text/AutoSizeFalseTests.cs index a1a23d785..e9108405a 100644 --- a/UnitTests/View/Text/AutoSizeFalseTests.cs +++ b/UnitTests/View/Text/AutoSizeFalseTests.cs @@ -11,13 +11,11 @@ public class AutoSizeFalseTests (ITestOutputHelper output) 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); view.Text = "New text\nNew line"; super.LayoutSubviews (); Rectangle expectedViewBounds = new (0, 0, 30, 80); - Assert.False (view.AutoSize); Assert.Equal (expectedViewBounds, view.Viewport); Assert.False (view.IsInitialized); @@ -25,7 +23,6 @@ public class AutoSizeFalseTests (ITestOutputHelper output) super.EndInit (); Assert.True (view.IsInitialized); - Assert.False (view.AutoSize); Assert.Equal (expectedViewBounds, view.Viewport); } @@ -44,7 +41,6 @@ public class AutoSizeFalseTests (ITestOutputHelper output) frame.LayoutSubviews (); Assert.Equal (5, text.Length); - Assert.False (view.AutoSize); Assert.Equal (new (0, 0, 3, 1), view.Frame); Assert.Equal (new (3, 1), view.TextFormatter.Size); Assert.Equal (new() { "Vie" }, view.TextFormatter.GetLines ()); @@ -118,8 +114,6 @@ public class AutoSizeFalseTests (ITestOutputHelper output) top.BeginInit (); top.EndInit (); - Assert.False (horizontalView.AutoSize); - Assert.False (verticalView.AutoSize); Assert.Equal (new (0, 0, 20, 1), horizontalView.Frame); Assert.Equal (new (0, 3, 1, 20), verticalView.Frame); diff --git a/UnitTests/View/Text/AutoSizeTrueTests.cs b/UnitTests/View/Text/AutoSizeTrueTests.cs index 6c4b1cad6..87b39b6e2 100644 --- a/UnitTests/View/Text/AutoSizeTrueTests.cs +++ b/UnitTests/View/Text/AutoSizeTrueTests.cs @@ -5,10 +5,8 @@ using Xunit.Abstractions; namespace Terminal.Gui.ViewTests; /// Tests of the property which auto sizes Views based on . -public class AutoSizeTrueTests +public class AutoSizeTrueTests (ITestOutputHelper output) { - private readonly ITestOutputHelper _output; - private readonly string [] expecteds = new string [21] { @" @@ -330,15 +328,13 @@ public class AutoSizeTrueTests private static readonly Size _size1x1 = new (1, 1); - public AutoSizeTrueTests (ITestOutputHelper output) { _output = output; } - + // TODO: This is a Label test. Move to label tests if there's not already a test for this. [Fact] [AutoInitShutdown] public void AutoSize_AnchorEnd_Better_Than_Bottom_Equal_Inside_Window () { var win = new Window (); - // Label is AutoSize == true var label = new Label { Text = "This should be the last line.", @@ -356,7 +352,6 @@ public class AutoSizeTrueTests RunState rs = Application.Begin (top); ((FakeDriver)Application.Driver).SetBufferSize (40, 10); - Assert.True (label.AutoSize); Assert.Equal (29, label.Text.Length); Assert.Equal (new Rectangle (0, 0, 40, 10), top.Frame); Assert.Equal (new Rectangle (0, 0, 40, 10), win.Frame); @@ -375,10 +370,11 @@ public class AutoSizeTrueTests └──────────────────────────────────────┘ "; - TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Application.End (rs); } + // TODO: This is a Label test. Move to label tests if there's not already a test for this. [Fact] [AutoInitShutdown] public void AutoSize_AnchorEnd_Better_Than_Bottom_Equal_Inside_Window_With_MenuBar_And_StatusBar_On_Toplevel () @@ -391,7 +387,6 @@ public class AutoSizeTrueTests Text = "This should be the last line.", ColorScheme = Colors.ColorSchemes ["Menu"], - //Width = Dim.Fill (), X = 0, Y = Pos.AnchorEnd (1) }; @@ -404,7 +399,6 @@ public class AutoSizeTrueTests top.Add (win, menu, status); RunState rs = Application.Begin (top); - Assert.True (label.AutoSize); Assert.Equal (new Rectangle (0, 0, 80, 25), top.Frame); Assert.Equal (new Rectangle (0, 0, 80, 1), menu.Frame); Assert.Equal (new Rectangle (0, 24, 80, 1), status.Frame); @@ -439,10 +433,11 @@ public class AutoSizeTrueTests F1 Help "; - TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Application.End (rs); } + // TODO: This is a Label test. Move to label tests if there's not already a test for this. [Fact] [AutoInitShutdown] public void AutoSize_Bottom_Equal_Inside_Window () @@ -468,7 +463,6 @@ public class AutoSizeTrueTests RunState rs = Application.Begin (top); ((FakeDriver)Application.Driver).SetBufferSize (40, 10); - Assert.True (label.AutoSize); Assert.Equal (new Rectangle (0, 0, 40, 10), top.Frame); Assert.Equal (new Rectangle (0, 0, 40, 10), win.Frame); Assert.Equal (new Rectangle (0, 7, 29, 1), label.Frame); @@ -486,10 +480,12 @@ public class AutoSizeTrueTests └──────────────────────────────────────┘ "; - TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Application.End (rs); } + // TODO: This is a Label test. Move to label tests if there's not already a test for this. + [Fact] [AutoInitShutdown] public void AutoSize_Bottom_Equal_Inside_Window_With_MenuBar_And_StatusBar_On_Toplevel () @@ -504,8 +500,7 @@ public class AutoSizeTrueTests //Width = Dim.Fill (), X = 0, - Y = Pos.Bottom (win) - - 4 // two lines top and bottom borders more two lines above border + Y = Pos.Bottom (win) - 4 // two lines top and bottom borders more two lines above border }; win.Add (label); @@ -516,7 +511,6 @@ public class AutoSizeTrueTests top.Add (win, menu, status); RunState rs = Application.Begin (top); - Assert.True (label.AutoSize); Assert.Equal (new Rectangle (0, 0, 80, 25), top.Frame); Assert.Equal (new Rectangle (0, 0, 80, 1), menu.Frame); Assert.Equal (new Rectangle (0, 24, 80, 1), status.Frame); @@ -551,10 +545,11 @@ public class AutoSizeTrueTests F1 Help "; - TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Application.End (rs); } + // TODO: This is a Label test. Move to label tests if there's not already a test for this. [Fact] [AutoInitShutdown] public void AutoSize_Dim_Add_Operator_With_Text () @@ -580,7 +575,7 @@ public class AutoSizeTrueTests if (k.KeyCode == KeyCode.Enter) { ((FakeDriver)Application.Driver).SetBufferSize (22, count + 4); - Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expecteds [count], _output); + Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expecteds [count], output); Assert.Equal (new Rectangle (0, 0, 22, count + 4), pos); if (count < 20) @@ -638,6 +633,8 @@ public class AutoSizeTrueTests Assert.Equal (count, listLabels.Count); } + // TODO: This is a Dim test. Move to Dim tests. + [Fact] [AutoInitShutdown] public void AutoSize_Dim_Subtract_Operator_With_Text () @@ -686,7 +683,7 @@ public class AutoSizeTrueTests if (k.KeyCode == KeyCode.Enter) { ((FakeDriver)Application.Driver).SetBufferSize (22, count + 4); - Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expecteds [count], _output); + Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expecteds [count], output); Assert.Equal (new Rectangle (0, 0, 22, count + 4), pos); if (count > 0) @@ -742,71 +739,18 @@ public class AutoSizeTrueTests Assert.Equal (count, listLabels.Count); } - //[Fact] - //[AutoInitShutdown] - //public void AutoSize_False_Label_IsEmpty_True_Return_Null_Lines () - //{ - // var text = "Label"; - // var label = new Label - // { - // AutoSize = false, - // Height = 1, - // Text = text, - // }; - // var win = new Window - // { - // Width = Dim.Fill (), - // Height = Dim.Fill () - // }; - // win.Add (label); - // var top = new Toplevel (); - // top.Add (win); - // Application.Begin (top); - // ((FakeDriver)Application.Driver).SetBufferSize (10, 4); - - // Assert.Equal (5, text.Length); - // Assert.False (label.AutoSize); - // Assert.Equal (new (0, 0, 0, 1), label.Frame); - // Assert.Equal (new (3, 1), label.TextFormatter.Size); - // Assert.Equal (new List { "Lab" }, label.TextFormatter.GetLines()); - // Assert.Equal (new (0, 0, 10, 4), win.Frame); - // Assert.Equal (new (0, 0, 10, 4), Application.Top.Frame); - // var expected = @" - //┌────────┐ - //│Lab │ - //│ │ - //└────────┘ - //"; - - // var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); - // Assert.Equal (new (0, 0, 10, 4), pos); - - // text = "0123456789"; - // Assert.Equal (10, text.Length); - // //label.Width = Dim.Fill () - text.Length; - // Application.Refresh (); - - // Assert.False (label.AutoSize); - // Assert.Equal (new (0, 0, 0, 1), label.Frame); - // Assert.Equal (new (0, 1), label.TextFormatter.Size); - // Assert.Equal (new List { string.Empty }, label.TextFormatter.GetLines()); - // expected = @" - //┌────────┐ - //│ │ - //│ │ - //└────────┘ - //"; - - // pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); - // Assert.Equal (new (0, 0, 10, 4), pos); - //} + // TODO: This is a Label test. Move to Label tests. [Fact] [SetupFakeDriver] public void AutoSize_False_Label_Height_Zero_Stays_Zero () { var text = "Label"; - var label = new Label { Text = text, AutoSize = false }; + var label = new Label { + Text = text, + Width = Dim.Auto(Dim.DimAutoStyle.Text), + Height = Dim.Auto(Dim.DimAutoStyle.Text) + }; label.Width = Dim.Fill () - text.Length; label.Height = 0; @@ -819,7 +763,6 @@ public class AutoSizeTrueTests win.Draw (); Assert.Equal (5, text.Length); - Assert.False (label.AutoSize); Assert.Equal (new (0, 0, 3, 0), label.Frame); //Assert.Equal (new (5, 1), label.TextFormatter.Size); Assert.Single (label.TextFormatter.GetLines ()); @@ -832,7 +775,7 @@ public class AutoSizeTrueTests └────────┘ "; - Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new (0, 0, 10, 4), pos); text = "0123456789"; @@ -860,330 +803,10 @@ public class AutoSizeTrueTests └────────┘ "; - pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new (0, 0, 10, 4), pos); } - [Fact] - public void AutoSize_False_SetWidthHeight_With_Dim_Fill_And_Dim_Absolute_With_Initialization () - { - var win = new Window { Frame = new (0, 0, 30, 80) }; - var label = new Label (); - win.Add (label); - win.BeginInit (); - win.EndInit (); - - Assert.True (label.AutoSize); - Rectangle expectedLabelBounds = Rectangle.Empty; - Assert.Equal (expectedLabelBounds, label.Viewport); - Assert.True (label.AutoSize); - - label.Text = "First line\nSecond line"; - win.LayoutSubviews (); - - expectedLabelBounds = new (0, 0, 11, 2); - Assert.True (label.AutoSize); - Assert.Equal (expectedLabelBounds, label.Viewport); - - label.AutoSize = false; - label.Width = Dim.Fill (); - label.Height = 2; - win.LayoutSubviews (); - - // Here the SetMinWidthHeight ensuring the minimum height - // #3127: After: (0,0,28,2) because turning off AutoSize leaves - // Height set to 2. - expectedLabelBounds = new (0, 0, 28, 2); - Assert.False (label.AutoSize); - Assert.Equal (expectedLabelBounds, label.Viewport); - - label.Text = "First changed line\nSecond changed line\nNew line"; - win.LayoutSubviews (); - - // Here the AutoSize is false and the width 28 (Dim.Fill) and - // #3127: Before: height 1 because it wasn't set and SetMinWidthHeight ensuring the minimum height - // #3127: After: (0,0,28,2) because setting Text leaves Height set to 2. - expectedLabelBounds = new (0, 0, 28, 2); - Assert.False (label.AutoSize); - Assert.Equal (expectedLabelBounds, label.Viewport); - - label.AutoSize = true; - - win.LayoutSubviews (); - - // Here the AutoSize ensuring the right size with width 19 (width of longest line) - // and height 3 because the text has 3 lines - expectedLabelBounds = new (0, 0, 19, 3); - Assert.True (label.AutoSize); - Assert.Equal (expectedLabelBounds, label.Viewport); - } - - //[Fact] - //[AutoInitShutdown] - //public void AutoSize_GetAutoSize_Centered () - //{ - // var text = "This is some text."; - // var view = new View { Text = text, TextAlignment = TextAlignment.Centered, AutoSize = true }; - // var win = new Window { Width = Dim.Fill (), Height = Dim.Fill () }; - // win.Add (view); - // var top = new Toplevel (); - // top.Add (win); - // Application.Begin (top); - // ((FakeDriver)Application.Driver).SetBufferSize (10, 4); - - // Size size = view.GetTextAutoSize (); - // Assert.Equal (new Size (text.Length, 1), size); - - // view.Text = $"{text}\n{text}"; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (text.Length, 2), size); - - // view.Text = $"{text}\n{text}\n{text}+"; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (text.Length + 1, 3), size); - - // text = string.Empty; - // view.Text = text; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (0, 0), size); - - // text = "1"; - // view.Text = text; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (1, 1), size); - - // text = "界"; - // view.Text = text; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (2, 1), size); - //} - - //[Fact] - //[AutoInitShutdown] - //public void AutoSize_GetAutoSize_Horizontal () - //{ - // var text = "text"; - // var view = new View { Text = text, AutoSize = true }; - // var win = new Window { Width = Dim.Fill (), Height = Dim.Fill () }; - // win.Add (view); - // var top = new Toplevel (); - // top.Add (win); - // Application.Begin (top); - // ((FakeDriver)Application.Driver).SetBufferSize (10, 4); - - // Size size = view.GetTextAutoSize (); - // Assert.Equal (new Size (text.Length, 1), size); - - // view.Text = $"{text}\n{text}"; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (text.Length, 2), size); - - // view.Text = $"{text}\n{text}\n{text}+"; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (text.Length + 1, 3), size); - - // text = string.Empty; - // view.Text = text; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (0, 0), size); - - // text = "1"; - // view.Text = text; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (1, 1), size); - - // text = "界"; - // view.Text = text; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (2, 1), size); - //} - - //[Fact] - //[AutoInitShutdown] - //public void AutoSize_GetAutoSize_Left () - //{ - // var text = "This is some text."; - // var view = new View { Text = text, TextAlignment = TextAlignment.Left, AutoSize = true }; - // var win = new Window { Width = Dim.Fill (), Height = Dim.Fill () }; - // win.Add (view); - // var top = new Toplevel (); - // top.Add (win); - // Application.Begin (top); - // ((FakeDriver)Application.Driver).SetBufferSize (10, 4); - - // Size size = view.GetTextAutoSize (); - // Assert.Equal (new Size (text.Length, 1), size); - - // view.Text = $"{text}\n{text}"; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (text.Length, 2), size); - - // view.Text = $"{text}\n{text}\n{text}+"; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (text.Length + 1, 3), size); - - // text = string.Empty; - // view.Text = text; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (0, 0), size); - - // text = "1"; - // view.Text = text; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (1, 1), size); - - // text = "界"; - // view.Text = text; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (2, 1), size); - //} - - //[Fact] - //[AutoInitShutdown] - //public void AutoSize_GetAutoSize_Right () - //{ - // var text = "This is some text."; - // var view = new View { Text = text, TextAlignment = TextAlignment.Right, AutoSize = true }; - // var win = new Window { Width = Dim.Fill (), Height = Dim.Fill () }; - // win.Add (view); - // var top = new Toplevel (); - // top.Add (win); - // Application.Begin (top); - // ((FakeDriver)Application.Driver).SetBufferSize (10, 4); - - // Size size = view.GetTextAutoSize (); - // Assert.Equal (new Size (text.Length, 1), size); - - // view.Text = $"{text}\n{text}"; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (text.Length, 2), size); - - // view.Text = $"{text}\n{text}\n{text}+"; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (text.Length + 1, 3), size); - - // text = string.Empty; - // view.Text = text; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (0, 0), size); - - // text = "1"; - // view.Text = text; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (1, 1), size); - - // text = "界"; - // view.Text = text; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (2, 1), size); - //} - - //[Fact] - //[AutoInitShutdown] - //public void AutoSize_GetAutoSize_Vertical () - //{ - // var text = "text"; - // var view = new View { Text = text, TextDirection = TextDirection.TopBottom_LeftRight, AutoSize = true }; - // var win = new Window { Width = Dim.Fill (), Height = Dim.Fill () }; - // win.Add (view); - // var top = new Toplevel (); - // top.Add (win); - // Application.Begin (top); - // ((FakeDriver)Application.Driver).SetBufferSize (10, 4); - - // Size size = view.GetTextAutoSize (); - // Assert.Equal (new Size (1, text.Length), size); - - // view.Text = $"{text}\n{text}"; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (2, text.Length), size); - - // view.Text = $"{text}\n{text}\n{text}+"; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (3, text.Length + 1), size); - - // text = string.Empty; - // view.Text = text; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (0, 0), size); - - // text = "1"; - // view.Text = text; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (1, 1), size); - - // text = "界"; - // view.Text = text; - // size = view.GetTextAutoSize (); - // Assert.Equal (new Size (2, 1), size); - //} - -// [Fact] -// [SetupFakeDriver] -// public void AutoSize_Label_Set_AutoSize_To_False_Height_Positive_Does_Not_Change () -// { -// var text = "Label"; -// var label = new Label { Text = text }; -// Assert.Equal (Dim.Auto (Dim.DimAutoStyle.Text), label.Height); -// label.AutoSize = false; -// label.Width = Dim.Fill () - text.Length; -// label.Height = 1; -// Assert.Equal (Dim.Sized (1), label.Height); - -// var win = new FrameView { Width = Dim.Fill (), Height = Dim.Fill () }; -// win.Add (label); -// ((FakeDriver)Application.Driver).SetBufferSize (10, 4); -// win.BeginInit (); -// win.EndInit (); -// win.LayoutSubviews (); -// win.Draw (); - -// Assert.Equal (5, text.Length); -// Assert.False (label.AutoSize); -// Assert.Equal (new (0, 0, 3, 1), label.Frame); -// Assert.Equal (new (5, 1), label.TextFormatter.Size); -// Assert.Single (label.TextFormatter.GetLines ()); -// Assert.Equal (new (0, 0, 10, 4), win.Frame); - -// var expected = @" -//┌────────┐ -//│Lab │ -//│ │ -//└────────┘ -//"; - -// Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); -// Assert.Equal (new (0, 0, 10, 4), pos); - -// text = "0123456789"; -// Assert.Equal (10, text.Length); -// label.Width = Dim.Fill () - text.Length; -// win.LayoutSubviews (); -// win.Clear (); -// win.Draw (); - -// Assert.Equal (new (0, 0, 0, 1), label.Frame); -// Assert.Equal (new (0, 1), label.TextFormatter.Size); - -// Exception exception = Record.Exception ( -// () => Assert.Equal ( -// new List { string.Empty }, -// label.TextFormatter.GetLines () -// ) -// ); -// Assert.Null (exception); - -// expected = @" -//┌────────┐ -//│ │ -//│ │ -//└────────┘ -//"; - -// pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); -// Assert.Equal (new (0, 0, 10, 4), pos); -// } - [Fact] [AutoInitShutdown] public void AutoSize_Stays_True_Center_HotKeySpecifier () @@ -1195,7 +818,6 @@ public class AutoSizeTrueTests var top = new Toplevel (); top.Add (win); - Assert.True (label.AutoSize); RunState rs = Application.Begin (top); ((FakeDriver)Application.Driver).SetBufferSize (30, 5); @@ -1208,11 +830,9 @@ public class AutoSizeTrueTests └────────────────────────────┘ "; - TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); - Assert.True (label.AutoSize); label.Text = "Say Hello 你 changed"; - Assert.True (label.AutoSize); Application.Refresh (); expected = @" @@ -1223,156 +843,13 @@ public class AutoSizeTrueTests └────────────────────────────┘ "; - TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Application.End (rs); } - //[Fact] - //public void AutoSize_True_Equal_Before_And_After_IsInitialized_With_Different_Orders () - //{ - // var top = new Toplevel (); - - // var view1 = new View - // { - // Text = "Say Hello view1 你", AutoSize = true /*, Width = 10, Height = 5*/, ValidatePosDim = true - // }; - - // var view2 = new View - // { - // Text = "Say Hello view2 你", - // Width = 10, - // Height = 5, - // AutoSize = true, - // ValidatePosDim = true - // }; - - // var view3 = new View - // { - // AutoSize = true /*, Width = 10, Height = 5*/, Text = "Say Hello view3 你", ValidatePosDim = true - // }; - - // var view4 = new View - // { - // Text = "Say Hello view4 你", - // AutoSize = true, - - // //Width = 2, - // //Height = 17, - // TextDirection = TextDirection.TopBottom_LeftRight, - // ValidatePosDim = true - // }; - - // var view5 = new View - // { - // Text = "Say Hello view5 你", - // AutoSize = true, - - // //Width = 2, - // //Height = 17, - // TextDirection = TextDirection.TopBottom_LeftRight, - // ValidatePosDim = true - // }; - - // var view6 = new View - // { - // AutoSize = true, - - // //Width = 2, - // //Height = 17, - // TextDirection = TextDirection.TopBottom_LeftRight, - // Text = "Say Hello view6 你", - // ValidatePosDim = true - // }; - // 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.True (view1.AutoSize); - // Assert.Equal (new (0, 0, 18, 1), view1.Frame); - // Assert.Equal (Dim.Auto (Dim.DimAutoStyle.Text), view1.Width); - // Assert.Equal (Dim.Auto (Dim.DimAutoStyle.Text), view1.Height); - - // Assert.True (view2.AutoSize); - // Assert.Equal (view2.Text.GetColumns (), view2.Frame.Width); - // Assert.Equal (18, view2.Frame.Width); - // Assert.Equal (new (0, 0, 18, 1), view2.Frame); - // Assert.Equal (Dim.Auto (Dim.DimAutoStyle.Text), view2.Width); - // Assert.Equal (Dim.Auto (Dim.DimAutoStyle.Text), view2.Height); - - // Assert.True (view3.AutoSize); - // Assert.Equal (new (0, 0, 18, 1), view3.Frame); - // Assert.Equal (Dim.Auto (Dim.DimAutoStyle.Text), view3.Width); - // Assert.Equal (Dim.Auto (Dim.DimAutoStyle.Text), view3.Height); - - // // Vertical text - // Assert.True (view4.AutoSize); - // Assert.Equal (Dim.Auto (Dim.DimAutoStyle.Text), view4.Width); - // Assert.Equal (Dim.Auto (Dim.DimAutoStyle.Text), view4.Height); - // // Use Lenght for vertical text, not GetColumns - // Assert.Equal (view4.Text.Length, view4.Frame.Height); - // Assert.Equal (new (0, 0, 2, 17), view4.Frame); - - // Assert.True (view5.AutoSize); - // Assert.Equal (new (0, 0, 2, 17), view5.Frame); - - // Assert.True (view6.AutoSize); - // Assert.Equal (new (0, 0, 2, 17), view6.Frame); - - // 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.True (view1.AutoSize); - // Assert.Equal (new (0, 0, 18, 1), view1.Frame); - // Assert.True (view2.AutoSize); - - // Assert.Equal (new (0, 0, 18, 1), view2.Frame); - // Assert.True (view3.AutoSize); - // Assert.Equal (new (0, 0, 18, 1), view3.Frame); - // Assert.True (view4.AutoSize); - // Assert.Equal (new (0, 0, 2, 17), view4.Frame); - // Assert.True (view5.AutoSize); - // Assert.Equal (new (0, 0, 2, 17), view5.Frame); - // Assert.True (view6.AutoSize); - // Assert.Equal (new (0, 0, 2, 17), view6.Frame); - //} - - [Fact] - public void AutoSize_True_Label_If_Text_Empty () - { - var label1 = new Label (); - var label3 = new Label { Text = "" }; - - Assert.True (label1.AutoSize); - Assert.True (label3.AutoSize); - label1.Dispose (); - label3.Dispose (); - } - - [Fact] - public void AutoSize_True_Label_If_Text_Is_Not_Empty () - { - var label1 = new Label (); - label1.Text = "Hello World"; - var label3 = new Label { Text = "Hello World" }; - - Assert.True (label1.AutoSize); - Assert.True (label3.AutoSize); - label1.Dispose (); - label3.Dispose (); - } - [Fact] [AutoInitShutdown] - public void AutoSize_True_Label_IsEmpty_False_Minimum_Height () + public void Label_IsEmpty_False_Minimum_Height () { var text = "Label"; @@ -1389,7 +866,6 @@ public class AutoSizeTrueTests ((FakeDriver)Application.Driver).SetBufferSize (10, 4); Assert.Equal (5, text.Length); - Assert.True (label.AutoSize); Assert.Equal (new (0, 0, 5, 1), label.Frame); Assert.Equal (new (5, 1), label.TextFormatter.Size); Assert.Equal (["Label"], label.TextFormatter.GetLines ()); @@ -1403,7 +879,7 @@ public class AutoSizeTrueTests └────────┘ "; - Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new (0, 0, 10, 4), pos); text = "0123456789"; @@ -1424,13 +900,13 @@ public class AutoSizeTrueTests └────────┘ "; - pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new (0, 0, 10, 4), pos); } [Fact] [AutoInitShutdown] - public void AutoSize_True_Label_IsEmpty_False_Never_Return_Null_Lines () + public void Label_IsEmpty_False_Never_Return_Null_Lines () { var text = "Label"; @@ -1448,7 +924,6 @@ public class AutoSizeTrueTests ((FakeDriver)Application.Driver).SetBufferSize (10, 4); Assert.Equal (5, text.Length); - Assert.True (label.AutoSize); Assert.Equal (new (0, 0, 5, 1), label.Frame); Assert.Equal (new (5, 1), label.TextFormatter.Size); Assert.Equal (["Label"], label.TextFormatter.GetLines ()); @@ -1462,7 +937,7 @@ public class AutoSizeTrueTests └────────┘ "; - Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new (0, 0, 10, 4), pos); text = "0123456789"; @@ -1483,12 +958,12 @@ public class AutoSizeTrueTests └────────┘ "; - pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new (0, 0, 10, 4), pos); } [Fact] - public void AutoSize_True_ResizeView_With_Dim_Absolute () + public void Label_ResizeView_With_Dim_Absolute () { var super = new View () { @@ -1501,7 +976,6 @@ public class AutoSizeTrueTests super.Add (label); super.LayoutSubviews (); - Assert.True (label.AutoSize); Rectangle expectedLabelBounds = new (0, 0, 8, 1); Assert.Equal (expectedLabelBounds, label.Viewport); super.Dispose (); @@ -1521,7 +995,6 @@ public class AutoSizeTrueTests top.BeginInit (); top.EndInit (); - Assert.True (label.AutoSize); Assert.Equal (new (0, 0, 5, 1), label.Frame); top.LayoutSubviews (); @@ -1532,7 +1005,7 @@ HelloX Y "; - Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); label.AutoSize = false; label.Width = 10; @@ -1549,7 +1022,7 @@ Hello X Y "; - pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); } [Fact] @@ -1583,7 +1056,7 @@ o Y "; - Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); label.AutoSize = false; label.Width = 2; @@ -1608,7 +1081,7 @@ Y " ; - pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Application.End (rs); } @@ -1656,7 +1129,7 @@ Y └─────────────┘ "; - Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); view.Text = "Hello World"; view.Width = 11; @@ -1688,7 +1161,7 @@ Y └─────────────┘ "; - pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); view.AutoSize = true; view.Text = "Hello Worlds"; @@ -1715,7 +1188,7 @@ Y └─────────────┘ "; - pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); view.TextDirection = TextDirection.TopBottom_LeftRight; Application.Refresh (); @@ -1741,7 +1214,7 @@ Y └─────────────┘ "; - pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); // Setting to false causes Width and Height to be set to the current ContentSize view.AutoSize = false; @@ -1758,7 +1231,7 @@ Y view.Draw (); expected = @" HelloWorlds"; - TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Application.Refresh (); @@ -1783,7 +1256,7 @@ Y └─────────────┘ "; - pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); view.PreserveTrailingSpaces = true; Application.Refresh (); @@ -1808,7 +1281,7 @@ Y └─────────────┘ "; - pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); view.PreserveTrailingSpaces = false; Rectangle f = view.Frame; @@ -1837,7 +1310,7 @@ Y └─────────────┘ "; - pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); view.AutoSize = true; Application.Refresh (); @@ -1862,7 +1335,7 @@ Y └─────────────┘ "; - pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Application.End (rs); } @@ -1907,7 +1380,7 @@ Y └──┘ "; - Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new (0, 0, 4, 10), pos); text = "0123456789"; @@ -1934,7 +1407,7 @@ Y └──┘ "; - pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rectangle (0, 0, 4, 10), pos); } @@ -1979,7 +1452,7 @@ Y └──┘ "; - Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new (0, 0, 4, 10), pos); text = "0123456789"; @@ -2012,7 +1485,7 @@ Y └──┘ "; - pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rectangle (0, 0, 4, 10), pos); } @@ -2084,7 +1557,7 @@ Y └──────────────────┘ "; - Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); verticalView.Text = $"最初の行{Environment.NewLine}二行目"; Application.Top.Draw (); @@ -2113,7 +1586,7 @@ Y └──────────────────┘ "; - pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Application.End (rs); } @@ -2175,7 +1648,7 @@ Y └────────────────────┘ "; - Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); verticalView.Text = "最初の行二行目"; Application.Top.Draw (); @@ -2210,51 +1683,10 @@ Y └────────────────────┘ "; - pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Application.End (rs); } - // Moved from DimTests.cs - This is really a bogus test - [Theory] - [AutoInitShutdown] - [InlineData (0, true)] - [InlineData (0, false)] - [InlineData (50, true)] - [InlineData (50, false)] - public void DimPercentPlusOne (int startingDistance, bool testHorizontal) - { - var container = new View { Width = 100, Height = 100 }; - - var label = new Label - { - X = testHorizontal ? startingDistance : 0, Y = testHorizontal ? 0 : startingDistance - - //Width = testHorizontal ? Dim.Percent (50) + 1 : 1, - //Height = testHorizontal ? 1 : Dim.Percent (50) + 1 - }; - - container.Add (label); - var top = new Toplevel (); - top.Add (container); - top.BeginInit (); - top.EndInit (); - top.LayoutSubviews (); - - Assert.Equal (100, container.Frame.Width); - Assert.Equal (100, container.Frame.Height); - - if (testHorizontal) - { - Assert.Equal (0, label.Frame.Width); // BUGBUG: Shoudl be 0 not since there's no text - Assert.Equal (0, label.Frame.Height); - } - else - { - Assert.Equal (0, label.Frame.Width); // BUGBUG: Shoudl be 0 not since there's no text - Assert.Equal (0, label.Frame.Height); - } - } - [Fact] [AutoInitShutdown] public void Excess_Text_Is_Erased_When_The_Width_Is_Reduced () @@ -2290,379 +1722,7 @@ Y Application.End (rs); } - - //[Fact] - //public void GetCurrentHeight_TrySetHeight () - //{ - // var top = new View { X = 0, Y = 0, Height = 20 }; - - // var v = new View { Height = Dim.Fill (), ValidatePosDim = true }; - // top.Add (v); - // top.BeginInit (); - // top.EndInit (); - // top.LayoutSubviews (); - - // Assert.False (v.AutoSize); - // Assert.False (v.TrySetHeight (0, out _)); - // Assert.Equal (20, v.Frame.Height); - - // v.Height = Dim.Fill (1); - // top.LayoutSubviews (); - - // Assert.False (v.TrySetHeight (0, out _)); - // Assert.True (v.Height is Dim.DimFill); - // Assert.Equal (19, v.Frame.Height); - - // v.AutoSize = true; - // top.LayoutSubviews (); - - // Assert.True (v.TrySetHeight (0, out _)); - // Assert.True (v.Height is Dim.DimAbsolute); - // Assert.Equal (0, v.Frame.Height); // No text, so height is 0 - // top.Dispose (); - //} - - //[Fact] - //[TestRespondersDisposed] - //public void GetCurrentWidth_TrySetWidth () - //{ - // var top = new View { X = 0, Y = 0, Width = 80 }; - - // var v = new View { Width = Dim.Fill (), ValidatePosDim = true }; - // top.Add (v); - // top.BeginInit (); - // top.EndInit (); - // top.LayoutSubviews (); - - // Assert.False (v.AutoSize); - // Assert.False (v.TrySetWidth (0, out _)); - // Assert.True (v.Width is Dim.DimFill); - // Assert.Equal (80, v.Frame.Width); - - // v.Width = Dim.Fill (1); - // top.LayoutSubviews (); - - // Assert.False (v.TrySetWidth (0, out _)); - // Assert.True (v.Width is Dim.DimFill); - // Assert.Equal (79, v.Frame.Width); - - // v.AutoSize = true; - // top.LayoutSubviews (); - - // Assert.True (v.TrySetWidth (0, out _)); - // Assert.True (v.Width is Dim.DimAbsolute); - // Assert.Equal (0, v.Frame.Width); // No text, so width is 0 - // top.Dispose (); - //} - - // [Fact] - // [AutoInitShutdown] - // public void AutoSize_False_TextDirection_Toggle () - // { - // var win = new Window { Width = Dim.Fill (), Height = Dim.Fill () }; - // // View is AutoSize == true - // var view = new View (); - // win.Add (view); - // var top = new Toplevel (); - // top.Add (win); - - // var rs = Application.Begin (top); - // ((FakeDriver)Application.Driver).SetBufferSize (22, 22); - - // Assert.Equal (new (0, 0, 22, 22), win.Frame); - // Assert.Equal (new (0, 0, 22, 22), win.Margin.Frame); - // Assert.Equal (new (0, 0, 22, 22), win.Border.Frame); - // Assert.Equal (new (1, 1, 20, 20), win.Padding.Frame); - // Assert.False (view.AutoSize); - // Assert.Equal (TextDirection.LeftRight_TopBottom, view.TextDirection); - // Assert.Equal (Rectangle.Empty, view.Frame); - // Assert.Equal ("Absolute(0)", view.X.ToString ()); - // Assert.Equal ("Absolute(0)", view.Y.ToString ()); - // Assert.Equal ("Absolute(0)", view.Width.ToString ()); - // Assert.Equal ("Absolute(0)", view.Height.ToString ()); - // var expected = @" - //┌────────────────────┐ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //└────────────────────┘"; - - // var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); - // Assert.Equal (new (0, 0, 22, 22), pos); - - // view.Text = "Hello World"; - // view.Width = 11; - // view.Height = 1; - // win.LayoutSubviews (); - // Application.Refresh (); - - // Assert.Equal (new (0, 0, 11, 1), view.Frame); - // Assert.Equal ("Absolute(0)", view.X.ToString ()); - // Assert.Equal ("Absolute(0)", view.Y.ToString ()); - // Assert.Equal ("Absolute(11)", view.Width.ToString ()); - // Assert.Equal ("Absolute(1)", view.Height.ToString ()); - // expected = @" - //┌────────────────────┐ - //│Hello World │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //└────────────────────┘"; - - // pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); - // Assert.Equal (new (0, 0, 22, 22), pos); - - // view.AutoSize = true; - // view.Text = "Hello Worlds"; - // Application.Refresh (); - - // Assert.Equal (new (0, 0, 12, 1), view.Frame); - // Assert.Equal ("Absolute(0)", view.X.ToString ()); - // Assert.Equal ("Absolute(0)", view.Y.ToString ()); - // Assert.Equal ("Absolute(11)", view.Width.ToString ()); - // Assert.Equal ("Absolute(1)", view.Height.ToString ()); - // expected = @" - //┌────────────────────┐ - //│Hello Worlds │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //└────────────────────┘"; - - // pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); - // Assert.Equal (new (0, 0, 22, 22), pos); - - // view.TextDirection = TextDirection.TopBottom_LeftRight; - // Application.Refresh (); - - // Assert.Equal (new (0, 0, 11, 12), view.Frame); - // Assert.Equal ("Absolute(0)", view.X.ToString ()); - // Assert.Equal ("Absolute(0)", view.Y.ToString ()); - // Assert.Equal ("Absolute(11)", view.Width.ToString ()); - // Assert.Equal ("Absolute(1)", view.Height.ToString ()); - // expected = @" - //┌────────────────────┐ - //│H │ - //│e │ - //│l │ - //│l │ - //│o │ - //│ │ - //│W │ - //│o │ - //│r │ - //│l │ - //│d │ - //│s │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //└────────────────────┘"; - - // pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); - // Assert.Equal (new (0, 0, 22, 22), pos); - - // view.AutoSize = false; - // view.Height = 1; - // Application.Refresh (); - - // Assert.Equal (new (0, 0, 11, 1), view.Frame); - // Assert.Equal ("Absolute(0)", view.X.ToString ()); - // Assert.Equal ("Absolute(0)", view.Y.ToString ()); - // Assert.Equal ("Absolute(11)", view.Width.ToString ()); - // Assert.Equal ("Absolute(1)", view.Height.ToString ()); - // expected = @" - //┌────────────────────┐ - //│HelloWorlds │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //└────────────────────┘"; - - // pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); - // Assert.Equal (new (0, 0, 22, 22), pos); - - // view.PreserveTrailingSpaces = true; - // Application.Refresh (); - - // Assert.Equal (new (0, 0, 11, 1), view.Frame); - // Assert.Equal ("Absolute(0)", view.X.ToString ()); - // Assert.Equal ("Absolute(0)", view.Y.ToString ()); - // Assert.Equal ("Absolute(11)", view.Width.ToString ()); - // Assert.Equal ("Absolute(1)", view.Height.ToString ()); - // expected = @" - //┌────────────────────┐ - //│Hello World │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //└────────────────────┘"; - - // pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); - // Assert.Equal (new (0, 0, 22, 22), pos); - - // view.PreserveTrailingSpaces = false; - // var f = view.Frame; - // view.Width = f.Height; - // view.Height = f.Width; - // view.TextDirection = TextDirection.TopBottom_LeftRight; - // Application.Refresh (); - - // Assert.Equal (new (0, 0, 1, 11), view.Frame); - // Assert.Equal ("Absolute(0)", view.X.ToString ()); - // Assert.Equal ("Absolute(0)", view.Y.ToString ()); - // Assert.Equal ("Absolute(1)", view.Width.ToString ()); - // Assert.Equal ("Absolute(11)", view.Height.ToString ()); - // expected = @" - //┌────────────────────┐ - //│H │ - //│e │ - //│l │ - //│l │ - //│o │ - //│ │ - //│W │ - //│o │ - //│r │ - //│l │ - //│d │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //└────────────────────┘"; - - // pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); - // Assert.Equal (new (0, 0, 22, 22), pos); - - // view.AutoSize = true; - // Application.Refresh (); - - // Assert.Equal (new (0, 0, 1, 12), view.Frame); - // Assert.Equal ("Absolute(0)", view.X.ToString ()); - // Assert.Equal ("Absolute(0)", view.Y.ToString ()); - // Assert.Equal ("Absolute(1)", view.Width.ToString ()); - // Assert.Equal ("Absolute(12)", view.Height.ToString ()); - // expected = @" - //┌────────────────────┐ - //│H │ - //│e │ - //│l │ - //│l │ - //│o │ - //│ │ - //│W │ - //│o │ - //│r │ - //│l │ - //│d │ - //│s │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //│ │ - //└────────────────────┘"; - - // pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); - // Assert.Equal (new (0, 0, 22, 22), pos); - // Application.End (rs); - // } - + [Fact] [AutoInitShutdown] public void GetTextFormatterBoundsSize_GetSizeNeededForText_HotKeySpecifier () @@ -2726,70 +1786,7 @@ Y Assert.Equal (new (0, 0, 20, 1), view.Frame); } - - //[Fact] - //[AutoInitShutdown] - //public void TrySetHeight_ForceValidatePosDim () - //{ - // var top = new View { X = 0, Y = 0, Height = 20 }; - - // var v = new View { Height = Dim.Fill (), ValidatePosDim = true }; - // top.Add (v); - - // Assert.False (v.TrySetHeight (10, out int rHeight)); - // Assert.Equal (10, rHeight); - - // v.Height = Dim.Fill (1); - // Assert.False (v.TrySetHeight (10, out rHeight)); - // Assert.Equal (9, rHeight); - - // v.Height = 0; - // Assert.True (v.TrySetHeight (10, out rHeight)); - // Assert.Equal (10, rHeight); - // Assert.False (v.IsInitialized); - - // var toplevel = new Toplevel (); - // toplevel.Add (top); - // Application.Begin (toplevel); - - // Assert.True (v.IsInitialized); - - // v.Height = 15; - // Assert.True (v.TrySetHeight (5, out rHeight)); - // Assert.Equal (5, rHeight); - //} - - //[Fact] - //[AutoInitShutdown] - //public void TrySetWidth_ForceValidatePosDim () - //{ - // var top = new View { X = 0, Y = 0, Width = 80 }; - - // var v = new View { Width = Dim.Fill (), ValidatePosDim = true }; - // top.Add (v); - - // Assert.False (v.TrySetWidth (70, out int rWidth)); - // Assert.Equal (70, rWidth); - - // v.Width = Dim.Fill (1); - // Assert.False (v.TrySetWidth (70, out rWidth)); - // Assert.Equal (69, rWidth); - - // v.Width = 0; - // Assert.True (v.TrySetWidth (70, out rWidth)); - // Assert.Equal (70, rWidth); - // Assert.False (v.IsInitialized); - - // var toplevel = new Toplevel (); - // toplevel.Add (top); - // Application.Begin (toplevel); - - // Assert.True (v.IsInitialized); - // v.Width = 75; - // Assert.True (v.TrySetWidth (60, out rWidth)); - // Assert.Equal (60, rWidth); - //} - + [Theory] [AutoInitShutdown] [InlineData (true)] @@ -2889,7 +1886,7 @@ Y "; } - Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new (0, 0, width + 2, 6), pos); } @@ -3035,7 +2032,7 @@ Y "; } - Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new (0, 0, 9, height + 2), pos); } }