summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-06-21 08:11:35 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-06-22 08:04:39 -0700
commite4201e207c3a6b33da64fdc2f9a00ec08586dc09 (patch)
tree802af93e981de8f5e6aff2523f4895944423d052 /test
parent122db775818a305cbae797875cc5aae48b6dfe19 (diff)
downloadqtlocation-mapboxgl-e4201e207c3a6b33da64fdc2f9a00ec08586dc09.tar.gz
[tests] Add tests for MapObserver::on{WillStart,DidFinish}LoadingMap
Diffstat (limited to 'test')
-rw-r--r--test/map/map.test.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp
index be78c8714b..0ff828ce40 100644
--- a/test/map/map.test.cpp
+++ b/test/map/map.test.cpp
@@ -28,6 +28,26 @@ class BackendTest : public HeadlessBackend {
public:
BackendTest() : HeadlessBackend(test::sharedDisplay()) {}
+ void invalidate() {
+ if (invalidateCallback) {
+ invalidateCallback();
+ }
+ }
+
+ std::function<void()> invalidateCallback;
+
+ void onWillStartLoadingMap() final {
+ if (onWillStartLoadingMapCallback) {
+ onWillStartLoadingMapCallback();
+ }
+ }
+
+ void onDidFinishLoadingMap() final {
+ if (onDidFinishLoadingMapCallback) {
+ onDidFinishLoadingMapCallback();
+ }
+ }
+
void onDidFailLoadingMap(std::exception_ptr) final {
if (didFailLoadingMapCallback) {
didFailLoadingMapCallback();
@@ -40,6 +60,8 @@ public:
}
}
+ std::function<void()> onWillStartLoadingMapCallback;
+ std::function<void()> onDidFinishLoadingMapCallback;
std::function<void()> didFailLoadingMapCallback;
std::function<void()> didFinishLoadingStyleCallback;
};
@@ -277,6 +299,34 @@ TEST(Map, StyleEarlyMutation) {
EXPECT_NE(nullptr, map.getLayer("water"));
}
+TEST(Map, MapLoadingSignal) {
+ MapTest test;
+ Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still);
+
+ bool emitted = false;
+ test.backend.onWillStartLoadingMapCallback = [&]() {
+ emitted = true;
+ };
+ map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
+ EXPECT_TRUE(emitted);
+}
+
+TEST(Map, MapLoadedSignal) {
+ MapTest test;
+ Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Continuous);
+
+ test.backend.onDidFinishLoadingMapCallback = [&]() {
+ test.runLoop.stop();
+ };
+
+ test.backend.invalidateCallback = [&]() {
+ map.render(test.view);
+ };
+
+ map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
+ test.runLoop.run();
+}
+
TEST(Map, StyleLoadedSignal) {
MapTest test;
Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still);