summaryrefslogtreecommitdiff
path: root/render-test/runner.cpp
diff options
context:
space:
mode:
authorzmiao <miao.zhao@mapbox.com>2019-10-23 12:04:23 +0300
committerGitHub <noreply@github.com>2019-10-23 12:04:23 +0300
commit2385f4cd86261cdfc6253de5fed217bfc06fa6c8 (patch)
tree8d5e98b83efce930ff8b9454d75c3eedc8513a22 /render-test/runner.cpp
parent99feb9bb306ddf06c228f0b6bbfb88abead6b33a (diff)
downloadqtlocation-mapboxgl-2385f4cd86261cdfc6253de5fed217bfc06fa6c8.tar.gz
[render-test] Add configurable rootPath, ignorePath via CLI arguments (#15832)
* [render-test] Add configurable path via CLI arguments * [render-test] Change ignore path config
Diffstat (limited to 'render-test/runner.cpp')
-rw-r--r--render-test/runner.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/render-test/runner.cpp b/render-test/runner.cpp
index 46b890b76c..4c0967a9e9 100644
--- a/render-test/runner.cpp
+++ b/render-test/runner.cpp
@@ -58,12 +58,6 @@ public:
};
// static
-const std::string& TestRunner::getBasePath() {
- const static std::string result = std::string(TEST_RUNNER_ROOT_PATH).append("/mapbox-gl-js/test/integration");
- return result;
-}
-
-// static
gfx::HeadlessBackend::SwapBehaviour swapBehavior(MapMode mode) {
return mode == MapMode::Continuous ? gfx::HeadlessBackend::SwapBehaviour::Flush
: gfx::HeadlessBackend::SwapBehaviour::NoFlush;
@@ -107,6 +101,8 @@ std::string simpleDiff(const Value& result, const Value& expected) {
return diff.str();
}
+TestRunner::TestRunner(const std::string& testRootPath_) : maps(), testRootPath(testRootPath_) {}
+
bool TestRunner::checkQueryTestResults(mbgl::PremultipliedImage&& actualImage,
std::vector<mbgl::Feature>&& features,
TestMetadata& metadata) {
@@ -491,7 +487,7 @@ bool TestRunner::runOperations(const std::string& key, TestMetadata& metadata) {
std::string imagePath = operationArray[2].GetString();
imagePath.erase(std::remove(imagePath.begin(), imagePath.end(), '"'), imagePath.end());
- const mbgl::filesystem::path filePath(std::string(TEST_RUNNER_ROOT_PATH) + "/mapbox-gl-js/test/integration/" + imagePath);
+ const mbgl::filesystem::path filePath = mbgl::filesystem::path(getTestPath(testRootPath)) / imagePath;
mbgl::optional<std::string> maybeImage = mbgl::util::readFile(filePath.string());
if (!maybeImage) {
@@ -511,15 +507,15 @@ bool TestRunner::runOperations(const std::string& key, TestMetadata& metadata) {
// setStyle
assert(operationArray.Size() >= 2u);
if (operationArray[1].IsString()) {
- std::string stylePath = localizeURL(operationArray[1].GetString());
+ std::string stylePath = localizeURL(operationArray[1].GetString(), testRootPath);
auto maybeStyle = readJson(stylePath);
if (maybeStyle.is<mbgl::JSDocument>()) {
auto& style = maybeStyle.get<mbgl::JSDocument>();
- localizeStyleURLs((mbgl::JSValue&)style, style);
+ localizeStyleURLs((mbgl::JSValue&)style, style, testRootPath);
map.getStyle().loadJSON(serializeJsonValue(style));
}
} else {
- localizeStyleURLs(operationArray[1], metadata.document);
+ localizeStyleURLs(operationArray[1], metadata.document, testRootPath);
map.getStyle().loadJSON(serializeJsonValue(operationArray[1]));
}
} else if (operationArray[0].GetString() == setCenterOp) {
@@ -620,7 +616,7 @@ bool TestRunner::runOperations(const std::string& key, TestMetadata& metadata) {
assert(operationArray[1].IsString());
assert(operationArray[2].IsObject());
- localizeSourceURLs(operationArray[2], metadata.document);
+ localizeSourceURLs(operationArray[2], metadata.document, testRootPath);
mbgl::style::conversion::Error error;
auto converted = mbgl::style::conversion::convert<std::unique_ptr<mbgl::style::Source>>(operationArray[2], error, operationArray[1].GetString());