summaryrefslogtreecommitdiff
path: root/test/src
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2020-02-15 12:33:31 +0200
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2020-02-17 10:14:05 +0200
commitd0dfd40b0abe32615d33f867f5b07f8d490e146e (patch)
treef899b398ec6da5bb11c0ba2991cd26f24ecc0117 /test/src
parentb97f40469b6f3d386ae93bc9a23722ff017162f0 (diff)
downloadqtlocation-mapboxgl-d0dfd40b0abe32615d33f867f5b07f8d490e146e.tar.gz
[core] Add unit test for Style::Impl::onSpriteLoaded
Diffstat (limited to 'test/src')
-rw-r--r--test/src/mbgl/test/http_server.cpp10
-rw-r--r--test/src/mbgl/test/stub_map_observer.hpp7
2 files changed, 17 insertions, 0 deletions
diff --git a/test/src/mbgl/test/http_server.cpp b/test/src/mbgl/test/http_server.cpp
index 2b72bb2c94..5679b1188b 100644
--- a/test/src/mbgl/test/http_server.cpp
+++ b/test/src/mbgl/test/http_server.cpp
@@ -1,6 +1,7 @@
#include <mbgl/test/util.hpp>
#include <mbgl/util/chrono.hpp>
+#include <mbgl/util/io.hpp>
#include <mbgl/util/logging.hpp>
// Limit to 4 threads (default is the nbr of CPU cores)
@@ -9,6 +10,8 @@
#include <atomic>
+using namespace std::literals::string_literals;
+
namespace mbgl {
namespace test {
@@ -182,6 +185,13 @@ void runServer(std::unique_ptr<httplib::Server>& server) {
res.set_content("Request " + std::string(numbers), "text/plain");
});
+ server->Get(R"(/online/(.*))", [](const Request req, Response& res) {
+ res.status = 200;
+ auto file = "test/fixtures/map/online/"s + std::string(req.matches[1]);
+ auto content = util::read_file(file);
+ res.set_content(content, "text/plain");
+ });
+
server->listen("127.0.0.1", 3000);
}
diff --git a/test/src/mbgl/test/stub_map_observer.hpp b/test/src/mbgl/test/stub_map_observer.hpp
index 89ee4e7953..63e42fa6ab 100644
--- a/test/src/mbgl/test/stub_map_observer.hpp
+++ b/test/src/mbgl/test/stub_map_observer.hpp
@@ -38,11 +38,18 @@ public:
}
}
+ void onDidBecomeIdle() final {
+ if (didBecomeIdleCallback) {
+ didBecomeIdleCallback();
+ }
+ }
+
std::function<void()> willStartLoadingMapCallback;
std::function<void()> didFinishLoadingMapCallback;
std::function<void()> didFailLoadingMapCallback;
std::function<void()> didFinishLoadingStyleCallback;
std::function<void(RenderFrameStatus)> didFinishRenderingFrameCallback;
+ std::function<void()> didBecomeIdleCallback;
};