Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CheckBox: AutoSize = true causes control to not be visible #1797

Closed
tig opened this issue Jun 13, 2022 · 0 comments · Fixed by #1807
Closed

CheckBox: AutoSize = true causes control to not be visible #1797

tig opened this issue Jun 13, 2022 · 0 comments · Fixed by #1807
Labels

Comments

@tig
Copy link
Collaborator

tig commented Jun 13, 2022

This unit test should be added to CheckBoxTests.cs:

		[Fact, AutoInitShutdown]
		public void AutoSize_StaysVisible ()
		{

			var checkBox = new CheckBox () {
				X = 1,
				Y = Pos.Center (),
				Text = "Check this out 你"
			};
			var win = new Window () {
				Width = Dim.Fill (),
				Height = Dim.Fill (),
				Title = "Test Demo 你"
			};
			win.Add (checkBox);
			Application.Top.Add (win);

			Assert.False (checkBox.IsInitialized);

			var runstate = Application.Begin (Application.Top);
			((FakeDriver)Application.Driver).SetBufferSize (30, 5);

			Assert.True (checkBox.IsInitialized);
			Assert.Equal ("Check this out 你", checkBox.Text);

			var expected = @"
┌ Test Demo 你 ──────────────┐
│                            │
│ ╴ Check this out 你        │
│                            │
└────────────────────────────┘
";

			// Positive test
			var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);

			// Negative test
			checkBox.AutoSize = true;
			bool first = false;
			Application.RunMainLoopIteration (ref runstate, true, ref first);

			GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
		}

Output as of now:

 Terminal.Gui.Views.CheckboxTests.AutoSize_StaysVisible
   Source: CheckboxTests.cs line 72
   Duration: 106 ms

  Message: 
    Assert.Equal() Failure
                                      ↓ (pos 63)
    Expected: ···                │\n│ ╴ Check this out 你        │\n│            ···
    Actual:   ···                │\n│                            │\n│           ···
                                      ↑ (pos 63)

  Stack Trace: 
    GraphViewTests.AssertDriverContentsWithFrameAre(String expectedLook, ITestOutputHelper output) line 208
    CheckboxTests.AutoSize_StaysVisible() line 112

  Standard Output: 
    Expected:
    ┌ Test Demo 你 ──────────────┐
    │                            │
    │ ╴ Check this out 你        │
    │                            │
    └────────────────────────────┘
    But Was:
    ┌ Test Demo 你 ──────────────┐
    │                            │
    │ ╴ Check this out 你        │
    │                            │
    └────────────────────────────┘
    Expected:
    ┌ Test Demo 你 ──────────────┐
    │                            │
    │ ╴ Check this out 你        │
    │                            │
    └────────────────────────────┘
    But Was:
    ┌ Test Demo 你 ──────────────┐
    │                            │
    │                            │
    │                            │
    └────────────────────────────┘
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant