From bcc3034db7d25cff599ab9d470afd866315dadda Mon Sep 17 00:00:00 2001 From: BDisp Date: Wed, 6 Jul 2022 02:04:24 +0100 Subject: [PATCH] Fixes #1812. AutoSize stays true with empty text. (#1824) * Fixes #1812. AutoSize stays true with empty text. * Added some more features and bug fixes. * Reformat files. --- UnitTests/ButtonTests.cs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/UnitTests/ButtonTests.cs b/UnitTests/ButtonTests.cs index b7bc55685..43808ea81 100644 --- a/UnitTests/ButtonTests.cs +++ b/UnitTests/ButtonTests.cs @@ -277,6 +277,42 @@ namespace Terminal.Gui.Views { Assert.Equal (new Rect (0, 0, 30, 5), pos); } + [Fact, AutoInitShutdown] + public void AutoSize_Stays_True_With_EmptyText () + { + var btn = new Button () { + X = Pos.Center (), + Y = Pos.Center (), + AutoSize = true + }; + + var win = new Window () { + Width = Dim.Fill (), + Height = Dim.Fill (), + Title = "Test Demo 你" + }; + win.Add (btn); + Application.Top.Add (win); + + Assert.True (btn.AutoSize); + + btn.Text = "Say Hello 你"; + + Assert.True (btn.AutoSize); + + Application.Begin (Application.Top); + ((FakeDriver)Application.Driver).SetBufferSize (30, 5); + var expected = @" +┌ Test Demo 你 ──────────────┐ +│ │ +│ [ Say Hello 你 ] │ +│ │ +└────────────────────────────┘ +"; + + GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + } + [Fact, AutoInitShutdown] public void AutoSize_Stays_True_Center () {