summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2011-12-22 17:16:48 +1000
committerQt by Nokia <qt-info@nokia.com>2011-12-28 04:48:11 +0100
commitea415e20607016651f3cef02dff109235d84eb4d (patch)
tree8c954afe7d078b0ca742a1f2249ccc5a9ddf1b82 /tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
parent1e7296f3f2e7346f52e8f70d4e531405a248aa8b (diff)
Cleanup corelib autotests.
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>
Diffstat (limited to 'tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp')
-rw-r--r--tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
index 51b7359980..61fd31ca69 100644
--- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
+++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -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);