From aebcaf685f863ee055b48f6f0a7b2f46fb8bc4ad Mon Sep 17 00:00:00 2001 From: Asheem Mamoowala Date: Tue, 20 Aug 2019 19:49:19 -0700 Subject: Add unit test and fixture --- test/fixtures/resources/glyphs-12244-12543.pbf | Bin 0 -> 134697 bytes test/text/glyph_manager.test.cpp | 51 +++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 test/fixtures/resources/glyphs-12244-12543.pbf 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 Binary files /dev/null and b/test/fixtures/resources/glyphs-12244-12543.pbf 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(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 = *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; -- cgit v1.2.1