From bdb5fb283eef11d2929df9a68d695ee711bb2cee Mon Sep 17 00:00:00 2001 From: Tig Kindel Date: Sat, 6 Jan 2024 09:58:10 -0700 Subject: [PATCH] Moved AutoSize specific tests out of Pos/Dim tests --- Terminal.Gui/View/Layout/ViewLayout.cs | 10 +- UnitTests/View/Layout/AutoSizeTests.cs | 705 +++++++++++++++++++++++++ UnitTests/View/Layout/DimTests.cs | 473 +---------------- UnitTests/View/Layout/PosTests.cs | 280 ---------- 4 files changed, 720 insertions(+), 748 deletions(-) diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs index bd658eee3..3f8e0bb6f 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -61,10 +61,12 @@ public partial class View { get => _frame; set { _frame = new Rect (value.X, value.Y, Math.Max (value.Width, 0), Math.Max (value.Height, 0)); - _x = _frame.X; - _y = _frame.Y; - _width = _frame.Width; - _height = _frame.Height; + if (LayoutStyle == LayoutStyle.Absolute) { + _x = _frame.X; + _y = _frame.Y; + _width = _frame.Width; + _height = _frame.Height; + } if (IsInitialized || LayoutStyle == LayoutStyle.Absolute) { LayoutFrames (); TextFormatter.Size = GetTextFormatterSizeNeededForTextAndHotKey (); diff --git a/UnitTests/View/Layout/AutoSizeTests.cs b/UnitTests/View/Layout/AutoSizeTests.cs index 056e68408..2b03d61da 100644 --- a/UnitTests/View/Layout/AutoSizeTests.cs +++ b/UnitTests/View/Layout/AutoSizeTests.cs @@ -1474,4 +1474,709 @@ Y Application.End (rs); } + + readonly string [] expecteds = new string [21] { + @" +┌────────────────────┐ +│View with long text │ +│ │ +└────────────────────┘", + @" +┌────────────────────┐ +│View with long text │ +│Label 0 │ +│Label 0 │ +└────────────────────┘", + @" +┌────────────────────┐ +│View with long text │ +│Label 0 │ +│Label 1 │ +│Label 1 │ +└────────────────────┘", + @" +┌────────────────────┐ +│View with long text │ +│Label 0 │ +│Label 1 │ +│Label 2 │ +│Label 2 │ +└────────────────────┘", + @" +┌────────────────────┐ +│View with long text │ +│Label 0 │ +│Label 1 │ +│Label 2 │ +│Label 3 │ +│Label 3 │ +└────────────────────┘", + @" +┌────────────────────┐ +│View with long text │ +│Label 0 │ +│Label 1 │ +│Label 2 │ +│Label 3 │ +│Label 4 │ +│Label 4 │ +└────────────────────┘", + @" +┌────────────────────┐ +│View with long text │ +│Label 0 │ +│Label 1 │ +│Label 2 │ +│Label 3 │ +│Label 4 │ +│Label 5 │ +│Label 5 │ +└────────────────────┘", + @" +┌────────────────────┐ +│View with long text │ +│Label 0 │ +│Label 1 │ +│Label 2 │ +│Label 3 │ +│Label 4 │ +│Label 5 │ +│Label 6 │ +│Label 6 │ +└────────────────────┘", + @" +┌────────────────────┐ +│View with long text │ +│Label 0 │ +│Label 1 │ +│Label 2 │ +│Label 3 │ +│Label 4 │ +│Label 5 │ +│Label 6 │ +│Label 7 │ +│Label 7 │ +└────────────────────┘", + @" +┌────────────────────┐ +│View with long text │ +│Label 0 │ +│Label 1 │ +│Label 2 │ +│Label 3 │ +│Label 4 │ +│Label 5 │ +│Label 6 │ +│Label 7 │ +│Label 8 │ +│Label 8 │ +└────────────────────┘", + @" +┌────────────────────┐ +│View with long text │ +│Label 0 │ +│Label 1 │ +│Label 2 │ +│Label 3 │ +│Label 4 │ +│Label 5 │ +│Label 6 │ +│Label 7 │ +│Label 8 │ +│Label 9 │ +│Label 9 │ +└────────────────────┘", + @" +┌────────────────────┐ +│View with long text │ +│Label 0 │ +│Label 1 │ +│Label 2 │ +│Label 3 │ +│Label 4 │ +│Label 5 │ +│Label 6 │ +│Label 7 │ +│Label 8 │ +│Label 9 │ +│Label 10 │ +│Label 10 │ +└────────────────────┘", + @" +┌────────────────────┐ +│View with long text │ +│Label 0 │ +│Label 1 │ +│Label 2 │ +│Label 3 │ +│Label 4 │ +│Label 5 │ +│Label 6 │ +│Label 7 │ +│Label 8 │ +│Label 9 │ +│Label 10 │ +│Label 11 │ +│Label 11 │ +└────────────────────┘", + @" +┌────────────────────┐ +│View with long text │ +│Label 0 │ +│Label 1 │ +│Label 2 │ +│Label 3 │ +│Label 4 │ +│Label 5 │ +│Label 6 │ +│Label 7 │ +│Label 8 │ +│Label 9 │ +│Label 10 │ +│Label 11 │ +│Label 12 │ +│Label 12 │ +└────────────────────┘", + @" +┌────────────────────┐ +│View with long text │ +│Label 0 │ +│Label 1 │ +│Label 2 │ +│Label 3 │ +│Label 4 │ +│Label 5 │ +│Label 6 │ +│Label 7 │ +│Label 8 │ +│Label 9 │ +│Label 10 │ +│Label 11 │ +│Label 12 │ +│Label 13 │ +│Label 13 │ +└────────────────────┘", + @" +┌────────────────────┐ +│View with long text │ +│Label 0 │ +│Label 1 │ +│Label 2 │ +│Label 3 │ +│Label 4 │ +│Label 5 │ +│Label 6 │ +│Label 7 │ +│Label 8 │ +│Label 9 │ +│Label 10 │ +│Label 11 │ +│Label 12 │ +│Label 13 │ +│Label 14 │ +│Label 14 │ +└────────────────────┘", + @" +┌────────────────────┐ +│View with long text │ +│Label 0 │ +│Label 1 │ +│Label 2 │ +│Label 3 │ +│Label 4 │ +│Label 5 │ +│Label 6 │ +│Label 7 │ +│Label 8 │ +│Label 9 │ +│Label 10 │ +│Label 11 │ +│Label 12 │ +│Label 13 │ +│Label 14 │ +│Label 15 │ +│Label 15 │ +└────────────────────┘", + @" +┌────────────────────┐ +│View with long text │ +│Label 0 │ +│Label 1 │ +│Label 2 │ +│Label 3 │ +│Label 4 │ +│Label 5 │ +│Label 6 │ +│Label 7 │ +│Label 8 │ +│Label 9 │ +│Label 10 │ +│Label 11 │ +│Label 12 │ +│Label 13 │ +│Label 14 │ +│Label 15 │ +│Label 16 │ +│Label 16 │ +└────────────────────┘", + @" +┌────────────────────┐ +│View with long text │ +│Label 0 │ +│Label 1 │ +│Label 2 │ +│Label 3 │ +│Label 4 │ +│Label 5 │ +│Label 6 │ +│Label 7 │ +│Label 8 │ +│Label 9 │ +│Label 10 │ +│Label 11 │ +│Label 12 │ +│Label 13 │ +│Label 14 │ +│Label 15 │ +│Label 16 │ +│Label 17 │ +│Label 17 │ +└────────────────────┘", + @" +┌────────────────────┐ +│View with long text │ +│Label 0 │ +│Label 1 │ +│Label 2 │ +│Label 3 │ +│Label 4 │ +│Label 5 │ +│Label 6 │ +│Label 7 │ +│Label 8 │ +│Label 9 │ +│Label 10 │ +│Label 11 │ +│Label 12 │ +│Label 13 │ +│Label 14 │ +│Label 15 │ +│Label 16 │ +│Label 17 │ +│Label 18 │ +│Label 18 │ +└────────────────────┘", + @" +┌────────────────────┐ +│View with long text │ +│Label 0 │ +│Label 1 │ +│Label 2 │ +│Label 3 │ +│Label 4 │ +│Label 5 │ +│Label 6 │ +│Label 7 │ +│Label 8 │ +│Label 9 │ +│Label 10 │ +│Label 11 │ +│Label 12 │ +│Label 13 │ +│Label 14 │ +│Label 15 │ +│Label 16 │ +│Label 17 │ +│Label 18 │ +│Label 19 │ +│Label 19 │ +└────────────────────┘" + }; + + + [Fact] + [AutoInitShutdown] + public void AutoSize_Dim_Add_Operator_With_Text () + { + var top = Application.Top; + + var view = new View ("View with long text") { X = 0, Y = 0, Width = 20, Height = 1 }; + var field = new TextField { X = 0, Y = Pos.Bottom (view), Width = 20 }; + var count = 0; + var listLabels = new List