diff options
Diffstat (limited to 'async/autotests/asynctest.cpp')
-rw-r--r-- | async/autotests/asynctest.cpp | 192 |
1 files changed, 96 insertions, 96 deletions
diff --git a/async/autotests/asynctest.cpp b/async/autotests/asynctest.cpp index 9bc9f6b..ffc732c 100644 --- a/async/autotests/asynctest.cpp +++ b/async/autotests/asynctest.cpp | |||
@@ -82,7 +82,7 @@ private: | |||
82 | template<typename T> | 82 | template<typename T> |
83 | class AsyncSimulator { | 83 | class AsyncSimulator { |
84 | public: | 84 | public: |
85 | AsyncSimulator(Async::Future<T> &future, const T &result) | 85 | AsyncSimulator(KAsync::Future<T> &future, const T &result) |
86 | : mFuture(future) | 86 | : mFuture(future) |
87 | , mResult(result) | 87 | , mResult(result) |
88 | { | 88 | { |
@@ -99,7 +99,7 @@ private: | |||
99 | mTimer.start(200); | 99 | mTimer.start(200); |
100 | } | 100 | } |
101 | 101 | ||
102 | AsyncSimulator(Async::Future<T> &future, std::function<void(Async::Future<T>&)> callback) | 102 | AsyncSimulator(KAsync::Future<T> &future, std::function<void(KAsync::Future<T>&)> callback) |
103 | : mFuture(future) | 103 | : mFuture(future) |
104 | , mCallback(callback) | 104 | , mCallback(callback) |
105 | { | 105 | { |
@@ -116,8 +116,8 @@ private: | |||
116 | } | 116 | } |
117 | 117 | ||
118 | private: | 118 | private: |
119 | Async::Future<T> mFuture; | 119 | KAsync::Future<T> mFuture; |
120 | std::function<void(Async::Future<T>&)> mCallback; | 120 | std::function<void(KAsync::Future<T>&)> mCallback; |
121 | T mResult; | 121 | T mResult; |
122 | QTimer mTimer; | 122 | QTimer mTimer; |
123 | }; | 123 | }; |
@@ -127,7 +127,7 @@ private: | |||
127 | template<> | 127 | template<> |
128 | class AsyncTest::AsyncSimulator<void> { | 128 | class AsyncTest::AsyncSimulator<void> { |
129 | public: | 129 | public: |
130 | AsyncSimulator(Async::Future<void> &future) | 130 | AsyncSimulator(KAsync::Future<void> &future) |
131 | : mFuture(future) | 131 | : mFuture(future) |
132 | { | 132 | { |
133 | QObject::connect(&mTimer, &QTimer::timeout, | 133 | QObject::connect(&mTimer, &QTimer::timeout, |
@@ -143,7 +143,7 @@ public: | |||
143 | } | 143 | } |
144 | 144 | ||
145 | private: | 145 | private: |
146 | Async::Future<void> mFuture; | 146 | KAsync::Future<void> mFuture; |
147 | QTimer mTimer; | 147 | QTimer mTimer; |
148 | }; | 148 | }; |
149 | 149 | ||
@@ -151,24 +151,24 @@ private: | |||
151 | 151 | ||
152 | void AsyncTest::testSyncPromises() | 152 | void AsyncTest::testSyncPromises() |
153 | { | 153 | { |
154 | auto baseJob = Async::start<int>( | 154 | auto baseJob = KAsync::start<int>( |
155 | [](Async::Future<int> &f) { | 155 | [](KAsync::Future<int> &f) { |
156 | f.setValue(42); | 156 | f.setValue(42); |
157 | f.setFinished(); | 157 | f.setFinished(); |
158 | }) | 158 | }) |
159 | .then<QString, int>( | 159 | .then<QString, int>( |
160 | [](int v, Async::Future<QString> &f) { | 160 | [](int v, KAsync::Future<QString> &f) { |
161 | f.setValue("Result is " + QString::number(v)); | 161 | f.setValue(QLatin1String("Result is ") + QString::number(v)); |
162 | f.setFinished(); | 162 | f.setFinished(); |
163 | }); | 163 | }); |
164 | 164 | ||
165 | auto job = baseJob.then<QString, QString>( | 165 | auto job = baseJob.then<QString, QString>( |
166 | [](const QString &v, Async::Future<QString> &f) { | 166 | [](const QString &v, KAsync::Future<QString> &f) { |
167 | f.setValue(v.toUpper()); | 167 | f.setValue(v.toUpper()); |
168 | f.setFinished(); | 168 | f.setFinished(); |
169 | }); | 169 | }); |
170 | 170 | ||
171 | Async::Future<QString> future = job.exec(); | 171 | KAsync::Future<QString> future = job.exec(); |
172 | 172 | ||
173 | QVERIFY(future.isFinished()); | 173 | QVERIFY(future.isFinished()); |
174 | QCOMPARE(future.value(), QString::fromLatin1("RESULT IS 42")); | 174 | QCOMPARE(future.value(), QString::fromLatin1("RESULT IS 42")); |
@@ -176,12 +176,12 @@ void AsyncTest::testSyncPromises() | |||
176 | 176 | ||
177 | void AsyncTest::testAsyncPromises() | 177 | void AsyncTest::testAsyncPromises() |
178 | { | 178 | { |
179 | auto job = Async::start<int>( | 179 | auto job = KAsync::start<int>( |
180 | [](Async::Future<int> &future) { | 180 | [](KAsync::Future<int> &future) { |
181 | new AsyncSimulator<int>(future, 42); | 181 | new AsyncSimulator<int>(future, 42); |
182 | }); | 182 | }); |
183 | 183 | ||
184 | Async::Future<int> future = job.exec(); | 184 | KAsync::Future<int> future = job.exec(); |
185 | 185 | ||
186 | future.waitForFinished(); | 186 | future.waitForFinished(); |
187 | QCOMPARE(future.value(), 42); | 187 | QCOMPARE(future.value(), 42); |
@@ -191,11 +191,11 @@ void AsyncTest::testAsyncPromises2() | |||
191 | { | 191 | { |
192 | bool done = false; | 192 | bool done = false; |
193 | 193 | ||
194 | auto job = Async::start<int>( | 194 | auto job = KAsync::start<int>( |
195 | [](Async::Future<int> &future) { | 195 | [](KAsync::Future<int> &future) { |
196 | new AsyncSimulator<int>(future, 42); | 196 | new AsyncSimulator<int>(future, 42); |
197 | } | 197 | } |
198 | ).then<int, int>([&done](int result, Async::Future<int> &future) { | 198 | ).then<int, int>([&done](int result, KAsync::Future<int> &future) { |
199 | done = true; | 199 | done = true; |
200 | future.setValue(result); | 200 | future.setValue(result); |
201 | future.setFinished(); | 201 | future.setFinished(); |
@@ -210,17 +210,17 @@ void AsyncTest::testNestedAsync() | |||
210 | { | 210 | { |
211 | bool done = false; | 211 | bool done = false; |
212 | 212 | ||
213 | auto job = Async::start<int>( | 213 | auto job = KAsync::start<int>( |
214 | [](Async::Future<int> &future) { | 214 | [](KAsync::Future<int> &future) { |
215 | auto innerJob = Async::start<int>([](Async::Future<int> &innerFuture) { | 215 | auto innerJob = KAsync::start<int>([](KAsync::Future<int> &innerFuture) { |
216 | new AsyncSimulator<int>(innerFuture, 42); | 216 | new AsyncSimulator<int>(innerFuture, 42); |
217 | }).then<void>([&future](Async::Future<void> &innerThenFuture) { | 217 | }).then<void>([&future](KAsync::Future<void> &innerThenFuture) { |
218 | future.setFinished(); | 218 | future.setFinished(); |
219 | innerThenFuture.setFinished(); | 219 | innerThenFuture.setFinished(); |
220 | }); | 220 | }); |
221 | innerJob.exec().waitForFinished(); | 221 | innerJob.exec().waitForFinished(); |
222 | } | 222 | } |
223 | ).then<int, int>([&done](int result, Async::Future<int> &future) { | 223 | ).then<int, int>([&done](int result, KAsync::Future<int> &future) { |
224 | done = true; | 224 | done = true; |
225 | future.setValue(result); | 225 | future.setValue(result); |
226 | future.setFinished(); | 226 | future.setFinished(); |
@@ -232,8 +232,8 @@ void AsyncTest::testNestedAsync() | |||
232 | 232 | ||
233 | void AsyncTest::testStartValue() | 233 | void AsyncTest::testStartValue() |
234 | { | 234 | { |
235 | auto job = Async::start<int, int>( | 235 | auto job = KAsync::start<int, int>( |
236 | [](int in, Async::Future<int> &future) { | 236 | [](int in, KAsync::Future<int> &future) { |
237 | future.setValue(in); | 237 | future.setValue(in); |
238 | future.setFinished(); | 238 | future.setFinished(); |
239 | }); | 239 | }); |
@@ -249,8 +249,8 @@ void AsyncTest::testStartValue() | |||
249 | 249 | ||
250 | void AsyncTest::testAsyncThen() | 250 | void AsyncTest::testAsyncThen() |
251 | { | 251 | { |
252 | auto job = Async::start<int>( | 252 | auto job = KAsync::start<int>( |
253 | [](Async::Future<int> &future) { | 253 | [](KAsync::Future<int> &future) { |
254 | new AsyncSimulator<int>(future, 42); | 254 | new AsyncSimulator<int>(future, 42); |
255 | }); | 255 | }); |
256 | 256 | ||
@@ -264,7 +264,7 @@ void AsyncTest::testAsyncThen() | |||
264 | 264 | ||
265 | void AsyncTest::testSyncThen() | 265 | void AsyncTest::testSyncThen() |
266 | { | 266 | { |
267 | auto job = Async::start<int>( | 267 | auto job = KAsync::start<int>( |
268 | []() -> int { | 268 | []() -> int { |
269 | return 42; | 269 | return 42; |
270 | }) | 270 | }) |
@@ -280,13 +280,13 @@ void AsyncTest::testSyncThen() | |||
280 | 280 | ||
281 | void AsyncTest::testJoinedThen() | 281 | void AsyncTest::testJoinedThen() |
282 | { | 282 | { |
283 | auto job1 = Async::start<int, int>( | 283 | auto job1 = KAsync::start<int, int>( |
284 | [](int in, Async::Future<int> &future) { | 284 | [](int in, KAsync::Future<int> &future) { |
285 | new AsyncSimulator<int>(future, in * 2); | 285 | new AsyncSimulator<int>(future, in * 2); |
286 | }); | 286 | }); |
287 | 287 | ||
288 | auto job2 = Async::start<int>( | 288 | auto job2 = KAsync::start<int>( |
289 | [](Async::Future<int> &future) { | 289 | [](KAsync::Future<int> &future) { |
290 | new AsyncSimulator<int>(future, 42); | 290 | new AsyncSimulator<int>(future, 42); |
291 | }) | 291 | }) |
292 | .then<int>(job1); | 292 | .then<int>(job1); |
@@ -302,13 +302,13 @@ void AsyncTest::testVoidThen() | |||
302 | { | 302 | { |
303 | int check = 0; | 303 | int check = 0; |
304 | 304 | ||
305 | auto job = Async::start<void>( | 305 | auto job = KAsync::start<void>( |
306 | [&check](Async::Future<void> &future) { | 306 | [&check](KAsync::Future<void> &future) { |
307 | new AsyncSimulator<void>(future); | 307 | new AsyncSimulator<void>(future); |
308 | ++check; | 308 | ++check; |
309 | }) | 309 | }) |
310 | .then<void>( | 310 | .then<void>( |
311 | [&check](Async::Future<void> &future) { | 311 | [&check](KAsync::Future<void> &future) { |
312 | new AsyncSimulator<void>(future); | 312 | new AsyncSimulator<void>(future); |
313 | ++check; | 313 | ++check; |
314 | }) | 314 | }) |
@@ -328,12 +328,12 @@ void AsyncTest::testVoidThen() | |||
328 | 328 | ||
329 | void AsyncTest::testAsyncEach() | 329 | void AsyncTest::testAsyncEach() |
330 | { | 330 | { |
331 | auto job = Async::start<QList<int>>( | 331 | auto job = KAsync::start<QList<int>>( |
332 | [](Async::Future<QList<int>> &future) { | 332 | [](KAsync::Future<QList<int>> &future) { |
333 | new AsyncSimulator<QList<int>>(future, { 1, 2, 3, 4 }); | 333 | new AsyncSimulator<QList<int>>(future, { 1, 2, 3, 4 }); |
334 | }) | 334 | }) |
335 | .each<QList<int>, int>( | 335 | .each<QList<int>, int>( |
336 | [](const int &v, Async::Future<QList<int>> &future) { | 336 | [](const int &v, KAsync::Future<QList<int>> &future) { |
337 | new AsyncSimulator<QList<int>>(future, { v + 1 }); | 337 | new AsyncSimulator<QList<int>>(future, { v + 1 }); |
338 | }); | 338 | }); |
339 | 339 | ||
@@ -347,7 +347,7 @@ void AsyncTest::testAsyncEach() | |||
347 | 347 | ||
348 | void AsyncTest::testSyncEach() | 348 | void AsyncTest::testSyncEach() |
349 | { | 349 | { |
350 | auto job = Async::start<QList<int>>( | 350 | auto job = KAsync::start<QList<int>>( |
351 | []() -> QList<int> { | 351 | []() -> QList<int> { |
352 | return { 1, 2, 3, 4 }; | 352 | return { 1, 2, 3, 4 }; |
353 | }) | 353 | }) |
@@ -356,7 +356,7 @@ void AsyncTest::testSyncEach() | |||
356 | return { v + 1 }; | 356 | return { v + 1 }; |
357 | }); | 357 | }); |
358 | 358 | ||
359 | Async::Future<QList<int>> future = job.exec(); | 359 | KAsync::Future<QList<int>> future = job.exec(); |
360 | 360 | ||
361 | const QList<int> expected({ 2, 3, 4, 5 }); | 361 | const QList<int> expected({ 2, 3, 4, 5 }); |
362 | QVERIFY(future.isFinished()); | 362 | QVERIFY(future.isFinished()); |
@@ -365,12 +365,12 @@ void AsyncTest::testSyncEach() | |||
365 | 365 | ||
366 | void AsyncTest::testJoinedEach() | 366 | void AsyncTest::testJoinedEach() |
367 | { | 367 | { |
368 | auto job1 = Async::start<QList<int>, int>( | 368 | auto job1 = KAsync::start<QList<int>, int>( |
369 | [](int v, Async::Future<QList<int>> &future) { | 369 | [](int v, KAsync::Future<QList<int>> &future) { |
370 | new AsyncSimulator<QList<int>>(future, { v * 2 }); | 370 | new AsyncSimulator<QList<int>>(future, { v * 2 }); |
371 | }); | 371 | }); |
372 | 372 | ||
373 | auto job = Async::start<QList<int>>( | 373 | auto job = KAsync::start<QList<int>>( |
374 | []() -> QList<int> { | 374 | []() -> QList<int> { |
375 | return { 1, 2, 3, 4 }; | 375 | return { 1, 2, 3, 4 }; |
376 | }) | 376 | }) |
@@ -387,7 +387,7 @@ void AsyncTest::testJoinedEach() | |||
387 | void AsyncTest::testVoidEachThen() | 387 | void AsyncTest::testVoidEachThen() |
388 | { | 388 | { |
389 | QList<int> check; | 389 | QList<int> check; |
390 | auto job = Async::start<QList<int>>( | 390 | auto job = KAsync::start<QList<int>>( |
391 | []() -> QList<int> { | 391 | []() -> QList<int> { |
392 | return { 1, 2, 3, 4 }; | 392 | return { 1, 2, 3, 4 }; |
393 | }).each<void, int>( | 393 | }).each<void, int>( |
@@ -406,14 +406,14 @@ void AsyncTest::testAsyncVoidEachThen() | |||
406 | { | 406 | { |
407 | bool completedJob = false; | 407 | bool completedJob = false; |
408 | QList<int> check; | 408 | QList<int> check; |
409 | auto job = Async::start<QList<int>>( | 409 | auto job = KAsync::start<QList<int>>( |
410 | [](Async::Future<QList<int> > &future) { | 410 | [](KAsync::Future<QList<int> > &future) { |
411 | new AsyncSimulator<QList<int>>(future, { 1, 2, 3, 4 }); | 411 | new AsyncSimulator<QList<int>>(future, { 1, 2, 3, 4 }); |
412 | }).each<void, int>( | 412 | }).each<void, int>( |
413 | [&check](const int &v, Async::Future<void> &future) { | 413 | [&check](const int &v, KAsync::Future<void> &future) { |
414 | check << v; | 414 | check << v; |
415 | new AsyncSimulator<void>(future); | 415 | new AsyncSimulator<void>(future); |
416 | }).then<void>([&completedJob](Async::Future<void> &future) { | 416 | }).then<void>([&completedJob](KAsync::Future<void> &future) { |
417 | completedJob = true; | 417 | completedJob = true; |
418 | future.setFinished(); | 418 | future.setFinished(); |
419 | }); | 419 | }); |
@@ -433,14 +433,14 @@ void AsyncTest::testAsyncVoidEachThen() | |||
433 | 433 | ||
434 | void AsyncTest::testAsyncReduce() | 434 | void AsyncTest::testAsyncReduce() |
435 | { | 435 | { |
436 | auto job = Async::start<QList<int>>( | 436 | auto job = KAsync::start<QList<int>>( |
437 | [](Async::Future<QList<int>> &future) { | 437 | [](KAsync::Future<QList<int>> &future) { |
438 | new AsyncSimulator<QList<int>>(future, { 1, 2, 3, 4 }); | 438 | new AsyncSimulator<QList<int>>(future, { 1, 2, 3, 4 }); |
439 | }) | 439 | }) |
440 | .reduce<int, QList<int>>( | 440 | .reduce<int, QList<int>>( |
441 | [](const QList<int> &list, Async::Future<int> &future) { | 441 | [](const QList<int> &list, KAsync::Future<int> &future) { |
442 | new AsyncSimulator<int>(future, | 442 | new AsyncSimulator<int>(future, |
443 | [list](Async::Future<int> &future) { | 443 | [list](KAsync::Future<int> &future) { |
444 | int sum = 0; | 444 | int sum = 0; |
445 | for (int i : list) sum += i; | 445 | for (int i : list) sum += i; |
446 | future.setValue(sum); | 446 | future.setValue(sum); |
@@ -449,7 +449,7 @@ void AsyncTest::testAsyncReduce() | |||
449 | ); | 449 | ); |
450 | }); | 450 | }); |
451 | 451 | ||
452 | Async::Future<int> future = job.exec(); | 452 | KAsync::Future<int> future = job.exec(); |
453 | future.waitForFinished(); | 453 | future.waitForFinished(); |
454 | 454 | ||
455 | QVERIFY(future.isFinished()); | 455 | QVERIFY(future.isFinished()); |
@@ -458,7 +458,7 @@ void AsyncTest::testAsyncReduce() | |||
458 | 458 | ||
459 | void AsyncTest::testSyncReduce() | 459 | void AsyncTest::testSyncReduce() |
460 | { | 460 | { |
461 | auto job = Async::start<QList<int>>( | 461 | auto job = KAsync::start<QList<int>>( |
462 | []() -> QList<int> { | 462 | []() -> QList<int> { |
463 | return { 1, 2, 3, 4 }; | 463 | return { 1, 2, 3, 4 }; |
464 | }) | 464 | }) |
@@ -469,7 +469,7 @@ void AsyncTest::testSyncReduce() | |||
469 | return sum; | 469 | return sum; |
470 | }); | 470 | }); |
471 | 471 | ||
472 | Async::Future<int> future = job.exec(); | 472 | KAsync::Future<int> future = job.exec(); |
473 | 473 | ||
474 | QVERIFY(future.isFinished()); | 474 | QVERIFY(future.isFinished()); |
475 | QCOMPARE(future.value(), 10); | 475 | QCOMPARE(future.value(), 10); |
@@ -478,14 +478,14 @@ void AsyncTest::testSyncReduce() | |||
478 | 478 | ||
479 | void AsyncTest::testJoinedReduce() | 479 | void AsyncTest::testJoinedReduce() |
480 | { | 480 | { |
481 | auto job1 = Async::start<int, QList<int>>( | 481 | auto job1 = KAsync::start<int, QList<int>>( |
482 | [](const QList<int> &list, Async::Future<int> &future) { | 482 | [](const QList<int> &list, KAsync::Future<int> &future) { |
483 | int sum = 0; | 483 | int sum = 0; |
484 | for (int i : list) sum += i; | 484 | for (int i : list) sum += i; |
485 | new AsyncSimulator<int>(future, sum); | 485 | new AsyncSimulator<int>(future, sum); |
486 | }); | 486 | }); |
487 | 487 | ||
488 | auto job = Async::start<QList<int>>( | 488 | auto job = KAsync::start<QList<int>>( |
489 | []() -> QList<int> { | 489 | []() -> QList<int> { |
490 | return { 1, 2, 3, 4 }; | 490 | return { 1, 2, 3, 4 }; |
491 | }) | 491 | }) |
@@ -502,7 +502,7 @@ void AsyncTest::testVoidReduce() | |||
502 | { | 502 | { |
503 | // This must not compile (reduce with void result makes no sense) | 503 | // This must not compile (reduce with void result makes no sense) |
504 | #ifdef TEST_BUILD_FAIL | 504 | #ifdef TEST_BUILD_FAIL |
505 | auto job = Async::start<QList<int>>( | 505 | auto job = KAsync::start<QList<int>>( |
506 | []() -> QList<int> { | 506 | []() -> QList<int> { |
507 | return { 1, 2, 3, 4 }; | 507 | return { 1, 2, 3, 4 }; |
508 | }) | 508 | }) |
@@ -522,8 +522,8 @@ void AsyncTest::testProgressReporting() | |||
522 | static int progress; | 522 | static int progress; |
523 | progress = 0; | 523 | progress = 0; |
524 | 524 | ||
525 | auto job = Async::start<void>( | 525 | auto job = KAsync::start<void>( |
526 | [](Async::Future<void> &f) { | 526 | [](KAsync::Future<void> &f) { |
527 | QTimer *timer = new QTimer(); | 527 | QTimer *timer = new QTimer(); |
528 | connect(timer, &QTimer::timeout, | 528 | connect(timer, &QTimer::timeout, |
529 | [&f, timer]() { | 529 | [&f, timer]() { |
@@ -538,8 +538,8 @@ void AsyncTest::testProgressReporting() | |||
538 | }); | 538 | }); |
539 | 539 | ||
540 | int progressCheck = 0; | 540 | int progressCheck = 0; |
541 | Async::FutureWatcher<void> watcher; | 541 | KAsync::FutureWatcher<void> watcher; |
542 | connect(&watcher, &Async::FutureWatcher<void>::futureProgress, | 542 | connect(&watcher, &KAsync::FutureWatcher<void>::futureProgress, |
543 | [&progressCheck](qreal progress) { | 543 | [&progressCheck](qreal progress) { |
544 | progressCheck++; | 544 | progressCheck++; |
545 | // FIXME: Don't use Q_ASSERT in unit tests | 545 | // FIXME: Don't use Q_ASSERT in unit tests |
@@ -556,9 +556,9 @@ void AsyncTest::testErrorHandler() | |||
556 | { | 556 | { |
557 | 557 | ||
558 | { | 558 | { |
559 | auto job = Async::start<int>( | 559 | auto job = KAsync::start<int>( |
560 | [](Async::Future<int> &f) { | 560 | [](KAsync::Future<int> &f) { |
561 | f.setError(1, "error"); | 561 | f.setError(1, QLatin1String("error")); |
562 | }); | 562 | }); |
563 | 563 | ||
564 | auto future = job.exec(); | 564 | auto future = job.exec(); |
@@ -569,9 +569,9 @@ void AsyncTest::testErrorHandler() | |||
569 | 569 | ||
570 | { | 570 | { |
571 | int error = 0; | 571 | int error = 0; |
572 | auto job = Async::start<int>( | 572 | auto job = KAsync::start<int>( |
573 | [](Async::Future<int> &f) { | 573 | [](KAsync::Future<int> &f) { |
574 | f.setError(1, "error"); | 574 | f.setError(1, QLatin1String("error")); |
575 | }, | 575 | }, |
576 | [&error](int errorCode, const QString &errorMessage) { | 576 | [&error](int errorCode, const QString &errorMessage) { |
577 | error += errorCode; | 577 | error += errorCode; |
@@ -590,12 +590,12 @@ void AsyncTest::testErrorPropagation() | |||
590 | { | 590 | { |
591 | int error = 0; | 591 | int error = 0; |
592 | bool called = false; | 592 | bool called = false; |
593 | auto job = Async::start<int>( | 593 | auto job = KAsync::start<int>( |
594 | [](Async::Future<int> &f) { | 594 | [](KAsync::Future<int> &f) { |
595 | f.setError(1, "error"); | 595 | f.setError(1, QLatin1String("error")); |
596 | }) | 596 | }) |
597 | .then<int, int>( | 597 | .then<int, int>( |
598 | [&called](int v, Async::Future<int> &f) { | 598 | [&called](int v, KAsync::Future<int> &f) { |
599 | called = true; | 599 | called = true; |
600 | f.setFinished(); | 600 | f.setFinished(); |
601 | }, | 601 | }, |
@@ -614,11 +614,11 @@ void AsyncTest::testErrorPropagation() | |||
614 | void AsyncTest::testErrorHandlerAsync() | 614 | void AsyncTest::testErrorHandlerAsync() |
615 | { | 615 | { |
616 | { | 616 | { |
617 | auto job = Async::start<int>( | 617 | auto job = KAsync::start<int>( |
618 | [](Async::Future<int> &f) { | 618 | [](KAsync::Future<int> &f) { |
619 | new AsyncSimulator<int>(f, | 619 | new AsyncSimulator<int>(f, |
620 | [](Async::Future<int> &f) { | 620 | [](KAsync::Future<int> &f) { |
621 | f.setError(1, "error"); | 621 | f.setError(1, QLatin1String("error")); |
622 | } | 622 | } |
623 | ); | 623 | ); |
624 | } | 624 | } |
@@ -634,11 +634,11 @@ void AsyncTest::testErrorHandlerAsync() | |||
634 | 634 | ||
635 | { | 635 | { |
636 | int error = 0; | 636 | int error = 0; |
637 | auto job = Async::start<int>( | 637 | auto job = KAsync::start<int>( |
638 | [](Async::Future<int> &f) { | 638 | [](KAsync::Future<int> &f) { |
639 | new AsyncSimulator<int>(f, | 639 | new AsyncSimulator<int>(f, |
640 | [](Async::Future<int> &f) { | 640 | [](KAsync::Future<int> &f) { |
641 | f.setError(1, "error"); | 641 | f.setError(1, QLatin1String("error")); |
642 | } | 642 | } |
643 | ); | 643 | ); |
644 | }, | 644 | }, |
@@ -661,16 +661,16 @@ void AsyncTest::testErrorPropagationAsync() | |||
661 | { | 661 | { |
662 | int error = 0; | 662 | int error = 0; |
663 | bool called = false; | 663 | bool called = false; |
664 | auto job = Async::start<int>( | 664 | auto job = KAsync::start<int>( |
665 | [](Async::Future<int> &f) { | 665 | [](KAsync::Future<int> &f) { |
666 | new AsyncSimulator<int>(f, | 666 | new AsyncSimulator<int>(f, |
667 | [](Async::Future<int> &f) { | 667 | [](KAsync::Future<int> &f) { |
668 | f.setError(1, "error"); | 668 | f.setError(1, QLatin1String("error")); |
669 | } | 669 | } |
670 | ); | 670 | ); |
671 | }) | 671 | }) |
672 | .then<int, int>( | 672 | .then<int, int>( |
673 | [&called](int v, Async::Future<int> &f) { | 673 | [&called](int v, KAsync::Future<int> &f) { |
674 | called = true; | 674 | called = true; |
675 | f.setFinished(); | 675 | f.setFinished(); |
676 | }, | 676 | }, |
@@ -692,9 +692,9 @@ void AsyncTest::testErrorPropagationAsync() | |||
692 | void AsyncTest::testNestedErrorPropagation() | 692 | void AsyncTest::testNestedErrorPropagation() |
693 | { | 693 | { |
694 | int error = 0; | 694 | int error = 0; |
695 | auto job = Async::start<void>([](){}) | 695 | auto job = KAsync::start<void>([](){}) |
696 | .then<void>(Async::error<void>(1, "error")) //Nested job that throws error | 696 | .then<void>(KAsync::error<void>(1, QLatin1String("error"))) //Nested job that throws error |
697 | .then<void>([](Async::Future<void> &future) { | 697 | .then<void>([](KAsync::Future<void> &future) { |
698 | //We should never get here | 698 | //We should never get here |
699 | Q_ASSERT(false); | 699 | Q_ASSERT(false); |
700 | }, | 700 | }, |
@@ -719,8 +719,8 @@ void AsyncTest::testChainingRunningJob() | |||
719 | { | 719 | { |
720 | int check = 0; | 720 | int check = 0; |
721 | 721 | ||
722 | auto job = Async::start<int>( | 722 | auto job = KAsync::start<int>( |
723 | [&check](Async::Future<int> &future) { | 723 | [&check](KAsync::Future<int> &future) { |
724 | QTimer *timer = new QTimer(); | 724 | QTimer *timer = new QTimer(); |
725 | QObject::connect(timer, &QTimer::timeout, | 725 | QObject::connect(timer, &QTimer::timeout, |
726 | [&future, &check]() { | 726 | [&future, &check]() { |
@@ -763,7 +763,7 @@ void AsyncTest::testChainingFinishedJob() | |||
763 | { | 763 | { |
764 | int check = 0; | 764 | int check = 0; |
765 | 765 | ||
766 | auto job = Async::start<int>( | 766 | auto job = KAsync::start<int>( |
767 | [&check]() -> int { | 767 | [&check]() -> int { |
768 | ++check; | 768 | ++check; |
769 | return 42; | 769 | return 42; |
@@ -799,7 +799,7 @@ void AsyncTest::testLifetimeWithoutHandle() | |||
799 | { | 799 | { |
800 | bool done = false; | 800 | bool done = false; |
801 | { | 801 | { |
802 | auto job = Async::start<void>([&done](Async::Future<void> &future) { | 802 | auto job = KAsync::start<void>([&done](KAsync::Future<void> &future) { |
803 | QTimer *timer = new QTimer(); | 803 | QTimer *timer = new QTimer(); |
804 | QObject::connect(timer, &QTimer::timeout, | 804 | QObject::connect(timer, &QTimer::timeout, |
805 | [&future, &done]() { | 805 | [&future, &done]() { |
@@ -823,9 +823,9 @@ void AsyncTest::testLifetimeWithoutHandle() | |||
823 | */ | 823 | */ |
824 | void AsyncTest::testLifetimeWithHandle() | 824 | void AsyncTest::testLifetimeWithHandle() |
825 | { | 825 | { |
826 | Async::Future<void> future; | 826 | KAsync::Future<void> future; |
827 | { | 827 | { |
828 | auto job = Async::start<void>([](Async::Future<void> &future) { | 828 | auto job = KAsync::start<void>([](KAsync::Future<void> &future) { |
829 | QTimer *timer = new QTimer(); | 829 | QTimer *timer = new QTimer(); |
830 | QObject::connect(timer, &QTimer::timeout, | 830 | QObject::connect(timer, &QTimer::timeout, |
831 | [&future]() { | 831 | [&future]() { |
@@ -844,7 +844,7 @@ void AsyncTest::testLifetimeWithHandle() | |||
844 | 844 | ||
845 | void AsyncTest::benchmarkSyncThenExecutor() | 845 | void AsyncTest::benchmarkSyncThenExecutor() |
846 | { | 846 | { |
847 | auto job = Async::start<int>( | 847 | auto job = KAsync::start<int>( |
848 | []() -> int { | 848 | []() -> int { |
849 | return 0; | 849 | return 0; |
850 | }); | 850 | }); |