summaryrefslogtreecommitdiff
path: root/test/style
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2015-12-17 18:15:06 -0800
committerBruno de Oliveira Abinader <bruno@mapbox.com>2015-12-17 18:15:06 -0800
commit3e00ab158246ba220fa6c73a9f44c4116b0f98e2 (patch)
tree75424f511f68682413a61e5e2ab4956276804431 /test/style
parent9d3fe01991ce881a89847b9ed44cb68cbef25efd (diff)
downloadqtlocation-mapboxgl-3e00ab158246ba220fa6c73a9f44c4116b0f98e2.tar.gz
[core] Add more tests to on-demand source load
Diffstat (limited to 'test/style')
-rw-r--r--test/style/unused_sources.cpp37
1 files changed, 36 insertions, 1 deletions
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