|
@@ -1,4 +1,5 @@
|
|
|
-๏ปฟusing System;
|
|
|
+๏ปฟusing NStack;
|
|
|
+using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Text;
|
|
|
using Xunit;
|
|
@@ -14,13 +15,407 @@ namespace Terminal.Gui.DrawingTests {
|
|
|
this.output = output;
|
|
|
}
|
|
|
|
|
|
+ [InlineData (0, 0, 0,
|
|
|
+ 0, 0, 1, 1)]
|
|
|
+ [InlineData (0, 0, 1,
|
|
|
+ 0, 0, 1, 1)]
|
|
|
+ [InlineData (0, 0, 2,
|
|
|
+ 0, 0, 2, 1)]
|
|
|
+ [InlineData (0, 0, 3,
|
|
|
+ 0, 0, 3, 1)]
|
|
|
+ [InlineData (0, 0, -1,
|
|
|
+ 0, 0, 1, 1)]
|
|
|
+ [InlineData (0, 0, -2,
|
|
|
+ -1, 0, 2, 1)]
|
|
|
+ [InlineData (0, 0, -3,
|
|
|
+ -2, 0, 3, 1)]
|
|
|
+
|
|
|
+ [Theory, SetupFakeDriver]
|
|
|
+ public void Bounds_H_Line (int x, int y, int length,
|
|
|
+ int expectedX, int expectedY, int expectedWidth, int expectedHeight)
|
|
|
+ {
|
|
|
+ var canvas = new LineCanvas ();
|
|
|
+ canvas.AddLine (new Point (x, y), length, Orientation.Horizontal, LineStyle.Single);
|
|
|
+
|
|
|
+ Assert.Equal (new Rect (expectedX, expectedY, expectedWidth, expectedHeight), canvas.Bounds);
|
|
|
+ }
|
|
|
+
|
|
|
+ [InlineData (0, 0, 0,
|
|
|
+ 0, 0, 1, 1)]
|
|
|
+ [InlineData (0, 0, 1,
|
|
|
+ 0, 0, 1, 1)]
|
|
|
+ [InlineData (0, 0, 2,
|
|
|
+ 0, 0, 2, 2)]
|
|
|
+ [InlineData (0, 0, 3,
|
|
|
+ 0, 0, 3, 3)]
|
|
|
+ [InlineData (0, 0, -1,
|
|
|
+ 0, 0, 1, 1)]
|
|
|
+ [InlineData (0, 0, -2,
|
|
|
+ -1, -1, 2, 2)]
|
|
|
+ [InlineData (0, 0, -3,
|
|
|
+ -2, -2, 3, 3)]
|
|
|
+ [Theory, SetupFakeDriver]
|
|
|
+ public void Bounds_H_And_V_Lines_Both_Positive (int x, int y, int length,
|
|
|
+ int expectedX, int expectedY, int expectedWidth, int expectedHeight)
|
|
|
+ {
|
|
|
+ var canvas = new LineCanvas ();
|
|
|
+ canvas.AddLine (new Point (x, y), length, Orientation.Horizontal, LineStyle.Single);
|
|
|
+ canvas.AddLine (new Point (x, y), length, Orientation.Vertical, LineStyle.Single);
|
|
|
+
|
|
|
+ Assert.Equal (new Rect (expectedX, expectedY, expectedWidth, expectedHeight), canvas.Bounds);
|
|
|
+ }
|
|
|
+
|
|
|
+ [Fact, SetupFakeDriver]
|
|
|
+ public void Canvas_Updates_On_Changes ()
|
|
|
+ {
|
|
|
+ var lc = new LineCanvas ();
|
|
|
+
|
|
|
+ Assert.Equal (Rect.Empty, lc.Bounds);
|
|
|
+
|
|
|
+ lc.AddLine (new Point (0, 0), 2, Orientation.Horizontal, LineStyle.Double);
|
|
|
+ Assert.NotEqual (Rect.Empty, lc.Bounds);
|
|
|
+
|
|
|
+ lc.Clear ();
|
|
|
+ Assert.Equal (Rect.Empty, lc.Bounds);
|
|
|
+ }
|
|
|
+
|
|
|
+ [Fact, SetupFakeDriver]
|
|
|
+ public void Bounds_Specific ()
|
|
|
+ {
|
|
|
+ // Draw at 1,1 within client area of View (i.e. leave a top and left margin of 1)
|
|
|
+ // This proves we aren't drawing excess above
|
|
|
+ int x = 1;
|
|
|
+ int y = 2;
|
|
|
+ int width = 3;
|
|
|
+ int height = 2;
|
|
|
+
|
|
|
+ var lc = new LineCanvas ();
|
|
|
+
|
|
|
+ // 01230
|
|
|
+ // โโกโโ1
|
|
|
+ // โ โ2
|
|
|
+
|
|
|
+ // Add a short horiz line for โโก
|
|
|
+ lc.AddLine (new Point (x, y), 2, Orientation.Horizontal, LineStyle.Double);
|
|
|
+ Assert.Equal (new Rect (x, y, 2, 1), lc.Bounds);
|
|
|
+
|
|
|
+ //LHS line down
|
|
|
+ lc.AddLine (new Point (x, y), height, Orientation.Vertical, LineStyle.Double);
|
|
|
+ Assert.Equal (new Rect (x, y, 2, 2), lc.Bounds);
|
|
|
+
|
|
|
+ //Vertical line before Title, results in a โก
|
|
|
+ lc.AddLine (new Point (x + 1, y), 0, Orientation.Vertical, LineStyle.Single);
|
|
|
+ Assert.Equal (new Rect (x, y, 2, 2), lc.Bounds);
|
|
|
+
|
|
|
+ //Vertical line after Title, results in a โ
|
|
|
+ lc.AddLine (new Point (x + 2, y), 0, Orientation.Vertical, LineStyle.Single);
|
|
|
+ Assert.Equal (new Rect (x, y, 3, 2), lc.Bounds);
|
|
|
+
|
|
|
+ // remainder of top line
|
|
|
+ lc.AddLine (new Point (x + 2, y), width - 1, Orientation.Horizontal, LineStyle.Double);
|
|
|
+ Assert.Equal (new Rect (x, y, 4, 2), lc.Bounds);
|
|
|
+
|
|
|
+ //RHS line down
|
|
|
+ lc.AddLine (new Point (x + width, y), height, Orientation.Vertical, LineStyle.Double);
|
|
|
+ Assert.Equal (new Rect (x, y, 4, 2), lc.Bounds);
|
|
|
+
|
|
|
+ TestHelpers.AssertEqual (output, @"
|
|
|
+โโกโโ
|
|
|
+โ โ",
|
|
|
+ $"{Environment.NewLine}{lc}");
|
|
|
+ }
|
|
|
+
|
|
|
+ [Fact, SetupFakeDriver]
|
|
|
+ public void Bounds_Specific_With_Ustring ()
|
|
|
+ {
|
|
|
+ // Draw at 1,1 within client area of View (i.e. leave a top and left margin of 1)
|
|
|
+ // This proves we aren't drawing excess above
|
|
|
+ int x = 1;
|
|
|
+ int y = 2;
|
|
|
+ int width = 3;
|
|
|
+ int height = 2;
|
|
|
+
|
|
|
+ var lc = new LineCanvas ();
|
|
|
+
|
|
|
+ // 01230
|
|
|
+ // โโกโโ1
|
|
|
+ // โ โ2
|
|
|
+
|
|
|
+ // Add a short horiz line for โโก
|
|
|
+ lc.AddLine (new Point (x, y), 2, Orientation.Horizontal, LineStyle.Double);
|
|
|
+ Assert.Equal (new Rect (x, y, 2, 1), lc.Bounds);
|
|
|
+
|
|
|
+ //LHS line down
|
|
|
+ lc.AddLine (new Point (x, y), height, Orientation.Vertical, LineStyle.Double);
|
|
|
+ Assert.Equal (new Rect (x, y, 2, 2), lc.Bounds);
|
|
|
+
|
|
|
+ //Vertical line before Title, results in a โก
|
|
|
+ lc.AddLine (new Point (x + 1, y), 0, Orientation.Vertical, LineStyle.Single);
|
|
|
+ Assert.Equal (new Rect (x, y, 2, 2), lc.Bounds);
|
|
|
+
|
|
|
+ //Vertical line after Title, results in a โ
|
|
|
+ lc.AddLine (new Point (x + 2, y), 0, Orientation.Vertical, LineStyle.Single);
|
|
|
+ Assert.Equal (new Rect (x, y, 3, 2), lc.Bounds);
|
|
|
+
|
|
|
+ // remainder of top line
|
|
|
+ lc.AddLine (new Point (x + 2, y), width - 1, Orientation.Horizontal, LineStyle.Double);
|
|
|
+ Assert.Equal (new Rect (x, y, 4, 2), lc.Bounds);
|
|
|
+
|
|
|
+ //RHS line down
|
|
|
+ lc.AddLine (new Point (x + width, y), height, Orientation.Vertical, LineStyle.Double);
|
|
|
+ Assert.Equal (new Rect (x, y, 4, 2), lc.Bounds);
|
|
|
+
|
|
|
+ TestHelpers.AssertEqual (output, @"
|
|
|
+โโกโโ
|
|
|
+โ โ",
|
|
|
+ ustring.Make ($"{Environment.NewLine}{lc}"));
|
|
|
+ }
|
|
|
+
|
|
|
+ [Fact, SetupFakeDriver]
|
|
|
+ public void ToString_Empty ()
|
|
|
+ {
|
|
|
+ var lc = new LineCanvas ();
|
|
|
+ TestHelpers.AssertEqual (output, string.Empty, lc.ToString ());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 012
|
|
|
+ [InlineData (0, 0, "โโโ")]
|
|
|
+ [InlineData (1, 0, "โโโ")]
|
|
|
+ [InlineData (0, 1, "โโโ")]
|
|
|
+ [InlineData (1, 1, "โโโ")]
|
|
|
+ [InlineData (2, 2, "โโโ")]
|
|
|
+ [InlineData (-1, 0, "โโโ")]
|
|
|
+ [InlineData (0, -1, "โโโ")]
|
|
|
+ [InlineData (-1, -1, "โโโ")]
|
|
|
+ [InlineData (-2, -2, "โโโ")]
|
|
|
+ [Theory, SetupFakeDriver]
|
|
|
+ public void ToString_Positive_Horizontal_1Line_Offset (int x, int y, string expected)
|
|
|
+ {
|
|
|
+ var lc = new LineCanvas ();
|
|
|
+ lc.AddLine (new Point (x, y), 3, Orientation.Horizontal, LineStyle.Double);
|
|
|
+ TestHelpers.AssertEqual (output, expected, $"{lc}");
|
|
|
+ }
|
|
|
+
|
|
|
+ [InlineData (0, 0, 0, 0, "โโโ")]
|
|
|
+ [InlineData (1, 0, 1, 0, "โโโ")]
|
|
|
+ [InlineData (-1, 0, -1, 0, "โโโ")]
|
|
|
+ [InlineData (0, 0, 1, 0, "โโโโ")]
|
|
|
+ [InlineData (1, 0, 3, 0, "โโโโโ")]
|
|
|
+ [InlineData (1, 0, 4, 0, "โโโโโโ")]
|
|
|
+ [InlineData (1, 0, 5, 0, "โโโ โโโ")]
|
|
|
+
|
|
|
+ [InlineData (0, 0, 0, 1, $"โโโ\r\nโโโ")]
|
|
|
+ [InlineData (0, 0, 1, 1, "โโโ \r\n โโโ")]
|
|
|
+ [InlineData (0, 0, 2, 1, "โโโ \r\n โโโ")]
|
|
|
+
|
|
|
+ [InlineData (1, 0, 0, 1, " โโโ\r\nโโโ ")]
|
|
|
+ [InlineData (0, 1, 0, 1, "โโโ")]
|
|
|
+ [InlineData (1, 1, 0, 1, "โโโโ")]
|
|
|
+ [InlineData (2, 2, 0, 1, "โโโ \r\n โโโ")]
|
|
|
+ [Theory, SetupFakeDriver]
|
|
|
+ public void ToString_Positive_Horizontal_2Line_Offset (int x1, int y1, int x2, int y2, string expected)
|
|
|
+ {
|
|
|
+ var lc = new LineCanvas ();
|
|
|
+ lc.AddLine (new Point (x1, y1), 3, Orientation.Horizontal, LineStyle.Double);
|
|
|
+ lc.AddLine (new Point (x2, y2), 3, Orientation.Horizontal, LineStyle.Double);
|
|
|
+
|
|
|
+ TestHelpers.AssertEqual (output, expected, $"{lc}");
|
|
|
+ }
|
|
|
+
|
|
|
+ [InlineData (0, 0, Orientation.Horizontal, "โ")]
|
|
|
+ [InlineData (1, 0, Orientation.Horizontal, "โ")]
|
|
|
+ [InlineData (0, 1, Orientation.Horizontal, "โ")]
|
|
|
+ [InlineData (0, 0, Orientation.Vertical, "โ")]
|
|
|
+ [InlineData (1, 0, Orientation.Vertical, "โ")]
|
|
|
+ [InlineData (0, 1, Orientation.Vertical, "โ")]
|
|
|
+ [Theory, SetupFakeDriver]
|
|
|
+ public void Length_Zero_Alone_Is_Line (int x, int y, Orientation orientation, string expected)
|
|
|
+ {
|
|
|
+ var lc = new LineCanvas ();
|
|
|
+ // Add a line at 0, 0 that's has length of 0
|
|
|
+ lc.AddLine (new Point (0, 0), 0, orientation, LineStyle.Single);
|
|
|
+ TestHelpers.AssertEqual (output, expected, $"{lc}");
|
|
|
+ }
|
|
|
+
|
|
|
+ [InlineData (0, 0, Orientation.Horizontal, "โผ")]
|
|
|
+ [InlineData (1, 0, Orientation.Horizontal, "โผ")]
|
|
|
+ [InlineData (0, 1, Orientation.Horizontal, "โผ")]
|
|
|
+ [InlineData (0, 0, Orientation.Vertical, "โผ")]
|
|
|
+ [InlineData (1, 0, Orientation.Vertical, "โผ")]
|
|
|
+ [InlineData (0, 1, Orientation.Vertical, "โผ")]
|
|
|
+ [Theory, SetupFakeDriver]
|
|
|
+ public void Length_Zero_Cross_Is_Cross (int x, int y, Orientation orientation, string expected)
|
|
|
+ {
|
|
|
+ var lc = new LineCanvas ();
|
|
|
+
|
|
|
+ // Add point at opposite orientation
|
|
|
+ lc.AddLine (new Point (0, 0), 0, orientation == Orientation.Horizontal ? Orientation.Vertical : Orientation.Horizontal, LineStyle.Single);
|
|
|
+
|
|
|
+ // Add a line at 0, 0 that's has length of 0
|
|
|
+ lc.AddLine (new Point (0, 0), 0, orientation, LineStyle.Single);
|
|
|
+ TestHelpers.AssertEqual (output, expected, $"{lc}");
|
|
|
+ }
|
|
|
+
|
|
|
+ [InlineData (0, 0, Orientation.Horizontal, "โฅ")]
|
|
|
+ [InlineData (1, 0, Orientation.Horizontal, "โฅ")]
|
|
|
+ [InlineData (0, 1, Orientation.Horizontal, "โฅ")]
|
|
|
+ [InlineData (0, 0, Orientation.Vertical, "โ")]
|
|
|
+ [InlineData (1, 0, Orientation.Vertical, "โ")]
|
|
|
+ [InlineData (0, 1, Orientation.Vertical, "โ")]
|
|
|
+ [Theory, SetupFakeDriver]
|
|
|
+ public void Length_Zero_NextTo_Opposite_Is_T (int x, int y, Orientation orientation, string expected)
|
|
|
+ {
|
|
|
+ var lc = new LineCanvas ();
|
|
|
+
|
|
|
+ // Add line with length of 1 in opposite orientation starting at same location
|
|
|
+ if (orientation == Orientation.Horizontal) {
|
|
|
+ lc.AddLine (new Point (0, 0), 1, Orientation.Vertical, LineStyle.Double);
|
|
|
+ } else {
|
|
|
+ lc.AddLine (new Point (0, 0), 1, Orientation.Horizontal, LineStyle.Double);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // Add a line at 0, 0 that's has length of 0
|
|
|
+ lc.AddLine (new Point (0, 0), 0, orientation, LineStyle.Single);
|
|
|
+ TestHelpers.AssertEqual (output, expected, $"{lc}");
|
|
|
+ }
|
|
|
+
|
|
|
+ [InlineData (0, 0, Orientation.Horizontal, "โ")]
|
|
|
+ [InlineData (1, 0, Orientation.Horizontal, "โ")]
|
|
|
+ [InlineData (0, 1, Orientation.Horizontal, "โ")]
|
|
|
+ [InlineData (-1, 0, Orientation.Horizontal, "โ")]
|
|
|
+ [InlineData (0, -1, Orientation.Horizontal, "โ")]
|
|
|
+ [InlineData (-1, -1, Orientation.Horizontal, "โ")]
|
|
|
+ [InlineData (0, 0, Orientation.Vertical, "โ")]
|
|
|
+ [InlineData (1, 0, Orientation.Vertical, "โ")]
|
|
|
+ [InlineData (0, 1, Orientation.Vertical, "โ")]
|
|
|
+ [InlineData (0, -1, Orientation.Vertical, "โ")]
|
|
|
+ [InlineData (-1, 0, Orientation.Vertical, "โ")]
|
|
|
+ [InlineData (-1, -1, Orientation.Vertical, "โ")]
|
|
|
+ [Theory, SetupFakeDriver]
|
|
|
+ public void Length_0_Is_1_Long (int x, int y, Orientation orientation, string expected)
|
|
|
+ {
|
|
|
+ var canvas = new LineCanvas ();
|
|
|
+ // Add a line at 5, 5 that's has length of 1
|
|
|
+ canvas.AddLine (new Point (x, y), 1, orientation, LineStyle.Single);
|
|
|
+ TestHelpers.AssertEqual (output, $"{expected}", $"{canvas}");
|
|
|
+ }
|
|
|
+
|
|
|
+ // X is offset by 2
|
|
|
+ [InlineData (0, 0, 1, Orientation.Horizontal, "โ")]
|
|
|
+ [InlineData (1, 0, 1, Orientation.Horizontal, "โ")]
|
|
|
+ [InlineData (0, 1, 1, Orientation.Horizontal, "โ")]
|
|
|
+ [InlineData (0, 0, 1, Orientation.Vertical, "โ")]
|
|
|
+ [InlineData (1, 0, 1, Orientation.Vertical, "โ")]
|
|
|
+ [InlineData (0, 1, 1, Orientation.Vertical, "โ")]
|
|
|
+ [InlineData (-1, 0, 1, Orientation.Horizontal, "โ")]
|
|
|
+ [InlineData (0, -1, 1, Orientation.Horizontal, "โ")]
|
|
|
+ [InlineData (-1, 0, 1, Orientation.Vertical, "โ")]
|
|
|
+ [InlineData (0, -1, 1, Orientation.Vertical, "โ")]
|
|
|
+
|
|
|
+ [InlineData (0, 0, -1, Orientation.Horizontal, "โ")]
|
|
|
+ [InlineData (1, 0, -1, Orientation.Horizontal, "โ")]
|
|
|
+ [InlineData (0, 1, -1, Orientation.Horizontal, "โ")]
|
|
|
+ [InlineData (0, 0, -1, Orientation.Vertical, "โ")]
|
|
|
+ [InlineData (1, 0, -1, Orientation.Vertical, "โ")]
|
|
|
+ [InlineData (0, 1, -1, Orientation.Vertical, "โ")]
|
|
|
+ [InlineData (-1, 0, -1, Orientation.Horizontal, "โ")]
|
|
|
+ [InlineData (0, -1, -1, Orientation.Horizontal, "โ")]
|
|
|
+ [InlineData (-1, 0, -1, Orientation.Vertical, "โ")]
|
|
|
+ [InlineData (0, -1, -1, Orientation.Vertical, "โ")]
|
|
|
+
|
|
|
+ [InlineData (0, 0, 2, Orientation.Horizontal, "โโ")]
|
|
|
+ [InlineData (1, 0, 2, Orientation.Horizontal, "โโ")]
|
|
|
+ [InlineData (0, 1, 2, Orientation.Horizontal, "โโ")]
|
|
|
+ [InlineData (1, 1, 2, Orientation.Horizontal, "โโ")]
|
|
|
+ [InlineData (0, 0, 2, Orientation.Vertical, "โ\r\nโ")]
|
|
|
+ [InlineData (1, 0, 2, Orientation.Vertical, "โ\r\nโ")]
|
|
|
+ [InlineData (0, 1, 2, Orientation.Vertical, "โ\r\nโ")]
|
|
|
+ [InlineData (1, 1, 2, Orientation.Vertical, "โ\r\nโ")]
|
|
|
+ [InlineData (-1, 0, 2, Orientation.Horizontal, "โโ")]
|
|
|
+ [InlineData (0, -1, 2, Orientation.Horizontal, "โโ")]
|
|
|
+ [InlineData (-1, 0, 2, Orientation.Vertical, "โ\r\nโ")]
|
|
|
+ [InlineData (0, -1, 2, Orientation.Vertical, "โ\r\nโ")]
|
|
|
+ [InlineData (-1, -1, 2, Orientation.Vertical, "โ\r\nโ")]
|
|
|
+
|
|
|
+ [InlineData (0, 0, -2, Orientation.Horizontal, "โโ")]
|
|
|
+ [InlineData (1, 0, -2, Orientation.Horizontal, "โโ")]
|
|
|
+ [InlineData (0, 1, -2, Orientation.Horizontal, "โโ")]
|
|
|
+ [InlineData (0, 0, -2, Orientation.Vertical, "โ\r\nโ")]
|
|
|
+ [InlineData (1, 0, -2, Orientation.Vertical, "โ\r\nโ")]
|
|
|
+ [InlineData (0, 1, -2, Orientation.Vertical, "โ\r\nโ")]
|
|
|
+ [InlineData (1, 1, -2, Orientation.Vertical, "โ\r\nโ")]
|
|
|
+ [InlineData (-1, 0, -2, Orientation.Horizontal, "โโ")]
|
|
|
+ [InlineData (0, -1, -2, Orientation.Horizontal, "โโ")]
|
|
|
+ [InlineData (-1, 0, -2, Orientation.Vertical, "โ\r\nโ")]
|
|
|
+ [InlineData (0, -1, -2, Orientation.Vertical, "โ\r\nโ")]
|
|
|
+ [InlineData (-1, -1, -2, Orientation.Vertical, "โ\r\nโ")]
|
|
|
+ [Theory, SetupFakeDriver]
|
|
|
+ public void Length_n_Is_n_Long (int x, int y, int length, Orientation orientation, string expected)
|
|
|
+ {
|
|
|
+ var canvas = new LineCanvas ();
|
|
|
+ canvas.AddLine (new Point (x, y), length, orientation, LineStyle.Single);
|
|
|
+
|
|
|
+ var result = canvas.ToString ();
|
|
|
+ TestHelpers.AssertEqual (output, expected, result);
|
|
|
+ }
|
|
|
+
|
|
|
+ [Fact, SetupFakeDriver]
|
|
|
+ public void Length_Negative ()
|
|
|
+ {
|
|
|
+ var offset = new Point (5, 5);
|
|
|
+
|
|
|
+ var canvas = new LineCanvas ();
|
|
|
+ canvas.AddLine (offset, -3, Orientation.Horizontal, LineStyle.Single);
|
|
|
+
|
|
|
+ string looksLike = "โโโ";
|
|
|
+
|
|
|
+ Assert.Equal (looksLike, $"{canvas}");
|
|
|
+ }
|
|
|
+
|
|
|
+ [Fact, SetupFakeDriver]
|
|
|
+ public void Zero_Length_Intersections ()
|
|
|
+ {
|
|
|
+ // Draw at 1,2 within client area of View (i.e. leave a top and left margin of 1)
|
|
|
+ // This proves we aren't drawing excess above
|
|
|
+ int x = 1;
|
|
|
+ int y = 2;
|
|
|
+ int width = 5;
|
|
|
+ int height = 2;
|
|
|
+
|
|
|
+ var lc = new LineCanvas ();
|
|
|
+
|
|
|
+ // โโกโโโโโโโ
|
|
|
+ // Add a short horiz line for โโก
|
|
|
+ lc.AddLine (new Point (x, y), 2, Orientation.Horizontal, LineStyle.Double);
|
|
|
+ //LHS line down
|
|
|
+ lc.AddLine (new Point (x, y), height, Orientation.Vertical, LineStyle.Double);
|
|
|
+
|
|
|
+ //Vertical line before Title, results in a โก
|
|
|
+ lc.AddLine (new Point (x + 1, y), 0, Orientation.Vertical, LineStyle.Single);
|
|
|
+
|
|
|
+ //Vertical line after Title, results in a โ
|
|
|
+ lc.AddLine (new Point (x + 2, y), 0, Orientation.Vertical, LineStyle.Single);
|
|
|
+
|
|
|
+ // remainder of top line
|
|
|
+ lc.AddLine (new Point (x + 2, y), width - 1, Orientation.Horizontal, LineStyle.Double);
|
|
|
+
|
|
|
+ //RHS line down
|
|
|
+ lc.AddLine (new Point (x + width, y), height, Orientation.Vertical, LineStyle.Double);
|
|
|
+
|
|
|
+ string looksLike = @"
|
|
|
+โโกโโโโ
|
|
|
+โ โ";
|
|
|
+ TestHelpers.AssertEqual (output, looksLike, $"{Environment.NewLine}{lc}");
|
|
|
+ }
|
|
|
+
|
|
|
[InlineData (LineStyle.Single)]
|
|
|
[InlineData (LineStyle.Rounded)]
|
|
|
[Theory, AutoInitShutdown]
|
|
|
- public void TestLineCanvas_Horizontal (LineStyle style)
|
|
|
+ public void View_Draws_Horizontal (LineStyle style)
|
|
|
{
|
|
|
var v = GetCanvas (out var canvas);
|
|
|
- canvas.AddLine (new Point (0, 0), 1, Orientation.Horizontal, style);
|
|
|
+ canvas.AddLine (new Point (0, 0), 2, Orientation.Horizontal, style);
|
|
|
|
|
|
v.Redraw (v.Bounds);
|
|
|
|
|
@@ -31,10 +426,10 @@ namespace Terminal.Gui.DrawingTests {
|
|
|
}
|
|
|
|
|
|
[Fact, AutoInitShutdown]
|
|
|
- public void TestLineCanvas_Horizontal_Double ()
|
|
|
+ public void View_Draws_Horizontal_Double ()
|
|
|
{
|
|
|
var v = GetCanvas (out var canvas);
|
|
|
- canvas.AddLine (new Point (0, 0), 1, Orientation.Horizontal, LineStyle.Double);
|
|
|
+ canvas.AddLine (new Point (0, 0), 2, Orientation.Horizontal, LineStyle.Double);
|
|
|
|
|
|
v.Redraw (v.Bounds);
|
|
|
|
|
@@ -47,10 +442,10 @@ namespace Terminal.Gui.DrawingTests {
|
|
|
[InlineData (LineStyle.Single)]
|
|
|
[InlineData (LineStyle.Rounded)]
|
|
|
[Theory, AutoInitShutdown]
|
|
|
- public void TestLineCanvas_Vertical (LineStyle style)
|
|
|
+ public void View_Draws_Vertical (LineStyle style)
|
|
|
{
|
|
|
var v = GetCanvas (out var canvas);
|
|
|
- canvas.AddLine (new Point (0, 0), 1, Orientation.Vertical, style);
|
|
|
+ canvas.AddLine (new Point (0, 0), 2, Orientation.Vertical, style);
|
|
|
|
|
|
v.Redraw (v.Bounds);
|
|
|
|
|
@@ -62,10 +457,10 @@ namespace Terminal.Gui.DrawingTests {
|
|
|
}
|
|
|
|
|
|
[Fact, AutoInitShutdown]
|
|
|
- public void TestLineCanvas_Vertical_Double ()
|
|
|
+ public void View_Draws_Vertical_Double ()
|
|
|
{
|
|
|
var v = GetCanvas (out var canvas);
|
|
|
- canvas.AddLine (new Point (0, 0), 1, Orientation.Vertical, LineStyle.Double);
|
|
|
+ canvas.AddLine (new Point (0, 0), 2, Orientation.Vertical, LineStyle.Double);
|
|
|
|
|
|
v.Redraw (v.Bounds);
|
|
|
|
|
@@ -81,11 +476,11 @@ namespace Terminal.Gui.DrawingTests {
|
|
|
/// Not when they terminate adjacent to one another.
|
|
|
/// </summary>
|
|
|
[Fact, AutoInitShutdown]
|
|
|
- public void TestLineCanvas_Corner_NoOverlap ()
|
|
|
+ public void View_Draws_Corner_NoOverlap ()
|
|
|
{
|
|
|
var v = GetCanvas (out var canvas);
|
|
|
- canvas.AddLine (new Point (0, 0), 1, Orientation.Horizontal, LineStyle.Single);
|
|
|
- canvas.AddLine (new Point (0, 1), 1, Orientation.Vertical, LineStyle.Single);
|
|
|
+ canvas.AddLine (new Point (0, 0), 2, Orientation.Horizontal, LineStyle.Single);
|
|
|
+ canvas.AddLine (new Point (0, 1), 2, Orientation.Vertical, LineStyle.Single);
|
|
|
|
|
|
v.Redraw (v.Bounds);
|
|
|
|
|
@@ -101,10 +496,10 @@ namespace Terminal.Gui.DrawingTests {
|
|
|
/// overlapping the lines in the same cell
|
|
|
/// </summary>
|
|
|
[Fact, AutoInitShutdown]
|
|
|
- public void TestLineCanvas_Corner_Correct ()
|
|
|
+ public void View_Draws_Corner_Correct ()
|
|
|
{
|
|
|
var v = GetCanvas (out var canvas);
|
|
|
- canvas.AddLine (new Point (0, 0), 1, Orientation.Horizontal, LineStyle.Single);
|
|
|
+ canvas.AddLine (new Point (0, 0), 2, Orientation.Horizontal, LineStyle.Single);
|
|
|
canvas.AddLine (new Point (0, 0), 2, Orientation.Vertical, LineStyle.Single);
|
|
|
|
|
|
v.Redraw (v.Bounds);
|
|
@@ -112,37 +507,66 @@ namespace Terminal.Gui.DrawingTests {
|
|
|
string looksLike =
|
|
|
@"
|
|
|
โโ
|
|
|
-โ
|
|
|
โ";
|
|
|
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
|
|
|
|
|
}
|
|
|
|
|
|
- [Fact, AutoInitShutdown]
|
|
|
- public void TestLineCanvas_Window ()
|
|
|
+
|
|
|
+ [Fact, SetupFakeDriver]
|
|
|
+ public void Top_With_1Down ()
|
|
|
{
|
|
|
- var v = GetCanvas (out var canvas);
|
|
|
+ var canvas = new LineCanvas ();
|
|
|
|
|
|
- // outer box
|
|
|
- canvas.AddLine (new Point (0, 0), 9, Orientation.Horizontal, LineStyle.Single);
|
|
|
- canvas.AddLine (new Point (9, 0), 4, Orientation.Vertical, LineStyle.Single);
|
|
|
- canvas.AddLine (new Point (9, 4), -9, Orientation.Horizontal, LineStyle.Single);
|
|
|
- canvas.AddLine (new Point (0, 4), -4, Orientation.Vertical, LineStyle.Single);
|
|
|
+ // Top โ
|
|
|
+ canvas.AddLine (new Point (0, 0), 1, Orientation.Horizontal, LineStyle.Single);
|
|
|
|
|
|
+ // Bottom โ
|
|
|
+ canvas.AddLine (new Point (1, 1), -1, Orientation.Horizontal, LineStyle.Single);
|
|
|
|
|
|
- canvas.AddLine (new Point (5, 0), 4, Orientation.Vertical, LineStyle.Single);
|
|
|
- canvas.AddLine (new Point (0, 2), 9, Orientation.Horizontal, LineStyle.Single);
|
|
|
+ //// Right down
|
|
|
+ //canvas.AddLine (new Point (9, 0), 3, Orientation.Vertical, LineStyle.Single);
|
|
|
|
|
|
- v.Redraw (v.Bounds);
|
|
|
+ //// Bottom
|
|
|
+ //canvas.AddLine (new Point (9, 3), -10, Orientation.Horizontal, LineStyle.Single);
|
|
|
+
|
|
|
+ //// Left Up
|
|
|
+ //canvas.AddLine (new Point (0, 3), -3, Orientation.Vertical, LineStyle.Single);
|
|
|
+
|
|
|
+ Assert.Equal (new Rect (0, 0, 2, 2), canvas.Bounds);
|
|
|
+
|
|
|
+ var map = canvas.GetMap ();
|
|
|
+ Assert.Equal (2, map.Count);
|
|
|
+
|
|
|
+ TestHelpers.AssertEqual (output, @"
|
|
|
+โ
|
|
|
+ โ",
|
|
|
+ $"{Environment.NewLine}{canvas}");
|
|
|
+ }
|
|
|
+
|
|
|
+ [Fact, SetupFakeDriver]
|
|
|
+ public void Window ()
|
|
|
+ {
|
|
|
+ var canvas = new LineCanvas ();
|
|
|
+
|
|
|
+ // Frame
|
|
|
+ canvas.AddLine (new Point (0, 0), 10, Orientation.Horizontal, LineStyle.Single);
|
|
|
+ canvas.AddLine (new Point (9, 0), 5, Orientation.Vertical, LineStyle.Single);
|
|
|
+ canvas.AddLine (new Point (9, 4), -10, Orientation.Horizontal, LineStyle.Single);
|
|
|
+ canvas.AddLine (new Point (0, 4), -5, Orientation.Vertical, LineStyle.Single);
|
|
|
+
|
|
|
+ // Cross
|
|
|
+ canvas.AddLine (new Point (5, 0), 5, Orientation.Vertical, LineStyle.Single);
|
|
|
+ canvas.AddLine (new Point (0, 2), 10, Orientation.Horizontal, LineStyle.Single);
|
|
|
|
|
|
string looksLike =
|
|
|
-@"
|
|
|
+@"
|
|
|
โโโโโโฌโโโโ
|
|
|
โ โ โ
|
|
|
โโโโโโผโโโโค
|
|
|
โ โ โ
|
|
|
โโโโโโดโโโโ";
|
|
|
- TestHelpers.AssertDriverContentsAre (looksLike, output);
|
|
|
+ TestHelpers.AssertEqual (output, looksLike, $"{Environment.NewLine}{canvas}");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -151,22 +575,22 @@ namespace Terminal.Gui.DrawingTests {
|
|
|
/// to be used then if any of them are rounded a rounded corner is used.
|
|
|
/// </summary>
|
|
|
[Fact, AutoInitShutdown]
|
|
|
- public void TestLineCanvas_Window_Rounded ()
|
|
|
+ public void View_Draws_Window_Rounded ()
|
|
|
{
|
|
|
var v = GetCanvas (out var canvas);
|
|
|
|
|
|
// outer box
|
|
|
- canvas.AddLine (new Point (0, 0), 9, Orientation.Horizontal, LineStyle.Rounded);
|
|
|
+ canvas.AddLine (new Point (0, 0), 10, Orientation.Horizontal, LineStyle.Rounded);
|
|
|
|
|
|
// BorderStyle.Single is ignored because corner overlaps with the above line which is Rounded
|
|
|
// this results in a rounded corner being used.
|
|
|
- canvas.AddLine (new Point (9, 0), 4, Orientation.Vertical, LineStyle.Single);
|
|
|
- canvas.AddLine (new Point (9, 4), -9, Orientation.Horizontal, LineStyle.Rounded);
|
|
|
- canvas.AddLine (new Point (0, 4), -4, Orientation.Vertical, LineStyle.Single);
|
|
|
+ canvas.AddLine (new Point (9, 0), 5, Orientation.Vertical, LineStyle.Single);
|
|
|
+ canvas.AddLine (new Point (9, 4), -10, Orientation.Horizontal, LineStyle.Rounded);
|
|
|
+ canvas.AddLine (new Point (0, 4), -5, Orientation.Vertical, LineStyle.Single);
|
|
|
|
|
|
// These lines say rounded but they will result in the T sections which are never rounded.
|
|
|
- canvas.AddLine (new Point (5, 0), 4, Orientation.Vertical, LineStyle.Rounded);
|
|
|
- canvas.AddLine (new Point (0, 2), 9, Orientation.Horizontal, LineStyle.Rounded);
|
|
|
+ canvas.AddLine (new Point (5, 0), 5, Orientation.Vertical, LineStyle.Rounded);
|
|
|
+ canvas.AddLine (new Point (0, 2), 10, Orientation.Horizontal, LineStyle.Rounded);
|
|
|
|
|
|
v.Redraw (v.Bounds);
|
|
|
|
|
@@ -181,19 +605,19 @@ namespace Terminal.Gui.DrawingTests {
|
|
|
}
|
|
|
|
|
|
[Fact, AutoInitShutdown]
|
|
|
- public void TestLineCanvas_Window_Double ()
|
|
|
+ public void View_Draws_Window_Double ()
|
|
|
{
|
|
|
var v = GetCanvas (out var canvas);
|
|
|
|
|
|
// outer box
|
|
|
- canvas.AddLine (new Point (0, 0), 9, Orientation.Horizontal, LineStyle.Double);
|
|
|
- canvas.AddLine (new Point (9, 0), 4, Orientation.Vertical, LineStyle.Double);
|
|
|
- canvas.AddLine (new Point (9, 4), -9, Orientation.Horizontal, LineStyle.Double);
|
|
|
- canvas.AddLine (new Point (0, 4), -4, Orientation.Vertical, LineStyle.Double);
|
|
|
+ canvas.AddLine (new Point (0, 0), 10, Orientation.Horizontal, LineStyle.Double);
|
|
|
+ canvas.AddLine (new Point (9, 0), 5, Orientation.Vertical, LineStyle.Double);
|
|
|
+ canvas.AddLine (new Point (9, 4), -10, Orientation.Horizontal, LineStyle.Double);
|
|
|
+ canvas.AddLine (new Point (0, 4), -5, Orientation.Vertical, LineStyle.Double);
|
|
|
|
|
|
|
|
|
- canvas.AddLine (new Point (5, 0), 4, Orientation.Vertical, LineStyle.Double);
|
|
|
- canvas.AddLine (new Point (0, 2), 9, Orientation.Horizontal, LineStyle.Double);
|
|
|
+ canvas.AddLine (new Point (5, 0), 5, Orientation.Vertical, LineStyle.Double);
|
|
|
+ canvas.AddLine (new Point (0, 2), 10, Orientation.Horizontal, LineStyle.Double);
|
|
|
|
|
|
v.Redraw (v.Bounds);
|
|
|
|
|
@@ -211,19 +635,19 @@ namespace Terminal.Gui.DrawingTests {
|
|
|
[Theory, AutoInitShutdown]
|
|
|
[InlineData (LineStyle.Single)]
|
|
|
[InlineData (LineStyle.Rounded)]
|
|
|
- public void TestLineCanvas_Window_DoubleTop_SingleSides (LineStyle thinStyle)
|
|
|
+ public void View_Draws_Window_DoubleTop_SingleSides (LineStyle thinStyle)
|
|
|
{
|
|
|
var v = GetCanvas (out var canvas);
|
|
|
|
|
|
// outer box
|
|
|
- canvas.AddLine (new Point (0, 0), 9, Orientation.Horizontal, LineStyle.Double);
|
|
|
- canvas.AddLine (new Point (9, 0), 4, Orientation.Vertical, thinStyle);
|
|
|
- canvas.AddLine (new Point (9, 4), -9, Orientation.Horizontal, LineStyle.Double);
|
|
|
- canvas.AddLine (new Point (0, 4), -4, Orientation.Vertical, thinStyle);
|
|
|
+ canvas.AddLine (new Point (0, 0), 10, Orientation.Horizontal, LineStyle.Double);
|
|
|
+ canvas.AddLine (new Point (9, 0), 5, Orientation.Vertical, thinStyle);
|
|
|
+ canvas.AddLine (new Point (9, 4), -10, Orientation.Horizontal, LineStyle.Double);
|
|
|
+ canvas.AddLine (new Point (0, 4), -5, Orientation.Vertical, thinStyle);
|
|
|
|
|
|
|
|
|
- canvas.AddLine (new Point (5, 0), 4, Orientation.Vertical, thinStyle);
|
|
|
- canvas.AddLine (new Point (0, 2), 9, Orientation.Horizontal, LineStyle.Double);
|
|
|
+ canvas.AddLine (new Point (5, 0), 5, Orientation.Vertical, thinStyle);
|
|
|
+ canvas.AddLine (new Point (0, 2), 10, Orientation.Horizontal, LineStyle.Double);
|
|
|
|
|
|
v.Redraw (v.Bounds);
|
|
|
|
|
@@ -241,19 +665,19 @@ namespace Terminal.Gui.DrawingTests {
|
|
|
[Theory, AutoInitShutdown]
|
|
|
[InlineData (LineStyle.Single)]
|
|
|
[InlineData (LineStyle.Rounded)]
|
|
|
- public void TestLineCanvas_Window_SingleTop_DoubleSides (LineStyle thinStyle)
|
|
|
+ public void View_Draws_Window_SingleTop_DoubleSides (LineStyle thinStyle)
|
|
|
{
|
|
|
var v = GetCanvas (out var canvas);
|
|
|
|
|
|
// outer box
|
|
|
- canvas.AddLine (new Point (0, 0), 9, Orientation.Horizontal, thinStyle);
|
|
|
- canvas.AddLine (new Point (9, 0), 4, Orientation.Vertical, LineStyle.Double);
|
|
|
- canvas.AddLine (new Point (9, 4), -9, Orientation.Horizontal, thinStyle);
|
|
|
- canvas.AddLine (new Point (0, 4), -4, Orientation.Vertical, LineStyle.Double);
|
|
|
+ canvas.AddLine (new Point (0, 0), 10, Orientation.Horizontal, thinStyle);
|
|
|
+ canvas.AddLine (new Point (9, 0), 5, Orientation.Vertical, LineStyle.Double);
|
|
|
+ canvas.AddLine (new Point (9, 4), -10, Orientation.Horizontal, thinStyle);
|
|
|
+ canvas.AddLine (new Point (0, 4), -5, Orientation.Vertical, LineStyle.Double);
|
|
|
|
|
|
|
|
|
- canvas.AddLine (new Point (5, 0), 4, Orientation.Vertical, LineStyle.Double);
|
|
|
- canvas.AddLine (new Point (0, 2), 9, Orientation.Horizontal, thinStyle);
|
|
|
+ canvas.AddLine (new Point (5, 0), 5, Orientation.Vertical, LineStyle.Double);
|
|
|
+ canvas.AddLine (new Point (0, 2), 10, Orientation.Horizontal, thinStyle);
|
|
|
|
|
|
v.Redraw (v.Bounds);
|
|
|
|
|
@@ -269,74 +693,78 @@ namespace Terminal.Gui.DrawingTests {
|
|
|
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
|
|
}
|
|
|
|
|
|
- [Fact, AutoInitShutdown]
|
|
|
- public void TestLineCanvas_LeaveMargin_Top1_Left1 ()
|
|
|
+ [Fact, SetupFakeDriver]
|
|
|
+ public void Top_Left_From_TopRigth_TopDown ()
|
|
|
{
|
|
|
- // Draw at 1,1 within client area of View (i.e. leave a top and left margin of 1)
|
|
|
- var v = GetCanvas (out var canvas, 1, 1);
|
|
|
+ var canvas = new LineCanvas ();
|
|
|
|
|
|
- // outer box
|
|
|
- canvas.AddLine (new Point (0, 0), 8, Orientation.Horizontal, LineStyle.Single);
|
|
|
- canvas.AddLine (new Point (8, 0), 3, Orientation.Vertical, LineStyle.Single);
|
|
|
- canvas.AddLine (new Point (8, 3), -8, Orientation.Horizontal, LineStyle.Single);
|
|
|
- canvas.AddLine (new Point (0, 3), -3, Orientation.Vertical, LineStyle.Single);
|
|
|
-
|
|
|
-
|
|
|
- canvas.AddLine (new Point (5, 0), 3, Orientation.Vertical, LineStyle.Single);
|
|
|
- canvas.AddLine (new Point (0, 2), 8, Orientation.Horizontal, LineStyle.Single);
|
|
|
-
|
|
|
- v.Redraw (v.Bounds);
|
|
|
+ // Upper box
|
|
|
+ canvas.AddLine (new Point (0, 0), 2, Orientation.Horizontal, LineStyle.Single);
|
|
|
+ canvas.AddLine (new Point (0, 0), 2, Orientation.Vertical, LineStyle.Single);
|
|
|
|
|
|
string looksLike =
|
|
|
@"
|
|
|
- โโโโโโฌโโโ
|
|
|
- โ โ โ
|
|
|
- โโโโโโผโโโค
|
|
|
- โโโโโโดโโโ
|
|
|
-";
|
|
|
- TestHelpers.AssertDriverContentsAre (looksLike, output);
|
|
|
+โโ
|
|
|
+โ ";
|
|
|
+ TestHelpers.AssertEqual (output, looksLike, $"{Environment.NewLine}{canvas}");
|
|
|
}
|
|
|
- [Fact, AutoInitShutdown]
|
|
|
- public void TestLineCanvas_ClipArea_Intersections ()
|
|
|
- {
|
|
|
- // Draw at 1,1 within client area of View (i.e. leave a top and left margin of 1)
|
|
|
- var v = GetCanvas (out var lc);
|
|
|
- v.Width = 10;
|
|
|
- v.Height = 1;
|
|
|
- v.Bounds = new Rect (0, 0, 10, 1);
|
|
|
-
|
|
|
- // โโก Title โโโโโโโ
|
|
|
- // Add a short horiz line for โโก
|
|
|
- lc.AddLine (new Point (0, 0), 1, Orientation.Horizontal, LineStyle.Double);
|
|
|
- //LHS line down
|
|
|
- lc.AddLine (new Point (0, 0), 5, Orientation.Vertical, LineStyle.Double);
|
|
|
|
|
|
- //Vertical line before Title, results in a โก
|
|
|
- lc.AddLine (new Point (1, 0), 0, Orientation.Vertical, LineStyle.Single);
|
|
|
- //Vertical line after Title, results in a โ
|
|
|
- lc.AddLine (new Point (6, 0), 0, Orientation.Vertical, LineStyle.Single);
|
|
|
-
|
|
|
- // remainder of title
|
|
|
- lc.AddLine (new Point (6, 0), 3, Orientation.Horizontal, LineStyle.Double);
|
|
|
- //RHS line down
|
|
|
- lc.AddLine (new Point (9, 0), 5, Orientation.Vertical, LineStyle.Double);
|
|
|
+ [Fact, SetupFakeDriver]
|
|
|
+ public void Top_Left_From_TopRigth_LeftUp ()
|
|
|
+ {
|
|
|
+ var canvas = new LineCanvas ();
|
|
|
|
|
|
- v.Redraw (v.Bounds);
|
|
|
+ // Upper box
|
|
|
+ canvas.AddLine (new Point (0, 0), 2, Orientation.Horizontal, LineStyle.Single);
|
|
|
+ canvas.AddLine (new Point (0, 1), -2, Orientation.Vertical, LineStyle.Single);
|
|
|
|
|
|
string looksLike =
|
|
|
- @"
|
|
|
-โโก โโโโ
|
|
|
-";
|
|
|
- TestHelpers.AssertDriverContentsAre (looksLike, output);
|
|
|
+@"
|
|
|
+โโ
|
|
|
+โ ";
|
|
|
+ TestHelpers.AssertEqual (output, looksLike, $"{Environment.NewLine}{canvas}");
|
|
|
}
|
|
|
|
|
|
- [InlineData(0,0,0, Orientation.Horizontal,LineStyle.Double,"โ")]
|
|
|
- [InlineData(0,0,0, Orientation.Vertical,LineStyle.Double,"โ")]
|
|
|
- [InlineData(0,0,0, Orientation.Horizontal,LineStyle.Single,"โ")]
|
|
|
- [InlineData(0,0,0, Orientation.Vertical,LineStyle.Single,"โ")]
|
|
|
+ // [Fact, SetupFakeDriver]
|
|
|
+ // public void LeaveMargin_Top1_Left1 ()
|
|
|
+ // {
|
|
|
+ // var canvas = new LineCanvas ();
|
|
|
+
|
|
|
+ // // Upper box
|
|
|
+ // canvas.AddLine (new Point (0, 0), 9, Orientation.Horizontal, LineStyle.Single);
|
|
|
+ // canvas.AddLine (new Point (8, 0), 3, Orientation.Vertical, LineStyle.Single);
|
|
|
+ // canvas.AddLine (new Point (8, 3), -9, Orientation.Horizontal, LineStyle.Single);
|
|
|
+ // canvas.AddLine (new Point (0, 2), -3, Orientation.Vertical, LineStyle.Single);
|
|
|
+
|
|
|
+ // // Lower Box
|
|
|
+ // canvas.AddLine (new Point (5, 0), 2, Orientation.Vertical, LineStyle.Single);
|
|
|
+ // canvas.AddLine (new Point (0, 2), 9, Orientation.Horizontal, LineStyle.Single);
|
|
|
+
|
|
|
+ // string looksLike =
|
|
|
+ //@"
|
|
|
+ //โโโโโโฌโโโ
|
|
|
+ //โ โ โ
|
|
|
+ //โโโโโโผโโโค
|
|
|
+ //โโโโโโดโโโ
|
|
|
+ //";
|
|
|
+ // Assert.Equal (looksLike, $"{Environment.NewLine}{canvas}");
|
|
|
+ // }
|
|
|
+
|
|
|
+ [InlineData (0, 0, 0, Orientation.Horizontal, LineStyle.Double, "โ")]
|
|
|
+ [InlineData (0, 0, 0, Orientation.Vertical, LineStyle.Double, "โ")]
|
|
|
+ [InlineData (0, 0, 0, Orientation.Horizontal, LineStyle.Single, "โ")]
|
|
|
+ [InlineData (0, 0, 0, Orientation.Vertical, LineStyle.Single, "โ")]
|
|
|
+ [InlineData (0, 0, 1, Orientation.Horizontal, LineStyle.Double, "โ")]
|
|
|
+ [InlineData (0, 0, 1, Orientation.Vertical, LineStyle.Double, "โ")]
|
|
|
+ [InlineData (0, 0, 1, Orientation.Horizontal, LineStyle.Single, "โ")]
|
|
|
+ [InlineData (0, 0, 1, Orientation.Vertical, LineStyle.Single, "โ")]
|
|
|
+ [InlineData (0, 0, 2, Orientation.Horizontal, LineStyle.Double, "โโ")]
|
|
|
+ [InlineData (0, 0, 2, Orientation.Vertical, LineStyle.Double, "โ\nโ")]
|
|
|
+ [InlineData (0, 0, 2, Orientation.Horizontal, LineStyle.Single, "โโ")]
|
|
|
+ [InlineData (0, 0, 2, Orientation.Vertical, LineStyle.Single, "โ\nโ")]
|
|
|
[AutoInitShutdown, Theory]
|
|
|
- public void TestLineCanvas_1LineTests(
|
|
|
- int x1, int y1,int l1, Orientation o1, LineStyle s1,
|
|
|
+ public void View_Draws_1LineTests (
|
|
|
+ int x1, int y1, int length, Orientation o1, LineStyle s1,
|
|
|
string expected
|
|
|
)
|
|
|
{
|
|
@@ -345,54 +773,103 @@ namespace Terminal.Gui.DrawingTests {
|
|
|
v.Height = 10;
|
|
|
v.Bounds = new Rect (0, 0, 10, 10);
|
|
|
|
|
|
- lc.AddLine (new Point (x1, y1), l1, o1, s1);
|
|
|
+ lc.AddLine (new Point (x1, y1), length, o1, s1);
|
|
|
|
|
|
v.Redraw (v.Bounds);
|
|
|
-
|
|
|
+
|
|
|
TestHelpers.AssertDriverContentsAre (expected, output);
|
|
|
}
|
|
|
|
|
|
|
|
|
[Theory, AutoInitShutdown]
|
|
|
- [InlineData(
|
|
|
- 0,0,1,Orientation.Horizontal,LineStyle.Double,
|
|
|
- 1,0,0, Orientation.Vertical,LineStyle.Single, "โโก"
|
|
|
+ // Horizontal lines with a vertical zero-length
|
|
|
+ [InlineData (
|
|
|
+ 0, 0, 1, Orientation.Horizontal, LineStyle.Double,
|
|
|
+ 0, 0, 0, Orientation.Vertical, LineStyle.Single, "โ"
|
|
|
)]
|
|
|
- [InlineData(
|
|
|
- 0,0,0, Orientation.Vertical,LineStyle.Single,
|
|
|
- 0,0,1,Orientation.Horizontal,LineStyle.Double,
|
|
|
- "โโ"
|
|
|
+ [InlineData (
|
|
|
+ 0, 0, -1, Orientation.Horizontal, LineStyle.Double,
|
|
|
+ 0, 0, 0, Orientation.Vertical, LineStyle.Single, "โก"
|
|
|
)]
|
|
|
- [InlineData(
|
|
|
- 0,0,1, Orientation.Vertical,LineStyle.Single,
|
|
|
- 0,0,0,Orientation.Horizontal,LineStyle.Double,
|
|
|
-@"
|
|
|
-โค
|
|
|
-โ"
|
|
|
+ [InlineData (
|
|
|
+ 0, 0, 1, Orientation.Horizontal, LineStyle.Single,
|
|
|
+ 0, 0, 0, Orientation.Vertical, LineStyle.Double, "โ"
|
|
|
)]
|
|
|
- [InlineData(
|
|
|
- 0,0,1, Orientation.Vertical,LineStyle.Single,
|
|
|
- 0,1,0,Orientation.Horizontal,LineStyle.Double,
|
|
|
- @"
|
|
|
-โ
|
|
|
-โง
|
|
|
-"
|
|
|
+ [InlineData (
|
|
|
+ 0, 0, -1, Orientation.Horizontal, LineStyle.Single,
|
|
|
+ 0, 0, 0, Orientation.Vertical, LineStyle.Double, "โข"
|
|
|
+ )]
|
|
|
+ [InlineData (
|
|
|
+ 0, 0, 1, Orientation.Horizontal, LineStyle.Single,
|
|
|
+ 0, 0, 0, Orientation.Vertical, LineStyle.Single, "โ"
|
|
|
+ )]
|
|
|
+ [InlineData (
|
|
|
+ 0, 0, -1, Orientation.Horizontal, LineStyle.Single,
|
|
|
+ 0, 0, 0, Orientation.Vertical, LineStyle.Single, "โค"
|
|
|
+ )]
|
|
|
+ [InlineData (
|
|
|
+ 0, 0, 1, Orientation.Horizontal, LineStyle.Double,
|
|
|
+ 0, 0, 0, Orientation.Vertical, LineStyle.Double, "โ "
|
|
|
+ )]
|
|
|
+ [InlineData (
|
|
|
+ 0, 0, -1, Orientation.Horizontal, LineStyle.Double,
|
|
|
+ 0, 0, 0, Orientation.Vertical, LineStyle.Double, "โฃ"
|
|
|
+ )]
|
|
|
+
|
|
|
+ // Vertical lines with a horizontal zero-length
|
|
|
+ [InlineData (
|
|
|
+ 0, 0, 1, Orientation.Vertical, LineStyle.Double,
|
|
|
+ 0, 0, 0, Orientation.Horizontal, LineStyle.Single, "โฅ"
|
|
|
+ )]
|
|
|
+ [InlineData (
|
|
|
+ 0, 0, -1, Orientation.Vertical, LineStyle.Double,
|
|
|
+ 0, 0, 0, Orientation.Horizontal, LineStyle.Single, "โจ"
|
|
|
+ )]
|
|
|
+ [InlineData (
|
|
|
+ 0, 0, 1, Orientation.Vertical, LineStyle.Single,
|
|
|
+ 0, 0, 0, Orientation.Horizontal, LineStyle.Double, "โค"
|
|
|
+ )]
|
|
|
+ [InlineData (
|
|
|
+ 0, 0, -1, Orientation.Vertical, LineStyle.Single,
|
|
|
+ 0, 0, 0, Orientation.Horizontal, LineStyle.Double, "โง"
|
|
|
)]
|
|
|
- [InlineData(
|
|
|
- 0,0,0, Orientation.Vertical,LineStyle.Single,
|
|
|
- 0,0,0,Orientation.Horizontal,LineStyle.Single,
|
|
|
- @"โผ
|
|
|
-"
|
|
|
+ [InlineData (
|
|
|
+ 0, 0, 1, Orientation.Vertical, LineStyle.Single,
|
|
|
+ 0, 0, 0, Orientation.Horizontal, LineStyle.Single, "โฌ"
|
|
|
)]
|
|
|
- [InlineData(
|
|
|
- 0,0,0, Orientation.Vertical,LineStyle.Double,
|
|
|
- 0,0,0,Orientation.Horizontal,LineStyle.Double,
|
|
|
- @"โฌ
|
|
|
-"
|
|
|
+ [InlineData (
|
|
|
+ 0, 0, -1, Orientation.Vertical, LineStyle.Single,
|
|
|
+ 0, 0, 0, Orientation.Horizontal, LineStyle.Single, "โด"
|
|
|
)]
|
|
|
- public void TestLineCanvas_2LineTests(
|
|
|
- int x1, int y1,int l1, Orientation o1, LineStyle s1,
|
|
|
- int x2, int y2, int l2, Orientation o2, LineStyle s2,
|
|
|
+ [InlineData (
|
|
|
+ 0, 0, 1, Orientation.Vertical, LineStyle.Double,
|
|
|
+ 0, 0, 0, Orientation.Horizontal, LineStyle.Double, "โฆ"
|
|
|
+ )]
|
|
|
+ [InlineData (
|
|
|
+ 0, 0, -1, Orientation.Vertical, LineStyle.Double,
|
|
|
+ 0, 0, 0, Orientation.Horizontal, LineStyle.Double, "โฉ"
|
|
|
+ )]
|
|
|
+
|
|
|
+ // Crosses (two zero-length)
|
|
|
+ [InlineData (
|
|
|
+ 0, 0, 0, Orientation.Vertical, LineStyle.Double,
|
|
|
+ 0, 0, 0, Orientation.Horizontal, LineStyle.Single, "โซ"
|
|
|
+ )]
|
|
|
+ [InlineData (
|
|
|
+ 0, 0, 0, Orientation.Vertical, LineStyle.Single,
|
|
|
+ 0, 0, 0, Orientation.Horizontal, LineStyle.Double, "โช"
|
|
|
+ )]
|
|
|
+ [InlineData (
|
|
|
+ 0, 0, 0, Orientation.Vertical, LineStyle.Single,
|
|
|
+ 0, 0, 0, Orientation.Horizontal, LineStyle.Single, "โผ"
|
|
|
+ )]
|
|
|
+ [InlineData (
|
|
|
+ 0, 0, 0, Orientation.Vertical, LineStyle.Double,
|
|
|
+ 0, 0, 0, Orientation.Horizontal, LineStyle.Double, "โฌ"
|
|
|
+ )]
|
|
|
+ public void Add_2_Lines (
|
|
|
+ int x1, int y1, int len1, Orientation o1, LineStyle s1,
|
|
|
+ int x2, int y2, int len2, Orientation o2, LineStyle s2,
|
|
|
string expected
|
|
|
)
|
|
|
{
|
|
@@ -401,15 +878,13 @@ namespace Terminal.Gui.DrawingTests {
|
|
|
v.Height = 10;
|
|
|
v.Bounds = new Rect (0, 0, 10, 10);
|
|
|
|
|
|
- lc.AddLine (new Point (x1, y1), l1, o1, s1);
|
|
|
- lc.AddLine (new Point (x2, y2), l2, o2, s2);
|
|
|
+ lc.AddLine (new Point (x1, y1), len1, o1, s1);
|
|
|
+ lc.AddLine (new Point (x2, y2), len2, o2, s2);
|
|
|
|
|
|
- v.Redraw (v.Bounds);
|
|
|
-
|
|
|
- TestHelpers.AssertDriverContentsAre (expected, output);
|
|
|
+ TestHelpers.AssertEqual (output, expected, lc.ToString ());
|
|
|
}
|
|
|
-
|
|
|
|
|
|
+ // TODO: Remove this and make all LineCanvas tests independent of View
|
|
|
/// <summary>
|
|
|
/// Creates a new <see cref="View"/> into which a <see cref="LineCanvas"/> is rendered
|
|
|
/// at <see cref="View.DrawContentComplete"/> time.
|
|
@@ -425,18 +900,20 @@ namespace Terminal.Gui.DrawingTests {
|
|
|
Height = 5,
|
|
|
Bounds = new Rect (0, 0, 10, 5)
|
|
|
};
|
|
|
- v.LayoutSubviews ();
|
|
|
+ Application.Top.Add (v);
|
|
|
+ Application.Begin (Application.Top);
|
|
|
|
|
|
var canvasCopy = canvas = new LineCanvas ();
|
|
|
v.DrawContentComplete += (s, e) => {
|
|
|
- foreach(var p in canvasCopy.GenerateImage(v.Bounds))
|
|
|
- {
|
|
|
- v.AddRune(
|
|
|
- offsetX + p.Key.X,
|
|
|
- offsetY + p.Key.Y,
|
|
|
- p.Value);
|
|
|
- }
|
|
|
- };
|
|
|
+ v.Clear ();
|
|
|
+ foreach (var p in canvasCopy.GetMap ()) {
|
|
|
+ v.AddRune (
|
|
|
+ offsetX + p.Key.X,
|
|
|
+ offsetY + p.Key.Y,
|
|
|
+ p.Value);
|
|
|
+ }
|
|
|
+ canvasCopy.Clear ();
|
|
|
+ };
|
|
|
|
|
|
return v;
|
|
|
}
|