summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2011-11-03 23:50:07 +0100
committerDavid Faure <faure@kde.org>2011-12-12 19:49:20 +0100
commita1b595fcfeff8ae3362ec69a44c2ed8e897a7ac4 (patch)
tree7f612495c2bed1dfbabd1cc4955931cda1b201ed
parentf44d9704b4c5f7d3a5704691cbffe57a9be687a2 (diff)
Test qmimedatabase from multiple concurrent threads
(Note: this needs a -Wshadow fix for a QtConcurrent header, which I submitted to qtbase.git as 480c1db1ba1743741cae6b0ef9b6afd733f765df)
-rw-r--r--tests/auto/qmimedatabase/tst_qmimedatabase.cpp21
-rw-r--r--tests/auto/qmimedatabase/tst_qmimedatabase.h1
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/qmimedatabase/tst_qmimedatabase.cpp
index 5f03d90..400289a 100644
--- a/tests/auto/qmimedatabase/tst_qmimedatabase.cpp
+++ b/tests/auto/qmimedatabase/tst_qmimedatabase.cpp
@@ -550,6 +550,27 @@ void tst_qmimedatabase::findByFile()
}
}
+
+void tst_qmimedatabase::test_fromThreads()
+{
+ // When using -Wshadow, a Qt 4 header breaks
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+ QThreadPool::globalInstance()->setMaxThreadCount(20);
+ // Note that data-based tests cannot be used here (QTest::fetchData asserts).
+ QList<QFuture<void> > futures;
+ futures << QtConcurrent::run(this, &tst_qmimedatabase::test_mimeTypeForName);
+ futures << QtConcurrent::run(this, &tst_qmimedatabase::test_aliases);
+ futures << QtConcurrent::run(this, &tst_qmimedatabase::test_allMimeTypes);
+ futures << QtConcurrent::run(this, &tst_qmimedatabase::test_icons);
+ futures << QtConcurrent::run(this, &tst_qmimedatabase::test_inheritance);
+ futures << QtConcurrent::run(this, &tst_qmimedatabase::test_knownSuffix);
+ futures << QtConcurrent::run(this, &tst_qmimedatabase::test_findByFileWithContent);
+ futures << QtConcurrent::run(this, &tst_qmimedatabase::test_allMimeTypes); // a second time
+ Q_FOREACH(QFuture<void> f, futures) // krazy:exclude=foreach
+ f.waitForFinished();
+#endif
+}
+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
//QTEST_MAIN(tst_qmimedatabase)
QTEST_GUILESS_MAIN(tst_qmimedatabase)
diff --git a/tests/auto/qmimedatabase/tst_qmimedatabase.h b/tests/auto/qmimedatabase/tst_qmimedatabase.h
index 67e97ca..eff5979 100644
--- a/tests/auto/qmimedatabase/tst_qmimedatabase.h
+++ b/tests/auto/qmimedatabase/tst_qmimedatabase.h
@@ -31,6 +31,7 @@ private Q_SLOTS:
void test_suffixes_data();
void test_suffixes();
void test_knownSuffix();
+ void test_fromThreads();
// shared-mime-info test suite