Przeglądaj źródła

Added a Pos.Combine unit test.

BDisp 2 lat temu
rodzic
commit
1136514bf8
1 zmienionych plików z 35 dodań i 0 usunięć
  1. 35 0
      UnitTests/PosTests.cs

+ 35 - 0
UnitTests/PosTests.cs

@@ -1032,5 +1032,40 @@ namespace Terminal.Gui.Core {
 			pos2 = Pos.Function (f2);
 			Assert.NotEqual (pos1, pos2);
 		}
+
+		[Theory, AutoInitShutdown]
+		[InlineData (true)]
+		[InlineData (false)]
+
+		public void PosPercentPlusOne (bool testHorizontal)
+		{
+			var container = new View {
+				Width = 100,
+				Height = 100,
+			};
+
+			var label = new Label {
+				X = testHorizontal ? Pos.Percent (50) + Pos.Percent (10) + 1 : 1,
+				Y = testHorizontal ? 1 : Pos.Percent (50) + Pos.Percent (10) + 1,
+				Width = 10,
+				Height = 10,
+			};
+
+			container.Add (label);
+			Application.Top.Add (container);
+			Application.Top.LayoutSubviews ();
+
+
+			Assert.Equal (100, container.Frame.Width);
+			Assert.Equal (100, container.Frame.Height);
+
+			if (testHorizontal) {
+				Assert.Equal (61, label.Frame.X);
+				Assert.Equal (1, label.Frame.Y);
+			} else {
+				Assert.Equal (1, label.Frame.X);
+				Assert.Equal (61, label.Frame.Y);
+			}
+		}
 	}
 }