Browse Source

Fixed sommeore tests

Tigger Kindel 2 years ago
parent
commit
503a3e0dbb
2 changed files with 53 additions and 81 deletions
  1. 8 8
      UnitTests/Types/DimTests.cs
  2. 45 73
      UnitTests/Types/PosTests.cs

+ 8 - 8
UnitTests/Types/DimTests.cs

@@ -435,12 +435,12 @@ namespace Terminal.Gui.TypeTests {
 				Assert.Equal (49, f2.Frame.Width); // 50-1=49
 				Assert.Equal (5, f2.Frame.Height);
 	
-				Assert.Equal ("Combine(View(Width,FrameView()({X=0,Y=0,Width=49,Height=5}))-Absolute(2))", v1.Width.ToString ());
+				Assert.Equal ("Combine(View(Width,FrameView(f1)({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 (47, v1.Frame.Width); // 49-2=47
 				Assert.Equal (89, v1.Frame.Height); // 98-5-2-2=89
 
-				Assert.Equal ("Combine(View(Width,FrameView()({X=49,Y=0,Width=49,Height=5}))-Absolute(2))", v2.Width.ToString ());
+				Assert.Equal ("Combine(View(Width,FrameView(f2)({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 (47, v2.Frame.Width); // 49-2=47
 				Assert.Equal (89, v2.Frame.Height); // 98-5-2-2=89
@@ -455,8 +455,8 @@ namespace Terminal.Gui.TypeTests {
 				Assert.Equal (50, v4.Frame.Width);
 				Assert.Equal (50, v4.Frame.Height);
 
-				Assert.Equal ("Combine(View(Width,Button()({X=2,Y=7,Width=47,Height=89}))-View(Width,Button()({X=0,Y=0,Width=9,Height=9})))", v5.Width.ToString ());
-				Assert.Equal ("Combine(View(Height,Button()({X=2,Y=7,Width=47,Height=89}))-View(Height,Button()({X=0,Y=0,Width=9,Height=9})))", v5.Height.ToString ());
+				Assert.Equal ("Combine(View(Width,Button(v1)({X=2,Y=7,Width=47,Height=89}))-View(Width,Button(v3)({X=0,Y=0,Width=9,Height=9})))", v5.Width.ToString ());
+				Assert.Equal ("Combine(View(Height,Button(v1)({X=2,Y=7,Width=47,Height=89}))-View(Height,Button(v3)({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
 
@@ -488,13 +488,13 @@ namespace Terminal.Gui.TypeTests {
 				Assert.Equal (5, f2.Frame.Height);
 
 				v1.Text = "Button1";
-				Assert.Equal ("Combine(View(Width,FrameView()({X=0,Y=0,Width=99,Height=5}))-Absolute(2))", v1.Width.ToString ());
+				Assert.Equal ("Combine(View(Width,FrameView(f1)({X=0,Y=0,Width=99,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
 
 				v2.Text = "Button2";
-				Assert.Equal ("Combine(View(Width,FrameView()({X=99,Y=0,Width=99,Height=5}))-Absolute(2))", v2.Width.ToString ());
+				Assert.Equal ("Combine(View(Width,FrameView(f2)({X=99,Y=0,Width=99,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
@@ -518,8 +518,8 @@ namespace Terminal.Gui.TypeTests {
 				Assert.Equal (1, v4.Frame.Height); // 1 because is Dim.DimAbsolute
 
 				v5.Text = "Button5";
-				Assert.Equal ("Combine(View(Width,Button()({X=2,Y=7,Width=97,Height=189}))-View(Width,Button()({X=0,Y=0,Width=19,Height=19})))", v5.Width.ToString ());
-				Assert.Equal ("Combine(View(Height,Button()({X=2,Y=7,Width=97,Height=189}))-View(Height,Button()({X=0,Y=0,Width=19,Height=19})))", v5.Height.ToString ());
+				Assert.Equal ("Combine(View(Width,Button(v1)({X=2,Y=7,Width=97,Height=189}))-View(Width,Button(v3)({X=0,Y=0,Width=19,Height=19})))", v5.Width.ToString ());
+				Assert.Equal ("Combine(View(Height,Button(v1)({X=2,Y=7,Width=97,Height=189}))-View(Height,Button(v3)({X=0,Y=0,Width=19,Height=19})))", v5.Height.ToString ());
 				Assert.Equal (78, v5.Frame.Width); // 97-9=78
 				Assert.Equal (170, v5.Frame.Height); // 189-19=170
 

+ 45 - 73
UnitTests/Types/PosTests.cs

@@ -78,11 +78,6 @@ namespace Terminal.Gui.TypeTests {
 
 			Assert.Equal (new Rect (0, 0, 80, 25), top.Frame);
 			Assert.Equal (new Rect (0, 0, 80, 25), win.Frame);
-			Assert.Equal (new Rect (1, 1, 78, 23), win.Subviews [0].Frame);
-			Assert.Equal ("ContentView()({X=1,Y=1,Width=78,Height=23})", win.Subviews [0].ToString ());
-			Assert.Equal (new Rect (1, 1, 79, 24), new Rect (
-				win.Subviews [0].Frame.Left, win.Subviews [0].Frame.Top,
-				win.Subviews [0].Frame.Right, win.Subviews [0].Frame.Bottom));
 			Assert.Equal (new Rect (68, 22, 10, 1), tv.Frame);
 		}
 
@@ -113,10 +108,6 @@ namespace Terminal.Gui.TypeTests {
 			Assert.Equal (new Rect (0, 0, 80, 1), menu.Frame);
 			Assert.Equal (new Rect (0, 24, 80, 1), status.Frame);
 			Assert.Equal (new Rect (0, 1, 80, 23), win.Frame);
-			Assert.Equal (new Rect (1, 1, 78, 21), win.Subviews [0].Frame);
-			Assert.Equal (new Rect (1, 1, 79, 22), new Rect (
-				win.Subviews [0].Frame.Left, win.Subviews [0].Frame.Top,
-				win.Subviews [0].Frame.Right, win.Subviews [0].Frame.Bottom));
 			Assert.Equal (new Rect (68, 20, 10, 1), tv.Frame);
 		}
 
@@ -144,11 +135,6 @@ namespace Terminal.Gui.TypeTests {
 			Assert.True (label.AutoSize);
 			Assert.Equal (new Rect (0, 0, 40, 10), top.Frame);
 			Assert.Equal (new Rect (0, 0, 40, 10), win.Frame);
-			Assert.Equal (new Rect (1, 1, 38, 8), win.Subviews [0].Frame);
-			Assert.Equal ("ContentView()({X=1,Y=1,Width=38,Height=8})", win.Subviews [0].ToString ());
-			Assert.Equal (new Rect (0, 0, 40, 10), new Rect (
-				win.Frame.Left, win.Frame.Top,
-				win.Frame.Right, win.Frame.Bottom));
 			Assert.Equal (new Rect (0, 7, 38, 1), label.Frame);
 			var expected = @"
 ┌──────────────────────────────────────┐
@@ -191,11 +177,6 @@ namespace Terminal.Gui.TypeTests {
 			Assert.Equal (29, label.Text.Length);
 			Assert.Equal (new Rect (0, 0, 40, 10), top.Frame);
 			Assert.Equal (new Rect (0, 0, 40, 10), win.Frame);
-			Assert.Equal (new Rect (1, 1, 38, 8), win.Subviews [0].Frame);
-			Assert.Equal ("ContentView()({X=1,Y=1,Width=38,Height=8})", win.Subviews [0].ToString ());
-			Assert.Equal (new Rect (0, 0, 40, 10), new Rect (
-				win.Frame.Left, win.Frame.Top,
-				win.Frame.Right, win.Frame.Bottom));
 			Assert.Equal (new Rect (0, 7, 38, 1), label.Frame);
 			var expected = @"
 ┌──────────────────────────────────────┐
@@ -240,10 +221,6 @@ namespace Terminal.Gui.TypeTests {
 			Assert.Equal (new Rect (0, 0, 80, 1), menu.Frame);
 			Assert.Equal (new Rect (0, 24, 80, 1), status.Frame);
 			Assert.Equal (new Rect (0, 1, 80, 23), win.Frame);
-			Assert.Equal (new Rect (1, 1, 78, 21), win.Subviews [0].Frame);
-			Assert.Equal (new Rect (0, 1, 80, 24), new Rect (
-				win.Frame.Left, win.Frame.Top,
-				win.Frame.Right, win.Frame.Bottom));
 			Assert.Equal (new Rect (0, 20, 78, 1), label.Frame);
 			var expected = @"
  Menu                                                                           
@@ -303,10 +280,6 @@ namespace Terminal.Gui.TypeTests {
 			Assert.Equal (new Rect (0, 0, 80, 1), menu.Frame);
 			Assert.Equal (new Rect (0, 24, 80, 1), status.Frame);
 			Assert.Equal (new Rect (0, 1, 80, 23), win.Frame);
-			Assert.Equal (new Rect (1, 1, 78, 21), win.Subviews [0].Frame);
-			Assert.Equal (new Rect (0, 1, 80, 24), new Rect (
-				win.Frame.Left, win.Frame.Top,
-				win.Frame.Right, win.Frame.Bottom));
 			Assert.Equal (new Rect (0, 20, 78, 1), label.Frame);
 			var expected = @"
  Menu                                                                           
@@ -784,52 +757,51 @@ namespace Terminal.Gui.TypeTests {
 
 		// DONE: Test PosCombine
 		// DONE: Test operators
-		[Fact]
-		public void PosCombine_Do_Not_Throws ()
-		{
-			Application.Init (new FakeDriver ());
-
-			var t = Application.Top;
-
-			var w = new Window ("w") {
-				X = Pos.Left (t) + 2,
-				Y = Pos.Top (t) + 2
-			};
-			var f = new FrameView ("f");
-			var v1 = new View ("v1") {
-				X = Pos.Left (w) + 2,
-				Y = Pos.Top (w) + 2
-			};
-			var v2 = new View ("v2") {
-				X = Pos.Left (v1) + 2,
-				Y = Pos.Top (v1) + 2
-			};
-
-			f.Add (v1, v2);
-			w.Add (f);
-			t.Add (w);
-
-			f.X = Pos.X (t) + Pos.X (v2) - Pos.X (v1);
-			f.Y = Pos.Y (t) + Pos.Y (v2) - Pos.Y (v1);
-
-			t.Ready += (s, e) => {
-				Assert.Equal (0, t.Frame.X);
-				Assert.Equal (0, t.Frame.Y);
-				Assert.Equal (2, w.Frame.X);
-				Assert.Equal (2, w.Frame.Y);
-				Assert.Equal (2, f.Frame.X);
-				Assert.Equal (2, f.Frame.Y);
-				Assert.Equal (4, v1.Frame.X);
-				Assert.Equal (4, v1.Frame.Y);
-				Assert.Equal (6, v2.Frame.X);
-				Assert.Equal (6, v2.Frame.Y);
-			};
-
-			Application.Iteration += () => Application.RequestStop ();
-
-			Application.Run ();
-			Application.Shutdown ();
-		}
+		// BUGBUG: v2 - This test is bogus. v1 and references it's superview's (f) superview (w). 
+		//[Fact]
+		//public void PosCombine_Do_Not_Throws ()
+		//{
+		//	Application.Init (new FakeDriver ());
+
+		//	var w = new Window ("w") {
+		//		X = Pos.Left (Application.Top) + 2,
+		//		Y = Pos.Top (Application.Top) + 2
+		//	};
+		//	var f = new FrameView ("f");
+		//	var v1 = new View ("v1") {
+		//		X = Pos.Left (w) + 2,
+		//		Y = Pos.Top (w) + 2
+		//	};
+		//	var v2 = new View ("v2") {
+		//		X = Pos.Left (v1) + 2,
+		//		Y = Pos.Top (v1) + 2
+		//	};
+
+		//	f.Add (v1, v2);
+		//	w.Add (f);
+		//	Application.Top.Add (w);
+
+		//	f.X = Pos.X (Application.Top) + Pos.X (v2) - Pos.X (v1);
+		//	f.Y = Pos.Y (Application.Top) + Pos.Y (v2) - Pos.Y (v1);
+
+		//	Application.Top.LayoutComplete += (s, e) => {
+		//		Assert.Equal (0, Application.Top.Frame.X);
+		//		Assert.Equal (0, Application.Top.Frame.Y);
+		//		Assert.Equal (2, w.Frame.X);
+		//		Assert.Equal (2, w.Frame.Y);
+		//		Assert.Equal (2, f.Frame.X);
+		//		Assert.Equal (2, f.Frame.Y);
+		//		Assert.Equal (4, v1.Frame.X);
+		//		Assert.Equal (4, v1.Frame.Y);
+		//		Assert.Equal (6, v2.Frame.X);
+		//		Assert.Equal (6, v2.Frame.Y);
+		//	};
+
+		//	Application.Iteration += () => Application.RequestStop ();
+
+		//	Application.Run ();
+		//	Application.Shutdown ();
+		//}
 
 		[Fact]
 		public void PosCombine_Will_Throws ()