summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsheem Mamoowala <asheem.mamoowala@mapbox.com>2019-08-20 19:49:19 -0700
committerAsheem Mamoowala <asheem.mamoowala@mapbox.com>2019-08-20 19:49:19 -0700
commit31031044653083371edebd9a9f8382cc7836fdae (patch)
tree3f61b4fb5baaa142dff3ac66071192afba01a618
parentdc8382aa6f3536cc9c359b8a88744ec53891f925 (diff)
downloadqtlocation-mapboxgl-31031044653083371edebd9a9f8382cc7836fdae.tar.gz
Add unit test and fixtureupstream/fix-local-glyphs
-rw-r--r--test/fixtures/resources/glyphs-12244-12543.pbfbin0 -> 134697 bytes
-rw-r--r--test/text/glyph_manager.test.cpp51
2 files changed, 51 insertions, 0 deletions
diff --git a/test/fixtures/resources/glyphs-12244-12543.pbf b/test/fixtures/resources/glyphs-12244-12543.pbf
new file mode 100644
index 0000000000..cbc4a52056
--- /dev/null
+++ b/test/fixtures/resources/glyphs-12244-12543.pbf
Binary files differ
diff --git a/test/text/glyph_manager.test.cpp b/test/text/glyph_manager.test.cpp
index 8c84bd5d08..1e9aef38ed 100644
--- a/test/text/glyph_manager.test.cpp
+++ b/test/text/glyph_manager.test.cpp
@@ -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;