diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-10-06 23:42:20 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-10-06 23:44:46 +0300 |
commit | 18765578e040c8d268ec7098671997625c22b53c (patch) | |
tree | 9a19f7e68417c90ef3450fd1e3fbd2b84d4b4433 /test/text/glyph_loader.test.cpp | |
parent | ce1e46f00b786172390ed0136297d4422f3cbeb4 (diff) | |
download | qtlocation-mapboxgl-18765578e040c8d268ec7098671997625c22b53c.tar.gz |
[test] Added GlyphManager.ImmediateFileSourceupstream/update-glyph-requestors
Diffstat (limited to 'test/text/glyph_loader.test.cpp')
-rw-r--r-- | test/text/glyph_loader.test.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/text/glyph_loader.test.cpp b/test/text/glyph_loader.test.cpp index be197ebb46..20ac045925 100644 --- a/test/text/glyph_loader.test.cpp +++ b/test/text/glyph_loader.test.cpp @@ -214,3 +214,52 @@ TEST(GlyphManager, LoadingInvalid) { {{{"Test Stack"}}, {u'A', u'E'}} }); } + +TEST(GlyphManager, ImmediateFileSource) { + class GlyphManagerTestSynchronous { + public: + util::RunLoop loop; + StubFileSource fileSource = { StubFileSource::ResponseType::Synchronous }; + StubGlyphManagerObserver observer; + StubGlyphRequestor requestor; + GlyphManager glyphManager { fileSource }; + + void run(const std::string& url, GlyphDependencies dependencies) { + // Squelch logging. + Log::setObserver(std::make_unique<Log::NullObserver>()); + + glyphManager.setURL(url); + glyphManager.setObserver(&observer); + glyphManager.getGlyphs(requestor, std::move(dependencies)); + + loop.run(); + } + + void end() { + loop.stop(); + } + }; + + GlyphManagerTestSynchronous test; + + test.fileSource.glyphsResponse = [&] (const Resource&) { + Response response; + response.data = std::make_shared<std::string>(util::read_file("test/fixtures/resources/glyphs.pbf")); + return response; + }; + + test.observer.glyphsError = [&] (const FontStack&, const GlyphRange&, std::exception_ptr) { + FAIL(); + test.end(); + }; + + test.requestor.glyphsAvailable = [&] (GlyphMap) { + test.end(); + }; + + test.run( + "test/fixtures/resources/glyphs.pbf", + GlyphDependencies { + {{{"Test Stack"}}, {u'a', u'å', u' '}} + }); +} |