From 3eb583f6e6e0075583aea7dbf46cf3cec48cb879 Mon Sep 17 00:00:00 2001 From: Thomas Kristensen Date: Wed, 13 Mar 2013 13:53:06 +0100 Subject: Fix a bug where completed was emitted twice when duration was zero. Change-Id: I72c16f3affb297985e9e5d2e9f524537212d06ad Reviewed-by: Michael Brasser Reviewed-by: Alan Alpert Reviewed-by: Andreas Aardal Hanssen --- .../tst_qdeclarativeanimations.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp index 00869268..6352d02b 100644 --- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp +++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp @@ -47,6 +47,7 @@ #include #include #include +#include class tst_qdeclarativeanimations : public QObject { @@ -82,6 +83,7 @@ private slots: void doubleRegistrationBug(); void alwaysRunToEndRestartBug(); void transitionAssignmentBug(); + void zeroDurationTwoCompletedEmittedBug(); }; #define QTIMED_COMPARE(lhs, rhs) do { \ @@ -850,6 +852,24 @@ void tst_qdeclarativeanimations::transitionAssignmentBug() QCOMPARE(rect->property("nullObject").toBool(), false); } +void tst_qdeclarativeanimations::zeroDurationTwoCompletedEmittedBug() +{ + QDeclarativeRectangle rect; + QDeclarativePropertyAnimation animation; + animation.setTarget(&rect); + animation.setProperty("x"); + animation.setFrom(1); + animation.setTo(200); + animation.setDuration(0); + QVERIFY(animation.from() == 1); + QSignalSpy spy(&animation, SIGNAL(completed(void))); + animation.start(); + QVERIFY(!animation.isRunning()); + QCOMPARE(rect.x(), qreal(200)); + QCOMPARE(spy.size(), 1); +} + + QTEST_MAIN(tst_qdeclarativeanimations) #include "tst_qdeclarativeanimations.moc" -- cgit v1.2.3