mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
Improves robustness of Dim, Pos, and SetRelativeLayout (#3077)
* Updated overview docs * Updated toc * Updated docs more * Updated yml via dependabot * Initial work in progress * Fixed some autosize things * Revamped Pos / Dim API docs * Removed margin * horiz->width * Updated MessageBoxes and Dialogs Scenarios to use AutoSize * AutoSize->Auxo * Adds validation * prep for Dialog to use Dim.Auto - Simplify unit tests to not depend on things not important to the unit test (like Dialog) * prep for Dialog to use Dim.Auto - Simplify unit tests * prep for Dialog to use Dim.Auto - Simplify unit tests * prep for Dialog to use Dim.Auto - Make Dialog tests not depend on MessageBox * Started on DimAuto unit tests * started impl on min/max. * started impl on min/max. * Added DimAutoStyle * Added arg checking for not implemented features * Temporarily made DimAutoStyle.Subviews default * Removed unneeded override of Anchor * Fixed GethashCode warning * Implemented DimAuto(min) * Fixed unit tests * renamed scenario * WIP * Moved ViewLayout.cs into Layout folder * Clean up cocde formatting * Renamed and moved SetFrameToFitText * Fixed API docs for SetRelativeLayout * Factored out SetRelativeLayout tests * Better documented existing SetRelativeLayout behavior + unit tess * Debugging Pos.Center + x in SetRelativeLayout - WIP * Progress on low level unit tess * Initial commit * Restored unmodified scenarios * Bump deps
This commit is contained in:
@@ -504,6 +504,7 @@ namespace Terminal.Gui.ViewTests {
|
||||
|
||||
var runState = Application.Begin (top);
|
||||
|
||||
// BUGBUG: This is a SetRelativeLayout test. It should be moved to SetRelativeLayoutTests.cs
|
||||
view.Width = Dim.Fill ();
|
||||
view.Height = Dim.Fill ();
|
||||
Assert.Equal (10, view.Bounds.Width);
|
||||
@@ -519,6 +520,7 @@ namespace Terminal.Gui.ViewTests {
|
||||
Assert.Equal (79, view.Bounds.Width);
|
||||
Assert.Equal (24, view.Bounds.Height);
|
||||
|
||||
// BUGBUG: This is a SetRelativeLayout test. It should be moved to SetRelativeLayoutTests.cs
|
||||
view.X = 0;
|
||||
view.Y = 0;
|
||||
Assert.Equal ("Absolute(0)", view.X.ToString ());
|
||||
@@ -532,6 +534,8 @@ namespace Terminal.Gui.ViewTests {
|
||||
Assert.Equal (0, view.Bounds.Y);
|
||||
Assert.Equal (80, view.Bounds.Width);
|
||||
Assert.Equal (25, view.Bounds.Height);
|
||||
|
||||
// BUGBUG: This is a layout test. It should be moved to LayoutTests.cs
|
||||
bool layoutStarted = false;
|
||||
view.LayoutStarted += (s, e) => layoutStarted = true;
|
||||
view.OnLayoutStarted (null);
|
||||
@@ -539,6 +543,10 @@ namespace Terminal.Gui.ViewTests {
|
||||
view.LayoutComplete += (s, e) => layoutStarted = false;
|
||||
view.OnLayoutComplete (null);
|
||||
Assert.False (layoutStarted);
|
||||
|
||||
// This test has been moved to SetRlativeLayoutTests because it is testing
|
||||
// SetRelativeLayout. In addition, the old test was bogus because it was testing the wrong thing (and
|
||||
// because in v1 Pos.Center was broken in this regard!
|
||||
view.X = Pos.Center () - 41;
|
||||
view.Y = Pos.Center () - 13;
|
||||
view.SetRelativeLayout (top.Bounds);
|
||||
@@ -546,7 +554,7 @@ namespace Terminal.Gui.ViewTests {
|
||||
view.BoundsToScreen (0, 0, out rcol, out rrow);
|
||||
Assert.Equal (-41, rcol);
|
||||
Assert.Equal (-13, rrow);
|
||||
|
||||
|
||||
Application.End (runState);
|
||||
}
|
||||
|
||||
@@ -1340,16 +1348,15 @@ At 0,0
|
||||
var frame = new FrameView ();
|
||||
|
||||
var label = new Label ("This should be the first line.") {
|
||||
TextAlignment = Terminal.Gui.TextAlignment.Centered,
|
||||
ColorScheme = Colors.Menu,
|
||||
Width = Dim.Fill (),
|
||||
X = Pos.Center (),
|
||||
Y = Pos.Center () - 2 // center minus 2 minus two lines top and bottom borders equal to zero (4-2-2=0)
|
||||
X = 0, // don't overcomplicate unit tests
|
||||
Y = 0
|
||||
};
|
||||
|
||||
var button = new Button ("Press me!") {
|
||||
X = Pos.Center (),
|
||||
Y = Pos.Center ()
|
||||
X = 0, // don't overcomplicate unit tests
|
||||
Y = 1
|
||||
};
|
||||
|
||||
frame.Add (label, button);
|
||||
@@ -1388,19 +1395,7 @@ At 0,0
|
||||
frame.Frame.Left, frame.Frame.Top,
|
||||
frame.Frame.Right, frame.Frame.Bottom));
|
||||
Assert.Equal (new Rect (0, 0, 38, 1), label.Frame);
|
||||
Assert.Equal (new Rect (12, 2, 13, 1), button.Frame);
|
||||
var expected = @$"
|
||||
┌──────────────────────────────────────┐
|
||||
│ This should be the first line. │
|
||||
│ │
|
||||
│ {CM.Glyphs.LeftBracket} Press me! {CM.Glyphs.RightBracket} │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
└──────────────────────────────────────┘
|
||||
";
|
||||
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
|
||||
Assert.Equal (new Rect (0, 1, 13, 1), button.Frame); // this proves frame was set
|
||||
Application.End (runState);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user