summaryrefslogtreecommitdiffstats
path: root/async/autotests/asynctest.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-04-28 09:45:26 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-04-28 09:45:26 +0200
commit3012dc36bbc40e6f8c07a6af7b2fba9d6c826399 (patch)
treec895b04f3b974a28a2b156b36cc9f8c4cd854bbe /async/autotests/asynctest.cpp
parentc5595c71f6db276513d5158ccef23c2c7d8d0834 (diff)
downloadsink-3012dc36bbc40e6f8c07a6af7b2fba9d6c826399.tar.gz
sink-3012dc36bbc40e6f8c07a6af7b2fba9d6c826399.zip
Async: Nested job error propagation.
Diffstat (limited to 'async/autotests/asynctest.cpp')
-rw-r--r--async/autotests/asynctest.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/async/autotests/asynctest.cpp b/async/autotests/asynctest.cpp
index 9789950..9bc9f6b 100644
--- a/async/autotests/asynctest.cpp
+++ b/async/autotests/asynctest.cpp
@@ -68,6 +68,7 @@ private Q_SLOTS:
68 void testErrorPropagation(); 68 void testErrorPropagation();
69 void testErrorHandlerAsync(); 69 void testErrorHandlerAsync();
70 void testErrorPropagationAsync(); 70 void testErrorPropagationAsync();
71 void testNestedErrorPropagation();
71 72
72 void testChainingRunningJob(); 73 void testChainingRunningJob();
73 void testChainingFinishedJob(); 74 void testChainingFinishedJob();
@@ -688,6 +689,28 @@ void AsyncTest::testErrorPropagationAsync()
688 QCOMPARE(error, 1); 689 QCOMPARE(error, 1);
689} 690}
690 691
692void AsyncTest::testNestedErrorPropagation()
693{
694 int error = 0;
695 auto job = Async::start<void>([](){})
696 .then<void>(Async::error<void>(1, "error")) //Nested job that throws error
697 .then<void>([](Async::Future<void> &future) {
698 //We should never get here
699 Q_ASSERT(false);
700 },
701 [&error](int errorCode, const QString &errorMessage) {
702 error += errorCode;
703 }
704 );
705 auto future = job.exec();
706
707 future.waitForFinished();
708
709 QVERIFY(future.isFinished());
710 QCOMPARE(future.errorCode(), 1);
711 QCOMPARE(future.errorMessage(), QString::fromLatin1("error"));
712 QCOMPARE(error, 1);
713}
691 714
692 715
693 716