diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2015-12-17 18:15:06 -0800 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2015-12-17 18:15:06 -0800 |
commit | 3e00ab158246ba220fa6c73a9f44c4116b0f98e2 (patch) | |
tree | 75424f511f68682413a61e5e2ab4956276804431 /test | |
parent | 9d3fe01991ce881a89847b9ed44cb68cbef25efd (diff) | |
download | qtlocation-mapboxgl-3e00ab158246ba220fa6c73a9f44c4116b0f98e2.tar.gz |
[core] Add more tests to on-demand source load
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/resources/style-unused-sources.json | 12 | ||||
-rw-r--r-- | test/style/unused_sources.cpp | 37 |
2 files changed, 48 insertions, 1 deletions
diff --git a/test/fixtures/resources/style-unused-sources.json b/test/fixtures/resources/style-unused-sources.json index f87166a678..3878f85dd8 100644 --- a/test/fixtures/resources/style-unused-sources.json +++ b/test/fixtures/resources/style-unused-sources.json @@ -32,5 +32,17 @@ "layout" : { "visibility" : "none" } + }, { + "id": "classylayer", + "type": "symbol", + "source": "unusedsource", + "paint" : { + "icon-opacity" : 0, + "text-opacity" : 0 + }, + "paint.visible" : { + "icon-opacity" : 1, + "text-opacity" : 1 + } }] } diff --git a/test/style/unused_sources.cpp b/test/style/unused_sources.cpp index 318a8928f7..43610ff603 100644 --- a/test/style/unused_sources.cpp +++ b/test/style/unused_sources.cpp @@ -68,6 +68,10 @@ public: callback(error, style.get()); } + void addClass(const std::string& class_) { + data.addClass(class_); + } + private: MapData data; std::unique_ptr<Style> style; @@ -77,7 +81,7 @@ private: MockStyleObserverCallback callback; }; -TEST(Style, UnusedSources) { +TEST(Style, UnusedSource) { util::RunLoop loop; MockView view; @@ -108,4 +112,35 @@ TEST(Style, UnusedSources) { observer.reset(); } +TEST(Style, UnusedSourceActiveViaClassUpdate) { + util::RunLoop loop; + + MockView view; + MockFileSource fileSource(MockFileSource::Success, ""); + + auto callback = [&loop](std::exception_ptr error, Style* style) { + loop.stop(); + + EXPECT_TRUE(error == nullptr); + + Source *unusedSource = style->getSource("unusedsource"); + EXPECT_TRUE(unusedSource); + EXPECT_TRUE(unusedSource->isLoaded()); + }; + + std::unique_ptr<util::Thread<MockStyleObserver>> observer( + std::make_unique<util::Thread<MockStyleObserver>>( + util::ThreadContext{"Map", util::ThreadType::Map, util::ThreadPriority::Regular}, view, fileSource, callback)); + + observer->invoke(&MockStyleObserver::addClass, "visible"); + observer->invoke(&MockStyleObserver::update); + + loop.run(); + + // Needed because it will make the Map thread + // join and cease logging after this point. + observer->invoke(&MockStyleObserver::cleanup); + observer.reset(); +} + } // namespace mbgl |