Cleans up/Refactors View.Subviews (#3962)

* Subview clean up

* New Add/Remove event pattern

* Using Logging

* cleanup

* Subview -> SubView

* Test code cleanup. Killed many warnings.

* Fix tznind feedback

* Refactored AllViewTest helpers

* Moved keyboard tests to parallel

* Moved mouse tests to parallel

* Moved view tests to parallel

* Test code cleanup. Killed many warnings.

* dupe test

* Some mouse tests can't run in parallel because MouseGrabView

* Made SpinnerView more testable

* Moved more tests

* SubViews to IReadOnlyCollection<View>

* SubViews to IReadOnlyCollection<View> 2

* scrollbar tests

* shortcut tests

* Use InternalSubViews vs. _subviews

* Nuked View.IsAdded.
Added View.SuperViewChanged.

* API doc updats

* Unit Test tweak

* Unit Test tweak
This commit is contained in:
Tig
2025-03-08 15:42:17 -07:00
committed by GitHub
parent 85cf6619ed
commit acb5979e6c
226 changed files with 7235 additions and 7188 deletions

View File

@@ -1,5 +1,4 @@
using UnitTests;
using UnitTests;
using Xunit.Abstractions;
using static Terminal.Gui.Application;
@@ -48,7 +47,7 @@ public class DialogTests
Width = width,
Height = 1,
ButtonAlignment = Alignment.Center,
Buttons = [new() { Text = btn1Text }]
Buttons = [new () { Text = btn1Text }]
};
// Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
@@ -76,7 +75,7 @@ public class DialogTests
Width = width,
Height = 1,
ButtonAlignment = Alignment.Fill,
Buttons = [new() { Text = btn1Text }]
Buttons = [new () { Text = btn1Text }]
};
// Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
@@ -103,7 +102,7 @@ public class DialogTests
Width = width,
Height = 1,
ButtonAlignment = Alignment.End,
Buttons = [new() { Text = btn1Text }]
Buttons = [new () { Text = btn1Text }]
};
// Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
@@ -131,7 +130,7 @@ public class DialogTests
Width = width,
Height = 1,
ButtonAlignment = Alignment.Start,
Buttons = [new() { Text = btn1Text }]
Buttons = [new () { Text = btn1Text }]
};
// Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
@@ -180,14 +179,14 @@ public class DialogTests
// Default - Center
(runstate, Dialog dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Center,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
title,
width,
Alignment.Center,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -197,14 +196,14 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Fill,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
title,
width,
Alignment.Fill,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -214,14 +213,14 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.End,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
title,
width,
Alignment.End,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -231,14 +230,14 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Start,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
title,
width,
Alignment.Start,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -275,14 +274,14 @@ public class DialogTests
$"{Glyphs.VLine} yes {Glyphs.RightBracket}{btn2}{btn3}{Glyphs.LeftBracket} never{Glyphs.VLine}";
(runstate, Dialog dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Center,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
title,
width,
Alignment.Center,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
Assert.Equal (new (width, 1), dlg.Frame.Size);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
@@ -293,14 +292,14 @@ public class DialogTests
$"{Glyphs.VLine}{Glyphs.LeftBracket} yes {Glyphs.LeftBracket} no {Glyphs.LeftBracket} maybe {Glyphs.LeftBracket} never {Glyphs.RightBracket}{Glyphs.VLine}";
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Fill,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
title,
width,
Alignment.Fill,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -310,14 +309,14 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.End,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
title,
width,
Alignment.End,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -326,14 +325,14 @@ public class DialogTests
buttonRow = $"{Glyphs.VLine}{btn1}{btn2}{btn3}{Glyphs.LeftBracket} neve{Glyphs.VLine}";
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Start,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
title,
width,
Alignment.Start,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -369,14 +368,14 @@ public class DialogTests
// Default - Center
(runstate, Dialog dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Center,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
title,
width,
Alignment.Center,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -386,14 +385,14 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Fill,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
title,
width,
Alignment.Fill,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -403,14 +402,14 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.End,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
title,
width,
Alignment.End,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -420,14 +419,14 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Start,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
title,
width,
Alignment.Start,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -465,14 +464,14 @@ public class DialogTests
// Default - Center
(runstate, Dialog dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Center,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
title,
width,
Alignment.Center,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -482,14 +481,14 @@ public class DialogTests
Assert.Equal (width, buttonRow.GetColumns ());
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Fill,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
title,
width,
Alignment.Fill,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -499,14 +498,14 @@ public class DialogTests
Assert.Equal (width, buttonRow.GetColumns ());
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.End,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
title,
width,
Alignment.End,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -516,14 +515,14 @@ public class DialogTests
Assert.Equal (width, buttonRow.GetColumns ());
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Start,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
title,
width,
Alignment.Start,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
new Button { Text = btn4Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -550,11 +549,11 @@ public class DialogTests
d.SetBufferSize (width, 1);
(runstate, Dialog dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Center,
new Button { Text = btnText }
);
title,
width,
Alignment.Center,
new Button { Text = btnText }
);
// Center
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
@@ -567,11 +566,11 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Fill,
new Button { Text = btnText }
);
title,
width,
Alignment.Fill,
new Button { Text = btnText }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -582,11 +581,11 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.End,
new Button { Text = btnText }
);
title,
width,
Alignment.End,
new Button { Text = btnText }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -597,11 +596,11 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Start,
new Button { Text = btnText }
);
title,
width,
Alignment.Start,
new Button { Text = btnText }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -614,11 +613,11 @@ public class DialogTests
d.SetBufferSize (width, 1);
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Center,
new Button { Text = btnText }
);
title,
width,
Alignment.Center,
new Button { Text = btnText }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -629,11 +628,11 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Fill,
new Button { Text = btnText }
);
title,
width,
Alignment.Fill,
new Button { Text = btnText }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -644,11 +643,11 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.End,
new Button { Text = btnText }
);
title,
width,
Alignment.End,
new Button { Text = btnText }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -659,11 +658,11 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Start,
new Button { Text = btnText }
);
title,
width,
Alignment.Start,
new Button { Text = btnText }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -695,13 +694,13 @@ public class DialogTests
d.SetBufferSize (buttonRow.Length, 3);
(runstate, Dialog dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Center,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text }
);
title,
width,
Alignment.Center,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -711,13 +710,13 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Fill,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text }
);
title,
width,
Alignment.Fill,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -727,13 +726,13 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.End,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text }
);
title,
width,
Alignment.End,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -743,13 +742,13 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Start,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text }
);
title,
width,
Alignment.Start,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -779,12 +778,12 @@ public class DialogTests
d.SetBufferSize (buttonRow.Length, 3);
(runstate, Dialog dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Center,
new Button { Text = btn1Text },
new Button { Text = btn2Text }
);
title,
width,
Alignment.Center,
new Button { Text = btn1Text },
new Button { Text = btn2Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -794,12 +793,12 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Fill,
new Button { Text = btn1Text },
new Button { Text = btn2Text }
);
title,
width,
Alignment.Fill,
new Button { Text = btn1Text },
new Button { Text = btn2Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -809,12 +808,12 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.End,
new Button { Text = btn1Text },
new Button { Text = btn2Text }
);
title,
width,
Alignment.End,
new Button { Text = btn1Text },
new Button { Text = btn2Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -824,12 +823,12 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Start,
new Button { Text = btn1Text },
new Button { Text = btn2Text }
);
title,
width,
Alignment.Start,
new Button { Text = btn1Text },
new Button { Text = btn2Text }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -863,8 +862,8 @@ public class DialogTests
Button button1, button2;
// Default (Center)
button1 = new() { Text = btn1Text };
button2 = new() { Text = btn2Text };
button1 = new () { Text = btn1Text };
button2 = new () { Text = btn2Text };
(runstate, dlg) = BeginButtonTestDialog (title, width, Alignment.Center, button1, button2);
button1.Visible = false;
RunIteration (ref runstate, firstIteration);
@@ -875,8 +874,8 @@ public class DialogTests
// Justify
Assert.Equal (width, buttonRow.Length);
button1 = new() { Text = btn1Text };
button2 = new() { Text = btn2Text };
button1 = new () { Text = btn1Text };
button2 = new () { Text = btn2Text };
(runstate, dlg) = BeginButtonTestDialog (title, width, Alignment.Fill, button1, button2);
button1.Visible = false;
RunIteration (ref runstate, firstIteration);
@@ -887,8 +886,8 @@ public class DialogTests
// Right
Assert.Equal (width, buttonRow.Length);
button1 = new() { Text = btn1Text };
button2 = new() { Text = btn2Text };
button1 = new () { Text = btn1Text };
button2 = new () { Text = btn2Text };
(runstate, dlg) = BeginButtonTestDialog (title, width, Alignment.End, button1, button2);
button1.Visible = false;
RunIteration (ref runstate, firstIteration);
@@ -898,8 +897,8 @@ public class DialogTests
// Left
Assert.Equal (width, buttonRow.Length);
button1 = new() { Text = btn1Text };
button2 = new() { Text = btn2Text };
button1 = new () { Text = btn1Text };
button2 = new () { Text = btn2Text };
(runstate, dlg) = BeginButtonTestDialog (title, width, Alignment.Start, button1, button2);
button1.Visible = false;
RunIteration (ref runstate, firstIteration);
@@ -1079,30 +1078,30 @@ public class DialogTests
string expected = null;
btn1.Accepting += (s, e) =>
{
btn2 = new () { Text = "Show Sub" };
btn3 = new () { Text = "Close" };
btn3.Accepting += (s, e) => RequestStop ();
{
btn2 = new () { Text = "Show Sub" };
btn3 = new () { Text = "Close" };
btn3.Accepting += (s, e) => RequestStop ();
btn2.Accepting += (s, e) =>
{
// Don't test MessageBox in Dialog unit tests!
var subBtn = new Button { Text = "Ok", IsDefault = true };
var subDlg = new Dialog { Text = "ya", Width = 20, Height = 5, Buttons = [subBtn] };
subBtn.Accepting += (s, e) => RequestStop (subDlg);
Run (subDlg);
};
btn2.Accepting += (s, e) =>
{
// Don't test MessageBox in Dialog unit tests!
var subBtn = new Button { Text = "Ok", IsDefault = true };
var subDlg = new Dialog { Text = "ya", Width = 20, Height = 5, Buttons = [subBtn] };
subBtn.Accepting += (s, e) => RequestStop (subDlg);
Run (subDlg);
};
var dlg = new Dialog
{
Buttons = [btn2, btn3],
Width = Dim.Percent (85),
Height = Dim.Percent (85)
};
var dlg = new Dialog
{
Buttons = [btn2, btn3],
Width = Dim.Percent (85),
Height = Dim.Percent (85)
};
Run (dlg);
dlg.Dispose ();
};
Run (dlg);
dlg.Dispose ();
};
var btn =
$"{Glyphs.LeftBracket}{Glyphs.LeftDefaultIndicator} Ok {Glyphs.RightDefaultIndicator}{Glyphs.RightBracket}";
@@ -1116,8 +1115,8 @@ public class DialogTests
switch (iterations)
{
case 0:
Top.SetNeedsLayout();
Top.SetNeedsDraw();
Top.SetNeedsLayout ();
Top.SetNeedsDraw ();
LayoutAndDraw ();
break;
@@ -1147,7 +1146,7 @@ public class DialogTests
LayoutAndDraw ();
DriverAssert.AssertDriverContentsWithFrameAre (
@$"
@$"
┌───────────────────────┐
│ ┌──────────────────┐ │
│ │ya │ │
@@ -1156,8 +1155,8 @@ public class DialogTests
│ └──────────────────┘ │
│{Glyphs.LeftBracket} Show Sub {Glyphs.RightBracket} {Glyphs.LeftBracket} Close {Glyphs.RightBracket} │
└───────────────────────┘",
_output
);
_output
);
Assert.False (Top.NewKeyDownEvent (Key.Enter));
@@ -1250,14 +1249,14 @@ public class DialogTests
Assert.Equal (new (expected, expected), d.Frame.Location);
DriverAssert.AssertDriverContentsWithFrameAre (
@"
@"
┌───┐
│ │
│ │
│ │
└───┘",
_output
);
_output
);
d.Dispose ();
}
@@ -1281,11 +1280,11 @@ public class DialogTests
d.SetBufferSize (buttonRow.Length, 10);
(runstate, Dialog dlg) = BeginButtonTestDialog (
title,
width,
Alignment.Center,
new Button { Text = btnText }
);
title,
width,
Alignment.Center,
new Button { Text = btnText }
);
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -1376,7 +1375,7 @@ public class DialogTests
RunState runState = Begin (dlg);
dlg.SetNeedsDraw();
dlg.SetNeedsDraw ();
dlg.SetNeedsLayout ();
dlg.Layout ();
dlg.Draw ();

View File

@@ -1,6 +1,5 @@
using System.Text;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities;
using UnitTests;
using UICatalog;
using UnitTests;
using Xunit.Abstractions;
@@ -19,7 +18,7 @@ public class MessageBoxTests
var iteration = 0;
int btnAcceptCount = 0;
var btnAcceptCount = 0;
Application.Iteration += (s, a) =>
{
@@ -37,7 +36,7 @@ public class MessageBoxTests
// Tab to btn2
Application.RaiseKeyDownEvent (Key.Tab);
Button btn = Application.Navigation!.GetFocused () as Button;
var btn = Application.Navigation!.GetFocused () as Button;
btn.Accepting += (sender, e) => { btnAcceptCount++; };
@@ -102,7 +101,7 @@ public class MessageBoxTests
var iteration = 0;
int btnAcceptCount = 0;
var btnAcceptCount = 0;
Application.Iteration += (s, a) =>
{
@@ -120,7 +119,7 @@ public class MessageBoxTests
// Tab to btn2
Application.RaiseKeyDownEvent (Key.Tab);
Button btn = Application.Navigation!.GetFocused () as Button;
var btn = Application.Navigation!.GetFocused () as Button;
btn.Accepting += (sender, e) => { btnAcceptCount++; };
@@ -138,7 +137,6 @@ public class MessageBoxTests
Assert.Equal (1, result);
Assert.Equal (1, btnAcceptCount);
}
[Theory]
@@ -161,7 +159,7 @@ public class MessageBoxTests
Dialog.DefaultShadow = ShadowStyle.None;
Button.DefaultShadow = ShadowStyle.None;
Rectangle mbFrame = Rectangle.Empty;
var mbFrame = Rectangle.Empty;
Application.Iteration += (s, a) =>
{
@@ -224,30 +222,30 @@ public class MessageBoxTests
Application.LayoutAndDraw ();
DriverAssert.AssertDriverContentsWithFrameAre (
@"
@"
╔════════════════╗
║ ff ff ff ff ff ║
║ ⟦► btn ◄⟧║
╚════════════════╝",
_output
);
_output
);
Application.RequestStop ();
// Really long text
MessageBox.Query (string.Empty, new string ('f', 500), 0, false, "btn");
MessageBox.Query (string.Empty, new ('f', 500), 0, false, "btn");
}
else if (iterations == 2)
{
Application.LayoutAndDraw ();
DriverAssert.AssertDriverContentsWithFrameAre (
@"
@"
╔════════════════╗
║ffffffffffffffff║
║ ⟦► btn ◄⟧║
╚════════════════╝",
_output
);
_output
);
Application.RequestStop ();
}
};
@@ -296,7 +294,7 @@ public class MessageBoxTests
Application.LayoutAndDraw ();
DriverAssert.AssertDriverContentsWithFrameAre (
@"
@"
╔══════════════╗
║ff ff ff ff ff║
║ff ff ff ff ff║
@@ -304,19 +302,19 @@ public class MessageBoxTests
║ ff ff ║
║ ⟦► btn ◄⟧║
╚══════════════╝",
_output
);
_output
);
Application.RequestStop ();
// Really long text
MessageBox.Query (string.Empty, new string ('f', 500), 0, true, "btn");
MessageBox.Query (string.Empty, new ('f', 500), 0, true, "btn");
}
else if (iterations == 2)
{
Application.LayoutAndDraw ();
DriverAssert.AssertDriverContentsWithFrameAre (
@$"
@"
╔════════════════╗
║ffffffffffffffff║
║ffffffffffffffff║
@@ -326,8 +324,8 @@ public class MessageBoxTests
║ffffffffffffffff║
║fffffff⟦► btn ◄⟧║
╚════════════════╝",
_output
);
_output
);
Application.RequestStop ();
}
};
@@ -463,8 +461,8 @@ public class MessageBoxTests
if (iterations == 0)
{
MessageBox.Query (
title: "",
message: UICatalog.UICatalogApp.GetAboutBoxMessage (),
"",
UICatalogApp.GetAboutBoxMessage (),
wrapMessage: false,
buttons: "_Ok"
);
@@ -475,23 +473,23 @@ public class MessageBoxTests
{
Application.LayoutAndDraw ();
string expectedText = """
UI Catalog: A comprehensive sample library and test app for
_______ _ _ _____ _
|__ __| (_) | | / ____| (_)
| | ___ _ __ _ __ ___ _ _ __ __ _| || | __ _ _ _
| |/ _ \ '__| '_ ` _ \| | '_ \ / _` | || | |_ | | | | |
| | __/ | | | | | | | | | | | (_| | || |__| | |_| | |
|_|\___|_| |_| |_| |_|_|_| |_|\__,_|_(_)_____|\__,_|_|
v2 - Pre-Alpha
Ok
""";
var expectedText = """
UI Catalog: A comprehensive sample library and test app for
_______ _ _ _____ _
|__ __| (_) | | / ____| (_)
| | ___ _ __ _ __ ___ _ _ __ __ _| || | __ _ _ _
| |/ _ \ '__| '_ ` _ \| | '_ \ / _` | || | |_ | | | | |
| | __/ | | | | | | | | | | | (_| | || |__| | |_| | |
|_|\___|_| |_| |_| |_|_|_| |_|\__,_|_(_)_____|\__,_|_|
v2 - Pre-Alpha
Ok
""";
DriverAssert.AssertDriverContentsAre (expectedText, _output);
@@ -506,11 +504,10 @@ public class MessageBoxTests
}
[Theory]
[SetupFakeDriver]
[MemberData (nameof (AcceptingKeys))]
public void Button_IsDefault_True_Return_His_Index_On_Accepting (Key key)
{
Application.Init ();
Application.Init (new FakeDriver ());
Application.Iteration += (_, _) => Assert.True (Application.RaiseKeyDownEvent (key));
int res = MessageBox.Query ("hey", "IsDefault", "Yes", "No");

View File

@@ -462,7 +462,7 @@ public class WizardTests ()
var wizard = new Wizard { Title = title, Width = width, Height = height };
wizard.AddStep (new() { Title = stepTitle });
//wizard.LayoutSubviews ();
//wizard.LayoutSubViews ();
var firstIteration = false;
RunState runstate = Application.Begin (wizard);
Application.RunIteration (ref runstate, firstIteration);