diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-12 13:01:00 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-13 09:28:53 -0700 |
commit | b3ec985568176b077756b66754470988436d43c1 (patch) | |
tree | 45638ff9787938cd34240542e95e51509773edbf /test | |
parent | 84e39611a096058826dbdb89dccbd1affad05f76 (diff) | |
download | qtlocation-mapboxgl-b3ec985568176b077756b66754470988436d43c1.tar.gz |
[core] Trim StyleObserver interface
It doesn't need to inherit from SpriteLoaderObserver and GlyphAtlasObserver.
Diffstat (limited to 'test')
-rw-r--r-- | test/sprite/sprite_loader.test.cpp | 19 | ||||
-rw-r--r-- | test/src/mbgl/test/stub_style_observer.hpp | 20 | ||||
-rw-r--r-- | test/text/glyph_atlas.test.cpp | 17 |
3 files changed, 32 insertions, 24 deletions
diff --git a/test/sprite/sprite_loader.test.cpp b/test/sprite/sprite_loader.test.cpp index 06018cc390..99f44e57e4 100644 --- a/test/sprite/sprite_loader.test.cpp +++ b/test/sprite/sprite_loader.test.cpp @@ -1,9 +1,9 @@ #include <mbgl/test/util.hpp> #include <mbgl/test/fixture_log_observer.hpp> #include <mbgl/test/stub_file_source.hpp> -#include <mbgl/test/stub_style_observer.hpp> #include <mbgl/sprite/sprite_loader.hpp> +#include <mbgl/sprite/sprite_loader_observer.hpp> #include <mbgl/sprite/sprite_parser.hpp> #include <mbgl/util/io.hpp> #include <mbgl/util/image.hpp> @@ -14,6 +14,21 @@ #include <utility> using namespace mbgl; +using namespace mbgl::style; + +class StubSpriteLoaderObserver : public SpriteLoaderObserver { +public: + void onSpriteLoaded(Images&& images) override { + if (spriteLoaded) spriteLoaded(std::move(images)); + } + + void onSpriteError(std::exception_ptr error) override { + if (spriteError) spriteError(error); + } + + std::function<void (Images&&)> spriteLoaded; + std::function<void (std::exception_ptr)> spriteError; +}; class SpriteLoaderTest { public: @@ -21,7 +36,7 @@ public: util::RunLoop loop; StubFileSource fileSource; - StubStyleObserver observer; + StubSpriteLoaderObserver observer; ThreadPool threadPool { 1 }; SpriteLoader spriteLoader{ 1 }; diff --git a/test/src/mbgl/test/stub_style_observer.hpp b/test/src/mbgl/test/stub_style_observer.hpp index a3a48b04c0..b97911cdb0 100644 --- a/test/src/mbgl/test/stub_style_observer.hpp +++ b/test/src/mbgl/test/stub_style_observer.hpp @@ -10,22 +10,6 @@ using namespace mbgl::style; */ class StubStyleObserver : public style::Observer { public: - void onGlyphsLoaded(const FontStack& fontStack, const GlyphRange& glyphRange) override { - if (glyphsLoaded) glyphsLoaded(fontStack, glyphRange); - } - - void onGlyphsError(const FontStack& fontStack, const GlyphRange& glyphRange, std::exception_ptr error) override { - if (glyphsError) glyphsError(fontStack, glyphRange, error); - } - - void onSpriteLoaded(Images&& images) override { - if (spriteLoaded) spriteLoaded(std::move(images)); - } - - void onSpriteError(std::exception_ptr error) override { - if (spriteError) spriteError(error); - } - void onSourceLoaded(Source& source) override { if (sourceLoaded) sourceLoaded(source); } @@ -46,10 +30,6 @@ public: if (resourceError) resourceError(error); }; - std::function<void (const FontStack&, const GlyphRange&)> glyphsLoaded; - std::function<void (const FontStack&, const GlyphRange&, std::exception_ptr)> glyphsError; - std::function<void (Images&&)> spriteLoaded; - std::function<void (std::exception_ptr)> spriteError; std::function<void (Source&)> sourceLoaded; std::function<void (Source&)> sourceChanged; std::function<void (Source&, std::exception_ptr)> sourceError; diff --git a/test/text/glyph_atlas.test.cpp b/test/text/glyph_atlas.test.cpp index 5aff1ee441..01e0f115c0 100644 --- a/test/text/glyph_atlas.test.cpp +++ b/test/text/glyph_atlas.test.cpp @@ -1,6 +1,5 @@ #include <mbgl/test/util.hpp> #include <mbgl/test/stub_file_source.hpp> -#include <mbgl/test/stub_style_observer.hpp> #include <mbgl/text/glyph_atlas.hpp> #include <mbgl/util/run_loop.hpp> @@ -10,6 +9,20 @@ using namespace mbgl; +class StubGlyphAtlasObserver : public GlyphAtlasObserver { +public: + void onGlyphsLoaded(const FontStack& fontStack, const GlyphRange& glyphRange) override { + if (glyphsLoaded) glyphsLoaded(fontStack, glyphRange); + } + + void onGlyphsError(const FontStack& fontStack, const GlyphRange& glyphRange, std::exception_ptr error) override { + if (glyphsError) glyphsError(fontStack, glyphRange, error); + } + + std::function<void (const FontStack&, const GlyphRange&)> glyphsLoaded; + std::function<void (const FontStack&, const GlyphRange&, std::exception_ptr)> glyphsError; +}; + class StubGlyphRequestor : public GlyphRequestor { public: void onGlyphsAvailable(GlyphPositionMap positions) override { @@ -23,7 +36,7 @@ class GlyphAtlasTest { public: util::RunLoop loop; StubFileSource fileSource; - StubStyleObserver observer; + StubGlyphAtlasObserver observer; StubGlyphRequestor requestor; GlyphAtlas glyphAtlas{ { 32, 32 }, fileSource }; |