diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-04-22 10:38:42 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-04-22 15:53:18 -0700 |
commit | 5939dd5b412fcc1ef857711a137589aa865bd442 (patch) | |
tree | 4bd4e021ea564ee262cff56ab7b6f76e98b29471 /test | |
parent | d77e35b6866e461c3cb05de2112d548be4ef7780 (diff) | |
download | qtlocation-mapboxgl-5939dd5b412fcc1ef857711a137589aa865bd442.tar.gz |
[core] Use the proper type for font stacks
Diffstat (limited to 'test')
-rw-r--r-- | test/map/map.cpp | 2 | ||||
-rw-r--r-- | test/src/mbgl/test/stub_style_observer.hpp | 8 | ||||
-rw-r--r-- | test/storage/resource.cpp | 2 | ||||
-rw-r--r-- | test/style/glyph_store.cpp | 36 | ||||
-rw-r--r-- | test/style/style_parser.cpp | 6 |
5 files changed, 27 insertions, 27 deletions
diff --git a/test/map/map.cpp b/test/map/map.cpp index 2fdf63a79a..1e8c1b2a4e 100644 --- a/test/map/map.cpp +++ b/test/map/map.cpp @@ -32,7 +32,7 @@ TEST(Map, Offline) { fileSource.put(Resource::spriteJSON(prefix + "/offline/sprite", 1.0), expiredItem("offline/sprite.json")); fileSource.put(Resource::spriteImage(prefix + "/offline/sprite", 1.0), expiredItem("offline/sprite.png")); fileSource.put(Resource::tile(prefix + "/offline/{z}-{x}-{y}.vector.pbf", 1.0, 0, 0, 0), expiredItem("offline/0-0-0.vector.pbf")); - fileSource.put(Resource::glyphs(prefix + "/offline/{fontstack}/{range}.pbf", "Helvetica", {0, 255}), expiredItem("offline/glyph.pbf")); + fileSource.put(Resource::glyphs(prefix + "/offline/{fontstack}/{range}.pbf", {{"Helvetica"}}, {0, 255}), expiredItem("offline/glyph.pbf")); NetworkStatus::Set(NetworkStatus::Status::Offline); Map map(view, fileSource, MapMode::Still); diff --git a/test/src/mbgl/test/stub_style_observer.hpp b/test/src/mbgl/test/stub_style_observer.hpp index 7236ca74f5..f428b4fda7 100644 --- a/test/src/mbgl/test/stub_style_observer.hpp +++ b/test/src/mbgl/test/stub_style_observer.hpp @@ -10,11 +10,11 @@ namespace mbgl { */ class StubStyleObserver : public Style::Observer { public: - void onGlyphsLoaded(const std::string& fontStack, const GlyphRange& glyphRange) override { + void onGlyphsLoaded(const FontStack& fontStack, const GlyphRange& glyphRange) override { if (glyphsLoaded) glyphsLoaded(fontStack, glyphRange); } - void onGlyphsError(const std::string& fontStack, const GlyphRange& glyphRange, std::exception_ptr error) override { + void onGlyphsError(const FontStack& fontStack, const GlyphRange& glyphRange, std::exception_ptr error) override { if (glyphsError) glyphsError(fontStack, glyphRange, error); } @@ -50,8 +50,8 @@ public: if (resourceError) resourceError(error); }; - std::function<void (const std::string& fontStack, const GlyphRange&)> glyphsLoaded; - std::function<void (const std::string& fontStack, const GlyphRange&, std::exception_ptr)> glyphsError; + std::function<void (const FontStack&, const GlyphRange&)> glyphsLoaded; + std::function<void (const FontStack&, const GlyphRange&, std::exception_ptr)> glyphsError; std::function<void ()> spriteLoaded; std::function<void (std::exception_ptr)> spriteError; std::function<void (Source&)> sourceLoaded; diff --git a/test/storage/resource.cpp b/test/storage/resource.cpp index 0b04c1b3e4..5d6c3bcbf2 100644 --- a/test/storage/resource.cpp +++ b/test/storage/resource.cpp @@ -40,7 +40,7 @@ TEST(Resource, Tile) { TEST(Resource, Glyphs) { using namespace mbgl; - Resource resource = Resource::glyphs("http://example.com/{fontstack}/{range}", "stack", {0, 255}); + Resource resource = Resource::glyphs("http://example.com/{fontstack}/{range}", {{"stack"}}, {0, 255}); EXPECT_EQ(Resource::Kind::Glyphs, resource.kind); EXPECT_EQ("http://example.com/stack/0-255", resource.url); } diff --git a/test/style/glyph_store.cpp b/test/style/glyph_store.cpp index 96d112183a..2a874a05a7 100644 --- a/test/style/glyph_store.cpp +++ b/test/style/glyph_store.cpp @@ -18,7 +18,7 @@ public: StubStyleObserver observer; GlyphStore glyphStore { fileSource }; - void run(const std::string& url, const std::string& fontStack, const std::set<GlyphRange>& glyphRanges) { + void run(const std::string& url, const FontStack& fontStack, const std::set<GlyphRange>& glyphRanges) { // Squelch logging. Log::setObserver(std::make_unique<Log::NullObserver>()); @@ -44,16 +44,16 @@ TEST(GlyphStore, LoadingSuccess) { return response; }; - test.observer.glyphsError = [&] (const std::string&, const GlyphRange&, std::exception_ptr) { + test.observer.glyphsError = [&] (const FontStack&, const GlyphRange&, std::exception_ptr) { FAIL(); test.end(); }; - test.observer.glyphsLoaded = [&] (const std::string&, const GlyphRange&) { - if (!test.glyphStore.hasGlyphRanges("Test Stack", {{0, 255}, {256, 511}})) + test.observer.glyphsLoaded = [&] (const FontStack&, const GlyphRange&) { + if (!test.glyphStore.hasGlyphRanges({{"Test Stack"}}, {{0, 255}, {256, 511}})) return; - auto glyphSet = test.glyphStore.getGlyphSet("Test Stack"); + auto glyphSet = test.glyphStore.getGlyphSet({{"Test Stack"}}); ASSERT_FALSE(glyphSet->getSDFs().empty()); test.end(); @@ -61,7 +61,7 @@ TEST(GlyphStore, LoadingSuccess) { test.run( "test/fixtures/resources/glyphs.pbf", - "Test Stack", + {{"Test Stack"}}, {{0, 255}, {256, 511}}); } @@ -76,23 +76,23 @@ TEST(GlyphStore, LoadingFail) { return response; }; - test.observer.glyphsError = [&] (const std::string& fontStack, const GlyphRange& glyphRange, std::exception_ptr error) { - EXPECT_EQ(fontStack, "Test Stack"); + test.observer.glyphsError = [&] (const FontStack& fontStack, const GlyphRange& glyphRange, std::exception_ptr error) { + EXPECT_EQ(fontStack, FontStack({"Test Stack"})); EXPECT_EQ(glyphRange, GlyphRange(0, 255)); EXPECT_TRUE(error != nullptr); EXPECT_EQ(util::toString(error), "Failed by the test case"); - auto glyphSet = test.glyphStore.getGlyphSet("Test Stack"); + auto glyphSet = test.glyphStore.getGlyphSet({{"Test Stack"}}); ASSERT_TRUE(glyphSet->getSDFs().empty()); - ASSERT_FALSE(test.glyphStore.hasGlyphRanges("Test Stack", {{0, 255}})); + ASSERT_FALSE(test.glyphStore.hasGlyphRanges({{"Test Stack"}}, {{0, 255}})); test.end(); }; test.run( "test/fixtures/resources/glyphs.pbf", - "Test Stack", + {{"Test Stack"}}, {{0, 255}}); } @@ -105,23 +105,23 @@ TEST(GlyphStore, LoadingCorrupted) { return response; }; - test.observer.glyphsError = [&] (const std::string& fontStack, const GlyphRange& glyphRange, std::exception_ptr error) { - EXPECT_EQ(fontStack, "Test Stack"); + test.observer.glyphsError = [&] (const FontStack& fontStack, const GlyphRange& glyphRange, std::exception_ptr error) { + EXPECT_EQ(fontStack, FontStack({"Test Stack"})); EXPECT_EQ(glyphRange, GlyphRange(0, 255)); EXPECT_TRUE(error != nullptr); EXPECT_EQ(util::toString(error), "pbf unknown field type exception"); - auto glyphSet = test.glyphStore.getGlyphSet("Test Stack"); + auto glyphSet = test.glyphStore.getGlyphSet({{"Test Stack"}}); ASSERT_TRUE(glyphSet->getSDFs().empty()); - ASSERT_FALSE(test.glyphStore.hasGlyphRanges("Test Stack", {{0, 255}})); + ASSERT_FALSE(test.glyphStore.hasGlyphRanges({{"Test Stack"}}, {{0, 255}})); test.end(); }; test.run( "test/fixtures/resources/glyphs.pbf", - "Test Stack", + {{"Test Stack"}}, {{0, 255}}); } @@ -133,12 +133,12 @@ TEST(GlyphStore, LoadingCancel) { return optional<Response>(); }; - test.observer.glyphsLoaded = [&] (const std::string&, const GlyphRange&) { + test.observer.glyphsLoaded = [&] (const FontStack&, const GlyphRange&) { FAIL() << "Should never be called"; }; test.run( "test/fixtures/resources/glyphs.pbf", - "Test Stack", + {{"Test Stack"}}, {{0, 255}}); } diff --git a/test/style/style_parser.cpp b/test/style/style_parser.cpp index f549d638a4..6245c326a5 100644 --- a/test/style/style_parser.cpp +++ b/test/style/style_parser.cpp @@ -120,7 +120,7 @@ TEST(StyleParser, FontStacks) { parser.parse(util::read_file("test/fixtures/style_parser/font_stacks.json")); auto result = parser.fontStacks(); ASSERT_EQ(3, result.size()); - ASSERT_EQ("a", result[0]); - ASSERT_EQ("a,b", result[1]); - ASSERT_EQ("a,b,c", result[2]); + ASSERT_EQ(FontStack({"a"}), result[0]); + ASSERT_EQ(FontStack({"a", "b"}), result[1]); + ASSERT_EQ(FontStack({"a", "b", "c"}), result[2]); } |