Skip to content

Commit 851066c

Browse files
authored
Merge pull request AvaloniaUI#8045 from Gillibald/fixes/stableSKTypefaceCollectionTests
Fix SKTypefaceCollection tests
2 parents c877c1b + ede918e commit 851066c

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

tests/Avalonia.Skia.UnitTests/Media/SKTypefaceCollectionCacheTests.cs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,37 @@ public void Should_Get_Near_Matching_Typeface(string familyName, FontWeight font
2626
Assert.Equal("Noto Mono", actual);
2727
}
2828
}
29-
29+
3030
[Fact]
31-
public void Should_Get_Null_For_Invalid_FamilyName()
31+
public void Should_Get_Typeface_For_Invalid_FamilyName()
3232
{
3333
using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface))
3434
{
3535
var notoMono =
3636
new FontFamily("resm:Avalonia.Skia.UnitTests.Assets?assembly=Avalonia.Skia.UnitTests#Noto Mono");
37-
37+
3838
var notoMonoCollection = SKTypefaceCollectionCache.GetOrAddTypefaceCollection(notoMono);
3939

4040
var typeface = notoMonoCollection.Get(new Typeface("ABC"));
41-
42-
Assert.Null(typeface);
41+
42+
Assert.NotNull(typeface);
43+
}
44+
}
45+
46+
[Fact]
47+
public void Should_Get_Typeface_For_Partial_FamilyName()
48+
{
49+
using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface))
50+
{
51+
var fontFamily = new FontFamily("resm:Avalonia.Skia.UnitTests.Assets?assembly=Avalonia.Skia.UnitTests#T");
52+
53+
var fontCollection = SKTypefaceCollectionCache.GetOrAddTypefaceCollection(fontFamily);
54+
55+
var typeface = fontCollection.Get(new Typeface(fontFamily));
56+
57+
Assert.NotNull(typeface);
58+
59+
Assert.Equal("Twitter Color Emoji", typeface.FamilyName);
4360
}
4461
}
4562
}

0 commit comments

Comments
 (0)