|
@@ -4,7 +4,7 @@ using static Terminal.Gui.Pos;
|
|
|
|
|
|
namespace Terminal.Gui.PosDimTests;
|
|
|
|
|
|
-public class PosTests (ITestOutputHelper output)
|
|
|
+public class PosTests ()
|
|
|
{
|
|
|
// Was named AutoSize_Pos_Validation_Do_Not_Throws_If_NewValue_Is_PosAbsolute_And_OldValue_Is_Another_Type_After_Sets_To_LayoutStyle_Absolute ()
|
|
|
// but doesn't actually have anything to do with AutoSize.
|
|
@@ -110,7 +110,7 @@ public class PosTests (ITestOutputHelper output)
|
|
|
{
|
|
|
Application.Init (new FakeDriver ());
|
|
|
|
|
|
- Toplevel t = new Toplevel();
|
|
|
+ Toplevel t = new Toplevel ();
|
|
|
|
|
|
var w = new Window { X = Pos.Left (t) + 2, Y = Pos.Top (t) + 2 };
|
|
|
var f = new FrameView ();
|
|
@@ -225,13 +225,13 @@ public class PosTests (ITestOutputHelper output)
|
|
|
Assert.Equal (10, posAbsolute.Anchor (0));
|
|
|
|
|
|
var posCombine = new Pos.PosCombine (true, posFactor, posAbsolute);
|
|
|
- Assert.Equal (posCombine.Left, posFactor);
|
|
|
- Assert.Equal (posCombine.Right, posAbsolute);
|
|
|
+ Assert.Equal (posCombine.LeftPos, posFactor);
|
|
|
+ Assert.Equal (posCombine.RightPos, posAbsolute);
|
|
|
Assert.Equal (20, posCombine.Anchor (100));
|
|
|
|
|
|
posCombine = new (true, posAbsolute, posFactor);
|
|
|
- Assert.Equal (posCombine.Left, posAbsolute);
|
|
|
- Assert.Equal (posCombine.Right, posFactor);
|
|
|
+ Assert.Equal (posCombine.LeftPos, posAbsolute);
|
|
|
+ Assert.Equal (posCombine.RightPos, posFactor);
|
|
|
Assert.Equal (20, posCombine.Anchor (100));
|
|
|
|
|
|
var view = new View { Frame = new (20, 10, 20, 1) };
|
|
@@ -255,7 +255,7 @@ public class PosTests (ITestOutputHelper output)
|
|
|
public void LeftTopBottomRight_Win_ShouldNotThrow ()
|
|
|
{
|
|
|
// Setup Fake driver
|
|
|
- (Toplevel top, Window win, Button button) setup ()
|
|
|
+ (Toplevel top, Window win, Button button) Setup ()
|
|
|
{
|
|
|
Application.Init (new FakeDriver ());
|
|
|
Application.Iteration += (s, a) => { Application.RequestStop (); };
|
|
@@ -271,7 +271,7 @@ public class PosTests (ITestOutputHelper output)
|
|
|
|
|
|
RunState rs;
|
|
|
|
|
|
- void cleanup (RunState rs)
|
|
|
+ void Cleanup (RunState rs)
|
|
|
{
|
|
|
// Cleanup
|
|
|
Application.End (rs);
|
|
@@ -283,53 +283,53 @@ public class PosTests (ITestOutputHelper output)
|
|
|
}
|
|
|
|
|
|
// Test cases:
|
|
|
- (Toplevel top, Window win, Button button) app = setup ();
|
|
|
+ (Toplevel top, Window win, Button button) app = Setup ();
|
|
|
app.button.Y = Pos.Left (app.win);
|
|
|
rs = Application.Begin (app.top);
|
|
|
|
|
|
// If Application.RunState is used then we must use Application.RunLoop with the rs parameter
|
|
|
Application.RunLoop (rs);
|
|
|
- cleanup (rs);
|
|
|
+ Cleanup (rs);
|
|
|
|
|
|
- app = setup ();
|
|
|
+ app = Setup ();
|
|
|
app.button.Y = Pos.X (app.win);
|
|
|
rs = Application.Begin (app.top);
|
|
|
|
|
|
// If Application.RunState is used then we must use Application.RunLoop with the rs parameter
|
|
|
Application.RunLoop (rs);
|
|
|
- cleanup (rs);
|
|
|
+ Cleanup (rs);
|
|
|
|
|
|
- app = setup ();
|
|
|
+ app = Setup ();
|
|
|
app.button.Y = Pos.Top (app.win);
|
|
|
rs = Application.Begin (app.top);
|
|
|
|
|
|
// If Application.RunState is used then we must use Application.RunLoop with the rs parameter
|
|
|
Application.RunLoop (rs);
|
|
|
- cleanup (rs);
|
|
|
+ Cleanup (rs);
|
|
|
|
|
|
- app = setup ();
|
|
|
+ app = Setup ();
|
|
|
app.button.Y = Pos.Y (app.win);
|
|
|
rs = Application.Begin (app.top);
|
|
|
|
|
|
// If Application.RunState is used then we must use Application.RunLoop with the rs parameter
|
|
|
Application.RunLoop (rs);
|
|
|
- cleanup (rs);
|
|
|
+ Cleanup (rs);
|
|
|
|
|
|
- app = setup ();
|
|
|
+ app = Setup ();
|
|
|
app.button.Y = Pos.Bottom (app.win);
|
|
|
rs = Application.Begin (app.top);
|
|
|
|
|
|
// If Application.RunState is used then we must use Application.RunLoop with the rs parameter
|
|
|
Application.RunLoop (rs);
|
|
|
- cleanup (rs);
|
|
|
+ Cleanup (rs);
|
|
|
|
|
|
- app = setup ();
|
|
|
+ app = Setup ();
|
|
|
app.button.Y = Pos.Right (app.win);
|
|
|
rs = Application.Begin (app.top);
|
|
|
|
|
|
// If Application.RunState is used then we must use Application.RunLoop with the rs parameter
|
|
|
Application.RunLoop (rs);
|
|
|
- cleanup (rs);
|
|
|
+ Cleanup (rs);
|
|
|
}
|
|
|
|
|
|
[Fact]
|
|
@@ -548,15 +548,15 @@ public class PosTests (ITestOutputHelper output)
|
|
|
pos = Pos.Left (new ());
|
|
|
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
|
|
|
|
|
|
- pos = Pos.Left (new() { Frame = testRect });
|
|
|
+ pos = Pos.Left (new () { Frame = testRect });
|
|
|
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
|
|
|
|
|
|
testRect = new (1, 2, 3, 4);
|
|
|
- pos = Pos.Left (new() { Frame = testRect });
|
|
|
+ pos = Pos.Left (new () { Frame = testRect });
|
|
|
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
|
|
|
|
|
|
// Pos.Left(win) + 0
|
|
|
- pos = Pos.Left (new() { Frame = testRect }) + testInt;
|
|
|
+ pos = Pos.Left (new () { Frame = testRect }) + testInt;
|
|
|
|
|
|
Assert.Equal (
|
|
|
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
|
|
@@ -566,7 +566,7 @@ public class PosTests (ITestOutputHelper output)
|
|
|
testInt = 1;
|
|
|
|
|
|
// Pos.Left(win) +1
|
|
|
- pos = Pos.Left (new() { Frame = testRect }) + testInt;
|
|
|
+ pos = Pos.Left (new () { Frame = testRect }) + testInt;
|
|
|
|
|
|
Assert.Equal (
|
|
|
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
|
|
@@ -576,7 +576,7 @@ public class PosTests (ITestOutputHelper output)
|
|
|
testInt = -1;
|
|
|
|
|
|
// Pos.Left(win) -1
|
|
|
- pos = Pos.Left (new() { Frame = testRect }) - testInt;
|
|
|
+ pos = Pos.Left (new () { Frame = testRect }) - testInt;
|
|
|
|
|
|
Assert.Equal (
|
|
|
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
|
|
@@ -590,15 +590,15 @@ public class PosTests (ITestOutputHelper output)
|
|
|
pos = Pos.X (new ());
|
|
|
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
|
|
|
|
|
|
- pos = Pos.X (new() { Frame = testRect });
|
|
|
+ pos = Pos.X (new () { Frame = testRect });
|
|
|
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
|
|
|
|
|
|
testRect = new (1, 2, 3, 4);
|
|
|
- pos = Pos.X (new() { Frame = testRect });
|
|
|
+ pos = Pos.X (new () { Frame = testRect });
|
|
|
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
|
|
|
|
|
|
// Pos.X(win) + 0
|
|
|
- pos = Pos.X (new() { Frame = testRect }) + testInt;
|
|
|
+ pos = Pos.X (new () { Frame = testRect }) + testInt;
|
|
|
|
|
|
Assert.Equal (
|
|
|
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
|
|
@@ -608,7 +608,7 @@ public class PosTests (ITestOutputHelper output)
|
|
|
testInt = 1;
|
|
|
|
|
|
// Pos.X(win) +1
|
|
|
- pos = Pos.X (new() { Frame = testRect }) + testInt;
|
|
|
+ pos = Pos.X (new () { Frame = testRect }) + testInt;
|
|
|
|
|
|
Assert.Equal (
|
|
|
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
|
|
@@ -618,7 +618,7 @@ public class PosTests (ITestOutputHelper output)
|
|
|
testInt = -1;
|
|
|
|
|
|
// Pos.X(win) -1
|
|
|
- pos = Pos.X (new() { Frame = testRect }) - testInt;
|
|
|
+ pos = Pos.X (new () { Frame = testRect }) - testInt;
|
|
|
|
|
|
Assert.Equal (
|
|
|
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
|
|
@@ -632,15 +632,15 @@ public class PosTests (ITestOutputHelper output)
|
|
|
pos = Pos.Top (new ());
|
|
|
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
|
|
|
|
|
|
- pos = Pos.Top (new() { Frame = testRect });
|
|
|
+ pos = Pos.Top (new () { Frame = testRect });
|
|
|
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
|
|
|
|
|
|
testRect = new (1, 2, 3, 4);
|
|
|
- pos = Pos.Top (new() { Frame = testRect });
|
|
|
+ pos = Pos.Top (new () { Frame = testRect });
|
|
|
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
|
|
|
|
|
|
// Pos.Top(win) + 0
|
|
|
- pos = Pos.Top (new() { Frame = testRect }) + testInt;
|
|
|
+ pos = Pos.Top (new () { Frame = testRect }) + testInt;
|
|
|
|
|
|
Assert.Equal (
|
|
|
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
|
|
@@ -650,7 +650,7 @@ public class PosTests (ITestOutputHelper output)
|
|
|
testInt = 1;
|
|
|
|
|
|
// Pos.Top(win) +1
|
|
|
- pos = Pos.Top (new() { Frame = testRect }) + testInt;
|
|
|
+ pos = Pos.Top (new () { Frame = testRect }) + testInt;
|
|
|
|
|
|
Assert.Equal (
|
|
|
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
|
|
@@ -660,7 +660,7 @@ public class PosTests (ITestOutputHelper output)
|
|
|
testInt = -1;
|
|
|
|
|
|
// Pos.Top(win) -1
|
|
|
- pos = Pos.Top (new() { Frame = testRect }) - testInt;
|
|
|
+ pos = Pos.Top (new () { Frame = testRect }) - testInt;
|
|
|
|
|
|
Assert.Equal (
|
|
|
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
|
|
@@ -674,15 +674,15 @@ public class PosTests (ITestOutputHelper output)
|
|
|
pos = Pos.Y (new ());
|
|
|
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
|
|
|
|
|
|
- pos = Pos.Y (new() { Frame = testRect });
|
|
|
+ pos = Pos.Y (new () { Frame = testRect });
|
|
|
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
|
|
|
|
|
|
testRect = new (1, 2, 3, 4);
|
|
|
- pos = Pos.Y (new() { Frame = testRect });
|
|
|
+ pos = Pos.Y (new () { Frame = testRect });
|
|
|
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
|
|
|
|
|
|
// Pos.Y(win) + 0
|
|
|
- pos = Pos.Y (new() { Frame = testRect }) + testInt;
|
|
|
+ pos = Pos.Y (new () { Frame = testRect }) + testInt;
|
|
|
|
|
|
Assert.Equal (
|
|
|
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
|
|
@@ -692,7 +692,7 @@ public class PosTests (ITestOutputHelper output)
|
|
|
testInt = 1;
|
|
|
|
|
|
// Pos.Y(win) +1
|
|
|
- pos = Pos.Y (new() { Frame = testRect }) + testInt;
|
|
|
+ pos = Pos.Y (new () { Frame = testRect }) + testInt;
|
|
|
|
|
|
Assert.Equal (
|
|
|
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
|
|
@@ -702,7 +702,7 @@ public class PosTests (ITestOutputHelper output)
|
|
|
testInt = -1;
|
|
|
|
|
|
// Pos.Y(win) -1
|
|
|
- pos = Pos.Y (new() { Frame = testRect }) - testInt;
|
|
|
+ pos = Pos.Y (new () { Frame = testRect }) - testInt;
|
|
|
|
|
|
Assert.Equal (
|
|
|
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
|
|
@@ -716,15 +716,15 @@ public class PosTests (ITestOutputHelper output)
|
|
|
pos = Pos.Bottom (new ());
|
|
|
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
|
|
|
|
|
|
- pos = Pos.Bottom (new() { Frame = testRect });
|
|
|
+ pos = Pos.Bottom (new () { Frame = testRect });
|
|
|
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
|
|
|
|
|
|
testRect = new (1, 2, 3, 4);
|
|
|
- pos = Pos.Bottom (new() { Frame = testRect });
|
|
|
+ pos = Pos.Bottom (new () { Frame = testRect });
|
|
|
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
|
|
|
|
|
|
// Pos.Bottom(win) + 0
|
|
|
- pos = Pos.Bottom (new() { Frame = testRect }) + testInt;
|
|
|
+ pos = Pos.Bottom (new () { Frame = testRect }) + testInt;
|
|
|
|
|
|
Assert.Equal (
|
|
|
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
|
|
@@ -734,7 +734,7 @@ public class PosTests (ITestOutputHelper output)
|
|
|
testInt = 1;
|
|
|
|
|
|
// Pos.Bottom(win) +1
|
|
|
- pos = Pos.Bottom (new() { Frame = testRect }) + testInt;
|
|
|
+ pos = Pos.Bottom (new () { Frame = testRect }) + testInt;
|
|
|
|
|
|
Assert.Equal (
|
|
|
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
|
|
@@ -744,7 +744,7 @@ public class PosTests (ITestOutputHelper output)
|
|
|
testInt = -1;
|
|
|
|
|
|
// Pos.Bottom(win) -1
|
|
|
- pos = Pos.Bottom (new() { Frame = testRect }) - testInt;
|
|
|
+ pos = Pos.Bottom (new () { Frame = testRect }) - testInt;
|
|
|
|
|
|
Assert.Equal (
|
|
|
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
|
|
@@ -878,7 +878,6 @@ public class PosTests (ITestOutputHelper output)
|
|
|
[SetupFakeDriver]
|
|
|
public void PosCombine_DimCombine_View_With_SubViews ()
|
|
|
{
|
|
|
- var clicked = false;
|
|
|
Toplevel top = new Toplevel () { Width = 80, Height = 25 };
|
|
|
var win1 = new Window { Id = "win1", Width = 20, Height = 10 };
|
|
|
var view1 = new View
|
|
@@ -887,10 +886,9 @@ public class PosTests (ITestOutputHelper output)
|
|
|
Width = Auto (DimAutoStyle.Text),
|
|
|
Height = Auto (DimAutoStyle.Text)
|
|
|
|
|
|
- };
|
|
|
+ };
|
|
|
var win2 = new Window { Id = "win2", Y = Pos.Bottom (view1) + 1, Width = 10, Height = 3 };
|
|
|
var view2 = new View { Id = "view2", Width = Dim.Fill (), Height = 1, CanFocus = true };
|
|
|
- view2.MouseClick += (sender, e) => clicked = true;
|
|
|
var view3 = new View { Id = "view3", Width = Dim.Fill (1), Height = 1, CanFocus = true };
|
|
|
|
|
|
view2.Add (view3);
|