Fixed unit tests: DimFactor changes broke - DOUBLE CHECK

This commit is contained in:
Tigger Kindel
2023-03-03 09:48:31 -07:00
parent 1c0c84cc21
commit 6f16af878b
2 changed files with 27 additions and 25 deletions

View File

@@ -149,7 +149,9 @@ namespace Terminal.Gui.TopLevelTests {
[AutoInitShutdown]
public void Internal_Tests ()
{
Toplevel.dragPosition = null; // dragPosition is `static` and must be reset for each instance or unit tests will fail?
var top = new Toplevel ();
var eventInvoked = "";
top.ChildUnloaded += (e) => eventInvoked = "ChildUnloaded";
@@ -898,9 +900,9 @@ namespace Terminal.Gui.TopLevelTests {
TestHelpers.AssertDriverContentsWithFrameAre (@"
File
┌────┐
│ │
└────┘
┌────
└────
@@ -908,7 +910,7 @@ namespace Terminal.Gui.TopLevelTests {
CTRL-N New", output);
Assert.Equal (win, Application.MouseGrabView);
Assert.Equal (new Rect (4, 2, 6, 3), Application.MouseGrabView.Frame);
Assert.Equal (new Rect (4, 2, 7, 3), Application.MouseGrabView.Frame);
} else if (iterations == 3) {
Assert.Equal (win, Application.MouseGrabView);
@@ -929,10 +931,10 @@ namespace Terminal.Gui.TopLevelTests {
TestHelpers.AssertDriverContentsWithFrameAre (@"
File
┌────┐
│ │
│ │
└────┘
┌────
└─────┘
@@ -940,7 +942,7 @@ namespace Terminal.Gui.TopLevelTests {
CTRL-N New", output);
Assert.Equal (win, Application.MouseGrabView);
Assert.Equal (new Rect (4, 1, 6, 4), Application.MouseGrabView.Frame);
Assert.Equal (new Rect (4, 1, 7, 3), Application.MouseGrabView.Frame);
} else if (iterations == 5) {
Assert.Equal (win, Application.MouseGrabView);

View File

@@ -477,32 +477,32 @@ namespace Terminal.Gui.TypeTests {
f1.Text = "Frame1";
Assert.Equal ("Factor(0.5,False)", f1.Width.ToString ());
Assert.Equal ("Absolute(5)", f1.Height.ToString ());
Assert.Equal (99, f1.Frame.Width); // 100-1=99
Assert.Equal (49, f1.Frame.Width); // 100*0.5=49
Assert.Equal (5, f1.Frame.Height);
f2.Text = "Frame2";
Assert.Equal ("Fill(0)", f2.Width.ToString ());
Assert.Equal ("Absolute(5)", f2.Height.ToString ());
Assert.Equal (99, f2.Frame.Width); // 100-1=99
Assert.Equal (49, f2.Frame.Width); // f2.X = Pos.Right(f1), thus 50-1=49
Assert.Equal (5, f2.Frame.Height);
v1.Text = "Button1";
Assert.Equal ("Combine(DimView(Width,FrameView()({X=0,Y=0,Width=99,Height=5}))-Absolute(2))", v1.Width.ToString ());
Assert.Equal ("Combine(DimView(Width,FrameView()({X=0,Y=0,Width=49,Height=5}))-Absolute(2))", v1.Width.ToString ());
Assert.Equal ("Combine(Fill(0)-Absolute(2))", v1.Height.ToString ());
Assert.Equal (97, v1.Frame.Width); // 99-2=97
Assert.Equal (189, v1.Frame.Height); // 198-2-7=189
Assert.Equal (47, v1.Frame.Width); // 49-2=47
Assert.Equal (89, v1.Frame.Height); // 98-2-7=89
v2.Text = "Button2";
Assert.Equal ("Combine(DimView(Width,FrameView()({X=99,Y=0,Width=99,Height=5}))-Absolute(2))", v2.Width.ToString ());
Assert.Equal ("Combine(DimView(Width,FrameView()({X=49,Y=0,Width=49,Height=5}))-Absolute(2))", v2.Width.ToString ());
Assert.Equal ("Combine(Fill(0)-Absolute(2))", v2.Height.ToString ());
Assert.Equal (97, v2.Frame.Width); // 99-2=97
Assert.Equal (189, v2.Frame.Height); // 198-2-7=189
Assert.Equal (47, v2.Frame.Width); // 49-2=47
Assert.Equal (89, v2.Frame.Height); // 98-2-7=89
v3.Text = "Button3";
Assert.Equal ("Factor(0.1,False)", v3.Width.ToString ());
Assert.Equal ("Factor(0.1,False)", v3.Height.ToString ());
Assert.Equal (19, v3.Frame.Width); // 198*10%=19 * Percent is related to the super-view if it isn't null otherwise the view width
Assert.Equal (19, v3.Frame.Height); // 199*10%=19
Assert.Equal (9, v3.Frame.Width); // 98*10%=9 * Percent is related to the super-view if it isn't null otherwise the view width
Assert.Equal (9, v3.Frame.Height); // 99*10%=9
v4.Text = "Button4";
v4.AutoSize = false;
@@ -517,16 +517,16 @@ namespace Terminal.Gui.TypeTests {
Assert.Equal (1, v4.Frame.Height); // 1 because is Dim.DimAbsolute
v5.Text = "Button5";
Assert.Equal ("Combine(DimView(Width,Button()({X=2,Y=7,Width=97,Height=189}))-DimView(Width,Button()({X=0,Y=0,Width=19,Height=19})))", v5.Width.ToString ());
Assert.Equal ("Combine(DimView(Height,Button()({X=2,Y=7,Width=97,Height=189}))-DimView(Height,Button()({X=0,Y=0,Width=19,Height=19})))", v5.Height.ToString ());
Assert.Equal (78, v5.Frame.Width); // 97-19=78
Assert.Equal (170, v5.Frame.Height); // 189-19=170
Assert.Equal ("Combine(DimView(Width,Button()({X=2,Y=7,Width=47,Height=89}))-DimView(Width,Button()({X=0,Y=0,Width=9,Height=9})))", v5.Width.ToString ());
Assert.Equal ("Combine(DimView(Height,Button()({X=2,Y=7,Width=47,Height=89}))-DimView(Height,Button()({X=0,Y=0,Width=9,Height=9})))", v5.Height.ToString ());
Assert.Equal (38, v5.Frame.Width); // 47-9=38
Assert.Equal (80, v5.Frame.Height); // 89-9=80
v6.Text = "Button6";
Assert.Equal ("Factor(0.2,True)", v6.Width.ToString ());
Assert.Equal ("Factor(0.2,True)", v6.Height.ToString ());
Assert.Equal (19, v6.Frame.Width); // 99*20%=19
Assert.Equal (38, v6.Frame.Height); // 198-7*20=38
Assert.Equal (9, v6.Frame.Width); // 49*20%=9
Assert.Equal (18, v6.Frame.Height); // 98-7*20=18
};
Application.Iteration += () => Application.RequestStop ();