From 11e6bd46c237ac23861362367120041e0d95d06c Mon Sep 17 00:00:00 2001 From: Mikhail Pozdnyakov Date: Wed, 18 Mar 2020 18:29:10 +0200 Subject: Add Map.KeepRenderData and Map.DontKeepRenderData tests --- test/map/map.test.cpp | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) 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()), + frontend(options.pixelRatio()), + map(frontend, observer, fileSource, options.withSize(frontend.getSize())) {} + template 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 -- cgit v1.2.1