mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 07:47:54 +01:00
I will never rely on zero-location-based unit test again.
This commit is contained in:
@@ -566,8 +566,8 @@ namespace Terminal.Gui {
|
||||
/// be greater or equal to the start and for <see cref="Side.Left"/> and <see cref="Side.Bottom"/> the end position must
|
||||
/// be less or equal to the start.
|
||||
/// </summary>
|
||||
/// <param name="startPos">The start and side position screen relative.</param>
|
||||
/// <param name="endPos">The end and side position screen relative.</param>
|
||||
/// <param name="startPos">The view relative of the start and side position.</param>
|
||||
/// <param name="endPos">The view relative of the end and side position.</param>
|
||||
/// <param name="rect">The view relative location and size of the frame.</param>
|
||||
/// <param name="lineStyle">The line style.</param>
|
||||
/// <param name="attribute">The colors to be used.</param>
|
||||
@@ -582,20 +582,42 @@ namespace Terminal.Gui {
|
||||
} else {
|
||||
lc = LineCanvas;
|
||||
}
|
||||
var start = startPos.start;
|
||||
var end = endPos.end;
|
||||
|
||||
int pStart = startPos.start;
|
||||
int pEnd = endPos.end;
|
||||
|
||||
switch (startPos.side) {
|
||||
case Side.Left:
|
||||
if (start == vts.Y) {
|
||||
lc.AddLine (new Point (vts.X, start), 1,
|
||||
case Side.Right:
|
||||
pStart += vts.Y;
|
||||
break;
|
||||
case Side.Top:
|
||||
case Side.Bottom:
|
||||
pStart += vts.X;
|
||||
break;
|
||||
}
|
||||
switch (endPos.side) {
|
||||
case Side.Left:
|
||||
case Side.Right:
|
||||
pEnd += vts.Y;
|
||||
break;
|
||||
case Side.Top:
|
||||
case Side.Bottom:
|
||||
pEnd += vts.X;
|
||||
break;
|
||||
}
|
||||
switch (startPos.side) {
|
||||
case Side.Left:
|
||||
if (pStart == vts.Y) {
|
||||
lc.AddLine (new Point (vts.X, pStart), 1,
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
} else {
|
||||
if (end <= start && startPos.side == endPos.side) {
|
||||
lc.AddLine (new Point (vts.X, start), end - start - 1,
|
||||
if (pEnd <= pStart && startPos.side == endPos.side) {
|
||||
lc.AddLine (new Point (vts.X, pStart), pEnd - pStart - 1,
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
break;
|
||||
} else {
|
||||
lc.AddLine (new Point (vts.X, start), vts.Y - start - 1,
|
||||
lc.AddLine (new Point (vts.X, pStart), vts.Y - pStart - 1,
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
}
|
||||
}
|
||||
@@ -607,19 +629,19 @@ namespace Terminal.Gui {
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
lc.AddLine (new Point (vts.Right - 1, vts.Bottom - 1), -vts.Width,
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
if (end <= vts.Bottom - 1 && startPos.side == endPos.side) {
|
||||
lc.AddLine (new Point (vts.X, vts.Bottom - 1), -(vts.Bottom - end),
|
||||
if (pEnd <= vts.Bottom - 1 && startPos.side == endPos.side) {
|
||||
lc.AddLine (new Point (vts.X, vts.Bottom - 1), -(vts.Bottom - pEnd),
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
}
|
||||
break;
|
||||
case Side.Top:
|
||||
lc.AddLine (new Point (vts.X, vts.Y), end,
|
||||
lc.AddLine (new Point (vts.X, vts.Y), pEnd - 1,
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
break;
|
||||
case Side.Right:
|
||||
lc.AddLine (new Point (vts.X, vts.Y), vts.Width,
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
lc.AddLine (new Point (vts.Right - 1, vts.Y), end + 1,
|
||||
lc.AddLine (new Point (vts.Right - 1, vts.Y), pEnd - 1,
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
break;
|
||||
case Side.Bottom:
|
||||
@@ -627,23 +649,25 @@ namespace Terminal.Gui {
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
lc.AddLine (new Point (vts.Right - 1, vts.Y), vts.Height,
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
lc.AddLine (new Point (vts.Right - 1, vts.Bottom - 1), -end,
|
||||
lc.AddLine (new Point (vts.Right - 1, vts.Bottom - 1), -(vts.Right - pEnd),
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case Side.Top:
|
||||
if (start == vts.Width - 1) {
|
||||
lc.AddLine (new Point (vts.X + start, vts.Y), -1,
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
} else if (end >= start && startPos.side == endPos.side) {
|
||||
lc.AddLine (new Point (vts.X + start, vts.Y), end - start + 1,
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
break;
|
||||
} else if (vts.Width - start > 0) {
|
||||
lc.AddLine (new Point (vts.X + start, vts.Y), Math.Max (vts.Width - start, 0),
|
||||
if (pStart == vts.Right - 1) {
|
||||
lc.AddLine (new Point (pStart, vts.Y), -1,
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
} else {
|
||||
if (pEnd >= pStart && startPos.side == endPos.side) {
|
||||
lc.AddLine (new Point (pStart, vts.Y), pEnd - pStart + 1,
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
break;
|
||||
} else {
|
||||
lc.AddLine (new Point (pStart, vts.Y), vts.Right - pStart,
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
}
|
||||
}
|
||||
switch (endPos.side) {
|
||||
case Side.Left:
|
||||
@@ -651,7 +675,7 @@ namespace Terminal.Gui {
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
lc.AddLine (new Point (vts.Right - 1, vts.Bottom - 1), -vts.Width,
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
lc.AddLine (new Point (vts.X, vts.Bottom - 1), -end,
|
||||
lc.AddLine (new Point (vts.X, vts.Bottom - 1), -(vts.Bottom - pEnd),
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
break;
|
||||
case Side.Top:
|
||||
@@ -661,91 +685,93 @@ namespace Terminal.Gui {
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
lc.AddLine (new Point (vts.X, vts.Bottom - 1), -vts.Height,
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
if (end >= 0 && startPos.side == endPos.side) {
|
||||
lc.AddLine (new Point (vts.X, vts.Y), end + 1,
|
||||
if (pEnd >= vts.X && startPos.side == endPos.side) {
|
||||
lc.AddLine (new Point (vts.X, vts.Y), pEnd - vts.X + 1,
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
}
|
||||
break;
|
||||
case Side.Right:
|
||||
lc.AddLine (new Point (vts.Right - 1, vts.Y), end,
|
||||
lc.AddLine (new Point (vts.Right - 1, vts.Y), pEnd - pStart + 1,
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
break;
|
||||
case Side.Bottom:
|
||||
lc.AddLine (new Point (vts.Right - 1, vts.Y), vts.Height,
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
lc.AddLine (new Point (vts.Right - 1, vts.Bottom - 1), -(vts.Width - end),
|
||||
lc.AddLine (new Point (vts.Right - 1, vts.Bottom - 1), -(vts.Right - pEnd),
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Side.Right:
|
||||
if (start == vts.Bottom - 1) {
|
||||
lc.AddLine (new Point (vts.Width - 1, start), -1,
|
||||
if (pStart == vts.Bottom - 1) {
|
||||
lc.AddLine (new Point (vts.Right - 1, pStart), -1,
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
} else {
|
||||
if (end >= start && startPos.side == endPos.side) {
|
||||
lc.AddLine (new Point (vts.Width - 1, start), end - start + 1,
|
||||
if (pEnd >= pStart && startPos.side == endPos.side) {
|
||||
lc.AddLine (new Point (vts.Right - 1, pStart), pEnd - pStart + 1,
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
break;
|
||||
} else {
|
||||
lc.AddLine (new Point (vts.Width - 1, start), vts.Bottom - start,
|
||||
lc.AddLine (new Point (vts.Right - 1, pStart), vts.Bottom - pStart,
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
}
|
||||
}
|
||||
switch (endPos.side) {
|
||||
case Side.Left:
|
||||
lc.AddLine (new Point (vts.Width - 1, vts.Bottom - 1), -vts.Width,
|
||||
lc.AddLine (new Point (vts.Right - 1, vts.Bottom - 1), -vts.Width,
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
lc.AddLine (new Point (vts.X, vts.Bottom - 1), -(vts.Bottom - end),
|
||||
lc.AddLine (new Point (vts.X, vts.Bottom - 1), -(vts.Bottom - pEnd),
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
break;
|
||||
case Side.Top:
|
||||
lc.AddLine (new Point (vts.Width - 1, vts.Bottom - 1), -vts.Width,
|
||||
lc.AddLine (new Point (vts.Right - 1, vts.Bottom - 1), -vts.Width,
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
lc.AddLine (new Point (vts.X, vts.Bottom - 1), -vts.Height,
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
lc.AddLine (new Point (vts.X, vts.Y), end,
|
||||
lc.AddLine (new Point (vts.X, vts.Y), pEnd - vts.X + 1,
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
break;
|
||||
case Side.Right:
|
||||
lc.AddLine (new Point (vts.Width - 1, vts.Bottom - 1), -vts.Width,
|
||||
lc.AddLine (new Point (vts.Right - 1, vts.Bottom - 1), -vts.Width,
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
lc.AddLine (new Point (vts.X, vts.Bottom - 1), -vts.Height,
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
lc.AddLine (new Point (vts.X, vts.Y), vts.Width,
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
if (end >= 0 && end < vts.Bottom - 1 && startPos.side == endPos.side) {
|
||||
lc.AddLine (new Point (vts.Width - 1, vts.Y), end + 1,
|
||||
if (pEnd >= vts.Y && pEnd < vts.Bottom - 1 && startPos.side == endPos.side) {
|
||||
lc.AddLine (new Point (vts.Right - 1, vts.Y), pEnd - vts.Y + 1,
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
}
|
||||
break;
|
||||
case Side.Bottom:
|
||||
lc.AddLine (new Point (vts.Width - 1, vts.Bottom - 1), -(vts.Width - end),
|
||||
lc.AddLine (new Point (vts.Right - 1, vts.Bottom - 1), -(vts.Right - pEnd),
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Side.Bottom:
|
||||
if (start == vts.X) {
|
||||
if (pStart == vts.X) {
|
||||
lc.AddLine (new Point (vts.X, vts.Bottom - 1), 1,
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
} else if (end <= start && startPos.side == endPos.side) {
|
||||
lc.AddLine (new Point (vts.X + start, vts.Bottom - 1), -(start - end + 1),
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
break;
|
||||
} else {
|
||||
lc.AddLine (new Point (vts.X + start, vts.Bottom - 1), -(start + 1),
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
if (pEnd <= pStart && startPos.side == endPos.side) {
|
||||
lc.AddLine (new Point (pStart, vts.Bottom - 1), -(pStart - pEnd + 1),
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
break;
|
||||
} else {
|
||||
lc.AddLine (new Point (pStart, vts.Bottom - 1), -(pStart - 1),
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
}
|
||||
}
|
||||
switch (endPos.side) {
|
||||
case Side.Left:
|
||||
lc.AddLine (new Point (vts.X, vts.Bottom - 1), -(vts.Bottom - end),
|
||||
lc.AddLine (new Point (vts.X, vts.Bottom - 1), -(vts.Bottom - pEnd),
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
break;
|
||||
case Side.Top:
|
||||
lc.AddLine (new Point (vts.X, vts.Bottom - 1), -vts.Height,
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
lc.AddLine (new Point (vts.X, vts.Y), end + 1,
|
||||
lc.AddLine (new Point (vts.X, vts.Y), pEnd - 1,
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
break;
|
||||
case Side.Right:
|
||||
@@ -753,7 +779,7 @@ namespace Terminal.Gui {
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
lc.AddLine (new Point (vts.X, vts.Y), vts.Width,
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
lc.AddLine (new Point (vts.Width - 1, vts.Y), end,
|
||||
lc.AddLine (new Point (vts.Right - 1, vts.Y), pEnd - 1,
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
break;
|
||||
case Side.Bottom:
|
||||
@@ -761,10 +787,10 @@ namespace Terminal.Gui {
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
lc.AddLine (new Point (vts.X, vts.Y), vts.Width,
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
lc.AddLine (new Point (vts.Width - 1, vts.Y), vts.Height,
|
||||
lc.AddLine (new Point (vts.Right - 1, vts.Y), vts.Height,
|
||||
Orientation.Vertical, lineStyle, attribute);
|
||||
if (vts.Width - end > 0 && startPos.side == endPos.side) {
|
||||
lc.AddLine (new Point (vts.Width - 1, vts.Bottom - 1), -(vts.Width - end),
|
||||
if (pEnd <= vts.Right - 1 && startPos.side == endPos.side) {
|
||||
lc.AddLine (new Point (vts.Right - 1, vts.Bottom - 1), -(vts.Right - pEnd),
|
||||
Orientation.Horizontal, lineStyle, attribute);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -375,128 +375,67 @@ t ", output);
|
||||
└────────┘", output);
|
||||
}
|
||||
|
||||
private static View GetViewsForDrawFrameTests (int start, Side startSide, int end, Side endSide)
|
||||
{
|
||||
var label = new View () { X = Pos.Center (), Y = Pos.Center (), Text = "test", AutoSize = true };
|
||||
// Using a non 0 location to avoids bugs on testing.
|
||||
var view = new View () { X = 2, Y = 2, Width = 10, Height = 5 };
|
||||
view.DrawContent += (s, e) =>
|
||||
view.DrawIncompleteFrame (new (start, startSide), new (end, endSide), view.Bounds, LineStyle.Single);
|
||||
view.Add (label);
|
||||
return view;
|
||||
}
|
||||
|
||||
[Theory, AutoInitShutdown]
|
||||
[InlineData (1, Side.Left, 5, Side.Left, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
test │
|
||||
│
|
||||
─────────┘")]
|
||||
[InlineData (1, Side.Left, 4, Side.Left, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
test │
|
||||
│
|
||||
└────────┘")]
|
||||
[InlineData (0, Side.Left, 3, Side.Left, @"
|
||||
┌────────┐
|
||||
│
|
||||
test │
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (5, Side.Top, -1, Side.Top, @"
|
||||
│ ────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (5, Side.Top, 0, Side.Top, @"
|
||||
┌ ────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (6, Side.Top, 1, Side.Top, @"
|
||||
┌─ ───┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (7, Side.Top, 2, Side.Top, @"
|
||||
┌── ──┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (8, Side.Top, 3, Side.Top, @"
|
||||
┌─── ─┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (9, Side.Top, 4, Side.Top, @"
|
||||
┌──── ┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (10, Side.Top, 5, Side.Top, @"
|
||||
┌───── │
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (3, Side.Right, -1, Side.Right, @"
|
||||
┌─────────
|
||||
│
|
||||
│ test
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (3, Side.Right, 0, Side.Right, @"
|
||||
┌────────┐
|
||||
│
|
||||
│ test
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (4, Side.Right, 1, Side.Right, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
│ test
|
||||
│
|
||||
└────────┘")]
|
||||
[InlineData (4, Side.Bottom, 10, Side.Bottom, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└──── │")]
|
||||
[InlineData (4, Side.Bottom, 9, Side.Bottom, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└──── ┘")]
|
||||
[InlineData (3, Side.Bottom, 8, Side.Bottom, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└─── ─┘")]
|
||||
[InlineData (2, Side.Bottom, 7, Side.Bottom, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└── ──┘")]
|
||||
[InlineData (1, Side.Bottom, 6, Side.Bottom, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└─ ───┘")]
|
||||
[InlineData (0, Side.Bottom, 5, Side.Bottom, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└ ────┘")]
|
||||
[InlineData (-1, Side.Bottom, 5, Side.Bottom, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
│ ────┘")]
|
||||
public void DrawIncompleteFrame_All_Sides (int start, Side startSide, int end, Side endSide, string expected)
|
||||
[InlineData (3, Side.Left, 0, Side.Bottom, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
─────────┘")]
|
||||
[InlineData (1, Side.Top, 0, Side.Left, @"
|
||||
│────────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (1, Side.Right, 9, Side.Top, @"
|
||||
┌─────────
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (8, Side.Bottom, 4, Side.Right, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└────────│")]
|
||||
[InlineData (0, Side.Right, 8, Side.Top, @"
|
||||
┌────────│
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (4, Side.Left, 1, Side.Bottom, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
│────────┘")]
|
||||
[InlineData (0, Side.Top, 1, Side.Left, @"
|
||||
─────────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (9, Side.Bottom, 3, Side.Right, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└─────────")]
|
||||
public void DrawIncompleteFrame_All_Sides_Width_One (int start, Side startSide, int end, Side endSide, string expected)
|
||||
{
|
||||
View view = GetViewsForDrawFrameTests (start, startSide, end, endSide);
|
||||
Application.Top.Add (view);
|
||||
@@ -505,41 +444,161 @@ t ", output);
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
|
||||
}
|
||||
|
||||
private static View GetViewsForDrawFrameTests (int start, Side startSide, int end, Side endSide)
|
||||
[Theory, AutoInitShutdown]
|
||||
[InlineData (1, Side.Left, 5, Side.Left, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
test │
|
||||
│
|
||||
─────────┘")]
|
||||
[InlineData (1, Side.Left, 4, Side.Left, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
test │
|
||||
│
|
||||
└────────┘")]
|
||||
[InlineData (0, Side.Left, 3, Side.Left, @"
|
||||
┌────────┐
|
||||
│
|
||||
test │
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (5, Side.Top, -1, Side.Top, @"
|
||||
│ ────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (5, Side.Top, 0, Side.Top, @"
|
||||
┌ ────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (6, Side.Top, 1, Side.Top, @"
|
||||
┌─ ───┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (7, Side.Top, 2, Side.Top, @"
|
||||
┌── ──┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (8, Side.Top, 3, Side.Top, @"
|
||||
┌─── ─┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (9, Side.Top, 4, Side.Top, @"
|
||||
┌──── ┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (0, Side.Right, 5, Side.Top, @"
|
||||
┌───── │
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (3, Side.Right, -1, Side.Right, @"
|
||||
┌─────────
|
||||
│
|
||||
│ test
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (3, Side.Right, 0, Side.Right, @"
|
||||
┌────────┐
|
||||
│
|
||||
│ test
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (4, Side.Right, 1, Side.Right, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
│ test
|
||||
│
|
||||
└────────┘")]
|
||||
[InlineData (4, Side.Bottom, 10, Side.Bottom, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└──── │")]
|
||||
[InlineData (4, Side.Bottom, 9, Side.Bottom, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└──── ┘")]
|
||||
[InlineData (3, Side.Bottom, 8, Side.Bottom, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└─── ─┘")]
|
||||
[InlineData (2, Side.Bottom, 7, Side.Bottom, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└── ──┘")]
|
||||
[InlineData (1, Side.Bottom, 6, Side.Bottom, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└─ ───┘")]
|
||||
[InlineData (0, Side.Bottom, 5, Side.Bottom, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└ ────┘")]
|
||||
[InlineData (4, Side.Left, 5, Side.Bottom, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
│ ────┘")]
|
||||
public void DrawIncompleteFrame_All_Sides_Width_Greater_Than_One (int start, Side startSide, int end, Side endSide, string expected)
|
||||
{
|
||||
var label = new View () { X = Pos.Center (), Y = Pos.Center (), Text = "test", AutoSize = true };
|
||||
var view = new View () { Width = 10, Height = 5 };
|
||||
view.DrawContent += (s, e) =>
|
||||
view.DrawIncompleteFrame (new (start, startSide), new (end, endSide), view.Bounds, LineStyle.Single);
|
||||
view.Add (label);
|
||||
return view;
|
||||
View view = GetViewsForDrawFrameTests (start, startSide, end, endSide);
|
||||
Application.Top.Add (view);
|
||||
Application.Begin (Application.Top);
|
||||
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
|
||||
}
|
||||
|
||||
[Theory, AutoInitShutdown]
|
||||
[InlineData (4, Side.Left, 4, Side.Right, @"
|
||||
┌────────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
│ │")]
|
||||
┌────────┐
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
│ │")]
|
||||
[InlineData (0, Side.Top, 0, Side.Bottom, @"
|
||||
─────────┐
|
||||
│
|
||||
test │
|
||||
│
|
||||
─────────┘")]
|
||||
─────────┐
|
||||
│
|
||||
test │
|
||||
│
|
||||
─────────┘")]
|
||||
[InlineData (0, Side.Right, 0, Side.Left, @"
|
||||
│ │
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└────────┘")]
|
||||
│ │
|
||||
│ │
|
||||
│ test │
|
||||
│ │
|
||||
└────────┘")]
|
||||
[InlineData (9, Side.Bottom, 9, Side.Top, @"
|
||||
┌─────────
|
||||
│
|
||||
│ test
|
||||
│
|
||||
└─────────")]
|
||||
┌─────────
|
||||
│
|
||||
│ test
|
||||
│
|
||||
└─────────")]
|
||||
public void DrawIncompleteFrame_Three_Full_Sides (int start, Side startSide, int end, Side endSide, string expected)
|
||||
{
|
||||
View view = GetViewsForDrawFrameTests (start, startSide, end, endSide);
|
||||
@@ -550,30 +609,30 @@ t ", output);
|
||||
}
|
||||
|
||||
[Theory, AutoInitShutdown]
|
||||
[InlineData (4, Side.Left, 10, Side.Top, @"
|
||||
┌─────────
|
||||
│
|
||||
│ test
|
||||
│
|
||||
│ ")]
|
||||
[InlineData (0, Side.Top, 5, Side.Right, @"
|
||||
─────────┐
|
||||
│
|
||||
test │
|
||||
│
|
||||
│")]
|
||||
[InlineData (4, Side.Left, 9, Side.Top, @"
|
||||
┌─────────
|
||||
│
|
||||
│ test
|
||||
│
|
||||
│ ")]
|
||||
[InlineData (0, Side.Top, 4, Side.Right, @"
|
||||
─────────┐
|
||||
│
|
||||
test │
|
||||
│
|
||||
│")]
|
||||
[InlineData (0, Side.Right, 0, Side.Bottom, @"
|
||||
│
|
||||
│
|
||||
test │
|
||||
│
|
||||
─────────┘")]
|
||||
│
|
||||
│
|
||||
test │
|
||||
│
|
||||
─────────┘")]
|
||||
[InlineData (9, Side.Bottom, 0, Side.Left, @"
|
||||
│
|
||||
│
|
||||
│ test
|
||||
│
|
||||
└─────────")]
|
||||
│
|
||||
│
|
||||
│ test
|
||||
│
|
||||
└─────────")]
|
||||
public void DrawIncompleteFrame_Two_Full_Sides (int start, Side startSide, int end, Side endSide, string expected)
|
||||
{
|
||||
View view = GetViewsForDrawFrameTests (start, startSide, end, endSide);
|
||||
@@ -585,25 +644,25 @@ t ", output);
|
||||
|
||||
[Theory, AutoInitShutdown]
|
||||
[InlineData (4, Side.Left, 0, Side.Left, @"
|
||||
│
|
||||
│
|
||||
│ test
|
||||
│
|
||||
│ ")]
|
||||
│
|
||||
│
|
||||
│ test
|
||||
│
|
||||
│ ")]
|
||||
[InlineData (0, Side.Top, 9, Side.Top, @"
|
||||
──────────
|
||||
|
||||
test ")]
|
||||
──────────
|
||||
|
||||
test ")]
|
||||
[InlineData (0, Side.Right, 4, Side.Right, @"
|
||||
│
|
||||
│
|
||||
test │
|
||||
│
|
||||
│")]
|
||||
│
|
||||
│
|
||||
test │
|
||||
│
|
||||
│")]
|
||||
[InlineData (9, Side.Bottom, 0, Side.Bottom, @"
|
||||
test
|
||||
|
||||
──────────")]
|
||||
test
|
||||
|
||||
──────────")]
|
||||
public void DrawIncompleteFrame_One_Full_Sides (int start, Side startSide, int end, Side endSide, string expected)
|
||||
{
|
||||
View view = GetViewsForDrawFrameTests (start, startSide, end, endSide);
|
||||
@@ -615,25 +674,25 @@ t ", output);
|
||||
|
||||
[Theory, AutoInitShutdown]
|
||||
[InlineData (0, Side.Bottom, 0, Side.Top, @"
|
||||
┌
|
||||
│
|
||||
│ test
|
||||
│
|
||||
└ ")]
|
||||
┌
|
||||
│
|
||||
│ test
|
||||
│
|
||||
└ ")]
|
||||
[InlineData (0, Side.Left, 0, Side.Right, @"
|
||||
┌────────┐
|
||||
|
||||
test ")]
|
||||
┌────────┐
|
||||
|
||||
test ")]
|
||||
[InlineData (9, Side.Top, 9, Side.Bottom, @"
|
||||
┐
|
||||
│
|
||||
test │
|
||||
│
|
||||
┘")]
|
||||
┐
|
||||
│
|
||||
test │
|
||||
│
|
||||
┘")]
|
||||
[InlineData (4, Side.Right, 4, Side.Left, @"
|
||||
test
|
||||
|
||||
└────────┘")]
|
||||
test
|
||||
|
||||
└────────┘")]
|
||||
public void DrawIncompleteFrame_One_Full_Sides_With_Corner (int start, Side startSide, int end, Side endSide, string expected)
|
||||
{
|
||||
View view = GetViewsForDrawFrameTests (start, startSide, end, endSide);
|
||||
@@ -645,17 +704,17 @@ t ", output);
|
||||
|
||||
[Theory, AutoInitShutdown]
|
||||
[InlineData (2, Side.Left, 2, Side.Left, @"
|
||||
│ test")]
|
||||
│ test")]
|
||||
[InlineData (3, Side.Top, 6, Side.Top, @"
|
||||
────
|
||||
|
||||
test")]
|
||||
────
|
||||
|
||||
test")]
|
||||
[InlineData (2, Side.Right, 2, Side.Right, @"
|
||||
test │")]
|
||||
test │")]
|
||||
[InlineData (6, Side.Bottom, 3, Side.Bottom, @"
|
||||
test
|
||||
|
||||
────")]
|
||||
test
|
||||
|
||||
────")]
|
||||
public void DrawIncompleteFrame_One_Part_Sides (int start, Side startSide, int end, Side endSide, string expected)
|
||||
{
|
||||
View view = GetViewsForDrawFrameTests (start, startSide, end, endSide);
|
||||
|
||||
Reference in New Issue
Block a user