summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-04-21 18:59:29 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-04-22 19:21:56 +0300
commitb120cdd207ef7d0f296ff6607cc481d882a2aa2d (patch)
tree959186bc75ce1e081ffb61a84c47b3d2f3f6b25e
parentdc7b1dd34fcea40e07d1a2831efee20132fbb4ab (diff)
downloadqtlocation-mapboxgl-b120cdd207ef7d0f296ff6607cc481d882a2aa2d.tar.gz
Add Map.VolatileSource unit test
-rw-r--r--test/map/map.test.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp
index 10cd3080c6..80118f41ec 100644
--- a/test/map/map.test.cpp
+++ b/test/map/map.test.cpp
@@ -1529,3 +1529,36 @@ TEST(Map, PlacedSymbolData) {
EXPECT_TRUE(test.frontend.getRenderer()->getPlacedSymbolsData().empty());
}
+
+TEST(Map, VolatileSource) {
+ MapTest<> test{1, MapMode::Continuous};
+
+ std::atomic_int requestedTiles(0);
+ bool isVolatile = true;
+ test.fileSource->tileResponse = [&](const Resource& resource) {
+ auto expectedPolicy = isVolatile ? Resource::StoragePolicy::Volatile : Resource::StoragePolicy::Permanent;
+ EXPECT_EQ(expectedPolicy, resource.storagePolicy);
+ ++requestedTiles;
+ Response res;
+ res.noContent = true;
+ return res;
+ };
+
+ test.map.getStyle().loadJSON(R"STYLE({
+ "version": 8,
+ "layers": [{
+ "id": "water",
+ "type": "fill",
+ "source": "vector",
+ "source-layer": "water"
+ }]
+ })STYLE");
+ auto source = std::make_unique<VectorSource>("vector", Tileset{{"a/{z}/{x}/{y}"}});
+ source->setVolatile(isVolatile);
+ test.map.getStyle().addSource(std::move(source));
+
+ test.map.jumpTo(CameraOptions().withZoom(16.0));
+ test.observer.didFinishLoadingMapCallback = [&] { test.runLoop.stop(); };
+ test.runLoop.run();
+ EXPECT_EQ(8, requestedTiles);
+} \ No newline at end of file