Fixes #2469 - Revamp file structure and namespace (#2471)

* initial commit

* All tests pass

* Updated readme

* Revert "All tests pass"

This reverts commit 94ac462350.

* Revert "initial commit"

This reverts commit 36d92cc4e5.

* Moved Terminal.Gui files around

* Nuked .Graphs namespace

* Nuked .Graphs namespace

* Nuked .Trees namespace

* Nuked .Configuration namespace

* Nuked .Configuration namespace

* All tests pass

* tweaked tests

* removed unneeded usings

* re-enabled scrollview tests

* move scrollview test to ScrollViewTests

* Moved view navigation related tests to separate cs file

* Moved view scrollbarview related tests ScrollBarTestse

* Refactored View tests into smaller files

* Refactored driver tests

* Fixed a ton of BUGBUGs
This commit is contained in:
Tig
2023-04-06 10:09:21 -06:00
committed by GitHub
parent ec08c12162
commit 574ed8fec7
187 changed files with 6591 additions and 6541 deletions

View File

@@ -1,8 +1,9 @@
using NStack;
using Microsoft.VisualStudio.TestPlatform.Utilities;
using NStack;
using Xunit;
using Xunit.Abstractions;
namespace Terminal.Gui.ViewTests {
namespace Terminal.Gui.ViewsTests {
public class ScrollViewTests {
readonly ITestOutputHelper output;
@@ -391,37 +392,37 @@ namespace Terminal.Gui.ViewTests {
// Application.Begin (Application.Top);
// TestHelpers.AssertDriverContentsWithFrameAre (@"
// █████████▲
// ██████But┬
// █████████┴
// ┌────────░
// │ But░
// └────────░
// ┌────────░
// │ But░
// └────────▼
// ◄├┤░░░░░► ", output);
// █████████▲
// ██████But┬
// █████████┴
// ┌────────░
// │ But░
// └────────░
// ┌────────░
// │ But░
// └────────▼
// ◄├┤░░░░░► ", output);
// sv.ContentOffset = new Point (5, 5);
// sv.LayoutSubviews ();
// Application.Refresh ();
// TestHelpers.AssertDriverContentsWithFrameAre (@"
// ─────────▲
// ─────────┬
// Button 2│
// ─────────┴
// ─────────░
// Button 3░
// ─────────░
// ─────────░
// Button 4▼
// ◄├─┤░░░░► ", output);
// ─────────▲
// ─────────┬
// Button 2│
// ─────────┴
// ─────────░
// Button 3░
// ─────────░
// ─────────░
// Button 4▼
// ◄├─┤░░░░► ", output);
//}
//private class CustomButton : FrameView {
// private Label labelFill;
// private Label labelText;
// public CustomButton (string fill, ustring text, int width, int height) : base ()
// {
// Width = width;
@@ -439,7 +440,7 @@ namespace Terminal.Gui.ViewTests {
// }
// labelFill.Text = fillText.ToString ();
// };
// labelText = new Label (text) { X = Pos.Center (), Y = Pos.Center () };
// Add (labelFill, labelText);
// CanFocus = true;
@@ -600,5 +601,284 @@ namespace Terminal.Gui.ViewTests {
00000000000000000000000
00000000000000000000000", attributes);
}
[Fact, AutoInitShutdown]
public void DrawTextFormatter_Respects_The_Clip_Bounds ()
{
var view = new View (new Rect (0, 0, 20, 20));
view.Add (new Label ("0123456789abcdefghij"));
view.Add (new Label (0, 1, "1\n2\n3\n4\n5\n6\n7\n8\n9\n0"));
view.Add (new Button (1, 1, "Press me!"));
var scrollView = new ScrollView (new Rect (1, 1, 15, 10)) {
ContentSize = new Size (40, 40),
ShowHorizontalScrollIndicator = true,
ShowVerticalScrollIndicator = true
};
scrollView.Add (view);
var win = new Window (new Rect (1, 1, 20, 14), "Test");
win.Add (scrollView);
Application.Top.Add (win);
Application.Begin (Application.Top);
var expected = @"
┌┤Test├────────────┐
│ │
│ 0123456789abcd▲ │
│ 1[ Press me! ]┬ │
│ 2 │ │
│ 3 ┴ │
│ 4 ░ │
│ 5 ░ │
│ 6 ░ │
│ 7 ░ │
│ 8 ▼ │
│ ◄├───┤░░░░░░░► │
│ │
└──────────────────┘
"
;
var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (1, 1, 21, 14), pos);
Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ())));
Application.Top.Redraw (Application.Top.Bounds);
expected = @"
┌┤Test├────────────┐
│ │
│ 123456789abcde▲ │
│ [ Press me! ] ┬ │
│ │ │
│ ┴ │
│ ░ │
│ ░ │
│ ░ │
│ ░ │
│ ▼ │
│ ◄├───┤░░░░░░░► │
│ │
└──────────────────┘
"
;
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (1, 1, 21, 14), pos);
Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ())));
Application.Top.Redraw (Application.Top.Bounds);
expected = @"
┌┤Test├────────────┐
│ │
│ 23456789abcdef▲ │
│ Press me! ] ┬ │
│ │ │
│ ┴ │
│ ░ │
│ ░ │
│ ░ │
│ ░ │
│ ▼ │
│ ◄├────┤░░░░░░► │
│ │
└──────────────────┘
"
;
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (1, 1, 21, 14), pos);
Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ())));
Application.Top.Redraw (Application.Top.Bounds);
expected = @"
┌┤Test├────────────┐
│ │
│ 3456789abcdefg▲ │
│ Press me! ] ┬ │
│ │ │
│ ┴ │
│ ░ │
│ ░ │
│ ░ │
│ ░ │
│ ▼ │
│ ◄├────┤░░░░░░► │
│ │
└──────────────────┘
"
;
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (1, 1, 21, 14), pos);
Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ())));
Application.Top.Redraw (Application.Top.Bounds);
expected = @"
┌┤Test├────────────┐
│ │
│ 456789abcdefgh▲ │
│ ress me! ] ┬ │
│ │ │
│ ┴ │
│ ░ │
│ ░ │
│ ░ │
│ ░ │
│ ▼ │
│ ◄░├───┤░░░░░░► │
│ │
└──────────────────┘
"
;
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (1, 1, 21, 14), pos);
Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ())));
Application.Top.Redraw (Application.Top.Bounds);
expected = @"
┌┤Test├────────────┐
│ │
│ 56789abcdefghi▲ │
│ ess me! ] ┬ │
│ │ │
│ ┴ │
│ ░ │
│ ░ │
│ ░ │
│ ░ │
│ ▼ │
│ ◄░├────┤░░░░░► │
│ │
└──────────────────┘
"
;
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (1, 1, 21, 14), pos);
Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ())));
Application.Top.Redraw (Application.Top.Bounds);
expected = @"
┌┤Test├────────────┐
│ │
│ 6789abcdefghij▲ │
│ ss me! ] ┬ │
│ │ │
│ ┴ │
│ ░ │
│ ░ │
│ ░ │
│ ░ │
│ ▼ │
│ ◄░├────┤░░░░░► │
│ │
└──────────────────┘
"
;
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (1, 1, 21, 14), pos);
Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ())));
Application.Top.Redraw (Application.Top.Bounds);
expected = @"
┌┤Test├────────────┐
│ │
│ 789abcdefghij ▲ │
│ s me! ] ┬ │
│ │ │
│ ┴ │
│ ░ │
│ ░ │
│ ░ │
│ ░ │
│ ▼ │
│ ◄░░├───┤░░░░░► │
│ │
└──────────────────┘
";
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (1, 1, 21, 14), pos);
Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CtrlMask | Key.Home, new KeyModifiers ())));
Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ())));
Application.Top.Redraw (Application.Top.Bounds);
expected = @"
┌┤Test├────────────┐
│ │
│ 1[ Press me! ]▲ │
│ 2 ┬ │
│ 3 │ │
│ 4 ┴ │
│ 5 ░ │
│ 6 ░ │
│ 7 ░ │
│ 8 ░ │
│ 9 ▼ │
│ ◄├───┤░░░░░░░► │
│ │
└──────────────────┘
";
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (1, 1, 21, 14), pos);
Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ())));
Application.Top.Redraw (Application.Top.Bounds);
expected = @"
┌┤Test├────────────┐
│ │
│ 2 ▲ │
│ 3 ┬ │
│ 4 │ │
│ 5 ┴ │
│ 6 ░ │
│ 7 ░ │
│ 8 ░ │
│ 9 ░ │
│ 0 ▼ │
│ ◄├───┤░░░░░░░► │
│ │
└──────────────────┘
";
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (1, 1, 21, 14), pos);
Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ())));
Application.Top.Redraw (Application.Top.Bounds);
expected = @"
┌┤Test├────────────┐
│ │
│ 3 ▲ │
│ 4 ┬ │
│ 5 │ │
│ 6 ┴ │
│ 7 ░ │
│ 8 ░ │
│ 9 ░ │
│ 0 ░ │
│ ▼ │
│ ◄├───┤░░░░░░░► │
│ │
└──────────────────┘
";
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (1, 1, 21, 14), pos);
}
}
}