summaryrefslogtreecommitdiff
path: root/test/map
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2017-02-06 16:27:51 +0100
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2017-02-07 12:17:40 +0100
commit318690645eb57e5c0092574e54a660991383dbec (patch)
treef57b93d5cfd265b9c8b47c9819ebc83d9774ac12 /test/map
parente6659242bc4b2b19f74cfa44d16e1da0e9127d66 (diff)
downloadqtlocation-mapboxgl-318690645eb57e5c0092574e54a660991383dbec.tar.gz
[test] Added unit test for style request failures
Diffstat (limited to 'test/map')
-rw-r--r--test/map/map.test.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp
index fa331288c5..fd3bfe58d7 100644
--- a/test/map/map.test.cpp
+++ b/test/map/map.test.cpp
@@ -10,6 +10,7 @@
#include <mbgl/sprite/sprite_image.hpp>
#include <mbgl/storage/network_status.hpp>
#include <mbgl/storage/default_file_source.hpp>
+#include <mbgl/storage/online_file_source.hpp>
#include <mbgl/util/image.hpp>
#include <mbgl/util/io.hpp>
#include <mbgl/util/run_loop.hpp>
@@ -244,6 +245,53 @@ TEST(Map, StyleLoadedSignal) {
EXPECT_FALSE(emitted);
}
+// Test for https://github.com/mapbox/mapbox-gl-native/issues/7902
+TEST(Map, TEST_REQUIRES_SERVER(StyleNetworkErrorRetry)) {
+ MapTest test;
+ OnlineFileSource fileSource;
+
+ Map map(test.backend, test.view.size, 1, fileSource, test.threadPool, MapMode::Still);
+ map.setStyleURL("http://127.0.0.1:3000/style-fail-once-500");
+
+ test.backend.setMapChangeCallback([&](MapChange change) {
+ if (change == mbgl::MapChangeDidFinishLoadingStyle) {
+ test.runLoop.stop();
+ }
+ });
+
+ test.runLoop.run();
+}
+
+TEST(Map, TEST_REQUIRES_SERVER(StyleNotFound)) {
+ MapTest test;
+ OnlineFileSource fileSource;
+
+ Map map(test.backend, test.view.size, 1, fileSource, test.threadPool, MapMode::Still);
+ map.setStyleURL("http://127.0.0.1:3000/style-fail-once-404");
+
+ using namespace std::chrono_literals;
+ util::Timer timer;
+
+ // Not found errors should not trigger a retry like other errors.
+ test.backend.setMapChangeCallback([&](MapChange change) {
+ if (change == mbgl::MapChangeDidFinishLoadingStyle) {
+ FAIL() << "Should not retry on not found!";
+ }
+
+ if (change == mbgl::MapChangeDidFailLoadingMap) {
+ timer.start(Milliseconds(1100), 0s, [&] {
+ test.runLoop.stop();
+ });
+ }
+ });
+
+ test.runLoop.run();
+
+ // Should also not retry if the response has cache headers.
+ map.setStyleURL("http://127.0.0.1:3000/style-fail-once-404-cache");
+ test.runLoop.run();
+}
+
TEST(Map, AddLayer) {
MapTest test;