Using location of 3 to avoid be divisible by 2 and so avoiding bugs.

This commit is contained in:
BDisp
2023-11-21 15:27:26 +00:00
parent 3641233eb6
commit dd3df135d8
2 changed files with 258 additions and 227 deletions

View File

@@ -635,13 +635,13 @@ namespace Terminal.Gui {
}
break;
case Side.Top:
lc.AddLine (new Point (vts.X, vts.Y), pEnd - 1,
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.X, vts.Y), vts.Width,
Orientation.Horizontal, lineStyle, attribute);
lc.AddLine (new Point (vts.Right - 1, vts.Y), pEnd - 1,
lc.AddLine (new Point (vts.Right - 1, vts.Y), pEnd - vts.Y + 1,
Orientation.Vertical, lineStyle, attribute);
break;
case Side.Bottom:
@@ -759,7 +759,7 @@ namespace Terminal.Gui {
Orientation.Horizontal, lineStyle, attribute);
break;
} else {
lc.AddLine (new Point (pStart, vts.Bottom - 1), -(pStart - 1),
lc.AddLine (new Point (pStart, vts.Bottom - 1), -(pStart - vts.X + 1),
Orientation.Horizontal, lineStyle, attribute);
}
}
@@ -771,7 +771,7 @@ namespace Terminal.Gui {
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), pEnd - 1,
lc.AddLine (new Point (vts.X, vts.Y), pEnd - vts.X + 1,
Orientation.Horizontal, lineStyle, attribute);
break;
case Side.Right:
@@ -779,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.Right - 1, vts.Y), pEnd - 1,
lc.AddLine (new Point (vts.Right - 1, vts.Y), pEnd - vts.Y + 1,
Orientation.Vertical, lineStyle, attribute);
break;
case Side.Bottom:

View File

@@ -379,7 +379,8 @@ t ", output);
{
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 };
// Using location of 3 to avoid be divisible by 2 and so avoiding bugs.
var view = new View () { X = 3, Y = 3, Width = 10, Height = 5 };
view.DrawContent += (s, e) =>
view.DrawIncompleteFrame (new (start, startSide), new (end, endSide), view.Bounds, LineStyle.Single);
view.Add (label);
@@ -388,53 +389,53 @@ t ", output);
[Theory, AutoInitShutdown]
[InlineData (3, Side.Left, 0, Side.Bottom, @"
┌────────┐
│ │
│ test │
│ │
─────────┘")]
┌────────┐
│ │
│ test │
│ │
─────────┘")]
[InlineData (1, Side.Top, 0, Side.Left, @"
│────────┐
│ │
│ test │
│ │
└────────┘")]
│────────┐
│ │
│ test │
│ │
└────────┘")]
[InlineData (1, Side.Right, 9, Side.Top, @"
┌─────────
│ │
│ test │
│ │
└────────┘")]
┌─────────
│ │
│ test │
│ │
└────────┘")]
[InlineData (8, Side.Bottom, 4, Side.Right, @"
┌────────┐
│ │
│ test │
│ │
└────────│")]
┌────────┐
│ │
│ test │
│ │
└────────│")]
[InlineData (0, Side.Right, 8, Side.Top, @"
┌────────│
│ │
│ test │
│ │
└────────┘")]
┌────────│
│ │
│ test │
│ │
└────────┘")]
[InlineData (4, Side.Left, 1, Side.Bottom, @"
┌────────┐
│ │
│ test │
│ │
│────────┘")]
┌────────┐
│ │
│ test │
│ │
│────────┘")]
[InlineData (0, Side.Top, 1, Side.Left, @"
─────────┐
│ │
│ test │
│ │
└────────┘")]
─────────┐
│ │
│ test │
│ │
└────────┘")]
[InlineData (9, Side.Bottom, 3, Side.Right, @"
┌────────┐
│ │
│ test │
│ │
└─────────")]
┌────────┐
│ │
│ 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);
@@ -446,125 +447,125 @@ t ", output);
[Theory, AutoInitShutdown]
[InlineData (1, Side.Left, 5, Side.Left, @"
┌────────┐
│ │
test │
─────────┘")]
┌────────┐
│ │
test │
─────────┘")]
[InlineData (1, Side.Left, 4, Side.Left, @"
┌────────┐
│ │
test │
└────────┘")]
┌────────┐
│ │
test │
└────────┘")]
[InlineData (0, Side.Left, 3, Side.Left, @"
┌────────┐
test │
│ │
└────────┘")]
┌────────┐
test │
│ │
└────────┘")]
[InlineData (5, Side.Top, -1, Side.Top, @"
│ ────┐
│ │
│ test │
│ │
└────────┘")]
│ ────┐
│ │
│ test │
│ │
└────────┘")]
[InlineData (5, Side.Top, 0, Side.Top, @"
┌ ────┐
│ │
│ test │
│ │
└────────┘")]
┌ ────┐
│ │
│ test │
│ │
└────────┘")]
[InlineData (6, Side.Top, 1, Side.Top, @"
┌─ ───┐
│ │
│ test │
│ │
└────────┘")]
┌─ ───┐
│ │
│ test │
│ │
└────────┘")]
[InlineData (7, Side.Top, 2, Side.Top, @"
┌── ──┐
│ │
│ test │
│ │
└────────┘")]
┌── ──┐
│ │
│ test │
│ │
└────────┘")]
[InlineData (8, Side.Top, 3, Side.Top, @"
┌─── ─┐
│ │
│ test │
│ │
└────────┘")]
┌─── ─┐
│ │
│ test │
│ │
└────────┘")]
[InlineData (9, Side.Top, 4, Side.Top, @"
┌──── ┐
│ │
│ test │
│ │
└────────┘")]
┌──── ┐
│ │
│ test │
│ │
└────────┘")]
[InlineData (0, Side.Right, 5, Side.Top, @"
┌───── │
│ │
│ test │
│ │
└────────┘")]
┌───── │
│ │
│ test │
│ │
└────────┘")]
[InlineData (3, Side.Right, -1, Side.Right, @"
┌─────────
│ test
│ │
└────────┘")]
┌─────────
│ test
│ │
└────────┘")]
[InlineData (3, Side.Right, 0, Side.Right, @"
┌────────┐
│ test
│ │
└────────┘")]
┌────────┐
│ test
│ │
└────────┘")]
[InlineData (4, Side.Right, 1, Side.Right, @"
┌────────┐
│ │
│ test
└────────┘")]
┌────────┐
│ │
│ test
└────────┘")]
[InlineData (4, Side.Bottom, 10, Side.Bottom, @"
┌────────┐
│ │
│ test │
│ │
└──── │")]
┌────────┐
│ │
│ test │
│ │
└──── │")]
[InlineData (4, Side.Bottom, 9, Side.Bottom, @"
┌────────┐
│ │
│ test │
│ │
└──── ┘")]
┌────────┐
│ │
│ test │
│ │
└──── ┘")]
[InlineData (3, Side.Bottom, 8, Side.Bottom, @"
┌────────┐
│ │
│ test │
│ │
└─── ─┘")]
┌────────┐
│ │
│ test │
│ │
└─── ─┘")]
[InlineData (2, Side.Bottom, 7, Side.Bottom, @"
┌────────┐
│ │
│ test │
│ │
└── ──┘")]
┌────────┐
│ │
│ test │
│ │
└── ──┘")]
[InlineData (1, Side.Bottom, 6, Side.Bottom, @"
┌────────┐
│ │
│ test │
│ │
└─ ───┘")]
┌────────┐
│ │
│ test │
│ │
└─ ───┘")]
[InlineData (0, Side.Bottom, 5, Side.Bottom, @"
┌────────┐
│ │
│ test │
│ │
└ ────┘")]
┌────────┐
│ │
│ test │
│ │
└ ────┘")]
[InlineData (4, Side.Left, 5, Side.Bottom, @"
┌────────┐
│ │
│ test │
│ │
│ ────┘")]
┌────────┐
│ │
│ test │
│ │
│ ────┘")]
public void DrawIncompleteFrame_All_Sides_Width_Greater_Than_One (int start, Side startSide, int end, Side endSide, string expected)
{
View view = GetViewsForDrawFrameTests (start, startSide, end, endSide);
@@ -576,29 +577,29 @@ t ", 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);
@@ -610,29 +611,29 @@ t ", output);
[Theory, AutoInitShutdown]
[InlineData (4, Side.Left, 9, Side.Top, @"
┌─────────
│ test
│ ")]
┌─────────
│ test
│ ")]
[InlineData (0, Side.Top, 4, Side.Right, @"
─────────┐
test │
│")]
─────────┐
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);
@@ -644,25 +645,25 @@ t ", output);
[Theory, AutoInitShutdown]
[InlineData (4, Side.Left, 0, Side.Left, @"
│ test
│ ")]
[InlineData (0, Side.Top, 9, Side.Top, @"
──────────
test ")]
│ test
│ ")]
[InlineData (0, Side.Top, 9, Side.Top, @"
──────────
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);
@@ -674,25 +675,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);
@@ -704,17 +705,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);
@@ -723,5 +724,35 @@ t ", output);
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
}
[Theory, AutoInitShutdown]
[InlineData (2, Side.Left, 2, Side.Right, @"
┌────────┐
│ │
│ test │")]
[InlineData (5, Side.Top, 5, Side.Bottom, @"
────┐
test │
────┘")]
[InlineData (2, Side.Right, 2, Side.Left, @"
│ test │
│ │
└────────┘")]
[InlineData (4, Side.Bottom, 4, Side.Top, @"
┌────
│ test
└──── ")]
public void DrawIncompleteFrame_On_The_Same_Opposite_Location (int start, Side startSide, int end, Side endSide, string expected)
{
View view = GetViewsForDrawFrameTests (start, startSide, end, endSide);
Application.Top.Add (view);
Application.Begin (Application.Top);
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
}
}
}