diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-22 13:28:09 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-26 11:21:56 -0700 |
commit | aa216d00254c18f7b5903026ab1a489ae7797dd8 (patch) | |
tree | 7decb42cb0f8a8a5ae0e9d3bdcfdf69e76949e15 /test/sprite/sprite_atlas.test.cpp | |
parent | 6cf9d5cfbfe8120121d8d53cbbf8915cea8f4879 (diff) | |
download | qtlocation-mapboxgl-aa216d00254c18f7b5903026ab1a489ae7797dd8.tar.gz |
[core] Don't use a separate SpriteAtlas for annotation images
Instead, just add them to the Style as needed. Includes changes from #8905 and takes care to avoid regressing #3817.
Diffstat (limited to 'test/sprite/sprite_atlas.test.cpp')
-rw-r--r-- | test/sprite/sprite_atlas.test.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/sprite/sprite_atlas.test.cpp b/test/sprite/sprite_atlas.test.cpp index 7a638a9ec5..4291fe9902 100644 --- a/test/sprite/sprite_atlas.test.cpp +++ b/test/sprite/sprite_atlas.test.cpp @@ -145,3 +145,43 @@ TEST(SpriteAtlas, RemoveReleasesBinPackRect) { EXPECT_TRUE(atlas.getIcon("big")); EXPECT_TRUE(log.empty()); } + +class StubIconRequestor : public IconRequestor { +public: + void onIconsAvailable(IconMap icons) final { + if (iconsAvailable) iconsAvailable(icons); + } + + std::function<void (IconMap)> iconsAvailable; +}; + +TEST(SpriteAtlas, NotifiesRequestorWhenSpriteIsLoaded) { + SpriteAtlas atlas; + StubIconRequestor requestor; + bool notified = false; + + requestor.iconsAvailable = [&] (IconMap) { + notified = true; + }; + + atlas.getIcons(requestor, {"one"}); + ASSERT_FALSE(notified); + + atlas.onSpriteLoaded(); + ASSERT_TRUE(notified); +} + +TEST(SpriteAtlas, NotifiesRequestorImmediatelyIfDependenciesAreSatisfied) { + SpriteAtlas atlas; + StubIconRequestor requestor; + bool notified = false; + + requestor.iconsAvailable = [&] (IconMap) { + notified = true; + }; + + atlas.addImage(makeMutable<style::Image::Impl>("one", PremultipliedImage({ 16, 16 }), 2)); + atlas.getIcons(requestor, {"one"}); + + ASSERT_TRUE(notified); +} |