Skip to content

Commit

Permalink
add unit tests for borders
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlm committed Dec 12, 2024
1 parent aae144b commit b61971f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/Consolonia.Core/Drawing/ConsoloniaRenderInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,10 @@ public IGeometryImpl CreateCombinedGeometry(GeometryCombineMode combineMode, IGe
if (g1 is not StreamGeometryImpl stream1 || g2 is not StreamGeometryImpl stream2)
throw new ArgumentException("Only StreamGeometryImpl is supported");

Debug.WriteLine($"=====");
Debug.WriteLine($"Stream1 Bounds: {stream1.Bounds}");
Debug.WriteLine($"Stream2 Bounds: {stream2.Bounds}");

var newGeometry = CreateStreamGeometry();
using (var ctx = newGeometry.Open())
{
// Resharper disable UnusedVariable
var hasLeftStroke = stream2.Bounds.X == 1;

Check warning on line 57 in src/Consolonia.Core/Drawing/ConsoloniaRenderInterface.cs

View workflow job for this annotation

GitHub Actions / build

"[CompareOfFloatsByEqualityOperator] Equality comparison of floating point numbers. Possible loss of precision while rounding values" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Drawing/ConsoloniaRenderInterface.cs(57,37)
var hasTopStroke = stream2.Bounds.Y == 1;

Check warning on line 58 in src/Consolonia.Core/Drawing/ConsoloniaRenderInterface.cs

View workflow job for this annotation

GitHub Actions / build

"[CompareOfFloatsByEqualityOperator] Equality comparison of floating point numbers. Possible loss of precision while rounding values" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Drawing/ConsoloniaRenderInterface.cs(58,36)
var hasRightStroke = (stream1.Bounds.Width - stream2.Bounds.Width) == stream2.Bounds.X + 1;

Check notice on line 59 in src/Consolonia.Core/Drawing/ConsoloniaRenderInterface.cs

View workflow job for this annotation

GitHub Actions / build

"[ArrangeRedundantParentheses] Redundant parentheses" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Drawing/ConsoloniaRenderInterface.cs(59,38)

Check warning on line 59 in src/Consolonia.Core/Drawing/ConsoloniaRenderInterface.cs

View workflow job for this annotation

GitHub Actions / build

"[CompareOfFloatsByEqualityOperator] Equality comparison of floating point numbers. Possible loss of precision while rounding values" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Drawing/ConsoloniaRenderInterface.cs(59,38)
Expand All @@ -69,6 +66,7 @@ public IGeometryImpl CreateCombinedGeometry(GeometryCombineMode combineMode, IGe
var rightStroke = stream1.Strokes[1];
var bottomStroke = stream1.Strokes[2];
var leftStroke = stream1.Strokes[3];
// Resharper enable UnusedVariable

// Layout patches. This is a mess, see avalonia bug https://github.com/AvaloniaUI/Avalonia/issues/17752

Expand Down
2 changes: 0 additions & 2 deletions src/Consolonia.Core/Drawing/DrawingContextImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -612,8 +612,6 @@ private void DrawEdgeLine(Line line, RectangleLinePosition linePosition, LineSty

if (includeEndSymbol)
DrawLineSymbolAndMoveHead(ref head, line.Vertical, endSymbol, color, 1);
else
head += line.Vertical ? new Vector(0, 1) : new Vector(1, 0);
}

/// <summary>
Expand Down
24 changes: 24 additions & 0 deletions src/Tests/Consolonia.Gallery.Tests/BorderTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Threading.Tasks;
using Avalonia.Input;
using Consolonia.Gallery.Tests.Base;
using Consolonia.NUnit;
using NUnit.Framework;

namespace Consolonia.Gallery.Tests
{
[TestFixture]
internal class BordersTests : GalleryTestsBaseBase
{
[Test]
public async Task PerformSingleTest()
{
await UITest.KeyInput(Key.Tab);
await UITest.AssertHasText("┌───────┐┌────────────────────┐╔════════════════════╗",
"│Default││LineStyle=SingleLine│║LineStyle=DoubleLine║",
"└───────┘└────────────────────┘╚════════════════════╝",
" ▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▗▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▖████████████████ ",
"▕LineStyle=Edge▏▐LineStyle=EdgeWide▌█LineStyle=Bold█ ",
" ▔▔▔▔▔▔▔▔▔▔▔▔▔▔ ▝▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▘████████████████ ");
}
}
}

0 comments on commit b61971f

Please sign in to comment.