Add unit test and fixture
This commit is contained in:
committed by
Mikhail Pozdnyakov
parent
0c017c3e49
commit
aebcaf685f
BIN
test/fixtures/resources/glyphs-12244-12543.pbf
vendored
Normal file
BIN
test/fixtures/resources/glyphs-12244-12543.pbf
vendored
Normal file
Binary file not shown.
@@ -253,6 +253,57 @@ TEST(GlyphManager, LoadLocalCJKGlyph) {
|
||||
});
|
||||
}
|
||||
|
||||
TEST(GlyphManager, LoadLocalCJKGlyphAfterLoadingRangeFromURL) {
|
||||
GlyphManagerTest test;
|
||||
int firstGlyphResponse = false;
|
||||
|
||||
test.fileSource.glyphsResponse = [&] (const Resource&) {
|
||||
firstGlyphResponse = true;
|
||||
Response response;
|
||||
response.data = std::make_shared<std::string>(util::read_file("test/fixtures/resources/glyphs-12244-12543.pbf"));
|
||||
return response;
|
||||
|
||||
};
|
||||
|
||||
test.requestor.glyphsAvailable = [&] (GlyphMap glyphs) {
|
||||
const auto& testPositions = glyphs.at(FontStackHasher()({{"Test Stack"}}));
|
||||
|
||||
if (firstGlyphResponse == true) {
|
||||
firstGlyphResponse = false;
|
||||
ASSERT_EQ(testPositions.size(), 1u);
|
||||
ASSERT_EQ(testPositions.count(u'々'), 1u);
|
||||
|
||||
//Katakana letter te, should be locally rasterized
|
||||
// instead of using the glyph recieved from the range
|
||||
// for the ideagraphic mark
|
||||
test.glyphManager.getGlyphs(test.requestor,
|
||||
GlyphDependencies {
|
||||
{{{"Test Stack"}}, {u'テ'}} // 0x30c6
|
||||
},
|
||||
test.fileSource);
|
||||
} else {
|
||||
ASSERT_EQ(testPositions.size(), 1u);
|
||||
ASSERT_EQ(testPositions.count(u'テ'), 1u);
|
||||
|
||||
Immutable<Glyph> glyph = *testPositions.at(u'テ');
|
||||
EXPECT_EQ(glyph->id, u'テ');
|
||||
EXPECT_EQ(glyph->metrics.width, 24ul);
|
||||
EXPECT_EQ(glyph->metrics.height, 24ul);
|
||||
EXPECT_EQ(glyph->metrics.left, 0);
|
||||
EXPECT_EQ(glyph->metrics.top, -8);
|
||||
EXPECT_EQ(glyph->metrics.advance, 24ul);
|
||||
EXPECT_EQ(glyph->bitmap.size, Size(30, 30));
|
||||
|
||||
test.end();
|
||||
}
|
||||
};
|
||||
|
||||
test.run(
|
||||
"test/fixtures/resources/glyphs-12244-12543.pbf",
|
||||
GlyphDependencies {
|
||||
{{{"Test Stack"}}, {u'々'}} //0x3005
|
||||
});
|
||||
}
|
||||
|
||||
TEST(GlyphManager, LoadingInvalid) {
|
||||
GlyphManagerTest test;
|
||||
|
||||
Reference in New Issue
Block a user