Skip to content

Commit

Permalink
Add some more specific tests (#2573)
Browse files Browse the repository at this point in the history
These tests are loading a custom typeface from a file and assigned to the paint and font Typeface properties. This is to ensure nothing obvious is going wrong.

Related to #2572
  • Loading branch information
mattleibow authored Aug 22, 2023
1 parent 8fd4dc5 commit 07aa3f3
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/Tests/SkiaSharp/SKFontTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Linq;
using Xunit;

Expand Down Expand Up @@ -473,5 +474,26 @@ public void BreakTextHasCorrectLogic(int textSize)
mm = m;
}
}

[SkippableTheory]
[InlineData("CourierNew.ttf")]
[InlineData("Distortable.ttf")]
[InlineData("Funkster.ttf")]
[InlineData("HangingS.ttf")]
[InlineData("ReallyBigA.ttf")]
[InlineData("Roboto.woff2")]
[InlineData("RobotoMono.woff2")]
[InlineData("Roboto2-Regular_NoEmbed.ttf")]
[InlineData("segoeui.ttf")]
[InlineData("上田雅美.ttf")]
public void CanSetTypefacesWithoutCrashing(string fontfile)
{
using var font = new SKFont();

using var typeface = SKTypeface.FromFile(Path.Combine(PathToFonts, fontfile));
font.Typeface = typeface;

Assert.Same(typeface, font.Typeface);
}
}
}
22 changes: 22 additions & 0 deletions tests/Tests/SkiaSharp/SKPaintTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -698,5 +698,27 @@ public void PaintWithAliasEdgingIsPreserved()
Assert.True(paint.IsAntialias);
Assert.Equal(SKFontEdging.Antialias, paint.GetFont().Edging);
}

[Obsolete]
[SkippableTheory]
[InlineData("CourierNew.ttf")]
[InlineData("Distortable.ttf")]
[InlineData("Funkster.ttf")]
[InlineData("HangingS.ttf")]
[InlineData("ReallyBigA.ttf")]
[InlineData("Roboto.woff2")]
[InlineData("RobotoMono.woff2")]
[InlineData("Roboto2-Regular_NoEmbed.ttf")]
[InlineData("segoeui.ttf")]
[InlineData("上田雅美.ttf")]
public void CanSetTypefacesWithoutCrashing(string fontfile)
{
using var paint = new SKPaint();

using var typeface = SKTypeface.FromFile(Path.Combine(PathToFonts, fontfile));
paint.Typeface = typeface;

Assert.Same(typeface, paint.Typeface);
}
}
}

0 comments on commit 07aa3f3

Please sign in to comment.