[render-test] Use image from the cache for addImage operation

Instead of trying to read it from the filesystem.
This commit is contained in:
Thiago Marcos P. Santos
2020-01-03 14:31:49 +02:00
parent f0d2a2f636
commit af8092a86f
4 changed files with 38 additions and 12 deletions

View File

@@ -688,12 +688,26 @@ TestOperations parseTestOperations(TestMetadata& metadata) {
imageName.erase(std::remove(imageName.begin(), imageName.end(), '"'), imageName.end());
std::string imagePath = operationArray[2].GetString();
imagePath.erase(std::remove(imagePath.begin(), imagePath.end(), '"'), imagePath.end());
result.emplace_back([imagePath, imageName, sdf, pixelRatio](TestContext& ctx) {
mbgl::optional<std::string> maybeImage = mbgl::util::readFile(imagePath);
result.emplace_back([imageName, imagePath, sdf, pixelRatio](TestContext& ctx) {
mbgl::optional<std::string> maybeImage;
bool requestCompleted = false;
auto req = ctx.getFileSource().request(mbgl::Resource::image("mapbox://render-tests/" + imagePath),
[&](mbgl::Response response) {
if (response.data) {
maybeImage = *response.data;
}
requestCompleted = true;
});
while (!requestCompleted) {
mbgl::util::RunLoop::Get()->runOnce();
}
if (!maybeImage) {
ctx.getMetadata().errorMessage = std::string("Failed to load expected image ") + imagePath;
ctx.getMetadata().errorMessage += std::string("Failed to load expected image ") + imagePath;
return false;
}