From 285d4b12cb937a5672d6eb15781f03d249f8cfc1 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 17 Aug 2009 17:13:56 +0200 Subject: Add autotest to make sure we receive the QVariantAnimation::valueChanged Reviewed-by: ogoffart --- .../qpropertyanimation/tst_qpropertyanimation.cpp | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index 5af6f39..3ff177a 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -113,6 +113,7 @@ private slots: void oneKeyValue(); void updateOnSetKeyValues(); void restart(); + void valueChanged(); }; tst_QPropertyAnimation::tst_QPropertyAnimation() @@ -1052,6 +1053,33 @@ void tst_QPropertyAnimation::restart() anim.start(); } +void tst_QPropertyAnimation::valueChanged() +{ + qRegisterMetaType("QVariant"); + + //we check that we receive the valueChanged signal + MyErrorObject o; + o.setOle(0); + QCOMPARE(o.property("ole").toInt(), 0); + QPropertyAnimation anim(&o, "ole"); + anim.setEndValue(5); + anim.setDuration(1000); + QSignalSpy spy(&anim, SIGNAL(valueChanged(QVariant))); + anim.start(); + + QTest::qWait(anim.duration() + 50); + + QCOMPARE(anim.state(), QAbstractAnimation::Stopped); + QCOMPARE(anim.currentTime(), anim.duration()); + + //let's check that the values go forward + QCOMPARE(spy.count(), 6); //we should have got everything from 0 to 5 + for (int i = 0; i < spy.count(); ++i) { + QCOMPARE(qvariant_cast(spy.at(i).first()).toInt(), i); + } +} + + QTEST_MAIN(tst_QPropertyAnimation) #include "tst_qpropertyanimation.moc" -- cgit v0.12