All unit tests PASS!!!

This commit is contained in:
Tigger Kindel
2023-04-03 21:34:57 -06:00
parent d00b11ae5d
commit 6de8642c0e
4 changed files with 64 additions and 56 deletions

View File

@@ -135,60 +135,59 @@ namespace Terminal.Gui {
{
this.Title = title; // this.Title holds just the "Wizard Title"; base.Title holds "Wizard Title - Step Title"
this.Border.BorderStyle = BorderStyle.Rounded;
base.Add (contentView);
helpTextView.ReadOnly = true;
helpTextView.WordWrap = true;
base.Add (helpTextView);
// BUGBUG: v2 - Disabling scrolling for now
//var scrollBar = new ScrollBarView (helpTextView, true);
//scrollBar.ChangedPosition += (s,e) => {
// helpTextView.TopRow = scrollBar.Position;
// if (helpTextView.TopRow != scrollBar.Position) {
// scrollBar.Position = helpTextView.TopRow;
// }
// helpTextView.SetNeedsDisplay ();
//};
//scrollBar.OtherScrollBarView.ChangedPosition += (s,e) => {
// helpTextView.LeftColumn = scrollBar.OtherScrollBarView.Position;
// if (helpTextView.LeftColumn != scrollBar.OtherScrollBarView.Position) {
// scrollBar.OtherScrollBarView.Position = helpTextView.LeftColumn;
// }
// helpTextView.SetNeedsDisplay ();
//};
//scrollBar.VisibleChanged += (s,e) => {
// if (scrollBar.Visible && helpTextView.RightOffset == 0) {
// helpTextView.RightOffset = 1;
// } else if (!scrollBar.Visible && helpTextView.RightOffset == 1) {
// helpTextView.RightOffset = 0;
// }
//};
//scrollBar.OtherScrollBarView.VisibleChanged += (s,e) => {
// if (scrollBar.OtherScrollBarView.Visible && helpTextView.BottomOffset == 0) {
// helpTextView.BottomOffset = 1;
// } else if (!scrollBar.OtherScrollBarView.Visible && helpTextView.BottomOffset == 1) {
// helpTextView.BottomOffset = 0;
// }
//};
//helpTextView.DrawContent += (s,e) => {
// scrollBar.Size = helpTextView.Lines;
// scrollBar.Position = helpTextView.TopRow;
// if (scrollBar.OtherScrollBarView != null) {
// scrollBar.OtherScrollBarView.Size = helpTextView.Maxlength;
// scrollBar.OtherScrollBarView.Position = helpTextView.LeftColumn;
// }
// scrollBar.LayoutSubviews ();
// scrollBar.Refresh ();
//};
//base.Add (scrollBar);
ShowHide ();
var scrollBar = new ScrollBarView (helpTextView, true);
scrollBar.ChangedPosition += (s,e) => {
helpTextView.TopRow = scrollBar.Position;
if (helpTextView.TopRow != scrollBar.Position) {
scrollBar.Position = helpTextView.TopRow;
}
helpTextView.SetNeedsDisplay ();
};
scrollBar.OtherScrollBarView.ChangedPosition += (s,e) => {
helpTextView.LeftColumn = scrollBar.OtherScrollBarView.Position;
if (helpTextView.LeftColumn != scrollBar.OtherScrollBarView.Position) {
scrollBar.OtherScrollBarView.Position = helpTextView.LeftColumn;
}
helpTextView.SetNeedsDisplay ();
};
scrollBar.VisibleChanged += (s,e) => {
if (scrollBar.Visible && helpTextView.RightOffset == 0) {
helpTextView.RightOffset = 1;
} else if (!scrollBar.Visible && helpTextView.RightOffset == 1) {
helpTextView.RightOffset = 0;
}
};
scrollBar.OtherScrollBarView.VisibleChanged += (s,e) => {
if (scrollBar.OtherScrollBarView.Visible && helpTextView.BottomOffset == 0) {
helpTextView.BottomOffset = 1;
} else if (!scrollBar.OtherScrollBarView.Visible && helpTextView.BottomOffset == 1) {
helpTextView.BottomOffset = 0;
}
};
helpTextView.DrawContent += (s,e) => {
scrollBar.Size = helpTextView.Lines;
scrollBar.Position = helpTextView.TopRow;
if (scrollBar.OtherScrollBarView != null) {
scrollBar.OtherScrollBarView.Size = helpTextView.Maxlength;
scrollBar.OtherScrollBarView.Position = helpTextView.LeftColumn;
}
scrollBar.LayoutSubviews ();
scrollBar.Refresh ();
};
base.Add (scrollBar);
}
/// <summary>
@@ -228,8 +227,9 @@ namespace Terminal.Gui {
public override void Add (View view)
{
contentView.Add (view);
if (view.CanFocus)
if (view.CanFocus) {
CanFocus = true;
}
ShowHide ();
}
@@ -240,15 +240,17 @@ namespace Terminal.Gui {
/// </remarks>
public override void Remove (View view)
{
if (view == null)
if (view == null) {
return;
}
SetNeedsDisplay ();
var touched = view.Frame;
contentView.Remove (view);
if (contentView.InternalSubviews.Count < 1)
if (contentView.InternalSubviews.Count < 1) {
this.CanFocus = false;
}
ShowHide ();
}
@@ -317,6 +319,7 @@ namespace Terminal.Gui {
ClearKeybinding (Command.QuitToplevel);
AddKeyBinding (Key.Esc, Command.QuitToplevel);
}
SetNeedsLayout ();
}

View File

@@ -1234,13 +1234,14 @@ namespace Terminal.Gui.CoreTests {
Assert.Equal (rect, view.ViewToScreen (view.Bounds));
Assert.Equal (top.Bounds, view.ScreenClip (top.Bounds));
Assert.True (view.LayoutStyle == LayoutStyle.Absolute);
Application.Begin (top);
view.Width = Dim.Fill ();
view.Height = Dim.Fill ();
// BUGBUG: v2 - Setting layout style should be automatic
view.LayoutStyle = LayoutStyle.Computed;
Assert.True (view.LayoutStyle == LayoutStyle.Computed);
Assert.Equal (10, view.Bounds.Width);
Assert.Equal (1, view.Bounds.Height);
view.LayoutStyle = LayoutStyle.Computed;
view.SetRelativeLayout (top.Bounds);
top.LayoutSubviews (); // BUGBUG: v2 - ??
Assert.Equal (1, view.Frame.X);
@@ -1251,11 +1252,13 @@ namespace Terminal.Gui.CoreTests {
Assert.Equal (0, view.Bounds.Y);
Assert.Equal (79, view.Bounds.Width);
Assert.Equal (24, view.Bounds.Height);
view.X = 0;
view.Y = 0;
Assert.Equal ("Absolute(0)", view.X.ToString ());
Assert.Equal ("Fill(0)", view.Width.ToString ());
//view.SetRelativeLayout (top.Bounds);
view.SetRelativeLayout (top.Bounds);
top.LayoutSubviews (); // BUGBUG: v2 - ??
Assert.Equal (0, view.Frame.X);
Assert.Equal (0, view.Frame.Y);

View File

@@ -112,7 +112,7 @@ namespace Terminal.Gui.TopLevelTests {
} else if (iterations == 1) {
Application.Refresh ();
TestHelpers.AssertDriverContentsWithFrameAre (@"
┌┤T├──
┌┤Tit├┐
│Messa│
│ ge │
│ Ok ◦│

View File

@@ -8,6 +8,7 @@ using Xunit;
using System.Globalization;
using Xunit.Abstractions;
using NStack;
using static Terminal.Gui.Application;
namespace Terminal.Gui.TopLevelTests {
@@ -126,8 +127,9 @@ namespace Terminal.Gui.TopLevelTests {
var bottomRow = $"{d.LLDCorner}{new string (d.HDLine.ToString () [0], width - 2)}{d.LRDCorner}";
var wizard = new Wizard (title) { Width = width, Height = height };
Application.End (Application.Begin (wizard));
var runstate = Application.Begin (wizard);
TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{row2}\n{row3}\n{separatorRow}\n{buttonRow}\n{bottomRow}", output);
Application.End (runstate);
}
[Fact, AutoInitShutdown]