summaryrefslogtreecommitdiff
path: root/render-test/parser.cpp
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2020-01-03 14:31:49 +0200
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2020-01-08 13:07:12 +0200
commitaf8092a86fc5465de3fe0bb2c9e1c24f3fec5965 (patch)
tree2925a8bf49759626ba1bf914b1562174a17c8d83 /render-test/parser.cpp
parentf0d2a2f636bf45889cf8082ba42e0d22875c1e3a (diff)
downloadqtlocation-mapboxgl-af8092a86fc5465de3fe0bb2c9e1c24f3fec5965.tar.gz
[render-test] Use image from the cache for addImage operation
Instead of trying to read it from the filesystem.
Diffstat (limited to 'render-test/parser.cpp')
-rw-r--r--render-test/parser.cpp22
1 files changed, 18 insertions, 4 deletions
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<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;
}