summaryrefslogtreecommitdiff
path: root/render-test
diff options
context:
space:
mode:
Diffstat (limited to 'render-test')
-rw-r--r--render-test/parser.cpp5
-rw-r--r--render-test/runner.cpp45
-rw-r--r--render-test/runner.hpp1
3 files changed, 40 insertions, 11 deletions
diff --git a/render-test/parser.cpp b/render-test/parser.cpp
index 7646b5b455..e58187eb15 100644
--- a/render-test/parser.cpp
+++ b/render-test/parser.cpp
@@ -497,9 +497,10 @@ TestMetadata parseTestMetadata(const TestPaths& paths, const Manifest& manifest)
metadata.outputsImage = true;
assert(testValue["mapMode"].IsString());
std::string mapModeStr = testValue["mapMode"].GetString();
- if (mapModeStr == "tile")
+ if (mapModeStr == "tile") {
metadata.mapMode = mbgl::MapMode::Tile;
- else if (mapModeStr == "continuous") {
+ metadata.size = {uint32_t(mbgl::util::tileSize), uint32_t(mbgl::util::tileSize)};
+ } else if (mapModeStr == "continuous") {
metadata.mapMode = mbgl::MapMode::Continuous;
metadata.outputsImage = false;
} else if (mapModeStr == "static")
diff --git a/render-test/runner.cpp b/render-test/runner.cpp
index af3948b123..7b356eb4de 100644
--- a/render-test/runner.cpp
+++ b/render-test/runner.cpp
@@ -10,8 +10,10 @@
#include <mbgl/util/chrono.hpp>
#include <mbgl/util/image.hpp>
#include <mbgl/util/io.hpp>
+#include <mbgl/util/projection.hpp>
#include <mbgl/util/run_loop.hpp>
#include <mbgl/util/string.hpp>
+#include <mbgl/util/tile_cover.hpp>
#include <mapbox/pixelmatch.hpp>
@@ -628,7 +630,6 @@ void resetContext(const TestMetadata& metadata, TestContext& ctx) {
.withYSkew(metadata.ySkew));
map.setDebug(metadata.debug);
map.getStyle().loadJSON(serializeJsonValue(metadata.document));
- map.jumpTo(map.getStyle().getDefaultCamera());
}
} // namespace
@@ -690,18 +691,30 @@ void TestRunner::run(TestMetadata& metadata) {
ctx.runnerImpl = maps[key].get();
auto& frontend = ctx.getFrontend();
+ auto& map = ctx.getMap();
resetContext(metadata, ctx);
-
- for (const auto& operation : parseTestOperations(metadata, manifest)) {
- if (!operation(ctx)) return;
- }
+ auto camera = map.getStyle().getDefaultCamera();
HeadlessFrontend::RenderResult result;
- try {
- if (metadata.outputsImage) result = frontend.render(ctx.getMap());
- } catch (const std::exception&) {
- return;
+
+ if (metadata.mapMode == MapMode::Tile) {
+ assert(camera.zoom);
+ assert(camera.center);
+ auto tileIds = util::tileCover(map.latLngBoundsForCamera(camera), *camera.zoom);
+ for (const auto& tileId : tileIds) {
+ auto cameraForTile{camera};
+ double scale = (1 << tileId.canonical.z) / util::tileSize;
+ Point<double> tileCenter{tileId.canonical.x + 0.5, tileId.canonical.y + 0.5};
+ cameraForTile.withCenter(Projection::unproject(tileCenter, scale));
+
+ map.jumpTo(cameraForTile);
+ result = runTest(metadata, ctx);
+ break;
+ }
+ } else {
+ map.jumpTo(camera);
+ result = runTest(metadata, ctx);
}
if (!metadata.ignoredTest) {
@@ -727,6 +740,20 @@ void TestRunner::run(TestMetadata& metadata) {
}
}
+mbgl::HeadlessFrontend::RenderResult TestRunner::runTest(TestMetadata& metadata, TestContext& ctx) {
+ HeadlessFrontend::RenderResult result{};
+ for (const auto& operation : parseTestOperations(metadata, manifest)) {
+ if (!operation(ctx)) return result;
+ }
+
+ try {
+ if (metadata.outputsImage) result = ctx.getFrontend().render(ctx.getMap());
+ } catch (const std::exception& e) {
+ ctx.getMetadata().errorMessage = std::string("Renering raised an exception: ") + e.what();
+ }
+ return result;
+}
+
void TestRunner::reset() {
maps.clear();
}
diff --git a/render-test/runner.hpp b/render-test/runner.hpp
index 22bfcc98f1..6ad204428c 100644
--- a/render-test/runner.hpp
+++ b/render-test/runner.hpp
@@ -46,6 +46,7 @@ public:
void doShuffle(uint32_t seed);
private:
+ mbgl::HeadlessFrontend::RenderResult runTest(TestMetadata& metadata, TestContext& ctx);
void checkQueryTestResults(mbgl::PremultipliedImage&& actualImage,
std::vector<mbgl::Feature>&& features,
TestMetadata&);