diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-08-22 21:00:40 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-09-17 06:47:05 +0000 |
commit | 542ba86e22a062445a57dc9aec3387d65258ab6b (patch) | |
tree | 9530c1b46a2bb3921967caae75ddf3317f2fa08b /tests/auto/corelib/mimetypes/qmimedatabase | |
parent | 1b98ce1986ae96a0966f9ea075e327d641790343 (diff) |
tests/auto/corelib/mimetypes: use local QThreadPool
Isolates the test from anything that might be going on on the globalInstance().
Enabled by the explicit thread-pool feature on QtConcurrent::run().
Add explicit timed wait (unit tests should contain as little indefinite waits
as possible).
Also avoids the use of QFutureSynchronizer, which makes my static QList
checker go nuts, with no way of fixing it until Qt 6.
Change-Id: I0829992642b2a49bb6a10ddd4b31eb3f88e3adeb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/mimetypes/qmimedatabase')
-rw-r--r-- | tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index 9e369792f1..2cf9ea4913 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -41,7 +41,6 @@ #include <QtCore/QStandardPaths> #include <QtCore/QTemporaryDir> #include <QtCore/QTextStream> -#include <QFutureSynchronizer> #include <QtConcurrent/QtConcurrentRun> #include <QtTest/QtTest> @@ -844,18 +843,18 @@ void tst_QMimeDatabase::findByFile() void tst_QMimeDatabase::fromThreads() { - QThreadPool::globalInstance()->setMaxThreadCount(20); + QThreadPool tp; + tp.setMaxThreadCount(20); // Note that data-based tests cannot be used here (QTest::fetchData asserts). - QFutureSynchronizer<void> sync; - sync.addFuture(QtConcurrent::run(this, &tst_QMimeDatabase::mimeTypeForName)); - sync.addFuture(QtConcurrent::run(this, &tst_QMimeDatabase::aliases)); - sync.addFuture(QtConcurrent::run(this, &tst_QMimeDatabase::allMimeTypes)); - sync.addFuture(QtConcurrent::run(this, &tst_QMimeDatabase::icons)); - sync.addFuture(QtConcurrent::run(this, &tst_QMimeDatabase::inheritance)); - sync.addFuture(QtConcurrent::run(this, &tst_QMimeDatabase::knownSuffix)); - sync.addFuture(QtConcurrent::run(this, &tst_QMimeDatabase::mimeTypeForFileWithContent)); - sync.addFuture(QtConcurrent::run(this, &tst_QMimeDatabase::allMimeTypes)); // a second time - // sync dtor blocks waiting for finished + QtConcurrent::run(&tp, this, &tst_QMimeDatabase::mimeTypeForName); + QtConcurrent::run(&tp, this, &tst_QMimeDatabase::aliases); + QtConcurrent::run(&tp, this, &tst_QMimeDatabase::allMimeTypes); + QtConcurrent::run(&tp, this, &tst_QMimeDatabase::icons); + QtConcurrent::run(&tp, this, &tst_QMimeDatabase::inheritance); + QtConcurrent::run(&tp, this, &tst_QMimeDatabase::knownSuffix); + QtConcurrent::run(&tp, this, &tst_QMimeDatabase::mimeTypeForFileWithContent); + QtConcurrent::run(&tp, this, &tst_QMimeDatabase::allMimeTypes); // a second time + QVERIFY(tp.waitForDone(60000)); } #ifndef QT_NO_PROCESS |