diff options
author | Liang Qi <liang.qi@qt.io> | 2016-08-25 16:12:11 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-08-25 16:12:11 +0200 |
commit | c7cdf3aac7ef9571ce0c0cf25a2c8455c7604451 (patch) | |
tree | ff17379a7643d47224a500714d825d561172a282 /tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp | |
parent | 3f64156e918a8cf5da1b68191a280f0daf3d954b (diff) | |
parent | 1e6630b54ce9a005c2cffac4dac95641838e8231 (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
src/corelib/mimetypes/qmimeprovider.cpp
src/corelib/mimetypes/qmimetype.cpp
Change-Id: Ib483ddb6bfc380e7c8f195feca535703814c3872
Diffstat (limited to 'tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp')
-rw-r--r-- | tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp index 1b0ac7a8bc..bd53aa69fe 100644 --- a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp +++ b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp @@ -464,6 +464,19 @@ int throwFunctionReturn() return 0; } +class SlowTask : public QRunnable +{ +public: + static QAtomicInt cancel; + void run() Q_DECL_OVERRIDE { + int iter = 60; + while (--iter && !cancel.load()) + QThread::currentThread()->msleep(25); + } +}; + +QAtomicInt SlowTask::cancel; + void tst_QtConcurrentRun::exceptions() { QThreadPool pool; @@ -504,6 +517,30 @@ void tst_QtConcurrentRun::exceptions() } if (!caught) QFAIL("did not get exception"); + + caught = false; + try { + QtConcurrent::run(&pool, throwFunctionReturn).result(); + } catch (QException &) { + caught = true; + } + QVERIFY2(caught, "did not get exception"); + + // Force the task to be run on this thread. + caught = false; + QThreadPool shortPool; + shortPool.setMaxThreadCount(1); + SlowTask *st = new SlowTask(); + try { + shortPool.start(st); + QtConcurrent::run(&shortPool, throwFunctionReturn).result(); + } catch (QException &) { + caught = true; + } + + SlowTask::cancel.store(true); + + QVERIFY2(caught, "did not get exception"); } #endif |