From 2ae96ad6879a00eba0b9115590f58e3eb3cbd019 Mon Sep 17 00:00:00 2001 From: Mikhail Pozdnyakov Date: Thu, 19 Mar 2020 17:21:21 +0200 Subject: [core] Introduce Renderer::clearData() instead of keepRenderData map options `Renderer::clearData()` is a better API than the removed `MapOptions::keepRenderData()`: - gives more flexibility to the client - similar to the existing `Renderer::reduceMemoryUse()` - the `MapOptions::keepRenderData()` API implementation could not handle the raise condition, which happened if the new still image request had come before all tiles from the previous requests were loaded. Co-authored-by: Dane Springmeyer --- test/map/map.test.cpp | 44 +++++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) (limited to 'test') diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index 0e619d3d1f..baf1cd03a6 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -1362,26 +1363,7 @@ constexpr auto styleJSON = R"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))}; + MapTest<> test; int requestsCount = 0; test.fileSource->tileResponse = [&](const Resource&) { ++requestsCount; @@ -1390,11 +1372,19 @@ TEST(Map, DontKeepRenderData) { 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); + const int iterations = 3; + // Keep render data. + for (int i = 1; i <= iterations; ++i) { + test.map.getStyle().loadJSON(styleJSON); + test.frontend.render(test.map); + EXPECT_EQ(4, requestsCount); + } + requestsCount = 0; + // Clear render data. + for (int i = 1; i <= iterations; ++i) { + test.frontend.getRenderer()->clearData(); + test.map.getStyle().loadJSON(styleJSON); + test.frontend.render(test.map); + EXPECT_EQ(4 * i, requestsCount); + } } \ No newline at end of file -- cgit v1.2.1