@@ -30,17 +30,17 @@ TEST(Map, PrefetchTiles) {
|
||||
});
|
||||
|
||||
StubMapObserver observer;
|
||||
observer.didFinishLoadingMapCallback = [&] () {
|
||||
observer.didFinishLoadingMapCallback = [&]() {
|
||||
runLoop.stop();
|
||||
};
|
||||
|
||||
HeadlessFrontend frontend { { 512, 512 }, 1 };
|
||||
MapAdapter map(frontend, observer, fileSource,
|
||||
MapOptions().withMapMode(MapMode::Continuous).withSize(frontend.getSize()));
|
||||
HeadlessFrontend frontend{{512, 512}, 1};
|
||||
MapAdapter map(
|
||||
frontend, observer, fileSource, MapOptions().withMapMode(MapMode::Continuous).withSize(frontend.getSize()));
|
||||
|
||||
std::vector<int> tiles;
|
||||
|
||||
fileSource->response = [&] (const Resource& res) -> std::optional<Response> {
|
||||
fileSource->response = [&](const Resource& res) -> std::optional<Response> {
|
||||
static std::string tile = util::read_file("test/fixtures/map/prefetch/tile.png");
|
||||
|
||||
auto zoom = std::stoi(res.url);
|
||||
@@ -57,7 +57,7 @@ TEST(Map, PrefetchTiles) {
|
||||
// Force tile reloading.
|
||||
map.getStyle().loadJSON(util::read_file("test/fixtures/map/prefetch/empty.json"));
|
||||
map.getStyle().loadJSON(util::read_file("test/fixtures/map/prefetch/style.json"));
|
||||
map.jumpTo(CameraOptions().withCenter(LatLng { 40.726989, -73.992857 }).withZoom(zoom)); // Manhattan
|
||||
map.jumpTo(CameraOptions().withCenter(LatLng{40.726989, -73.992857}).withZoom(zoom)); // Manhattan
|
||||
runLoop.run();
|
||||
|
||||
ASSERT_EQ(tiles.size(), expected.size());
|
||||
@@ -66,7 +66,7 @@ TEST(Map, PrefetchTiles) {
|
||||
|
||||
// Check defaults, should be 4.
|
||||
ASSERT_EQ(map.getPrefetchZoomDelta(), 4);
|
||||
checkTilesForZoom(12, { 13, 13, 13, 13, 13, 13, 13, 13, 13, 9 });
|
||||
checkTilesForZoom(12, {13, 13, 13, 13, 13, 13, 13, 13, 13, 9});
|
||||
|
||||
// Setting it to 0 disables prefetching.
|
||||
map.setPrefetchZoomDelta(0);
|
||||
@@ -75,16 +75,16 @@ TEST(Map, PrefetchTiles) {
|
||||
// tiles instead of the actual zoom level, that is
|
||||
// why the zoom levels for non-prefetched tiles are
|
||||
// not the same.
|
||||
checkTilesForZoom(10, { 11, 11, 11, 11, 11, 11, 11, 11, 11 });
|
||||
checkTilesForZoom(10, {11, 11, 11, 11, 11, 11, 11, 11, 11});
|
||||
|
||||
map.setPrefetchZoomDelta(5);
|
||||
checkTilesForZoom(12, { 13, 13, 13, 13, 13, 13, 13, 13, 13, 8 });
|
||||
checkTilesForZoom(12, {13, 13, 13, 13, 13, 13, 13, 13, 13, 8});
|
||||
|
||||
// Should clamp at `minzoom`.
|
||||
map.setPrefetchZoomDelta(20);
|
||||
checkTilesForZoom(10, { 11, 11, 11, 11, 11, 11, 11, 11, 11, 0 });
|
||||
checkTilesForZoom(10, {11, 11, 11, 11, 11, 11, 11, 11, 11, 0});
|
||||
|
||||
// Disabled again.
|
||||
map.setPrefetchZoomDelta(0);
|
||||
checkTilesForZoom(13, { 14, 14, 14, 14, 14, 14, 14, 14, 14 });
|
||||
checkTilesForZoom(13, {14, 14, 14, 14, 14, 14, 14, 14, 14});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user