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,6 +1,5 @@
using System.Text.RegularExpressions;
using UnitTests;
using UnitTests;
using Xunit.Abstractions;
namespace Terminal.Gui.TextTests;
@@ -26,87 +25,87 @@ public class AutocompleteTests (ITestOutputHelper output)
for (var i = 0; i < 7; i++)
{
Assert.True (tv.NewKeyDownEvent (Key.CursorRight));
top.SetNeedsDraw();
top.SetNeedsDraw ();
Application.RunIteration (ref rs);
if (i < 4 || i > 5)
{
DriverAssert.AssertDriverContentsWithFrameAre (
@"
@"
This a long line and against TextView.",
output
);
output
);
}
else
{
DriverAssert.AssertDriverContentsWithFrameAre (
@"
@"
This a long line and against TextView.
and
against ",
output
);
output
);
}
}
Assert.True (
tv.NewMouseEvent (
new() { Position = new (6, 0), Flags = MouseFlags.Button1Pressed }
new () { Position = new (6, 0), Flags = MouseFlags.Button1Pressed }
)
);
top.SetNeedsDraw ();
Application.RunIteration (ref rs);
DriverAssert.AssertDriverContentsWithFrameAre (
@"
@"
This a long line and against TextView.
and
against ",
output
);
output
);
Assert.True (tv.NewKeyDownEvent (Key.G));
top.SetNeedsDraw ();
Application.RunIteration (ref rs);
DriverAssert.AssertDriverContentsWithFrameAre (
@"
@"
This ag long line and against TextView.
against ",
output
);
output
);
Assert.True (tv.NewKeyDownEvent (Key.CursorLeft));
top.SetNeedsDraw ();
Application.RunIteration (ref rs);
DriverAssert.AssertDriverContentsWithFrameAre (
@"
@"
This ag long line and against TextView.
against ",
output
);
output
);
Assert.True (tv.NewKeyDownEvent (Key.CursorLeft));
top.SetNeedsDraw ();
Application.RunIteration (ref rs);
DriverAssert.AssertDriverContentsWithFrameAre (
@"
@"
This ag long line and against TextView.
against ",
output
);
output
);
Assert.True (tv.NewKeyDownEvent (Key.CursorLeft));
top.SetNeedsDraw ();
Application.RunIteration (ref rs);
DriverAssert.AssertDriverContentsWithFrameAre (
@"
@"
This ag long line and against TextView.",
output
);
output
);
for (var i = 0; i < 3; i++)
{
@@ -115,11 +114,11 @@ This ag long line and against TextView.",
Application.RunIteration (ref rs);
DriverAssert.AssertDriverContentsWithFrameAre (
@"
@"
This ag long line and against TextView.
against ",
output
);
output
);
}
Assert.True (tv.NewKeyDownEvent (Key.Backspace));
@@ -127,33 +126,33 @@ This ag long line and against TextView.
Application.RunIteration (ref rs);
DriverAssert.AssertDriverContentsWithFrameAre (
@"
@"
This a long line and against TextView.
and
against ",
output
);
output
);
Assert.True (tv.NewKeyDownEvent (Key.N));
top.SetNeedsDraw ();
Application.RunIteration (ref rs);
DriverAssert.AssertDriverContentsWithFrameAre (
@"
@"
This an long line and against TextView.
and ",
output
);
output
);
Assert.True (tv.NewKeyDownEvent (Key.CursorRight));
top.SetNeedsDraw ();
Application.RunIteration (ref rs);
DriverAssert.AssertDriverContentsWithFrameAre (
@"
@"
This an long line and against TextView.",
output
);
output
);
top.Dispose ();
}
@@ -257,7 +256,7 @@ This an long line and against TextView.",
var ac = new TextViewAutocomplete ();
((SingleWordSuggestionGenerator)ac.SuggestionGenerator).AllSuggestions =
new() { "fish", "const", "Cobble" };
new () { "fish", "const", "Cobble" };
var tv = new TextView ();
tv.InsertText ("co");
@@ -285,7 +284,7 @@ This an long line and against TextView.",
Assert.Same (Colors.ColorSchemes ["Menu"], tv.Autocomplete.ColorScheme);
// allocate a new custom scheme
tv.Autocomplete.ColorScheme = new()
tv.Autocomplete.ColorScheme = new ()
{
Normal = new (Color.Black, Color.Blue), Focus = new (Color.Black, Color.Cyan)
};

View File

@@ -1,5 +1,4 @@
using System.Text;
using UnitTests;
using UICatalog;
using UnitTests;
using Xunit.Abstractions;
@@ -13,7 +12,6 @@ public class TextFormatterTests
public TextFormatterTests (ITestOutputHelper output) { _output = output; }
private readonly ITestOutputHelper _output;
public static IEnumerable<object []> CMGlyphs =>
new List<object []> { new object [] { $"{Glyphs.LeftBracket} Say Hello 你 {Glyphs.RightBracket}", 16, 15 } };
@@ -3954,22 +3952,22 @@ ssb
Assert.False (tf.FillRemaining);
DriverAssert.AssertDriverContentsWithFrameAre (
@"
@"
Test
Test long
Test long long",
_output);
_output);
DriverAssert.AssertDriverAttributesAre (
@"
@"
000000000000000000000
011110000000000000000
011111111100000000000
011111111111111000000
000000000000000000000",
_output,
null,
attrs);
_output,
null,
attrs);
tf.FillRemaining = true;
@@ -3979,15 +3977,15 @@ ssb
attrs [2]);
DriverAssert.AssertDriverAttributesAre (
@"
@"
000000000000000000000
011111111111111111110
011111111111111111110
011111111111111111110
000000000000000000000",
_output,
null,
attrs);
_output,
null,
attrs);
}
[SetupFakeDriver]