diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-12-23 16:54:34 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-12-24 08:17:42 -0800 |
commit | 338f94e7ed73f6b0685f406ac1a8cf389b2aacbb (patch) | |
tree | 2ecf4dba0bf562e60a749fd1f984fff5b0f21fbb /test/fixtures | |
parent | aca584e124a53f83e12d7318de274fce3ff6e290 (diff) | |
download | qtlocation-mapboxgl-338f94e7ed73f6b0685f406ac1a8cf389b2aacbb.tar.gz |
[tests] Rewrite {Sprite,Glyph}Store tests in the style of ResourceLoading
Diffstat (limited to 'test/fixtures')
-rw-r--r-- | test/fixtures/stub_style_observer.hpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/test/fixtures/stub_style_observer.hpp b/test/fixtures/stub_style_observer.hpp new file mode 100644 index 0000000000..7236ca74f5 --- /dev/null +++ b/test/fixtures/stub_style_observer.hpp @@ -0,0 +1,67 @@ +#ifndef MBGL_TEST_STUB_STYLE_OBSERVER +#define MBGL_TEST_STUB_STYLE_OBSERVER + +#include <mbgl/style/style.hpp> + +namespace mbgl { + +/** + * An implementation of Style::Observer that forwards all methods to dynamically-settable lambas. + */ +class StubStyleObserver : public Style::Observer { +public: + void onGlyphsLoaded(const std::string& fontStack, const GlyphRange& glyphRange) override { + if (glyphsLoaded) glyphsLoaded(fontStack, glyphRange); + } + + void onGlyphsError(const std::string& fontStack, const GlyphRange& glyphRange, std::exception_ptr error) override { + if (glyphsError) glyphsError(fontStack, glyphRange, error); + } + + void onSpriteLoaded() override { + if (spriteLoaded) spriteLoaded(); + } + + void onSpriteError(std::exception_ptr error) override { + if (spriteError) spriteError(error); + } + + void onSourceLoaded(Source& source) override { + if (sourceLoaded) sourceLoaded(source); + } + + void onSourceError(Source& source, std::exception_ptr error) override { + if (sourceError) sourceError(source, error); + } + + void onTileLoaded(Source& source, const TileID& tileID, bool isNewTile) override { + if (tileLoaded) tileLoaded(source, tileID, isNewTile); + } + + void onTileError(Source& source, const TileID& tileID, std::exception_ptr error) override { + if (tileError) tileError(source, tileID, error); + } + + void onResourceLoaded() override { + if (resourceLoaded) resourceLoaded(); + }; + + void onResourceError(std::exception_ptr error) override { + 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 ()> spriteLoaded; + std::function<void (std::exception_ptr)> spriteError; + std::function<void (Source&)> sourceLoaded; + std::function<void (Source&, std::exception_ptr)> sourceError; + std::function<void (Source&, const TileID&, bool isNewTile)> tileLoaded; + std::function<void (Source&, const TileID&, std::exception_ptr)> tileError; + std::function<void ()> resourceLoaded; + std::function<void (std::exception_ptr)> resourceError; +}; + +} // namespace mbgl + +#endif |