summaryrefslogtreecommitdiffstats
path: root/tests/auto/qfuturewatcher
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qfuturewatcher')
-rw-r--r--tests/auto/qfuturewatcher/qfuturewatcher.pro1
-rw-r--r--tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp35
2 files changed, 35 insertions, 1 deletions
diff --git a/tests/auto/qfuturewatcher/qfuturewatcher.pro b/tests/auto/qfuturewatcher/qfuturewatcher.pro
index 79d8739..67f04ef 100644
--- a/tests/auto/qfuturewatcher/qfuturewatcher.pro
+++ b/tests/auto/qfuturewatcher/qfuturewatcher.pro
@@ -1,3 +1,4 @@
load(qttest_p4)
SOURCES += tst_qfuturewatcher.cpp
QT = core
+CONFIG += parallel_test
diff --git a/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp b/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp
index 9875fb5..a4598dc 100644
--- a/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp
+++ b/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp
@@ -47,6 +47,7 @@
#include <qfuturewatcher.h>
#include <qtconcurrentrun.h>
#include <qtconcurrentmap.h>
+#include "../../shared/util.h"
#ifndef QT_NO_CONCURRENT_TEST
#include <private/qfutureinterface_p.h>
@@ -81,6 +82,7 @@ private slots:
void incrementalMapResults();
void incrementalFilterResults();
void qfutureSynchornizer();
+ void warnRace();
};
QTEST_MAIN(tst_QFutureWatcher)
@@ -466,12 +468,12 @@ void tst_QFutureWatcher::toMuchProgress()
ProgressObject o;
QFutureWatcher<void> f;
- f.setFuture((new ProgressEmitterTask())->start());
QObject::connect(&f, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
#ifdef PRINT
QObject::connect(&f, SIGNAL(progressValueChanged(int)), &o, SLOT(printProgress(int)));
#endif
QObject::connect(&f, SIGNAL(progressValueChanged(int)), &o, SLOT(registerProgress(int)));
+ f.setFuture((new ProgressEmitterTask())->start());
QTestEventLoop::instance().enterLoop(5);
QVERIFY(!QTestEventLoop::instance().timeout());
@@ -890,6 +892,37 @@ void tst_QFutureWatcher::qfutureSynchornizer()
QVERIFY(t.elapsed() < taskCount * 10);
}
+class DummyObject : public QObject {
+ Q_OBJECT
+public slots:
+ void dummySlot() {}
+public:
+ static void function(QMutex *m)
+ {
+ QMutexLocker lock(m);
+ }
+};
+
+void tst_QFutureWatcher::warnRace()
+{
+#ifndef Q_OS_MAC //I don't know why it is not working on mac
+#ifndef QT_NO_DEBUG
+ QTest::ignoreMessage(QtWarningMsg, "QFutureWatcher::connect: connecting after calling setFuture() is likely to produce race");
+#endif
+#endif
+ QFutureWatcher<void> watcher;
+ DummyObject object;
+ QMutex mutex;
+ mutex.lock();
+
+ QFuture<void> future = QtConcurrent::run(DummyObject::function, &mutex);
+ watcher.setFuture(future);
+ QTRY_VERIFY(future.isStarted());
+ connect(&watcher, SIGNAL(finished()), &object, SLOT(dummySlot()));
+ mutex.unlock();
+ future.waitForFinished();
+}
+
#include "tst_qfuturewatcher.moc"
#else