summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-02-27 15:36:02 +0200
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-02-28 12:52:26 +0200
commit91437d8101645422f608fe9ef67b2d9ea1acbcbf (patch)
tree8b6319f1fac3ab3cb4ad54400e5f780761d8edbc
parent2b1bb1dc4a840a139e5f7823fea0641f7a7c91f8 (diff)
downloadqtlocation-mapboxgl-91437d8101645422f608fe9ef67b2d9ea1acbcbf.tar.gz
Add OfflineDownload.NoFreezingOnNotFoundError unit test
-rw-r--r--test/storage/offline_download.test.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/test/storage/offline_download.test.cpp b/test/storage/offline_download.test.cpp
index 45ecb31d8e..e5178e3901 100644
--- a/test/storage/offline_download.test.cpp
+++ b/test/storage/offline_download.test.cpp
@@ -1061,4 +1061,73 @@ TEST(OfflineDownload, NoFreezingOnCachedTilesAndNewStyle) {
test.loop.run();
// Passes if does not freeze.
+}
+
+TEST(OfflineDownload, NoFreezingOnNotFoundError) {
+ OfflineTest test;
+ auto region = test.createRegion();
+ ASSERT_TRUE(region);
+ OfflineDownload download(region->getID(),
+ OfflineTilePyramidRegionDefinition(
+ "http://127.0.0.1:3000/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0, true),
+ test.db,
+ test.fileSource);
+
+ test.fileSource.styleResponse = [&](const Resource& resource) {
+ EXPECT_EQ("http://127.0.0.1:3000/style.json", resource.url);
+ return test.response("style.json");
+ };
+
+ test.fileSource.spriteImageResponse = [&](const Resource& resource) {
+ EXPECT_TRUE(resource.url == "http://127.0.0.1:3000/sprite.png" ||
+ resource.url == "http://127.0.0.1:3000/sprite@2x.png");
+ return test.response("sprite.png");
+ };
+
+ test.fileSource.imageResponse = [&](const Resource& resource) {
+ EXPECT_EQ("http://127.0.0.1:3000/radar.gif", resource.url);
+ return test.response("radar.gif");
+ };
+
+ test.fileSource.spriteJSONResponse = [&](const Resource&) {
+ Response response;
+ response.error = std::make_unique<Response::Error>(Response::Error::Reason::NotFound);
+ return response;
+ };
+
+ test.fileSource.glyphsResponse = [&](const Resource&) { return test.response("glyph.pbf"); };
+
+ test.fileSource.sourceResponse = [&](const Resource& resource) {
+ EXPECT_EQ("http://127.0.0.1:3000/streets.json", resource.url);
+ return test.response("streets.json");
+ };
+
+ test.fileSource.tileResponse = [&](const Resource& resource) {
+ const Resource::TileData& tile = *resource.tileData;
+ EXPECT_EQ("http://127.0.0.1:3000/{z}-{x}-{y}.vector.pbf", tile.urlTemplate);
+ EXPECT_EQ(1, tile.pixelRatio);
+ EXPECT_EQ(0, tile.x);
+ EXPECT_EQ(0, tile.y);
+ EXPECT_EQ(0, tile.z);
+ return test.response("0-0-0.vector.pbf");
+ };
+
+ auto observer = std::make_unique<MockObserver>();
+ bool errorReported = false;
+ observer->responseErrorFn = [&](Response::Error error) {
+ EXPECT_EQ(Response::Error::Reason::NotFound, error.reason);
+ errorReported = true;
+ };
+ observer->statusChangedFn = [&](OfflineRegionStatus status) {
+ if (status.complete()) {
+ EXPECT_TRUE(errorReported);
+ test.loop.stop();
+ }
+ };
+
+ download.setObserver(std::move(observer));
+ download.setState(OfflineRegionDownloadState::Active);
+
+ test.loop.run();
+ // Passes if does not freeze.
} \ No newline at end of file