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

Commit

Permalink
[core] Add unit test for Source::setPrefetchZoomDelta
Browse files Browse the repository at this point in the history
Test verifies that tile pyramid will request only 4 tiles for
current zoom level, if Source's setPrefetchZoomDelta is 0.
  • Loading branch information
alexshalamov committed Feb 6, 2020
1 parent 0572180 commit f0ebf79
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/map/map.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <mbgl/style/layers/symbol_layer.hpp>
#include <mbgl/style/sources/geojson_source.hpp>
#include <mbgl/style/sources/image_source.hpp>
#include <mbgl/style/sources/vector_source.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/util/async_task.hpp>
#include <mbgl/util/color.hpp>
Expand Down Expand Up @@ -1119,3 +1120,36 @@ TEST(Map, NoHangOnMissingImage) {
// The test passes if the following call does not hang.
test.frontend.render(test.map);
}

TEST(Map, PrefetchDeltaOverride) {
MapTest<> test{1, MapMode::Continuous};

test.map.getStyle().loadJSON(
R"STYLE({
"layers": [{
"id": "a",
"type": "fill",
"source": "a",
"source-layer": "a",
"minzoom": 0,
"maxzoom": 24
}]
})STYLE");

auto source = std::make_unique<VectorSource>("a", Tileset{{"a/{z}/{x}/{y}"}});
source->setPrefetchZoomDelta(0);
test.map.getStyle().addSource(std::move(source));

unsigned requestedTiles = 0u;
test.fileSource->tileResponse = [&](const Resource&) {
++requestedTiles;
Response res;
res.noContent = true;
return res;
};

test.map.jumpTo(CameraOptions().withZoom(double(16)));
test.observer.didFinishLoadingMapCallback = [&] { test.runLoop.stop(); };
test.runLoop.run();
EXPECT_EQ(4, requestedTiles);
}

0 comments on commit f0ebf79

Please sign in to comment.