Cleanup corelib autotests.
authorJason McDonald <jason.mcdonald@nokia.com>
Thu, 22 Dec 2011 07:16:48 +0000 (17:16 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 28 Dec 2011 03:48:11 +0000 (04:48 +0100)
When using QSignalSpy, always verify that the signal spy is valid.  This
will cause the test to give a meaningful failure when spying on a
non-existant signal.  Without this change, tests that spy on a signal to
ensure that it is not emitted (i.e. by comparing the spy count to zero)
could pass erroneously if something went wrong when creating the signal
spy, as an invalid QSignalSpy will always return a count of zero.

Change-Id: I41f4a63d9f0de9190a86de237662dc96be802446
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
19 files changed:
tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp
tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
tests/auto/corelib/concurrent/qfuturewatcher/tst_qfuturewatcher.cpp
tests/auto/corelib/io/qfile/tst_qfile.cpp
tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
tests/auto/corelib/io/qprocess/tst_qprocess.cpp
tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp
tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
tests/auto/corelib/kernel/qitemmodel/tst_qitemmodel.cpp
tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp
tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp
tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp

index 4c111a8..d020fe9 100644 (file)
@@ -138,6 +138,7 @@ void tst_QAnimationGroup::emptyGroup()
 {
     QSequentialAnimationGroup group;
     QSignalSpy groupStateChangedSpy(&group, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+    QVERIFY(groupStateChangedSpy.isValid());
 
     QCOMPARE(group.state(), QAnimationGroup::Stopped);
     group.start();
index e091666..3f65d07 100644 (file)
@@ -261,6 +261,11 @@ void tst_QParallelAnimationGroup::stateChanged()
     QSignalSpy spy3(anim3, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
     QSignalSpy spy4(anim4, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
 
+    QVERIFY(spy1.isValid());
+    QVERIFY(spy2.isValid());
+    QVERIFY(spy3.isValid());
+    QVERIFY(spy4.isValid());
+
     //first; let's start forward
     group.start();
     //all the animations should be started
@@ -432,6 +437,9 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup()
     QSignalSpy groupStateChangedSpy(&group, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
     QSignalSpy childStateChangedSpy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
 
+    QVERIFY(groupStateChangedSpy.isValid());
+    QVERIFY(childStateChangedSpy.isValid());
+
     QCOMPARE(groupStateChangedSpy.count(), 0);
     QCOMPARE(childStateChangedSpy.count(), 0);
     QCOMPARE(group.state(), QAnimationGroup::Stopped);
@@ -596,6 +604,9 @@ void tst_QParallelAnimationGroup::startGroupWithRunningChild()
     QSignalSpy stateChangedSpy1(&anim1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
     QSignalSpy stateChangedSpy2(&anim2, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
 
+    QVERIFY(stateChangedSpy1.isValid());
+    QVERIFY(stateChangedSpy2.isValid());
+
     QCOMPARE(stateChangedSpy1.count(), 0);
     QCOMPARE(stateChangedSpy2.count(), 0);
     QCOMPARE(group.state(), QAnimationGroup::Stopped);
@@ -661,12 +672,21 @@ void tst_QParallelAnimationGroup::zeroDurationAnimation()
     QSignalSpy stateChangedSpy1(&anim1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
     QSignalSpy finishedSpy1(&anim1, SIGNAL(finished()));
 
+    QVERIFY(stateChangedSpy1.isValid());
+    QVERIFY(finishedSpy1.isValid());
+
     QSignalSpy stateChangedSpy2(&anim2, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
     QSignalSpy finishedSpy2(&anim2, SIGNAL(finished()));
 
+    QVERIFY(stateChangedSpy2.isValid());
+    QVERIFY(finishedSpy2.isValid());
+
     QSignalSpy stateChangedSpy3(&anim3, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
     QSignalSpy finishedSpy3(&anim3, SIGNAL(finished()));
 
+    QVERIFY(stateChangedSpy3.isValid());
+    QVERIFY(finishedSpy3.isValid());
+
     group.addAnimation(&anim1);
     group.addAnimation(&anim2);
     group.addAnimation(&anim3);
@@ -741,6 +761,7 @@ void tst_QParallelAnimationGroup::stopUncontrolledAnimations()
     loopsForever.setLoopCount(-1);
 
     QSignalSpy stateChangedSpy(&anim1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+    QVERIFY(stateChangedSpy.isValid());
 
     group.addAnimation(&anim1);
     group.addAnimation(&notTimeDriven);
@@ -948,6 +969,7 @@ void tst_QParallelAnimationGroup::pauseResume()
     QParallelAnimationGroup group;
     TestAnimation2 *anim = new TestAnimation2(250, &group);      // 0, duration = 250;
     QSignalSpy spy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+    QVERIFY(spy.isValid());
     QCOMPARE(group.duration(), 250);
     group.start();
     QTest::qWait(100);
index 51b7359..61fd31c 100644 (file)
@@ -230,6 +230,10 @@ void tst_QPropertyAnimation::statesAndSignals()
     QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
     QSignalSpy currentLoopSpy(anim, SIGNAL(currentLoopChanged(int)));
 
+    QVERIFY(finishedSpy.isValid());
+    QVERIFY(runningSpy.isValid());
+    QVERIFY(currentLoopSpy.isValid());
+
     anim->setCurrentTime(1);
     anim->setCurrentTime(100);
     QCOMPARE(finishedSpy.count(), 0);
@@ -305,6 +309,8 @@ void tst_QPropertyAnimation::deletion1()
     //test that the animation is deleted correctly depending of the deletion flag passed in start()
     QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
     QSignalSpy finishedSpy(anim, SIGNAL(finished()));
+    QVERIFY(runningSpy.isValid());
+    QVERIFY(finishedSpy.isValid());
     anim->setStartValue(10);
     anim->setEndValue(20);
     anim->setDuration(200);
@@ -348,6 +354,9 @@ void tst_QPropertyAnimation::deletion2()
     QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
     QSignalSpy finishedSpy(anim, SIGNAL(finished()));
 
+    QVERIFY(runningSpy.isValid());
+    QVERIFY(finishedSpy.isValid());
+
     anim->setStartValue(10);
     anim->setEndValue(20);
     anim->setDuration(200);
@@ -378,6 +387,10 @@ void tst_QPropertyAnimation::deletion3()
 
     QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
     QSignalSpy finishedSpy(anim, SIGNAL(finished()));
+
+    QVERIFY(runningSpy.isValid());
+    QVERIFY(finishedSpy.isValid());
+
     anim->start();
 
     QTest::qWait(50);
@@ -474,6 +487,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning()
         QPointer<QVariantAnimation> anim = new QPropertyAnimation(&o, "ole");
         anim->setEndValue(100);
         QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+        QVERIFY(runningSpy.isValid());
         anim->start(QVariantAnimation::DeleteWhenStopped);
         QTest::qWait(anim->duration() + 100);
         QTRY_COMPARE(runningSpy.count(), 2); //started and then stopped
@@ -484,6 +498,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning()
         QPointer<QVariantAnimation> anim = new QPropertyAnimation(&o, "ole");
         anim->setEndValue(100);
         QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+        QVERIFY(runningSpy.isValid());
         anim->start(QVariantAnimation::DeleteWhenStopped);
         QTest::qWait(anim->duration()/2);
         QPointer<QVariantAnimation> anim2 = new QPropertyAnimation(&o, "ole");
@@ -834,6 +849,7 @@ void tst_QPropertyAnimation::zeroDurationStart()
 {
     DummyPropertyAnimation anim;
     QSignalSpy spy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+    QVERIFY(spy.isValid());
     anim.setDuration(0);
     QCOMPARE(anim.state(), QAbstractAnimation::Stopped);
     anim.start();
@@ -911,6 +927,7 @@ void tst_QPropertyAnimation::operationsInStates()
     QPropertyAnimation anim(&o, "ole");
     anim.setEndValue(100);
     QSignalSpy spy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+    QVERIFY(spy.isValid());
 
     anim.stop();
     switch (originState) {
@@ -1071,6 +1088,7 @@ void tst_QPropertyAnimation::valueChanged()
     anim.setEndValue(5);
     anim.setDuration(1000);
     QSignalSpy spy(&anim, SIGNAL(valueChanged(QVariant)));
+    QVERIFY(spy.isValid());
     anim.start();
 
     QTest::qWait(anim.duration() + 100);
@@ -1203,6 +1221,9 @@ void tst_QPropertyAnimation::zeroLoopCount()
     QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
     QSignalSpy finishedSpy(anim, SIGNAL(finished()));
 
+    QVERIFY(runningSpy.isValid());
+    QVERIFY(finishedSpy.isValid());
+
     QCOMPARE(anim->state(), QAnimationGroup::Stopped);
     QCOMPARE(anim->currentValue().toInt(), 0);
     QCOMPARE(runningSpy.count(), 0);
index c7a9964..6cc406b 100644 (file)
@@ -642,6 +642,9 @@ void tst_QSequentialAnimationGroup::pauseAndResume()
     QSignalSpy a1StateChangedSpy(a1_s_o1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
     QSignalSpy seqStateChangedSpy(sequence, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
 
+    QVERIFY(a1StateChangedSpy.isValid());
+    QVERIFY(seqStateChangedSpy.isValid());
+
     QSequentialAnimationGroup group;
     group.addAnimation(sequence);
 
@@ -746,6 +749,9 @@ void tst_QSequentialAnimationGroup::restart()
     QSignalSpy seqCurrentAnimChangedSpy(sequence, SIGNAL(currentAnimationChanged(QAbstractAnimation*)));
     QSignalSpy seqStateChangedSpy(sequence, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
 
+    QVERIFY(seqCurrentAnimChangedSpy.isValid());
+    QVERIFY(seqStateChangedSpy.isValid());
+
     QVariantAnimation *anims[3];
     QSignalSpy *animsStateChanged[3];
 
@@ -753,6 +759,7 @@ void tst_QSequentialAnimationGroup::restart()
         anims[i] = new DummyPropertyAnimation;
         anims[i]->setDuration(100);
         animsStateChanged[i] = new QSignalSpy(anims[i], SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+        QVERIFY(animsStateChanged[i]->isValid());
     }
 
     anims[1]->setLoopCount(2);
@@ -816,6 +823,11 @@ void tst_QSequentialAnimationGroup::looping()
     QSignalSpy a3Spy(a3_s_o1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
     QSignalSpy seqSpy(sequence, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
 
+    QVERIFY(a1Spy.isValid());
+    QVERIFY(a2Spy.isValid());
+    QVERIFY(a3Spy.isValid());
+    QVERIFY(seqSpy.isValid());
+
     a2_s_o1->setLoopCount(2);
     sequence->addAnimation(a1_s_o1);
     sequence->addAnimation(a2_s_o1);
@@ -824,6 +836,7 @@ void tst_QSequentialAnimationGroup::looping()
 
     QSequentialAnimationGroup group;
     QSignalSpy groupSpy(&group, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+    QVERIFY(groupSpy.isValid());
 
     group.addAnimation(sequence);
     group.setLoopCount(2);
@@ -1093,6 +1106,9 @@ void tst_QSequentialAnimationGroup::updateChildrenWithRunningGroup()
     QSignalSpy groupStateChangedSpy(&group, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
     QSignalSpy childStateChangedSpy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
 
+    QVERIFY(groupStateChangedSpy.isValid());
+    QVERIFY(childStateChangedSpy.isValid());
+
     QCOMPARE(groupStateChangedSpy.count(), 0);
     QCOMPARE(childStateChangedSpy.count(), 0);
     QCOMPARE(group.state(), QAnimationGroup::Stopped);
@@ -1257,6 +1273,9 @@ void tst_QSequentialAnimationGroup::startGroupWithRunningChild()
     QSignalSpy stateChangedSpy1(anim1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
     QSignalSpy stateChangedSpy2(anim2, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
 
+    QVERIFY(stateChangedSpy1.isValid());
+    QVERIFY(stateChangedSpy2.isValid());
+
     QCOMPARE(stateChangedSpy1.count(), 0);
     QCOMPARE(stateChangedSpy2.count(), 0);
     QCOMPARE(group.state(), QAnimationGroup::Stopped);
@@ -1329,6 +1348,7 @@ void tst_QSequentialAnimationGroup::zeroDurationAnimation()
     anim3->setDuration(0);
 
     QSignalSpy stateChangedSpy(anim1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+    QVERIFY(stateChangedSpy.isValid());
 
     group.addAnimation(anim1);
     group.addAnimation(anim2);
@@ -1400,6 +1420,7 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation()
     QSequentialAnimationGroup group;
     UncontrolledAnimation notTimeDriven(&o1, &group);
     QSignalSpy spy(&group, SIGNAL(finished()));
+    QVERIFY(spy.isValid());
 
     group.start();
     QCOMPARE(group.state(), QAnimationGroup::Running);
@@ -1419,6 +1440,7 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation()
     spy.clear();
     DummyPropertyAnimation anim(&group);
     QSignalSpy animStateChangedSpy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+    QVERIFY(animStateChangedSpy.isValid());
 
     group.setCurrentTime(300);
     QCOMPARE(group.state(), QAnimationGroup::Stopped);
@@ -1620,6 +1642,7 @@ void tst_QSequentialAnimationGroup::pauseResume()
     anim->setDuration(250);
     anim->setEndValue(250);
     QSignalSpy spy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+    QVERIFY(spy.isValid());
     QCOMPARE(group.duration(), 250);
     group.start();
     QTest::qWait(100);
index c7e35e2..ca0816e 100644 (file)
@@ -90,17 +90,20 @@ void tst_QFutureWatcher::startFinish()
 {
     QFutureWatcher<void> futureWatcher;
 
-    QSignalSpy started(&futureWatcher, SIGNAL(started()));
-    QSignalSpy finished(&futureWatcher, SIGNAL(finished()));
+    QSignalSpy startedSpy(&futureWatcher, SIGNAL(started()));
+    QSignalSpy finishedSpy(&futureWatcher, SIGNAL(finished()));
+
+    QVERIFY(startedSpy.isValid());
+    QVERIFY(finishedSpy.isValid());
 
     futureWatcher.setFuture(QtConcurrent::run(sleeper));
     QTest::qWait(10); // spin the event loop to deliver queued signals.
-    QCOMPARE(started.count(), 1);
-    QCOMPARE(finished.count(), 0);
+    QCOMPARE(startedSpy.count(), 1);
+    QCOMPARE(finishedSpy.count(), 0);
     futureWatcher.future().waitForFinished();
     QTest::qWait(10);
-    QCOMPARE(started.count(), 1);
-    QCOMPARE(finished.count(), 1);
+    QCOMPARE(startedSpy.count(), 1);
+    QCOMPARE(finishedSpy.count(), 1);
 }
 
 void mapSleeper(int &)
@@ -323,6 +326,7 @@ void tst_QFutureWatcher::futureSignals()
         f.setFuture(a.future());
 
         QSignalSpy progressSpy(&f, SIGNAL(progressValueChanged(int)));
+        QVERIFY(progressSpy.isValid());
         const int progress = 1;
         a.setProgressValue(progress);
         QTest::qWait(10);
@@ -333,6 +337,9 @@ void tst_QFutureWatcher::futureSignals()
         QSignalSpy finishedSpy(&f, SIGNAL(finished()));
         QSignalSpy resultReadySpy(&f, SIGNAL(resultReadyAt(int)));
 
+        QVERIFY(finishedSpy.isValid());
+        QVERIFY(resultReadySpy.isValid());
+
         const int result = 10;
         a.reportResult(&result);
         QTest::qWait(10);
@@ -375,6 +382,11 @@ void tst_QFutureWatcher::watchFinishedFuture()
     QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int)));
     QSignalSpy canceledSpy(&watcher, SIGNAL(canceled()));
 
+    QVERIFY(startedSpy.isValid());
+    QVERIFY(finishedSpy.isValid());
+    QVERIFY(resultReadySpy.isValid());
+    QVERIFY(canceledSpy.isValid());
+
     watcher.setFuture(f);
     QTest::qWait(10);
 
@@ -404,6 +416,11 @@ void tst_QFutureWatcher::watchCanceledFuture()
     QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int)));
     QSignalSpy canceledSpy(&watcher, SIGNAL(canceled()));
 
+    QVERIFY(startedSpy.isValid());
+    QVERIFY(finishedSpy.isValid());
+    QVERIFY(resultReadySpy.isValid());
+    QVERIFY(canceledSpy.isValid());
+
     watcher.setFuture(f);
     QTest::qWait(10);
 
@@ -428,6 +445,9 @@ void tst_QFutureWatcher::disconnectRunningFuture()
     QSignalSpy finishedSpy(watcher, SIGNAL(finished()));
     QSignalSpy resultReadySpy(watcher, SIGNAL(resultReadyAt(int)));
 
+    QVERIFY(finishedSpy.isValid());
+    QVERIFY(resultReadySpy.isValid());
+
     const int result = 10;
     a.reportResult(&result);
     QTest::qWait(10);
@@ -618,6 +638,7 @@ void tst_QFutureWatcher::changeFuture()
     SignalSlotObject object;
     connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int)));
     QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int)));
+    QVERIFY(resultReadySpy.isValid());
 
     watcher.setFuture(a); // Watch 'a' which will genere a resultReady event.
     watcher.setFuture(b); // But oh no! we're switching to another future
@@ -649,6 +670,7 @@ void tst_QFutureWatcher::cancelEvents()
     SignalSlotObject object;
     connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int)));
     QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int)));
+    QVERIFY(resultReadySpy.isValid());
 
     watcher.setFuture(a);
     watcher.cancel();
@@ -676,6 +698,7 @@ void tst_QFutureWatcher::pauseEvents()
         SignalSlotObject object;
         connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int)));
         QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int)));
+        QVERIFY(resultReadySpy.isValid());
 
         watcher.setFuture(a);
         watcher.pause();
@@ -701,6 +724,7 @@ void tst_QFutureWatcher::pauseEvents()
         SignalSlotObject object;
         connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int)));
         QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int)));
+        QVERIFY(resultReadySpy.isValid());
 
         watcher.setFuture(a);
         a.pause();
index fdb0a7e..cae97f8 100644 (file)
@@ -1483,14 +1483,15 @@ void tst_QFile::tailFile()
     QVERIFY(tailFile.open(QFile::ReadOnly));
     tailFile.seek(file.size());
 
-    QSignalSpy readSignal(&tailFile, SIGNAL(readyRead()));
+    QSignalSpy readSignalSpy(&tailFile, SIGNAL(readyRead()));
+    QVERIFY(readSignalSpy.isValid());
 
     file.write("", 1);
 
     QTestEventLoop::instance().enterLoop(5);
 
     QVERIFY(!QTestEventLoop::instance().timeout());
-    QCOMPARE(readSignal.count(), 1);
+    QCOMPARE(readSignalSpy.count(), 1);
 }
 
 void tst_QFile::flush()
index b9840bd..0f2c163 100644 (file)
@@ -138,6 +138,7 @@ void tst_QFileSystemWatcher::basicTest()
     watcher.addPath(testFile.fileName());
 
     QSignalSpy changedSpy(&watcher, SIGNAL(fileChanged(const QString &)));
+    QVERIFY(changedSpy.isValid());
     QEventLoop eventLoop;
     QTimer timer;
     connect(&timer, SIGNAL(timeout()), &eventLoop, SLOT(quit()));
@@ -273,6 +274,7 @@ void tst_QFileSystemWatcher::watchDirectory()
     watcher.addPath(testDir.dirName());
 
     QSignalSpy changedSpy(&watcher, SIGNAL(directoryChanged(const QString &)));
+    QVERIFY(changedSpy.isValid());
     QEventLoop eventLoop;
     QTimer timer;
     connect(&timer, SIGNAL(timeout()), &eventLoop, SLOT(quit()));
@@ -423,6 +425,8 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory()
 
     QSignalSpy fileChangedSpy(&watcher, SIGNAL(fileChanged(const QString &)));
     QSignalSpy dirChangedSpy(&watcher, SIGNAL(directoryChanged(const QString &)));
+    QVERIFY(fileChangedSpy.isValid());
+    QVERIFY(dirChangedSpy.isValid());
     QEventLoop eventLoop;
     QTimer timer;
     connect(&timer, SIGNAL(timeout()), &eventLoop, SLOT(quit()));
index 9d01213..d8b0b38 100644 (file)
@@ -239,6 +239,7 @@ void tst_QProcess::simpleStart()
 
     process = new QProcess;
     QSignalSpy spy(process, SIGNAL(stateChanged(QProcess::ProcessState)));
+    QVERIFY(spy.isValid());
     connect(process, SIGNAL(readyRead()), this, SLOT(readFromProcess()));
 
     /* valgrind dislike SUID binaries(those that have the `s'-flag set), which
@@ -303,6 +304,7 @@ void tst_QProcess::crashTest()
 #endif
     process = new QProcess;
     QSignalSpy stateSpy(process, SIGNAL(stateChanged(QProcess::ProcessState)));
+    QVERIFY(stateSpy.isValid());
     process->start("testProcessCrash/testProcessCrash");
     QVERIFY(process->waitForStarted(5000));
 
@@ -312,6 +314,9 @@ void tst_QProcess::crashTest()
     QSignalSpy spy(process, SIGNAL(error(QProcess::ProcessError)));
     QSignalSpy spy2(process, SIGNAL(finished(int, QProcess::ExitStatus)));
 
+    QVERIFY(spy.isValid());
+    QVERIFY(spy2.isValid());
+
     QVERIFY(process->waitForFinished(30000));
 
     QCOMPARE(spy.count(), 1);
@@ -347,6 +352,9 @@ void tst_QProcess::crashTest2()
     QSignalSpy spy(process, SIGNAL(error(QProcess::ProcessError)));
     QSignalSpy spy2(process, SIGNAL(finished(int, QProcess::ExitStatus)));
 
+    QVERIFY(spy.isValid());
+    QVERIFY(spy2.isValid());
+
     QObject::connect(process, SIGNAL(finished(int)), this, SLOT(exitLoopSlot()));
 
     QTestEventLoop::instance().enterLoop(30);
@@ -461,6 +469,9 @@ void tst_QProcess::echoTest2()
     QSignalSpy spy1(process, SIGNAL(readyReadStandardOutput()));
     QSignalSpy spy2(process, SIGNAL(readyReadStandardError()));
 
+    QVERIFY(spy1.isValid());
+    QVERIFY(spy2.isValid());
+
     QTime stopWatch;
     stopWatch.start();
     forever {
@@ -516,6 +527,7 @@ void tst_QProcess::echoTest_performance()
     qint64 totalBytes = 0;
     QByteArray dump;
     QSignalSpy readyReadSpy(&process, SIGNAL(readyRead()));
+    QVERIFY(readyReadSpy.isValid());
     while (stopWatch.elapsed() < 2000) {
         process.write(array);
         while (process.bytesToWrite() > 0) {
@@ -697,6 +709,7 @@ void tst_QProcess::readTimeoutAndThenCrash()
 
     qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError");
     QSignalSpy spy(process, SIGNAL(error(QProcess::ProcessError)));
+    QVERIFY(spy.isValid());
 
     process->kill();
 
@@ -926,6 +939,7 @@ void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives()
     QProcess proc;
     connect(&proc, SIGNAL(readyRead()), this, SLOT(exitLoopSlot()));
     QSignalSpy spy(&proc, SIGNAL(readyRead()));
+    QVERIFY(spy.isValid());
 
 #ifdef Q_OS_MAC
     proc.start("testProcessEcho/testProcessEcho.app");
@@ -1307,6 +1321,7 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlot()
     QVERIFY(process->waitForStarted(5000));
 
     QSignalSpy spy(process, SIGNAL(readyRead()));
+    QVERIFY(spy.isValid());
     process->write("foo");
     QTestEventLoop::instance().enterLoop(30);
     QVERIFY(!QTestEventLoop::instance().timeout());
@@ -1353,6 +1368,7 @@ void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot()
 
     qRegisterMetaType<qint64>("qint64");
     QSignalSpy spy(process, SIGNAL(bytesWritten(qint64)));
+    QVERIFY(spy.isValid());
     process->write("f");
     QTestEventLoop::instance().enterLoop(30);
     QVERIFY(!QTestEventLoop::instance().timeout());
@@ -1572,6 +1588,11 @@ void tst_QProcess::failToStart()
     QSignalSpy finishedSpy(&process, SIGNAL(finished(int)));
     QSignalSpy finishedSpy2(&process, SIGNAL(finished(int, QProcess::ExitStatus)));
 
+    QVERIFY(stateSpy.isValid());
+    QVERIFY(errorSpy.isValid());
+    QVERIFY(finishedSpy.isValid());
+    QVERIFY(finishedSpy2.isValid());
+
 // Mac OS X and HP-UX have a really low default process limit (~100), so spawning
 // to many processes here will cause test failures later on.
 #if defined Q_OS_HPUX
@@ -1633,6 +1654,10 @@ void tst_QProcess::failToStartWithWait()
     QSignalSpy finishedSpy(&process, SIGNAL(finished(int)));
     QSignalSpy finishedSpy2(&process, SIGNAL(finished(int, QProcess::ExitStatus)));
 
+    QVERIFY(errorSpy.isValid());
+    QVERIFY(finishedSpy.isValid());
+    QVERIFY(finishedSpy2.isValid());
+
     for (int i = 0; i < 50; ++i) {
         process.start("/blurp", QStringList() << "-v" << "-debug");
         process.waitForStarted();
@@ -1656,6 +1681,10 @@ void tst_QProcess::failToStartWithEventLoop()
     QSignalSpy finishedSpy(&process, SIGNAL(finished(int)));
     QSignalSpy finishedSpy2(&process, SIGNAL(finished(int, QProcess::ExitStatus)));
 
+    QVERIFY(errorSpy.isValid());
+    QVERIFY(finishedSpy.isValid());
+    QVERIFY(finishedSpy2.isValid());
+
     // The error signal may be emitted before start() returns
     connect(&process, SIGNAL(error(QProcess::ProcessError)), &loop, SLOT(quit()), Qt::QueuedConnection);
 
@@ -1896,6 +1925,11 @@ void tst_QProcess::waitForReadyReadForNonexistantProcess()
     QSignalSpy errorSpy(&process, SIGNAL(error(QProcess::ProcessError)));
     QSignalSpy finishedSpy1(&process, SIGNAL(finished(int)));
     QSignalSpy finishedSpy2(&process, SIGNAL(finished(int, QProcess::ExitStatus)));
+
+    QVERIFY(errorSpy.isValid());
+    QVERIFY(finishedSpy1.isValid());
+    QVERIFY(finishedSpy2.isValid());
+
     QVERIFY(!process.waitForReadyRead()); // used to crash
     process.start("doesntexist");
     QVERIFY(!process.waitForReadyRead());
@@ -2233,6 +2267,7 @@ void tst_QProcess::invalidProgramString()
 
     qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError");
     QSignalSpy spy(&process, SIGNAL(error(QProcess::ProcessError)));
+    QVERIFY(spy.isValid());
 
     process.start(programString);
     QCOMPARE(process.error(), QProcess::FailedToStart);
@@ -2249,6 +2284,9 @@ void tst_QProcess::onlyOneStartedSignal()
     QSignalSpy spyStarted(&process,  SIGNAL(started()));
     QSignalSpy spyFinished(&process, SIGNAL(finished(int, QProcess::ExitStatus)));
 
+    QVERIFY(spyStarted.isValid());
+    QVERIFY(spyFinished.isValid());
+
     process.start("testProcessNormal/testProcessNormal");
     QVERIFY(process.waitForStarted(5000));
     QVERIFY(process.waitForFinished(5000));
index 199d96c..5028728 100644 (file)
@@ -720,6 +720,9 @@ void tst_QAbstractItemModel::removeRows()
     QSignalSpy rowsAboutToBeRemovedSpy(&model, SIGNAL(rowsAboutToBeRemoved( const QModelIndex &, int , int )));
     QSignalSpy rowsRemovedSpy(&model, SIGNAL(rowsRemoved( const QModelIndex &, int, int )));
 
+    QVERIFY(rowsAboutToBeRemovedSpy.isValid());
+    QVERIFY(rowsRemovedSpy.isValid());
+
     QCOMPARE(model.removeRows(6, 4), true);
     QCOMPARE(rowsAboutToBeRemovedSpy.count(), 1);
     QCOMPARE(rowsRemovedSpy.count(), 1);
@@ -732,6 +735,9 @@ void tst_QAbstractItemModel::removeColumns()
     QSignalSpy columnsAboutToBeRemovedSpy(&model, SIGNAL(columnsAboutToBeRemoved( const QModelIndex &, int , int )));
     QSignalSpy columnsRemovedSpy(&model, SIGNAL(columnsRemoved( const QModelIndex &, int, int )));
 
+    QVERIFY(columnsAboutToBeRemovedSpy.isValid());
+    QVERIFY(columnsRemovedSpy.isValid());
+
     QCOMPARE(model.removeColumns(6, 4), true);
     QCOMPARE(columnsAboutToBeRemovedSpy.count(), 1);
     QCOMPARE(columnsRemovedSpy.count(), 1);
@@ -744,6 +750,9 @@ void tst_QAbstractItemModel::insertRows()
     QSignalSpy rowsAboutToBeInsertedSpy(&model, SIGNAL(rowsAboutToBeInserted( const QModelIndex &, int , int )));
     QSignalSpy rowsInsertedSpy(&model, SIGNAL(rowsInserted( const QModelIndex &, int, int )));
 
+    QVERIFY(rowsAboutToBeInsertedSpy.isValid());
+    QVERIFY(rowsInsertedSpy.isValid());
+
     QCOMPARE(model.insertRows(6, 4), true);
     QCOMPARE(rowsAboutToBeInsertedSpy.count(), 1);
     QCOMPARE(rowsInsertedSpy.count(), 1);
@@ -756,6 +765,9 @@ void tst_QAbstractItemModel::insertColumns()
     QSignalSpy columnsAboutToBeInsertedSpy(&model, SIGNAL(columnsAboutToBeInserted( const QModelIndex &, int , int )));
     QSignalSpy columnsInsertedSpy(&model, SIGNAL(columnsInserted( const QModelIndex &, int, int )));
 
+    QVERIFY(columnsAboutToBeInsertedSpy.isValid());
+    QVERIFY(columnsInsertedSpy.isValid());
+
     QCOMPARE(model.insertColumns(6, 4), true);
     QCOMPARE(columnsAboutToBeInsertedSpy.count(), 1);
     QCOMPARE(columnsInsertedSpy.count(), 1);
@@ -766,6 +778,7 @@ void tst_QAbstractItemModel::reset()
     QtTestModel model(10, 10);
 
     QSignalSpy resetSpy(&model, SIGNAL(modelReset()));
+    QVERIFY(resetSpy.isValid());
     model.reset();
     QCOMPARE(resetSpy.count(), 1);
 }
@@ -894,6 +907,9 @@ void tst_QAbstractItemModel::testMoveSameParentDown()
     QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
     QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
 
+    QVERIFY(beforeSpy.isValid());
+    QVERIFY(afterSpy.isValid());
+
     ModelMoveCommand *moveCommand = new ModelMoveCommand(m_model, this);
     moveCommand->setNumCols(4);
     if (!topLevel)
@@ -1019,6 +1035,8 @@ void tst_QAbstractItemModel::testMoveSameParentUp()
     QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
     QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
 
+    QVERIFY(beforeSpy.isValid());
+    QVERIFY(afterSpy.isValid());
 
     ModelMoveCommand *moveCommand = new ModelMoveCommand(m_model, this);
     moveCommand->setNumCols(4);
@@ -1180,6 +1198,9 @@ void tst_QAbstractItemModel::testMoveToGrandParent()
     QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
     QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
 
+    QVERIFY(beforeSpy.isValid());
+    QVERIFY(afterSpy.isValid());
+
     QPersistentModelIndex persistentSource = sourceIndex;
 
     ModelMoveCommand *moveCommand = new ModelMoveCommand(m_model, this);
@@ -1329,6 +1350,9 @@ void tst_QAbstractItemModel::testMoveToSibling()
     QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
     QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
 
+    QVERIFY(beforeSpy.isValid());
+    QVERIFY(afterSpy.isValid());
+
     QPersistentModelIndex persistentDest = destIndex;
 
     ModelMoveCommand *moveCommand = new ModelMoveCommand(m_model, this);
@@ -1489,6 +1513,9 @@ void tst_QAbstractItemModel::testMoveToUncle()
     QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
     QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
 
+    QVERIFY(beforeSpy.isValid());
+    QVERIFY(afterSpy.isValid());
+
     ModelMoveCommand *moveCommand = new ModelMoveCommand(m_model, this);
     moveCommand->setAncestorRowNumbers(QList<int>() << 9);
     moveCommand->setNumCols(4);
@@ -1604,6 +1631,9 @@ void tst_QAbstractItemModel::testMoveToDescendants()
     QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
     QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
 
+    QVERIFY(beforeSpy.isValid());
+    QVERIFY(afterSpy.isValid());
+
     ModelMoveCommand *moveCommand;
     QList<int> ancestors;
     while (ancestors.size() < depth)
@@ -1670,6 +1700,9 @@ void tst_QAbstractItemModel::testMoveWithinOwnRange()
     QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
     QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
 
+    QVERIFY(beforeSpy.isValid());
+    QVERIFY(afterSpy.isValid());
+
     ModelMoveCommand *moveCommand = new ModelMoveCommand(m_model, this);
     moveCommand->setNumCols(4);
     moveCommand->setStartRow(startRow);
@@ -1755,6 +1788,8 @@ void tst_QAbstractItemModel::testReset()
     QSignalSpy beforeResetSpy(m_model, SIGNAL(modelAboutToBeReset()));
     QSignalSpy afterResetSpy(m_model, SIGNAL(modelReset()));
 
+    QVERIFY(beforeResetSpy.isValid());
+    QVERIFY(afterResetSpy.isValid());
 
     QSortFilterProxyModel *nullProxy = new QSortFilterProxyModel(this);
     nullProxy->setSourceModel(m_model);
@@ -1821,6 +1856,9 @@ void tst_QAbstractItemModel::testDataChanged()
     QSignalSpy withRoles(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QSet<int>)));
     QSignalSpy withoutRoles(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex)));
 
+    QVERIFY(withRoles.isValid());
+    QVERIFY(withoutRoles.isValid());
+
     model.emitSignals();
 
     QCOMPARE(withRoles.size(), withoutRoles.size());
@@ -1920,6 +1958,9 @@ void tst_QAbstractItemModel::testChildrenLayoutsChanged()
         QSignalSpy beforeSpy(&model, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)));
         QSignalSpy afterSpy(&model, SIGNAL(layoutChanged(QList<QPersistentModelIndex>)));
 
+        QVERIFY(beforeSpy.isValid());
+        QVERIFY(afterSpy.isValid());
+
         ModelChangeChildrenLayoutsCommand *changeCommand = new ModelChangeChildrenLayoutsCommand(&model, this);
         changeCommand->setAncestorRowNumbers(QList<int>() << 2);
         changeCommand->setSecondAncestorRowNumbers(QList<int>() << 5);
@@ -1984,6 +2025,9 @@ void tst_QAbstractItemModel::testChildrenLayoutsChanged()
         QSignalSpy beforeSpy(&model, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)));
         QSignalSpy afterSpy(&model, SIGNAL(layoutChanged(QList<QPersistentModelIndex>)));
 
+        QVERIFY(beforeSpy.isValid());
+        QVERIFY(afterSpy.isValid());
+
         // Because the arguments in the signal are persistent, we need to check them for the aboutToBe
         // case at emission time - before they get updated.
         SignalArgumentChecker checker(p1, p2);
index 86ff00f..2eb17c0 100644 (file)
@@ -169,6 +169,11 @@ void tst_QIdentityProxyModel::insertRows()
     QSignalSpy proxyBeforeSpy(m_proxy, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)));
     QSignalSpy proxyAfterSpy(m_proxy, SIGNAL(rowsInserted(QModelIndex,int,int)));
 
+    QVERIFY(modelBeforeSpy.isValid());
+    QVERIFY(modelAfterSpy.isValid());
+    QVERIFY(proxyBeforeSpy.isValid());
+    QVERIFY(proxyAfterSpy.isValid());
+
     QStandardItem *item = new QStandardItem(QString("new item"));
     parentItem->appendRow(item);
 
@@ -205,6 +210,11 @@ void tst_QIdentityProxyModel::removeRows()
     QSignalSpy proxyBeforeSpy(m_proxy, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)));
     QSignalSpy proxyAfterSpy(m_proxy, SIGNAL(rowsRemoved(QModelIndex,int,int)));
 
+    QVERIFY(modelBeforeSpy.isValid());
+    QVERIFY(modelAfterSpy.isValid());
+    QVERIFY(proxyBeforeSpy.isValid());
+    QVERIFY(proxyAfterSpy.isValid());
+
     const QModelIndex topLevel = m_model->index(0, 0, QModelIndex());
     const QModelIndex secondLevel = m_model->index(0, 0, topLevel);
     const QModelIndex thirdLevel = m_model->index(0, 0, secondLevel);
@@ -254,6 +264,11 @@ void tst_QIdentityProxyModel::moveRows()
     QSignalSpy proxyBeforeSpy(m_proxy, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
     QSignalSpy proxyAfterSpy(m_proxy, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)));
 
+    QVERIFY(modelBeforeSpy.isValid());
+    QVERIFY(modelAfterSpy.isValid());
+    QVERIFY(proxyBeforeSpy.isValid());
+    QVERIFY(proxyAfterSpy.isValid());
+
     {
         ModelMoveCommand moveCommand(&model, 0);
         moveCommand.setAncestorRowNumbers(QList<int>() << 5);
@@ -310,6 +325,11 @@ void tst_QIdentityProxyModel::reset()
     QSignalSpy proxyBeforeSpy(m_proxy, SIGNAL(modelAboutToBeReset()));
     QSignalSpy proxyAfterSpy(m_proxy, SIGNAL(modelReset()));
 
+    QVERIFY(modelBeforeSpy.isValid());
+    QVERIFY(modelAfterSpy.isValid());
+    QVERIFY(proxyBeforeSpy.isValid());
+    QVERIFY(proxyAfterSpy.isValid());
+
     {
         ModelResetCommandFixed resetCommand(&model, 0);
         resetCommand.setAncestorRowNumbers(QList<int>() << 5);
index 2097cb3..dedcd0f 100644 (file)
@@ -1550,6 +1550,7 @@ void tst_QItemSelectionModel::resetModel()
     view.setModel(&model);
 
     QSignalSpy spy(view.selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)));
+    QVERIFY(spy.isValid());
 
     view.selectionModel()->select(QItemSelection(model.index(0, 0), model.index(5, 5)), QItemSelectionModel::Select);
 
@@ -1612,6 +1613,7 @@ void tst_QItemSelectionModel::removeRows()
     MyStandardItemModel model(rowCount, columnCount);
     QItemSelectionModel selections(&model);
     QSignalSpy spy(&selections, SIGNAL(selectionChanged(QItemSelection,QItemSelection)));
+    QVERIFY(spy.isValid());
 
     QModelIndex tl = model.index(selectTop, selectLeft);
     QModelIndex br = model.index(selectBottom, selectRight);
@@ -1674,6 +1676,7 @@ void tst_QItemSelectionModel::removeColumns()
     MyStandardItemModel model(rowCount, columnCount);
     QItemSelectionModel selections(&model);
     QSignalSpy spy(&selections, SIGNAL(selectionChanged(QItemSelection,QItemSelection)));
+    QVERIFY(spy.isValid());
 
     QModelIndex tl = model.index(selectTop, selectLeft);
     QModelIndex br = model.index(selectBottom, selectRight);
@@ -1943,6 +1946,10 @@ void tst_QItemSelectionModel::setCurrentIndex()
     QSignalSpy columnSpy(selectionModel,
             SIGNAL(currentColumnChanged(QModelIndex,QModelIndex)));
 
+    QVERIFY(currentSpy.isValid());
+    QVERIFY(rowSpy.isValid());
+    QVERIFY(columnSpy.isValid());
+
     // Select the same row and column indexes, but with a different parent
     selectionModel->setCurrentIndex(
             treemodel->index(0, 0, treemodel->index(1, 0)),
@@ -2217,6 +2224,7 @@ void tst_QItemSelectionModel::task232634_childrenDeselectionSignal()
     selectionModel.select(sel, QItemSelectionModel::SelectCurrent);
 
     QSignalSpy deselectSpy(&selectionModel, SIGNAL(selectionChanged(const QItemSelection& , const QItemSelection&)));
+    QVERIFY(deselectSpy.isValid());
     model.removeRows(0, 1, root);
     QVERIFY(deselectSpy.count() == 1);
 
@@ -2401,6 +2409,7 @@ void tst_QItemSelectionModel::deselectRemovedMiddleRange()
     RemovalObserver ro(&selModel);
 
     QSignalSpy spy(&selModel, SIGNAL(selectionChanged(QItemSelection, QItemSelection)));
+    QVERIFY(spy.isValid());
     bool ok = model.removeRows(4, 2);
 
     QVERIFY(ok);
@@ -2735,6 +2744,7 @@ void tst_QItemSelectionModel::testClearCurrentIndex()
     QItemSelectionModel selectionModel(&model, 0);
 
     QSignalSpy currentIndexSpy(&selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex)));
+    QVERIFY(currentIndexSpy.isValid());
 
     QModelIndex firstIndex = model.index(0, 0);
     QVERIFY(firstIndex.isValid());
index cc8299e..6d3e890 100644 (file)
@@ -1504,6 +1504,7 @@ void tst_QSortFilterProxyModel::filterCurrent()
     view.show();
     view.setModel(&proxy);
     QSignalSpy spy(view.selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)));
+    QVERIFY(spy.isValid());
 
     view.setCurrentIndex(proxy.index(0, 0));
     QCOMPARE(spy.count(), 1);
@@ -1628,6 +1629,11 @@ void tst_QSortFilterProxyModel::removeSourceRows()
     QSignalSpy aboutToRemoveSpy(&proxy, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)));
     QSignalSpy aboutToInsertSpy(&proxy, SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int)));
 
+    QVERIFY(removeSpy.isValid());
+    QVERIFY(insertSpy.isValid());
+    QVERIFY(aboutToRemoveSpy.isValid());
+    QVERIFY(aboutToInsertSpy.isValid());
+
     model.removeRows(start, count, QModelIndex());
 
     QCOMPARE(aboutToRemoveSpy.count(), expectedRemovedProxyIntervals.count());
@@ -1802,6 +1808,9 @@ void tst_QSortFilterProxyModel::changeFilter()
     QSignalSpy initialRemoveSpy(&proxy, SIGNAL(rowsRemoved(QModelIndex, int, int)));
     QSignalSpy initialInsertSpy(&proxy, SIGNAL(rowsInserted(QModelIndex, int, int)));
 
+    QVERIFY(initialRemoveSpy.isValid());
+    QVERIFY(initialInsertSpy.isValid());
+
     proxy.setFilterRegExp(initialFilter);
 
     QCOMPARE(initialRemoveSpy.count(), initialRemoveIntervals.count());
@@ -1823,6 +1832,9 @@ void tst_QSortFilterProxyModel::changeFilter()
     QSignalSpy finalRemoveSpy(&proxy, SIGNAL(rowsRemoved(QModelIndex, int, int)));
     QSignalSpy finalInsertSpy(&proxy, SIGNAL(rowsInserted(QModelIndex, int, int)));
 
+    QVERIFY(finalRemoveSpy.isValid());
+    QVERIFY(finalInsertSpy.isValid());
+
     proxy.setFilterRegExp(finalFilter);
 
     QCOMPARE(finalRemoveSpy.count(), finalRemoveIntervals.count());
@@ -1971,6 +1983,9 @@ void tst_QSortFilterProxyModel::changeSourceData()
     QSignalSpy removeSpy(&proxy, SIGNAL(rowsRemoved(QModelIndex, int, int)));
     QSignalSpy insertSpy(&proxy, SIGNAL(rowsInserted(QModelIndex, int, int)));
 
+    QVERIFY(removeSpy.isValid());
+    QVERIFY(insertSpy.isValid());
+
     {
         QModelIndex index = model.index(row, 0, QModelIndex());
         model.setData(index, newValue, Qt::DisplayRole);
@@ -2065,6 +2080,7 @@ void tst_QSortFilterProxyModel::selectionFilteredOut()
     view.show();
     view.setModel(&proxy);
     QSignalSpy spy(view.selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)));
+    QVERIFY(spy.isValid());
 
     view.setCurrentIndex(proxy.index(0, 0));
     QCOMPARE(spy.count(), 1);
@@ -2181,6 +2197,9 @@ void tst_QSortFilterProxyModel::insertIntoChildrenlessItem()
     QSignalSpy colsInsertedSpy(&proxy, SIGNAL(columnsInserted(const QModelIndex&, int, int)));
     QSignalSpy rowsInsertedSpy(&proxy, SIGNAL(rowsInserted(const QModelIndex&, int, int)));
 
+    QVERIFY(colsInsertedSpy.isValid());
+    QVERIFY(rowsInsertedSpy.isValid());
+
     (void)proxy.rowCount(QModelIndex()); // force mapping of "a", "b", "c"
     QCOMPARE(colsInsertedSpy.count(), 0);
     QCOMPARE(rowsInsertedSpy.count(), 0);
@@ -2256,6 +2275,7 @@ void tst_QSortFilterProxyModel::insertRowIntoFilteredParent()
     proxy.setSourceModel(&model);
 
     QSignalSpy spy(&proxy, SIGNAL(rowsInserted(const QModelIndex&, int, int)));
+    QVERIFY(spy.isValid());
 
     QStandardItem *itemA = new QStandardItem();
     model.appendRow(itemA); // A will be filtered
@@ -2286,6 +2306,9 @@ void tst_QSortFilterProxyModel::filterOutParentAndFilterInChild()
     QSignalSpy removedSpy(&proxy, SIGNAL(rowsRemoved(const QModelIndex&, int, int)));
     QSignalSpy insertedSpy(&proxy, SIGNAL(rowsInserted(const QModelIndex&, int, int)));
 
+    QVERIFY(removedSpy.isValid());
+    QVERIFY(insertedSpy.isValid());
+
     proxy.setFilterRegExp("C"); // A and B will be filtered out, C filtered in
 
     // we should now have been notified that the subtree represented by itemA has been removed
@@ -2882,6 +2905,9 @@ void tst_QSortFilterProxyModel::taskQTBUG_7537_appearsAndSort()
     QSignalSpy spyAbout1(&proxyModel, SIGNAL(layoutAboutToBeChanged()));
     QSignalSpy spyChanged1(&proxyModel, SIGNAL(layoutChanged()));
 
+    QVERIFY(spyAbout1.isValid());
+    QVERIFY(spyChanged1.isValid());
+
     //introducing secondProxyModel to test the layoutChange when many items appears at once
     QSortFilterProxyModel secondProxyModel;
     secondProxyModel.setSourceModel(&proxyModel);
@@ -2891,6 +2917,9 @@ void tst_QSortFilterProxyModel::taskQTBUG_7537_appearsAndSort()
     QSignalSpy spyAbout2(&secondProxyModel, SIGNAL(layoutAboutToBeChanged()));
     QSignalSpy spyChanged2(&secondProxyModel, SIGNAL(layoutChanged()));
 
+    QVERIFY(spyAbout2.isValid());
+    QVERIFY(spyChanged2.isValid());
+
     proxyModel.updateXX();
     QApplication::processEvents();
     //now rows should be visible, and sorted
@@ -3248,16 +3277,27 @@ void tst_QSortFilterProxyModel::testParentLayoutChanged()
 
     QSignalSpy dataChangedSpy(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex)));
 
+    QVERIFY(dataChangedSpy.isValid());
+
     // Verify that the no-arg signal is still emitted.
     QSignalSpy layoutAboutToBeChangedSpy(&proxy, SIGNAL(layoutAboutToBeChanged()));
     QSignalSpy layoutChangedSpy(&proxy, SIGNAL(layoutChanged()));
 
+    QVERIFY(layoutAboutToBeChangedSpy.isValid());
+    QVERIFY(layoutChangedSpy.isValid());
+
     QSignalSpy parentsAboutToBeChangedSpy(&proxy, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)));
     QSignalSpy parentsChangedSpy(&proxy, SIGNAL(layoutChanged(QList<QPersistentModelIndex>)));
 
+    QVERIFY(parentsAboutToBeChangedSpy.isValid());
+    QVERIFY(parentsChangedSpy.isValid());
+
     QSignalSpy proxy2ParentsAboutToBeChangedSpy(&proxy2, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)));
     QSignalSpy proxy2ParentsChangedSpy(&proxy2, SIGNAL(layoutChanged(QList<QPersistentModelIndex>)));
 
+    QVERIFY(proxy2ParentsAboutToBeChangedSpy.isValid());
+    QVERIFY(proxy2ParentsChangedSpy.isValid());
+
     QStandardItem *item = model.invisibleRootItem()->child(1)->child(1);
 
     // Ensure mapped:
@@ -3426,6 +3466,17 @@ void tst_QSortFilterProxyModel::moveSourceRows()
     QSignalSpy filterBothBeforeParentLayoutSpy(&filterBothProxy, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)));
     QSignalSpy filterBothAfterParentLayoutSpy(&filterBothProxy, SIGNAL(layoutChanged(QList<QPersistentModelIndex>)));
 
+    QVERIFY(modelBeforeSpy.isValid());
+    QVERIFY(modelAfterSpy.isValid());
+    QVERIFY(proxyBeforeMoveSpy.isValid());
+    QVERIFY(proxyAfterMoveSpy.isValid());
+    QVERIFY(proxyBeforeParentLayoutSpy.isValid());
+    QVERIFY(proxyAfterParentLayoutSpy.isValid());
+    QVERIFY(filterBeforeParentLayoutSpy.isValid());
+    QVERIFY(filterAfterParentLayoutSpy.isValid());
+    QVERIFY(filterBothBeforeParentLayoutSpy.isValid());
+    QVERIFY(filterBothAfterParentLayoutSpy.isValid());
+
     {
         ModelMoveCommand moveCommand(&model, 0);
         moveCommand.setAncestorRowNumbers(QList<int>() << 2);
index f48a8eb..a2673ab 100644 (file)
@@ -203,6 +203,9 @@ void tst_QEventLoop::processEvents()
     QSignalSpy spy1(QAbstractEventDispatcher::instance(), SIGNAL(aboutToBlock()));
     QSignalSpy spy2(QAbstractEventDispatcher::instance(), SIGNAL(awake()));
 
+    QVERIFY(spy1.isValid());
+    QVERIFY(spy2.isValid());
+
     QEventLoop eventLoop;
 
     QCoreApplication::postEvent(&eventLoop, new QEvent(QEvent::User));
@@ -285,6 +288,7 @@ void tst_QEventLoop::exec()
 
         // make sure the eventloop runs
         QSignalSpy spy(QAbstractEventDispatcher::instance(&thread), SIGNAL(awake()));
+        QVERIFY(spy.isValid());
         thread.cond.wakeOne();
         thread.cond.wait(&thread.mutex);
         QVERIFY(spy.count() > 0);
@@ -396,6 +400,7 @@ void tst_QEventLoop::wakeUp()
     (void) eventLoop.exec();
 
     QSignalSpy spy(QAbstractEventDispatcher::instance(&thread), SIGNAL(awake()));
+    QVERIFY(spy.isValid());
     thread.eventLoop->wakeUp();
 
     // give the thread time to wake up
index a4b1044..3f68379 100644 (file)
@@ -601,6 +601,7 @@ void tst_QItemModel::setData()
     QVERIFY(currentModel);
     qRegisterMetaType<QModelIndex>("QModelIndex");
     QSignalSpy spy(currentModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)));
+    QVERIFY(spy.isValid());
     QCOMPARE(currentModel->setData(QModelIndex(), QVariant()), false);
     QCOMPARE(spy.count(), 0);
 
@@ -662,6 +663,7 @@ void tst_QItemModel::setHeaderData()
 
     qRegisterMetaType<Qt::Orientation>("Qt::Orientation");
     QSignalSpy spy(currentModel, SIGNAL(headerDataChanged( Qt::Orientation, int , int )));
+    QVERIFY(spy.isValid());
 
     QString text = "Index private pointers should always be the same";
     int signalCount = 0;
@@ -702,6 +704,7 @@ void tst_QItemModel::sort()
     QModelIndex index = currentModel->index(0, 0, topIndex);
     QVERIFY(index.isValid());
     QSignalSpy spy(currentModel, SIGNAL(layoutChanged()));
+    QVERIFY(spy.isValid());
     for (int i=-1; i < 10; ++i){
         currentModel->sort(i);
         if (index != currentModel->index(0, 0, topIndex)){
@@ -846,6 +849,13 @@ void tst_QItemModel::remove()
     QSignalSpy modelResetSpy(currentModel, SIGNAL(modelReset()));
     QSignalSpy modelLayoutChangedSpy(currentModel, SIGNAL(layoutChanged()));
 
+    QVERIFY(columnsAboutToBeRemovedSpy.isValid());
+    QVERIFY(rowsAboutToBeRemovedSpy.isValid());
+    QVERIFY(columnsRemovedSpy.isValid());
+    QVERIFY(rowsRemovedSpy.isValid());
+    QVERIFY(modelResetSpy.isValid());
+    QVERIFY(modelLayoutChangedSpy.isValid());
+
     QFETCH(int, numberOfRowsAboutToBeRemovedSignals);
     QFETCH(int, numberOfColumnsAboutToBeRemovedSignals);
     QFETCH(int, numberOfRowsRemovedSignals);
@@ -1182,6 +1192,13 @@ void tst_QItemModel::insert()
     QSignalSpy modelResetSpy(currentModel, SIGNAL(modelReset()));
     QSignalSpy modelLayoutChangedSpy(currentModel, SIGNAL(layoutChanged()));
 
+    QVERIFY(columnsAboutToBeInsertedSpy.isValid());
+    QVERIFY(rowsAboutToBeInsertedSpy.isValid());
+    QVERIFY(columnsInsertedSpy.isValid());
+    QVERIFY(rowsInsertedSpy.isValid());
+    QVERIFY(modelResetSpy.isValid());
+    QVERIFY(modelLayoutChangedSpy.isValid());
+
     QFETCH(int, numberOfRowsAboutToBeInsertedSignals);
     QFETCH(int, numberOfColumnsAboutToBeInsertedSignals);
     QFETCH(int, numberOfRowsInsertedSignals);
index 32d0ccf..f08bdd8 100644 (file)
@@ -796,6 +796,7 @@ void tst_QMetaObject::invokeTypedefTypes()
     qRegisterMetaType<CustomString>("CustomString");
     QtTestCustomObject obj;
     QSignalSpy spy(&obj, SIGNAL(sig_custom(CustomString)));
+    QVERIFY(spy.isValid());
 
     QCOMPARE(spy.count(), 0);
     CustomString arg("hello");
index 90c537b..31b6c2c 100644 (file)
@@ -263,12 +263,15 @@ void tst_QSocketNotifier::posixSockets()
         QSocketNotifier rn(posixSocket, QSocketNotifier::Read);
         connect(&rn, SIGNAL(activated(int)), &QTestEventLoop::instance(), SLOT(exitLoop()));
         QSignalSpy readSpy(&rn, SIGNAL(activated(int)));
+        QVERIFY(readSpy.isValid());
         QSocketNotifier wn(posixSocket, QSocketNotifier::Write);
         connect(&wn, SIGNAL(activated(int)), &QTestEventLoop::instance(), SLOT(exitLoop()));
         QSignalSpy writeSpy(&wn, SIGNAL(activated(int)));
+        QVERIFY(writeSpy.isValid());
         QSocketNotifier en(posixSocket, QSocketNotifier::Exception);
         connect(&en, SIGNAL(activated(int)), &QTestEventLoop::instance(), SLOT(exitLoop()));
         QSignalSpy errorSpy(&en, SIGNAL(activated(int)));
+        QVERIFY(errorSpy.isValid());
 
         passive->write("hello",6);
         passive->waitForBytesWritten(5000);
index c143977..2852f9b 100644 (file)
@@ -229,6 +229,8 @@ void tst_QPluginLoader::deleteinstanceOnUnload()
 
         QSignalSpy spy1(loader1.instance(), SIGNAL(destroyed()));
         QSignalSpy spy2(loader2.instance(), SIGNAL(destroyed()));
+        QVERIFY(spy1.isValid());
+        QVERIFY(spy2.isValid());
         if (pass == 0) {
             QCOMPARE(loader2.unload(), false);  // refcount not reached 0, not really unloaded
             QCOMPARE(spy1.count(), 0);
index bdb261e..773b1ff 100644 (file)
@@ -873,6 +873,7 @@ void tst_QStateMachine::historyStateAfterRestart()
 
     for (int x = 0; x < 2; ++x) {
         QSignalSpy startedSpy(&machine, SIGNAL(started()));
+        QVERIFY(startedSpy.isValid());
         machine.start();
         QTRY_COMPARE(startedSpy.count(), 1);
         QCOMPARE(machine.configuration().count(), 1);
@@ -908,6 +909,7 @@ void tst_QStateMachine::historyStateAfterRestart()
         QVERIFY(machine.configuration().contains(s22));
 
         QSignalSpy stoppedSpy(&machine, SIGNAL(stopped()));
+        QVERIFY(stoppedSpy.isValid());
         machine.stop();
         QTRY_COMPARE(stoppedSpy.count(), 1);
     }
@@ -1189,6 +1191,11 @@ void tst_QStateMachine::stateEntryAndExit()
         QSignalSpy startedSpy(&machine, SIGNAL(started()));
         QSignalSpy stoppedSpy(&machine, SIGNAL(stopped()));
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+
+        QVERIFY(startedSpy.isValid());
+        QVERIFY(stoppedSpy.isValid());
+        QVERIFY(finishedSpy.isValid());
+
         machine.setInitialState(s1);
         QCOMPARE(machine.initialState(), (QAbstractState*)s1);
         {
@@ -1206,6 +1213,13 @@ void tst_QStateMachine::stateEntryAndExit()
         QSignalSpy tTriggeredSpy(t, SIGNAL(triggered()));
         QSignalSpy s2EnteredSpy(s2, SIGNAL(entered()));
         QSignalSpy s2ExitedSpy(s2, SIGNAL(exited()));
+
+        QVERIFY(s1EnteredSpy.isValid());
+        QVERIFY(s1ExitedSpy.isValid());
+        QVERIFY(tTriggeredSpy.isValid());
+        QVERIFY(s2EnteredSpy.isValid());
+        QVERIFY(s2ExitedSpy.isValid());
+
         machine.start();
 
         QTRY_COMPARE(startedSpy.count(), 1);
@@ -1256,6 +1270,8 @@ void tst_QStateMachine::stateEntryAndExit()
 
         QSignalSpy startedSpy(&machine, SIGNAL(started()));
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(startedSpy.isValid());
+        QVERIFY(finishedSpy.isValid());
         machine.setInitialState(s1);
         globalTick = 0;
         machine.start();
@@ -1329,6 +1345,7 @@ void tst_QStateMachine::assignProperty()
 
     {
         QSignalSpy propertiesAssignedSpy(s1, SIGNAL(propertiesAssigned()));
+        QVERIFY(propertiesAssignedSpy.isValid());
         machine.start();
         QTRY_COMPARE(propertiesAssignedSpy.count(), 1);
     }
@@ -1384,6 +1401,7 @@ void tst_QStateMachine::assignPropertyWithAnimation()
 
         machine.setInitialState(s1);
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(finishedSpy.isValid());
         machine.start();
         QTRY_COMPARE(finishedSpy.count(), 1);
         QCOMPARE(obj.property("foo").toInt(), 456);
@@ -1412,6 +1430,7 @@ void tst_QStateMachine::assignPropertyWithAnimation()
 
         machine.setInitialState(s1);
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(finishedSpy.isValid());
         machine.start();
         QTRY_COMPARE(finishedSpy.count(), 1);
         QCOMPARE(obj.property("foo").toInt(), 456);
@@ -1440,6 +1459,7 @@ void tst_QStateMachine::assignPropertyWithAnimation()
 
         machine.setInitialState(s1);
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(finishedSpy.isValid());
         machine.start();
         QTRY_COMPARE(finishedSpy.count(), 1);
         QCOMPARE(obj.property("foo").toInt(), 456);
@@ -1489,6 +1509,7 @@ void tst_QStateMachine::assignPropertyWithAnimation()
 
         machine.setInitialState(s1);
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(finishedSpy.isValid());
         machine.start();
         QTRY_COMPARE(finishedSpy.count(), 1);
         QCOMPARE(obj.property("foo").toInt(), 321);
@@ -1523,6 +1544,7 @@ void tst_QStateMachine::assignPropertyWithAnimation()
         machine.start();
         QTRY_COMPARE(machine.configuration().contains(s1), true);
         QSignalSpy propertiesAssignedSpy(s2, SIGNAL(propertiesAssigned()));
+        QVERIFY(propertiesAssignedSpy.isValid());
         emitter.emitSignalWithNoArg();
         QTRY_COMPARE(machine.configuration().contains(s2), true);
         QVERIFY(propertiesAssignedSpy.isEmpty());
@@ -1610,6 +1632,7 @@ void tst_QStateMachine::postEvent()
         machine.addState(s2);
         machine.setInitialState(s1);
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(finishedSpy.isValid());
         machine.start();
         QTRY_COMPARE(finishedSpy.count(), 1);
         QCOMPARE(machine.configuration().size(), 1);
@@ -1639,6 +1662,7 @@ void tst_QStateMachine::cancelDelayedEvent()
     machine.setInitialState(s1);
 
     QSignalSpy startedSpy(&machine, SIGNAL(started()));
+    QVERIFY(startedSpy.isValid());
     machine.start();
     QTRY_COMPARE(startedSpy.count(), 1);
     QCOMPARE(machine.configuration().size(), 1);
@@ -1658,6 +1682,7 @@ void tst_QStateMachine::cancelDelayedEvent()
     QVERIFY(!machine.cancelDelayedEvent(id2));
 
     QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+    QVERIFY(finishedSpy.isValid());
     QTRY_COMPARE(finishedSpy.count(), 1);
     QCOMPARE(machine.configuration().size(), 1);
     QVERIFY(machine.configuration().contains(s2));
@@ -1672,6 +1697,7 @@ void tst_QStateMachine::postDelayedEventAndStop()
     machine.setInitialState(s1);
 
     QSignalSpy startedSpy(&machine, SIGNAL(started()));
+    QVERIFY(startedSpy.isValid());
     machine.start();
     QTRY_COMPARE(startedSpy.count(), 1);
     QCOMPARE(machine.configuration().size(), 1);
@@ -1680,6 +1706,7 @@ void tst_QStateMachine::postDelayedEventAndStop()
     int id1 = machine.postDelayedEvent(new StringEvent("a"), 0);
     QVERIFY(id1 != -1);
     QSignalSpy stoppedSpy(&machine, SIGNAL(stopped()));
+    QVERIFY(stoppedSpy.isValid());
     machine.stop();
     QTRY_COMPARE(stoppedSpy.count(), 1);
     QCOMPARE(machine.configuration().size(), 1);
@@ -1707,9 +1734,11 @@ void tst_QStateMachine::stopAndPostEvent()
     QState *s1 = new QState(&machine);
     machine.setInitialState(s1);
     QSignalSpy startedSpy(&machine, SIGNAL(started()));
+    QVERIFY(startedSpy.isValid());
     machine.start();
     QTRY_COMPARE(startedSpy.count(), 1);
     QSignalSpy stoppedSpy(&machine, SIGNAL(stopped()));
+    QVERIFY(stoppedSpy.isValid());
     machine.stop();
     QCOMPARE(stoppedSpy.count(), 0);
     machine.postEvent(new QEvent(QEvent::User));
@@ -1729,6 +1758,7 @@ void tst_QStateMachine::stateFinished()
     s1->addTransition(s1, SIGNAL(finished()), s2);
     machine.setInitialState(s1);
     QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+    QVERIFY(finishedSpy.isValid());
     machine.start();
     QTRY_COMPARE(finishedSpy.count(), 1);
     QCOMPARE(machine.configuration().size(), 1);
@@ -1766,6 +1796,7 @@ void tst_QStateMachine::parallelStates()
 
     machine.setInitialState(s1);
     QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+    QVERIFY(finishedSpy.isValid());
     machine.start();
     QTRY_COMPARE(finishedSpy.count(), 1);
     QCOMPARE(machine.configuration().size(), 1);
@@ -1788,6 +1819,7 @@ void tst_QStateMachine::parallelRootState()
     s2->setInitialState(s2_f);
 
     QSignalSpy startedSpy(&machine, SIGNAL(started()));
+    QVERIFY(startedSpy.isValid());
     QTest::ignoreMessage(QtWarningMsg, "QStateMachine::start: No initial state set for machine. Refusing to start.");
     machine.start();
     QCoreApplication::processEvents();
@@ -1833,6 +1865,7 @@ void tst_QStateMachine::allSourceToTargetConfigurations()
     s0->addTransition(new StringTransition("e", s211));
 
     QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+    QVERIFY(finishedSpy.isValid());
     machine.setInitialState(s0);
     machine.start();
     QCoreApplication::processEvents();
@@ -1919,6 +1952,7 @@ void tst_QStateMachine::signalTransitions()
         QCOMPARE(trans->signal(), QByteArray(SIGNAL(signalWithNoArg())));
 
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(finishedSpy.isValid());
         machine.setInitialState(s0);
         machine.start();
         QCoreApplication::processEvents();
@@ -1969,6 +2003,7 @@ void tst_QStateMachine::signalTransitions()
         QCOMPARE(trans->signal(), QByteArray("signalWithNoArg()"));
 
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(finishedSpy.isValid());
         machine.setInitialState(s0);
         machine.start();
         QCoreApplication::processEvents();
@@ -1993,6 +2028,7 @@ void tst_QStateMachine::signalTransitions()
         s0->addTransition(trans);
 
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(finishedSpy.isValid());
         machine.setInitialState(s0);
         machine.start();
         QCoreApplication::processEvents();
@@ -2014,6 +2050,7 @@ void tst_QStateMachine::signalTransitions()
         s0->addTransition(trans);
 
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(finishedSpy.isValid());
         machine.setInitialState(s0);
         machine.start();
         QCoreApplication::processEvents();
@@ -2045,6 +2082,7 @@ void tst_QStateMachine::signalTransitions()
         s0->addTransition(trans);
 
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(finishedSpy.isValid());
         machine.setInitialState(s0);
         machine.start();
         QCoreApplication::processEvents();
@@ -2063,6 +2101,7 @@ void tst_QStateMachine::signalTransitions()
         QSignalTransition *t1 = s1->addTransition(&emitter, SIGNAL(signalWithNoArg()), s0);
 
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(finishedSpy.isValid());
         machine.setInitialState(s0);
         machine.start();
         QCoreApplication::processEvents();
@@ -2112,6 +2151,8 @@ void tst_QStateMachine::signalTransitions()
 
         QSignalSpy startedSpy(&machine, SIGNAL(started()));
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(startedSpy.isValid());
+        QVERIFY(finishedSpy.isValid());
         machine.setInitialState(s0);
 
         machine.start();
@@ -2151,6 +2192,8 @@ void tst_QStateMachine::signalTransitions()
 
         QSignalSpy startedSpy(&machine, SIGNAL(started()));
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(startedSpy.isValid());
+        QVERIFY(finishedSpy.isValid());
         machine.setInitialState(s0);
         machine.start();
         QTRY_COMPARE(startedSpy.count(), 1);
@@ -2212,6 +2255,7 @@ void tst_QStateMachine::eventTransitions()
         s0->addTransition(trans);
 
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(finishedSpy.isValid());
         machine.setInitialState(s0);
         machine.start();
         QCoreApplication::processEvents();
@@ -2264,6 +2308,7 @@ void tst_QStateMachine::eventTransitions()
         s0->addTransition(trans);
 
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(finishedSpy.isValid());
         machine.setInitialState(s0);
         machine.start();
         QCoreApplication::processEvents();
@@ -2289,6 +2334,7 @@ void tst_QStateMachine::eventTransitions()
         s0->addTransition(trans);
 
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(finishedSpy.isValid());
         machine.setInitialState(s0);
         machine.start();
         QCoreApplication::processEvents();
@@ -2311,6 +2357,7 @@ void tst_QStateMachine::eventTransitions()
         s0->addTransition(trans);
 
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(finishedSpy.isValid());
         machine.setInitialState(s0);
         machine.start();
         QCoreApplication::processEvents();
@@ -2336,6 +2383,7 @@ void tst_QStateMachine::eventTransitions()
         s0->addTransition(trans);
 
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(finishedSpy.isValid());
         machine.setInitialState(s0);
         machine.start();
         QCoreApplication::processEvents();
@@ -2358,6 +2406,7 @@ void tst_QStateMachine::eventTransitions()
         s1->addTransition(t1);
 
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(finishedSpy.isValid());
         machine.setInitialState(s0);
         machine.start();
         QCoreApplication::processEvents();
@@ -2408,6 +2457,8 @@ void tst_QStateMachine::eventTransitions()
 
         QSignalSpy startedSpy(&machine, SIGNAL(started()));
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(startedSpy.isValid());
+        QVERIFY(finishedSpy.isValid());
         machine.setInitialState(s0);
 
         machine.start();
@@ -2435,6 +2486,7 @@ void tst_QStateMachine::eventTransitions()
         s0->addTransition(trans);
 
         QSignalSpy startedSpy(&machine, SIGNAL(started()));
+        QVERIFY(startedSpy.isValid());
         machine.setInitialState(s0);
         machine.start();
         QTest::ignoreMessage(QtWarningMsg, "QObject event transitions are not supported for custom types");
@@ -2452,6 +2504,7 @@ void tst_QStateMachine::eventTransitions()
         QCOMPARE(trans->eventTypeReceived(), QEvent::None);
 
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(finishedSpy.isValid());
         machine.setInitialState(s0);
         machine.start();
         QCoreApplication::processEvents();
@@ -2481,6 +2534,8 @@ void tst_QStateMachine::graphicsSceneEventTransitions()
 
     QSignalSpy startedSpy(&machine, SIGNAL(started()));
     QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+    QVERIFY(startedSpy.isValid());
+    QVERIFY(finishedSpy.isValid());
     machine.start();
     QTRY_COMPARE(startedSpy.count(), 1);
     QVERIFY(finishedSpy.count() == 0);
@@ -2527,6 +2582,7 @@ void tst_QStateMachine::historyStates()
         s0->setInitialState(s00);
 
         QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+        QVERIFY(finishedSpy.isValid());
         machine.start();
         QCoreApplication::processEvents();
         QCOMPARE(machine.configuration().size(), 2);
@@ -2565,6 +2621,11 @@ void tst_QStateMachine::startAndStop()
     QSignalSpy startedSpy(&machine, SIGNAL(started()));
     QSignalSpy stoppedSpy(&machine, SIGNAL(stopped()));
     QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+
+    QVERIFY(startedSpy.isValid());
+    QVERIFY(stoppedSpy.isValid());
+    QVERIFY(finishedSpy.isValid());
+
     QVERIFY(!machine.isRunning());
     QTest::ignoreMessage(QtWarningMsg, "QStateMachine::start: No initial state set for machine. Refusing to start.");
     machine.start();
@@ -2616,6 +2677,11 @@ void tst_QStateMachine::targetStateWithNoParent()
     QSignalSpy startedSpy(&machine, SIGNAL(started()));
     QSignalSpy stoppedSpy(&machine, SIGNAL(stopped()));
     QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+
+    QVERIFY(startedSpy.isValid());
+    QVERIFY(stoppedSpy.isValid());
+    QVERIFY(finishedSpy.isValid());
+
     machine.start();
     QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: No common ancestor for targets and source of transition from state 's1'");
     QTRY_COMPARE(startedSpy.count(), 1);
@@ -3045,12 +3111,14 @@ void tst_QStateMachine::propertiesAssignedSignalTransitionsReuseAnimationGroup()
     QParallelAnimationGroup animationGroup;
     animationGroup.addAnimation(new QPropertyAnimation(object, "foo"));
     QSignalSpy animationFinishedSpy(&animationGroup, SIGNAL(finished()));
+    QVERIFY(animationFinishedSpy.isValid());
     s1->addTransition(s1, SIGNAL(propertiesAssigned()), s2)->addAnimation(&animationGroup);
     s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3)->addAnimation(&animationGroup);
     s3->addTransition(s3, SIGNAL(propertiesAssigned()), s4);
 
     machine.setInitialState(s1);
     QSignalSpy machineFinishedSpy(&machine, SIGNAL(finished()));
+    QVERIFY(machineFinishedSpy.isValid());
     machine.start();
     QTRY_COMPARE(machineFinishedSpy.count(), 1);
     QCOMPARE(machine.configuration().size(), 1);
@@ -3551,6 +3619,8 @@ void tst_QStateMachine::nestedStateMachines()
 
     QSignalSpy startedSpy(&machine, SIGNAL(started()));
     QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+    QVERIFY(startedSpy.isValid());
+    QVERIFY(finishedSpy.isValid());
     machine.start();
     QTRY_COMPARE(startedSpy.count(), 1);
     QTRY_COMPARE(machine.configuration().count(), 1+2*3);
@@ -3573,6 +3643,7 @@ void tst_QStateMachine::goToState()
     QState *s2 = new QState(&machine);
     machine.setInitialState(s1);
     QSignalSpy startedSpy(&machine, SIGNAL(started()));
+    QVERIFY(startedSpy.isValid());
     machine.start();
     QTRY_COMPARE(startedSpy.count(), 1);
 
@@ -3615,6 +3686,7 @@ void tst_QStateMachine::goToStateFromSourceWithTransition()
     QState *s2 = new QState(&machine);
     machine.setInitialState(s1);
     QSignalSpy startedSpy(&machine, SIGNAL(started()));
+    QVERIFY(startedSpy.isValid());
     machine.start();
     QTRY_COMPARE(startedSpy.count(), 1);
 
@@ -3704,6 +3776,7 @@ void tst_QStateMachine::postEventFromOtherThread()
     poster.start();
 
     QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+    QVERIFY(finishedSpy.isValid());
     machine.start();
     QTRY_COMPARE(finishedSpy.count(), 1);
 }
@@ -3759,6 +3832,9 @@ void tst_QStateMachine::stopInTransitionToFinalState()
     QSignalSpy stoppedSpy(&machine, SIGNAL(stopped()));
     QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
     QSignalSpy s2EnteredSpy(s2, SIGNAL(entered()));
+    QVERIFY(stoppedSpy.isValid());
+    QVERIFY(finishedSpy.isValid());
+    QVERIFY(s2EnteredSpy.isValid());
     machine.start();
 
     // Stopping should take precedence over finished.
@@ -3799,11 +3875,14 @@ void tst_QStateMachine::stopInEventTest()
     machine.setInitialState(s1);
 
     QSignalSpy startedSpy(&machine, SIGNAL(started()));
+    QVERIFY(startedSpy.isValid());
     machine.start();
     QTRY_COMPARE(startedSpy.count(), 1);
 
     QSignalSpy stoppedSpy(&machine, SIGNAL(stopped()));
     QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+    QVERIFY(stoppedSpy.isValid());
+    QVERIFY(finishedSpy.isValid());
     machine.postEvent(new QEvent(QEvent::User), QStateMachine::EventPriority(eventPriority));
 
     QTRY_COMPARE(stoppedSpy.count(), 1);
index 0bc1352..3f994b5 100644 (file)
@@ -102,6 +102,7 @@ void tst_QTimeLine::range()
     // Verify that you can change the range in the timeLine
     timeLine.setFrameRange(10, 20);
     QSignalSpy spy(&timeLine, SIGNAL(frameChanged(int)));
+    QVERIFY(spy.isValid());
     timeLine.start();
 #ifdef Q_OS_WINCE
     QTest::qWait(1000);
@@ -131,6 +132,7 @@ void tst_QTimeLine::currentTime()
     timeLine.setUpdateInterval((timeLine.duration()/2) / 33);
     qRegisterMetaType<qreal>("qreal");
     QSignalSpy spy(&timeLine, SIGNAL(valueChanged(qreal)));
+    QVERIFY(spy.isValid());
     timeLine.setFrameRange(10, 20);
     QCOMPARE(timeLine.currentTime(), 0);
     timeLine.start();
@@ -200,6 +202,7 @@ void tst_QTimeLine::frameRate()
     // Default speed
     timeLine.setUpdateInterval(1000 / 33);
     QSignalSpy spy(&timeLine, SIGNAL(frameChanged(int)));
+    QVERIFY(spy.isValid());
     timeLine.start();
     QTest::qWait(timeLine.duration()*2);
     QCOMPARE(timeLine.state(), QTimeLine::NotRunning);
@@ -223,6 +226,7 @@ void tst_QTimeLine::value()
     // Default speed
     qRegisterMetaType<qreal>("qreal");
     QSignalSpy spy(&timeLine, SIGNAL(valueChanged(qreal)));
+    QVERIFY(spy.isValid());
     timeLine.start();
     QTest::qWait(timeLine.duration()/3);
     QVERIFY(timeLine.currentValue() > 0);
@@ -253,6 +257,7 @@ void tst_QTimeLine::currentFrame()
 
     // Default speed
     QSignalSpy spy(&timeLine, SIGNAL(frameChanged(int)));
+    QVERIFY(spy.isValid());
     timeLine.start();
     QTest::qWait(timeLine.duration()/3);
     QVERIFY(timeLine.currentFrame() > 10);
@@ -284,6 +289,7 @@ void tst_QTimeLine::loopCount()
 
     // Default speed infiniti looping
     QSignalSpy spy(&timeLine, SIGNAL(frameChanged(int)));
+    QVERIFY(spy.isValid());
     timeLine.start();
     QTest::qWait(timeLine.duration());
     QCOMPARE(timeLine.state(), QTimeLine::Running);
@@ -302,6 +308,8 @@ void tst_QTimeLine::loopCount()
 
     QSignalSpy finishedSpy(&timeLine, SIGNAL(finished()));
     QSignalSpy frameChangedSpy(&timeLine, SIGNAL(frameChanged(int)));
+    QVERIFY(finishedSpy.isValid());
+    QVERIFY(frameChangedSpy.isValid());
     QEventLoop loop;
     connect(&timeLine, SIGNAL(finished()), &loop, SLOT(quit()));
 
@@ -451,6 +459,7 @@ void tst_QTimeLine::frameChanged()
     timeLine.setFrameRange(0,9);
     timeLine.setUpdateInterval(1000);
     QSignalSpy spy(&timeLine, SIGNAL(frameChanged(int)));
+    QVERIFY(spy.isValid());
     timeLine.start();
     QTest::qWait(timeLine.duration()*2);
     QCOMPARE(timeLine.state(), QTimeLine::NotRunning);
@@ -473,6 +482,7 @@ void tst_QTimeLine::stopped()
     timeLine.setFrameRange(0, 9);
     qRegisterMetaType<QTimeLine::State>("QTimeLine::State");
     QSignalSpy spy(&timeLine, SIGNAL(stateChanged(QTimeLine::State)));
+    QVERIFY(spy.isValid());
     timeLine.start();
     QTest::qWait(timeLine.duration()*2);
     QCOMPARE(timeLine.state(), QTimeLine::NotRunning);
@@ -490,6 +500,7 @@ void tst_QTimeLine::finished()
     QTimeLine timeLine;
     timeLine.setFrameRange(0,9);
     QSignalSpy spy(&timeLine, SIGNAL(finished()));
+    QVERIFY(spy.isValid());
     timeLine.start();
     QTest::qWait(timeLine.duration()*2);
     QCOMPARE(timeLine.state(), QTimeLine::NotRunning);
@@ -522,6 +533,7 @@ void tst_QTimeLine::multipleTimeLines()
     QTimeLine timeLine(200);
     timeLine.setFrameRange(0,99);
     QSignalSpy spy(&timeLine, SIGNAL(finished()));
+    QVERIFY(spy.isValid());
 
     QTimeLine timeLineKiller;
     timeLineKiller.setFrameRange(0,99);