diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-09-01 15:07:17 +0300 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-04-14 13:44:08 -0700 |
commit | 204c7fee032bf8509747046b43a788366a189ae7 (patch) | |
tree | 8719b7ab8838bea52babd8bf42f2234ddc43dc9a /test/api/repeated_render.cpp | |
parent | 18d8e80f52345a13236ae1da99b5866e7643f85b (diff) | |
download | qtlocation-mapboxgl-204c7fee032bf8509747046b43a788366a189ae7.tar.gz |
[core] Render from the main thread
Do not create a thread for the MapContext anymore.
Diffstat (limited to 'test/api/repeated_render.cpp')
-rw-r--r-- | test/api/repeated_render.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/test/api/repeated_render.cpp b/test/api/repeated_render.cpp index ef707aa7c4..cf5d115997 100644 --- a/test/api/repeated_render.cpp +++ b/test/api/repeated_render.cpp @@ -7,12 +7,15 @@ #include <mbgl/storage/default_file_source.hpp> #include <mbgl/util/image.hpp> #include <mbgl/util/io.hpp> +#include <mbgl/util/run_loop.hpp> #include <future> TEST(API, RepeatedRender) { using namespace mbgl; + util::RunLoop loop; + const auto style = util::read_file("test/fixtures/api/water.json"); auto display = std::make_shared<mbgl::HeadlessDisplay>(); @@ -30,11 +33,15 @@ TEST(API, RepeatedRender) { { map.setStyleJSON(style, ""); - std::promise<PremultipliedImage> promise; - map.renderStill([&promise](std::exception_ptr, PremultipliedImage&& image) { - promise.set_value(std::move(image)); + PremultipliedImage result; + map.renderStill([&result](std::exception_ptr, PremultipliedImage&& image) { + result = std::move(image); }); - auto result = promise.get_future().get(); + + while (!result.size()) { + loop.runOnce(); + } + ASSERT_EQ(256, result.width); ASSERT_EQ(512, result.height); #if !TEST_READ_ONLY @@ -44,11 +51,15 @@ TEST(API, RepeatedRender) { { map.setStyleJSON(style, ""); - std::promise<PremultipliedImage> promise; - map.renderStill([&promise](std::exception_ptr, PremultipliedImage&& image) { - promise.set_value(std::move(image)); + PremultipliedImage result; + map.renderStill([&result](std::exception_ptr, PremultipliedImage&& image) { + result = std::move(image); }); - auto result = promise.get_future().get(); + + while (!result.size()) { + loop.runOnce(); + } + ASSERT_EQ(256, result.width); ASSERT_EQ(512, result.height); #if !TEST_READ_ONLY |