AutoSize in comments i gone too.

This commit is contained in:
Tig
2024-05-03 15:00:48 -06:00
parent e6b6f77f9a
commit 3e1025897b
9 changed files with 2 additions and 408 deletions

View File

@@ -32,219 +32,6 @@ public class ButtonTests (ITestOutputHelper output)
view.Dispose ();
}
// // BUGBUG: This test is NOT a unit test and needs to be broken apart into
// // more specific tests (e.g. it tests Checkbox as well as Button)
// [Fact]
// [AutoInitShutdown]
// public void AutoSize_False_With_Fixed_Width ()
// {
// var tab = new View ();
// var lblWidth = 8;
// var view = new View
// {
// Y = 1,
// Width = lblWidth,
// Height = 1,
// TextAlignment = TextAlignment.Right,
// Text = "Find:"
// };
// tab.Add (view);
// var txtToFind = new TextField
// {
// X = Pos.Right (view) + 1, Y = Pos.Top (view), Width = 20, Text = "Testing buttons."
// };
// tab.Add (txtToFind);
// var btnFindNext = new Button
// {
// X = Pos.Right (txtToFind) + 1,
// Y = Pos.Top (view),
// Width = 20,
// Enabled = !string.IsNullOrEmpty (txtToFind.Text),
// TextAlignment = TextAlignment.Centered,
// IsDefault = true,
// Text = "Find _Next"
// };
// tab.Add (btnFindNext);
// var btnFindPrevious = new Button
// {
// X = Pos.Right (txtToFind) + 1,
// Y = Pos.Top (btnFindNext) + 1,
// Width = 20,
// Enabled = !string.IsNullOrEmpty (txtToFind.Text),
// TextAlignment = TextAlignment.Centered,
// Text = "Find _Previous"
// };
// tab.Add (btnFindPrevious);
// var btnCancel = new Button
// {
// X = Pos.Right (txtToFind) + 1,
// Y = Pos.Top (btnFindPrevious) + 2,
// Width = 20,
// TextAlignment = TextAlignment.Centered,
// Text = "Cancel"
// };
// tab.Add (btnCancel);
// var ckbMatchCase = new CheckBox
// {
// X = 0,
// Y = Pos.Top (txtToFind) + 2,
// Checked = true, Text = "Match c_ase"
// };
// tab.Add (ckbMatchCase);
// Assert.Equal (new (0, 3, 10, 1), ckbMatchCase.Frame);
// var ckbMatchWholeWord = new CheckBox
// {
// X = 0,
// Y = Pos.Top (ckbMatchCase) + 1,
// Checked = false,
// Text = "Match _whole word"
// };
// tab.Add (ckbMatchWholeWord);
// var tabView = new TabView { Width = Dim.Fill (), Height = Dim.Fill () };
// tabView.AddTab (new () { DisplayText = "Find", View = tab }, true);
// var win = new Window { Width = Dim.Fill (), Height = Dim.Fill () };
// tab.Width = view.Width + txtToFind.Width + btnFindNext.Width + 2;
// tab.Height = btnFindNext.Height + btnFindPrevious.Height + btnCancel.Height + 4;
// win.Add (tabView);
// var top = new Toplevel ();
// top.Add (win);
// Application.Begin (top);
// ((FakeDriver)Application.Driver).SetBufferSize (54, 11);
// Assert.Equal (new (0, 3, 10, 1), ckbMatchCase.Frame);
// Assert.Equal (new (0, 0, 54, 11), win.Frame);
// Assert.Equal (new (0, 0, 52, 9), tabView.Frame);
// Assert.Equal (new (0, 0, 50, 7), tab.Frame);
// Assert.Equal (new (0, 1, 8, 1), view.Frame);
// Assert.Equal (new (9, 1, 20, 1), txtToFind.Frame);
// Assert.Equal (0, txtToFind.ScrollOffset);
// Assert.Equal (16, txtToFind.CursorPosition);
// Assert.Equal (new (30, 1, 20, 1), btnFindNext.Frame);
// Assert.Equal (new (30, 2, 20, 1), btnFindPrevious.Frame);
// Assert.Equal (new (30, 4, 20, 1), btnCancel.Frame);
// // Assert.Equal (new (0, 3, 12, 1), ckbMatchCase.Frame);
// // Assert.Equal (new (0, 4, 18, 1), ckbMatchWholeWord.Frame);
// var btn1 =
// $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} Find Next {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}";
// var btn2 = $"{CM.Glyphs.LeftBracket} Find Previous {CM.Glyphs.RightBracket}";
// var btn3 = $"{CM.Glyphs.LeftBracket} Cancel {CM.Glyphs.RightBracket}";
// var expected = @$"
//┌────────────────────────────────────────────────────┐
//│╭────╮ │
//││Find│ │
//││ ╰─────────────────────────────────────────────╮│
//││ ││
//││ Find: Testing buttons. {btn1} ││
//││ {btn2} ││
//││{CM.Glyphs.Checked} Match case ││
//││{CM.Glyphs.UnChecked} Match whole word {btn3} ││
//│└──────────────────────────────────────────────────┘│
//└────────────────────────────────────────────────────┘
//";
// TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
// view.Dispose ();
// }
// [Fact]
// [AutoInitShutdown]
// public void AutoSize_Stays_True_AnchorEnd ()
// {
// var btn = new Button { Y = Pos.Center (), Text = "Say Hello 你", AutoSize = true };
// var btnTxt = $"{CM.Glyphs.LeftBracket} {btn.Text} {CM.Glyphs.RightBracket}";
// btn.X = Pos.AnchorEnd (0) - Pos.Function (() => btn.TextFormatter.Text.GetColumns ());
// btn.X = Pos.AnchorEnd (0) - Pos.Function (() => btn.TextFormatter.Text.GetColumns ());
// var win = new Window { Width = Dim.Fill (), Height = Dim.Fill () };
// win.Add (btn);
// var top = new Toplevel ();
// top.Add (win);
// Assert.True (btn.AutoSize);
// Application.Begin (top);
// ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
// var expected = @$"
//┌────────────────────────────┐
//│ │
//│ {btnTxt}│
//│ │
//└────────────────────────────┘
//";
// TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
// Assert.True (btn.AutoSize);
// btn.Text = "Say Hello 你 changed";
// btnTxt = $"{CM.Glyphs.LeftBracket} {btn.Text} {CM.Glyphs.RightBracket}";
// Assert.True (btn.AutoSize);
// Application.Refresh ();
// expected = @$"
//┌────────────────────────────┐
//│ │
//│ {btnTxt}│
//│ │
//└────────────────────────────┘
//";
// TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
// top.Dispose ();
// }
// [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 () };
// win.Add (btn);
// var top = new Toplevel ();
// top.Add (win);
// Assert.True (btn.AutoSize);
// btn.Text = "Say Hello 你";
// Assert.True (btn.AutoSize);
// Application.Begin (top);
// ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
// var expected = @$"
//┌────────────────────────────┐
//│ │
//│ {CM.Glyphs.LeftBracket} Say Hello 你 {CM.Glyphs.RightBracket} │
//│ │
//└────────────────────────────┘
//";
// TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
// top.Dispose ();
// }
[Theory]
[InlineData ("01234", 0, 0, 0, 0)]
[InlineData ("01234", 1, 0, 1, 0)]