From af8092a86fc5465de3fe0bb2c9e1c24f3fec5965 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Fri, 3 Jan 2020 14:31:49 +0200 Subject: [render-test] Use image from the cache for addImage operation Instead of trying to read it from the filesystem. --- render-test/parser.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'render-test/parser.cpp') diff --git a/render-test/parser.cpp b/render-test/parser.cpp index c5fca18d64..484428976e 100644 --- a/render-test/parser.cpp +++ b/render-test/parser.cpp @@ -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 maybeImage = mbgl::util::readFile(imagePath); + result.emplace_back([imageName, imagePath, sdf, pixelRatio](TestContext& ctx) { + mbgl::optional 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; } -- cgit v1.2.1