summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-03-18 18:29:10 +0200
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-03-18 20:14:15 +0200
commit11e6bd46c237ac23861362367120041e0d95d06c (patch)
tree24342270887f537d189df0cd5a3721a5e597c16a
parent0f5e5311faa7526d9f200e8defd25fbb3ba504dd (diff)
downloadqtlocation-mapboxgl-11e6bd46c237ac23861362367120041e0d95d06c.tar.gz
Add Map.KeepRenderData and Map.DontKeepRenderData tests
-rw-r--r--test/map/map.test.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp
index b3c73be3d0..0e619d3d1f 100644
--- a/test/map/map.test.cpp
+++ b/test/map/map.test.cpp
@@ -53,6 +53,11 @@ public:
, map(frontend, observer, fileSource,
MapOptions().withMapMode(mode).withSize(frontend.getSize()).withPixelRatio(pixelRatio)) {}
+ explicit MapTest(MapOptions options)
+ : fileSource(std::make_shared<FileSource>()),
+ frontend(options.pixelRatio()),
+ map(frontend, observer, fileSource, options.withSize(frontend.getSize())) {}
+
template <typename T = FileSource>
MapTest(const std::string& cachePath,
const std::string& assetPath,
@@ -1341,3 +1346,55 @@ TEST(Map, TEST_REQUIRES_SERVER(ExpiredSpriteSheet)) {
test.runLoop.run();
}
+
+namespace {
+constexpr auto styleJSON = R"STYLE({
+ "sources": {
+ "a": { "type": "vector", "tiles": [ "a/{z}/{x}/{y}" ] }
+ },
+ "layers": [{
+ "id": "a",
+ "type": "fill",
+ "source": "a",
+ "source-layer": "a"
+ }]
+})STYLE";
+}
+
+TEST(Map, KeepRenderData) {
+ MapTest<> test{std::move(MapOptions().withMapMode(MapMode::Static).withKeepRenderData(true))};
+ int requestsCount = 0;
+ test.fileSource->tileResponse = [&](const Resource&) {
+ ++requestsCount;
+ Response res;
+ res.noContent = true;
+ return res;
+ };
+ test.map.jumpTo(CameraOptions().withZoom(10));
+ test.map.getStyle().loadJSON(styleJSON);
+ test.frontend.render(test.map);
+ EXPECT_EQ(4, requestsCount);
+
+ test.map.getStyle().loadJSON(styleJSON);
+ test.frontend.render(test.map);
+ EXPECT_EQ(4, requestsCount);
+}
+
+TEST(Map, DontKeepRenderData) {
+ MapTest<> test{std::move(MapOptions().withMapMode(MapMode::Static).withKeepRenderData(false))};
+ int requestsCount = 0;
+ test.fileSource->tileResponse = [&](const Resource&) {
+ ++requestsCount;
+ Response res;
+ res.noContent = true;
+ return res;
+ };
+ test.map.jumpTo(CameraOptions().withZoom(10));
+ test.map.getStyle().loadJSON(styleJSON);
+ test.frontend.render(test.map);
+ EXPECT_EQ(4, requestsCount);
+
+ test.map.getStyle().loadJSON(styleJSON);
+ test.frontend.render(test.map);
+ EXPECT_EQ(8, requestsCount);
+} \ No newline at end of file