Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Add Map.VolatileSource unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
pozdnyakov committed Apr 22, 2020
1 parent d9dac27 commit efcdfe6
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/map/map.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit efcdfe6

Please sign in to comment.