summaryrefslogtreecommitdiff
path: root/test/text/glyph_atlas.test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/text/glyph_atlas.test.cpp')
-rw-r--r--test/text/glyph_atlas.test.cpp37
1 files changed, 15 insertions, 22 deletions
diff --git a/test/text/glyph_atlas.test.cpp b/test/text/glyph_atlas.test.cpp
index e229cd117b..3679cabc1b 100644
--- a/test/text/glyph_atlas.test.cpp
+++ b/test/text/glyph_atlas.test.cpp
@@ -83,8 +83,7 @@ TEST(GlyphAtlas, LoadingFail) {
EXPECT_TRUE(error != nullptr);
EXPECT_EQ(util::toString(error), "Failed by the test case");
- auto glyphSet = test.glyphAtlas.getGlyphSet({{"Test Stack"}});
- ASSERT_TRUE(glyphSet->getSDFs().empty());
+ ASSERT_TRUE(test.glyphAtlas.getGlyphSet({{"Test Stack"}})->getSDFs().empty());
ASSERT_FALSE(test.glyphAtlas.hasGlyphRanges({{"Test Stack"}}, {{0, 255}}));
test.end();
@@ -112,8 +111,7 @@ TEST(GlyphAtlas, LoadingCorrupted) {
EXPECT_TRUE(error != nullptr);
EXPECT_EQ(util::toString(error), "unknown pbf field type exception");
- auto glyphSet = test.glyphAtlas.getGlyphSet({{"Test Stack"}});
- ASSERT_TRUE(glyphSet->getSDFs().empty());
+ ASSERT_TRUE(test.glyphAtlas.getGlyphSet({{"Test Stack"}})->getSDFs().empty());
ASSERT_FALSE(test.glyphAtlas.hasGlyphRanges({{"Test Stack"}}, {{0, 255}}));
test.end();
@@ -144,32 +142,27 @@ TEST(GlyphAtlas, LoadingCancel) {
}
TEST(GlyphAtlas, InvalidSDFGlyph) {
- GlyphSet glyphSet;
- glyphSet.insert(65, SDFGlyph{ 65 /* ASCII 'A' */,
- "x" /* bitmap is too short */,
- { 1 /* width */, 1 /* height */, 0 /* left */, 0 /* top */,
- 0 /* advance */ } });
- glyphSet.insert(66, SDFGlyph{ 66 /* ASCII 'B' */,
- std::string(7 * 7, 'x'), /* correct */
+ const FontStack fontStack{ "Mock Font" };
+
+ GlyphAtlasTest test;
+ GlyphPositions positions;
+
+ auto glyphSet = test.glyphAtlas.getGlyphSet(fontStack);
+ glyphSet->insert(66, SDFGlyph{ 66 /* ASCII 'B' */,
+ AlphaImage({7, 7}), /* correct */
{ 1 /* width */, 1 /* height */, 0 /* left */, 0 /* top */,
0 /* advance */ } });
- glyphSet.insert(67, SDFGlyph{ 67 /* ASCII 'C' */,
- std::string(518 * 8, 'x'), /* correct */
+ glyphSet->insert(67, SDFGlyph{ 67 /* ASCII 'C' */,
+ AlphaImage({518, 8}), /* correct */
{ 512 /* width */, 2 /* height */, 0 /* left */, 0 /* top */,
0 /* advance */ } });
-
- const FontStack fontStack{ "Mock Font" };
-
- GlyphAtlasTest test;
- GlyphPositions positions;
test.glyphAtlas.addGlyphs(1, std::u16string{u"ABC"}, fontStack, glyphSet, positions);
- ASSERT_EQ(3u, positions.size());
+ ASSERT_EQ(2u, positions.size());
- // 'A' was not placed because the bitmap size is invalid.
- ASSERT_NE(positions.end(), positions.find(65));
- ASSERT_EQ((Rect<uint16_t>{ 0, 0, 0, 0 }), positions[65].rect);
+ // 'A' was not placed because not in the glyph set.
+ ASSERT_EQ(positions.end(), positions.find(65));
// 'B' was placed at the top left.
ASSERT_NE(positions.end(), positions.find(66));