|
@@ -54,13 +54,33 @@ namespace Terminal.Gui.CoreTests {
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
- public void AbsoluteLayout_Set_Frame ()
|
|
|
+ public void AbsoluteLayout_Change_Frame ()
|
|
|
{
|
|
|
var frame = new Rect (1, 2, 3, 4);
|
|
|
var newFrame = new Rect (1, 2, 30, 40);
|
|
|
|
|
|
var v = new View (frame);
|
|
|
v.Frame = newFrame;
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
|
|
|
+ Assert.Equal (newFrame, v.Frame);
|
|
|
+ Assert.Equal (new Rect (0, 0, newFrame.Width, newFrame.Height), v.Bounds); // With Absolute Bounds *is* deterministic before Layout
|
|
|
+ Assert.Null (v.X);
|
|
|
+ Assert.Null (v.Y);
|
|
|
+ Assert.Null (v.Height);
|
|
|
+ Assert.Null (v.Width);
|
|
|
+
|
|
|
+ v = new View (frame.X, frame.Y, "v");
|
|
|
+ v.Frame = newFrame;
|
|
|
+ Assert.Equal (newFrame, v.Frame);
|
|
|
+ Assert.Equal (new Rect (0, 0, newFrame.Width, newFrame.Height), v.Bounds); // With Absolute Bounds *is* deterministic before Layout
|
|
|
+ Assert.Null (v.X);
|
|
|
+ Assert.Null (v.Y);
|
|
|
+ Assert.Null (v.Height);
|
|
|
+ Assert.Null (v.Width);
|
|
|
+
|
|
|
+ newFrame = new Rect (10, 20, 30, 40);
|
|
|
+ v = new View (frame);
|
|
|
+ v.Frame = newFrame;
|
|
|
Assert.Equal (newFrame, v.Frame);
|
|
|
Assert.Equal (new Rect (0, 0, newFrame.Width, newFrame.Height), v.Bounds); // With Absolute Bounds *is* deterministic before Layout
|
|
|
Assert.Null (v.X);
|
|
@@ -81,7 +101,7 @@ namespace Terminal.Gui.CoreTests {
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
- public void AbsoluteLayout_Set_Size ()
|
|
|
+ public void AbsoluteLayout_Change_Height_or_Width_Absolute ()
|
|
|
{
|
|
|
var frame = new Rect (1, 2, 3, 4);
|
|
|
var newFrame = new Rect (1, 2, 30, 40);
|
|
@@ -94,20 +114,185 @@ namespace Terminal.Gui.CoreTests {
|
|
|
Assert.Equal (new Rect (0, 0, newFrame.Width, newFrame.Height), v.Bounds); // With Absolute Bounds *is* deterministic before Layout
|
|
|
Assert.Null (v.X);
|
|
|
Assert.Null (v.Y);
|
|
|
- Assert.Null (v.Height);
|
|
|
- Assert.Null (v.Width);
|
|
|
+ Assert.Equal ($"Absolute({newFrame.Height})", v.Height.ToString());
|
|
|
+ Assert.Equal ($"Absolute({newFrame.Width})", v.Width.ToString ());
|
|
|
+ }
|
|
|
|
|
|
- v = new View (frame.X, frame.Y, "v");
|
|
|
- v.Height = newFrame.Height;
|
|
|
- v.Width = newFrame.Width;
|
|
|
+ [Fact]
|
|
|
+ public void AbsoluteLayout_Change_Height_or_Width_NotAbsolute ()
|
|
|
+ {
|
|
|
+ var v = new View (Rect.Empty);
|
|
|
+ v.Height = Dim.Fill ();
|
|
|
+ v.Width = Dim.Fill ();
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute); // BUGBUG: v2 - Changing the Height or Width should change the LayoutStyle
|
|
|
+ }
|
|
|
+
|
|
|
+ [Fact]
|
|
|
+ public void AbsoluteLayout_Change_Height_or_Width_Null ()
|
|
|
+ {
|
|
|
+ var v = new View (Rect.Empty);
|
|
|
+ v.Height = null;
|
|
|
+ v.Width = null;
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
|
|
|
+ }
|
|
|
+
|
|
|
+ [Fact]
|
|
|
+ public void AbsoluteLayout_Change_X_or_Y_Absolute ()
|
|
|
+ {
|
|
|
+ var frame = new Rect (1, 2, 3, 4);
|
|
|
+ var newFrame = new Rect (10, 20, 3, 4);
|
|
|
+
|
|
|
+ var v = new View (frame);
|
|
|
+ v.X = newFrame.X;
|
|
|
+ v.Y = newFrame.Y;
|
|
|
Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
|
|
|
Assert.Equal (newFrame, v.Frame);
|
|
|
Assert.Equal (new Rect (0, 0, newFrame.Width, newFrame.Height), v.Bounds); // With Absolute Bounds *is* deterministic before Layout
|
|
|
- Assert.Null (v.X);
|
|
|
- Assert.Null (v.Y);
|
|
|
+ Assert.Equal ($"Absolute({newFrame.X})", v.X.ToString ());
|
|
|
+ Assert.Equal ($"Absolute({newFrame.Y})", v.Y.ToString ());
|
|
|
Assert.Null (v.Height);
|
|
|
Assert.Null (v.Width);
|
|
|
+ }
|
|
|
|
|
|
+ [Fact]
|
|
|
+ public void AbsoluteLayout_Change_X_or_Y_NotAbsolute ()
|
|
|
+ {
|
|
|
+ var v = new View (Rect.Empty);
|
|
|
+ v.X = Pos.Center ();
|
|
|
+ v.Y = Pos.Center ();
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute); // BUGBUG: v2 - Changing the Height or Width should change the LayoutStyle
|
|
|
+ }
|
|
|
+
|
|
|
+ [Fact]
|
|
|
+ public void AbsoluteLayout_Change_X_or_Y_Null ()
|
|
|
+ {
|
|
|
+ var v = new View (Rect.Empty);
|
|
|
+ v.X = null;
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
|
|
|
+
|
|
|
+ v = new View (Rect.Empty);
|
|
|
+ v.X = Pos.Center ();
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute); // BUGBUG: v2 - Changing the Height or Width should change the LayoutStyle
|
|
|
+
|
|
|
+ v.X = null;
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
|
|
|
+
|
|
|
+ v = new View (Rect.Empty);
|
|
|
+ v.Y = null;
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
|
|
|
+
|
|
|
+ v = new View (Rect.Empty);
|
|
|
+ v.Y = Pos.Center ();
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute); // BUGBUG: v2 - Changing the Height or Width should change the LayoutStyle
|
|
|
+
|
|
|
+ v.Y = null;
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
|
|
|
+ }
|
|
|
+
|
|
|
+ [Fact]
|
|
|
+ public void AbsoluteLayout_Change_X_Y_Height_Width_Absolute ()
|
|
|
+ {
|
|
|
+ var v = new View (Rect.Empty);
|
|
|
+ v.X = 1;
|
|
|
+ v.Y = 2;
|
|
|
+ v.Height = 3;
|
|
|
+ v.Width = 4;
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
|
|
|
+
|
|
|
+ v = new View (Rect.Empty);
|
|
|
+ v.X = Pos.Center ();
|
|
|
+ v.Y = Pos.Center ();
|
|
|
+ v.Width = Dim.Fill ();
|
|
|
+ v.Height = Dim.Fill ();
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute); // BUGBUG: v2 - Changing the Height or Width should change the LayoutStyle
|
|
|
+
|
|
|
+ // BUGBUG: v2 - If all of X, Y, Width, and Height are null or Absolute(n), isn't that the same as LayoutStyle.Absoulte?
|
|
|
+ v.X = null;
|
|
|
+ v.Y = null;
|
|
|
+ v.Height = null;
|
|
|
+ v.Width = null;
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute); // We never automatically change to Absolute from Computed??
|
|
|
+
|
|
|
+ v = new View (Rect.Empty);
|
|
|
+ v.X = Pos.Center ();
|
|
|
+ v.Y = Pos.Center ();
|
|
|
+ v.Width = Dim.Fill ();
|
|
|
+ v.Height = Dim.Fill ();
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute); // BUGBUG: v2 - Changing the Height or Width should change the LayoutStyle
|
|
|
+
|
|
|
+ // BUGBUG: v2 - If all of X, Y, Width, and Height are null or Absolute(n), isn't that the same as LayoutStyle.Absoulte?
|
|
|
+ v.X = 1;
|
|
|
+ v.Y = null;
|
|
|
+ v.Height = null;
|
|
|
+ v.Width = null;
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute); // We never automatically change to Absolute from Computed??
|
|
|
+
|
|
|
+ v = new View (Rect.Empty);
|
|
|
+ v.X = Pos.Center ();
|
|
|
+ v.Y = Pos.Center ();
|
|
|
+ v.Width = Dim.Fill ();
|
|
|
+ v.Height = Dim.Fill ();
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute); // BUGBUG: v2 - Changing the Height or Width should change the LayoutStyle
|
|
|
+
|
|
|
+ // BUGBUG: v2 - If all of X, Y, Width, and Height are null or Absolute(n), isn't that the same as LayoutStyle.Absoulte?
|
|
|
+ v.X = null;
|
|
|
+ v.Y = 2;
|
|
|
+ v.Height = null;
|
|
|
+ v.Width = null;
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute); // We never automatically change to Absolute from Computed??
|
|
|
+
|
|
|
+ v = new View (Rect.Empty);
|
|
|
+ v.X = Pos.Center ();
|
|
|
+ v.Y = Pos.Center ();
|
|
|
+ v.Width = Dim.Fill ();
|
|
|
+ v.Height = Dim.Fill ();
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute); // BUGBUG: v2 - Changing the Height or Width should change the LayoutStyle
|
|
|
+
|
|
|
+ // BUGBUG: v2 - If all of X, Y, Width, and Height are null or Absolute(n), isn't that the same as LayoutStyle.Absoulte?
|
|
|
+ v.X = null;
|
|
|
+ v.Y = null;
|
|
|
+ v.Height = 3;
|
|
|
+ v.Width = null;
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute); // We never automatically change to Absolute from Computed??
|
|
|
+
|
|
|
+ v = new View (Rect.Empty);
|
|
|
+ v.X = Pos.Center ();
|
|
|
+ v.Y = Pos.Center ();
|
|
|
+ v.Width = Dim.Fill ();
|
|
|
+ v.Height = Dim.Fill ();
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute); // BUGBUG: v2 - Changing the Height or Width should change the LayoutStyle
|
|
|
+
|
|
|
+ // BUGBUG: v2 - If all of X, Y, Width, and Height are null or Absolute(n), isn't that the same as LayoutStyle.Absoulte?
|
|
|
+ v.X = null;
|
|
|
+ v.Y = null;
|
|
|
+ v.Height = null;
|
|
|
+ v.Width = 4;
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute); // We never automatically change to Absolute from Computed??
|
|
|
+ }
|
|
|
+
|
|
|
+ [Fact]
|
|
|
+ public void AbsoluteLayout_Change_X_Y_Height_Width_Null ()
|
|
|
+ {
|
|
|
+ var v = new View (Rect.Empty);
|
|
|
+ v.X = null;
|
|
|
+ v.Y = null;
|
|
|
+ v.Height = null;
|
|
|
+ v.Width = null;
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
|
|
|
+
|
|
|
+ v = new View (Rect.Empty);
|
|
|
+ v.X = Pos.Center ();
|
|
|
+ v.Y = Pos.Center ();
|
|
|
+ v.Width = Dim.Fill ();
|
|
|
+ v.Height = Dim.Fill ();
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute); // BUGBUG: v2 - Changing the Height or Width should change the LayoutStyle
|
|
|
+
|
|
|
+ // BUGBUG: v2 - If all of X, Y, Width, and Height are null or Absolute(n), isn't that the same as LayoutStyle.Absoulte?
|
|
|
+ v.X = null;
|
|
|
+ v.Y = null;
|
|
|
+ v.Height = null;
|
|
|
+ v.Width = null;
|
|
|
+ Assert.True (v.LayoutStyle == LayoutStyle.Absolute); // We never automatically change to Absolute from Computed??
|
|
|
}
|
|
|
|
|
|
[Fact]
|
|
@@ -115,14 +300,15 @@ namespace Terminal.Gui.CoreTests {
|
|
|
{
|
|
|
var superRect = new Rect (0, 0, 100, 100);
|
|
|
var super = new View (superRect, "super");
|
|
|
-
|
|
|
-
|
|
|
+ Assert.True (super.LayoutStyle == LayoutStyle.Absolute);
|
|
|
var v1 = new View () {
|
|
|
X = 0,
|
|
|
Y = 0,
|
|
|
Width = 10,
|
|
|
Height = 10
|
|
|
};
|
|
|
+ // BUGBUG: v2 - This should be LayoutStyle.Absolute
|
|
|
+ Assert.True (v1.LayoutStyle == LayoutStyle.Computed);
|
|
|
|
|
|
var v2 = new View () {
|
|
|
X = 10,
|
|
@@ -130,11 +316,11 @@ namespace Terminal.Gui.CoreTests {
|
|
|
Width = 10,
|
|
|
Height = 10
|
|
|
};
|
|
|
+ // BUGBUG: v2 - This should be LayoutStyle.Absolute
|
|
|
+ Assert.True (v1.LayoutStyle == LayoutStyle.Computed);
|
|
|
|
|
|
super.Add (v1, v2);
|
|
|
-
|
|
|
super.LayoutSubviews ();
|
|
|
-
|
|
|
Assert.Equal (new Rect (0, 0, 10, 10), v1.Frame);
|
|
|
Assert.Equal (new Rect (10, 10, 10, 10), v2.Frame);
|
|
|
}
|