summaryrefslogtreecommitdiff
path: root/test/miscellaneous
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-05-08 16:37:22 +0200
committerKonstantin Käfer <mail@kkaefer.com>2015-05-08 16:43:18 +0200
commite20faf7a8d531689642106164b5ee53b3353fe80 (patch)
tree254002919acd5938c2a5da670fa5bed49c395589 /test/miscellaneous
parentadec24c97c59dffeb7e49bc20d6422f0fbc4cb0a (diff)
downloadqtlocation-mapboxgl-e20faf7a8d531689642106164b5ee53b3353fe80.tar.gz
add worker cancellation test (failing)
Diffstat (limited to 'test/miscellaneous')
-rw-r--r--test/miscellaneous/worker.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/miscellaneous/worker.cpp b/test/miscellaneous/worker.cpp
index 50fabcebc8..de0654422c 100644
--- a/test/miscellaneous/worker.cpp
+++ b/test/miscellaneous/worker.cpp
@@ -68,3 +68,30 @@ TEST(Worker, WorkRequestJoinCancelsAfter) {
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
EXPECT_FALSE(didAfter);
}
+
+TEST(Worker, WorkRequestCancelsImmediately) {
+ RunLoop loop(uv_default_loop());
+
+ Worker worker(1);
+
+ loop.invoke([&] {
+ std::promise<void> started;
+ // First worker item.
+ WorkRequest request1 = worker.send([&] {
+ usleep(10000);
+ started.set_value();
+ }, [&] {});
+
+ WorkRequest request2 = worker.send([&] {
+ ADD_FAILURE() << "Second work item should not be invoked";
+ }, [&] {});
+ request2.join();
+
+ started.get_future().get();
+ request1.join();
+
+ loop.stop();
+ });
+
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
+}