diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2020-02-25 18:06:48 +0200 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2020-02-25 23:15:47 +0200 |
commit | c85e7cbce01d655424906750aeb6288e3ecf586d (patch) | |
tree | 1b2ea277c358d96db392596c54437f8e2d9f0a71 /test/storage | |
parent | 7c48611f9ee04e1320e1667ea0dae7c355a9935b (diff) | |
download | qtlocation-mapboxgl-c85e7cbce01d655424906750aeb6288e3ecf586d.tar.gz |
Add OfflineDownload.NoFreezingOnCachedTilesAndNewStyle unit test
Diffstat (limited to 'test/storage')
-rw-r--r-- | test/storage/offline_download.test.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/storage/offline_download.test.cpp b/test/storage/offline_download.test.cpp index ff0965039e..45ecb31d8e 100644 --- a/test/storage/offline_download.test.cpp +++ b/test/storage/offline_download.test.cpp @@ -1026,3 +1026,39 @@ TEST(OfflineDownload, InterruptAndResume) { download.setState(OfflineRegionDownloadState::Active); test.loop.run(); } + +TEST(OfflineDownload, NoFreezingOnCachedTilesAndNewStyle) { + OfflineTest test; + auto region = test.createRegion(); + ASSERT_TRUE(region); + OfflineDownload download(region->getID(), + OfflineTilePyramidRegionDefinition( + "http://127.0.0.1:3000/style.json", LatLngBounds::world(), 1.0, 1.0, 1.0, true), + test.db, + test.fileSource); + + test.fileSource.setProperty(MAX_CONCURRENT_REQUESTS_KEY, 2u); + test.fileSource.styleResponse = [&](const Resource&) { return test.response("inline_source.style.json"); }; + // Number of resources must exceed MAX_CONCURRENT_REQUESTS_KEY + test.db.put(Resource::tile("http://127.0.0.1:3000/{z}-{x}-{y}.vector.pbf", 1, 0, 0, 1, Tileset::Scheme::XYZ), + test.response("0-0-0.vector.pbf")); + test.db.put(Resource::tile("http://127.0.0.1:3000/{z}-{x}-{y}.vector.pbf", 1, 0, 1, 1, Tileset::Scheme::XYZ), + test.response("0-0-0.vector.pbf")); + test.db.put(Resource::tile("http://127.0.0.1:3000/{z}-{x}-{y}.vector.pbf", 1, 1, 0, 1, Tileset::Scheme::XYZ), + test.response("0-0-0.vector.pbf")); + test.db.put(Resource::tile("http://127.0.0.1:3000/{z}-{x}-{y}.vector.pbf", 1, 1, 1, 1, Tileset::Scheme::XYZ), + test.response("0-0-0.vector.pbf")); + + auto observer = std::make_unique<MockObserver>(); + observer->statusChangedFn = [&](OfflineRegionStatus status) { + if (status.complete()) { + 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 |