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

@@ -5,7 +5,7 @@ using System.Reflection;
using Xunit;
using Xunit.Abstractions;
namespace Terminal.Gui.ViewTests {
namespace Terminal.Gui.ViewsTests {
public class ScrollBarViewTests {
readonly ITestOutputHelper output;
@@ -19,9 +19,6 @@ namespace Terminal.Gui.ViewTests {
{
var width = 40;
var height = 3;
((FakeDriver)Application.Driver).SetBufferSize (width, height);
// BUGBUG: Application.Top only gets resized to Console size if it is set to computed?!?
Application.Top.LayoutStyle = LayoutStyle.Computed;
var super = new Window () { Id = "super", Width = Dim.Fill (), Height = Dim.Fill () };
Application.Top.Add (super);
@@ -35,6 +32,7 @@ namespace Terminal.Gui.ViewTests {
};
super.Add (sbv);
Application.Begin (Application.Top);
((FakeDriver)Application.Driver).SetBufferSize (width, height);
var expected = @"
┌──────────────────────────────────────┐
@@ -49,9 +47,6 @@ namespace Terminal.Gui.ViewTests {
{
var width = 3;
var height = 40;
((FakeDriver)Application.Driver).SetBufferSize (width, height);
// BUGBUG: Application.Top only gets resized to Console size if it is set to computed?!?
Application.Top.LayoutStyle = LayoutStyle.Computed;
var super = new Window () { Id = "super", Width = Dim.Fill (), Height = Dim.Fill () };
Application.Top.Add (super);
@@ -67,6 +62,7 @@ namespace Terminal.Gui.ViewTests {
super.Add (sbv);
Application.Begin (Application.Top);
((FakeDriver)Application.Driver).SetBufferSize (width, height);
var expected = @"
┌─┐
@@ -118,9 +114,6 @@ namespace Terminal.Gui.ViewTests {
{
var width = 3;
var height = 40;
((FakeDriver)Application.Driver).SetBufferSize (width, height);
// BUGBUG: Application.Top only gets resized to Console size if it is set to computed?!?
Application.Top.LayoutStyle = LayoutStyle.Computed;
var super = new Window () { Id = "super", Width = Dim.Fill (), Height = Dim.Fill () };
Application.Top.Add (super);
@@ -146,6 +139,7 @@ namespace Terminal.Gui.ViewTests {
super.Add (vert);
Application.Begin (Application.Top);
((FakeDriver)Application.Driver).SetBufferSize (width, height);
var expected = @"
┌─┐
@@ -569,8 +563,7 @@ namespace Terminal.Gui.ViewTests {
Assert.True (_scrollBar.OtherScrollBarView.Visible);
Assert.Equal ("View(Width,HostView()({X=0,Y=0,Width=80,Height=25}))",
_scrollBar.OtherScrollBarView.Width.ToString ());
// BUGBUG: v2 - Tig broke this test; not sure why. @bdisp?
//Assert.Equal (80, _scrollBar.OtherScrollBarView.Bounds.Width);
Assert.Equal (80, _scrollBar.OtherScrollBarView.Bounds.Width);
Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height);
@@ -587,8 +580,7 @@ namespace Terminal.Gui.ViewTests {
Assert.False (_scrollBar.OtherScrollBarView.Visible);
Assert.Equal ("View(Width,HostView()({X=0,Y=0,Width=80,Height=25}))",
_scrollBar.OtherScrollBarView.Width.ToString ());
// BUGBUG: v2 - Tig broke this test; not sure why. @bdisp?
//Assert.Equal (80, _scrollBar.OtherScrollBarView.Bounds.Width);
Assert.Equal (80, _scrollBar.OtherScrollBarView.Bounds.Width);
Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height);
@@ -600,14 +592,12 @@ namespace Terminal.Gui.ViewTests {
Assert.Equal (1, _scrollBar.Bounds.Width);
Assert.Equal ("View(Height,HostView()({X=0,Y=0,Width=80,Height=25}))",
_scrollBar.Height.ToString ());
// BUGBUG: v2 - Tig broke this test; not sure why. @bdisp?
//Assert.Equal (25, _scrollBar.Bounds.Height);
Assert.Equal (25, _scrollBar.Bounds.Height);
Assert.False (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
Assert.False (_scrollBar.OtherScrollBarView.Visible);
Assert.Equal ("View(Width,HostView()({X=0,Y=0,Width=80,Height=25}))",
_scrollBar.OtherScrollBarView.Width.ToString ());
// BUGBUG: v2 - Tig broke this test; not sure why. @bdisp?
//Assert.Equal (80, _scrollBar.OtherScrollBarView.Bounds.Width);
Assert.Equal (80, _scrollBar.OtherScrollBarView.Bounds.Width);
Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height);
@@ -798,7 +788,6 @@ namespace Terminal.Gui.ViewTests {
Assert.False (sbv.OtherScrollBarView.CanScroll (10, out max, sbv.OtherScrollBarView.IsVertical));
Assert.Equal (0, max);
// BUGBUG: v2 - bounds etc... are not valid until after BeginInit
Application.Begin (top);
// They aren't visible so they aren't drawn.
@@ -876,7 +865,6 @@ namespace Terminal.Gui.ViewTests {
}
};
// BUGBUG: v2 - Don't mix layout and redraw! Redraw should not change layout. It's ok for Layout to cause redraw.
textView.LayoutComplete += (s, e) => {
scrollBar.Size = textView.Lines;
scrollBar.Position = textView.TopRow;
@@ -1166,5 +1154,67 @@ This is a test
Assert.False (sbv.ShowScrollIndicator);
Assert.False (sbv.Visible);
}
[Fact, AutoInitShutdown]
public void ClearOnVisibleFalse_Gets_Sets ()
{
var text = "This is a test\nThis is a test\nThis is a test\nThis is a test\nThis is a test\nThis is a test";
var label = new Label (text);
Application.Top.Add (label);
var sbv = new ScrollBarView (label, true, false) {
Size = 100,
ClearOnVisibleFalse = false
};
Application.Begin (Application.Top);
Assert.True (sbv.Visible);
TestHelpers.AssertDriverContentsWithFrameAre (@"
This is a tes▲
This is a tes┬
This is a tes┴
This is a tes░
This is a tes░
This is a tes▼
", output);
sbv.Visible = false;
Assert.False (sbv.Visible);
Application.Top.Redraw (Application.Top.Bounds);
TestHelpers.AssertDriverContentsWithFrameAre (@"
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
", output);
sbv.Visible = true;
Assert.True (sbv.Visible);
Application.Top.Redraw (Application.Top.Bounds);
TestHelpers.AssertDriverContentsWithFrameAre (@"
This is a tes▲
This is a tes┬
This is a tes┴
This is a tes░
This is a tes░
This is a tes▼
", output);
sbv.ClearOnVisibleFalse = true;
sbv.Visible = false;
Assert.False (sbv.Visible);
TestHelpers.AssertDriverContentsWithFrameAre (@"
This is a tes
This is a tes
This is a tes
This is a tes
This is a tes
This is a tes
", output);
}
}
}