summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsheem Mamoowala <asheem.mamoowala@mapbox.com>2019-08-20 19:49:19 -0700
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-08-21 12:00:26 +0300
commitaebcaf685f863ee055b48f6f0a7b2f46fb8bc4ad (patch)
tree341522c8d87816a767c07c47dd154133a67654c5
parent0c017c3e49f99db8df405bf6876c0610bd512cec (diff)
downloadqtlocation-mapboxgl-aebcaf685f863ee055b48f6f0a7b2f46fb8bc4ad.tar.gz
Add unit test and fixture
-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;