summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-08-13 02:22:46 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-08-13 02:28:58 (GMT)
commitf9fe93e6e85294274d4e0ce81db09783cfacd733 (patch)
treedc71ee15b779379ea262f404d0209a6f0f9a5a2a /tests/auto/declarative
parentd904fe2273be5d39b54b987eef6b9cc0d1b85c4b (diff)
downloadQt-f9fe93e6e85294274d4e0ce81db09783cfacd733.zip
Qt-f9fe93e6e85294274d4e0ce81db09783cfacd733.tar.gz
Qt-f9fe93e6e85294274d4e0ce81db09783cfacd733.tar.bz2
Clear previous animation data for non-triggering animations.
We need to clear the data from the last run if the animation doesn't match any of the state actions (or if there are no actions). Task-number: QTBUG-12805
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/nonTransitionBug.qml30
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp31
2 files changed, 61 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeanimations/data/nonTransitionBug.qml b/tests/auto/declarative/qdeclarativeanimations/data/nonTransitionBug.qml
new file mode 100644
index 0000000..e9dc36e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanimations/data/nonTransitionBug.qml
@@ -0,0 +1,30 @@
+import Qt 4.7
+
+Rectangle {
+ id: root
+ width: 200
+ height: 200
+
+ Rectangle {
+ id: mover
+ objectName: "mover"
+ }
+
+ states: [
+ State {
+ name: "free"
+ },
+ State {
+ name: "left"
+ PropertyChanges {
+ restoreEntryValues: false
+ target: mover
+ x: 0
+ }
+ }
+ ]
+
+ transitions: Transition {
+ PropertyAnimation { properties: "x"; duration: 50 }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
index ec867fe..e5943fb 100644
--- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
+++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
@@ -48,6 +48,8 @@
#include <QVariantAnimation>
#include <QEasingCurve>
+#include "../../../shared/util.h"
+
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
#define SRCDIR "."
@@ -82,6 +84,7 @@ private slots:
void easingProperties();
void rotation();
void runningTrueBug();
+ void nonTransitionBug();
};
#define QTIMED_COMPARE(lhs, rhs) do { \
@@ -762,6 +765,34 @@ void tst_qdeclarativeanimations::runningTrueBug()
QVERIFY(cloud->x() > qreal(0));
}
+//QTBUG-12805
+void tst_qdeclarativeanimations::nonTransitionBug()
+{
+ //tests that the animation values from the previous transition are properly cleared
+ //in the case where an animation in the transition doesn't match anything (but previously did)
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, SRCDIR "/data/nonTransitionBug.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect != 0);
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
+ QDeclarativeRectangle *mover = rect->findChild<QDeclarativeRectangle*>("mover");
+
+ mover->setX(100);
+ QCOMPARE(mover->x(), qreal(100));
+
+ rectPrivate->setState("left");
+ QTRY_COMPARE(mover->x(), qreal(0));
+
+ mover->setX(100);
+ QCOMPARE(mover->x(), qreal(100));
+
+ //make sure we don't try to animate back to 0
+ rectPrivate->setState("free");
+ QTest::qWait(300);
+ QCOMPARE(mover->x(), qreal(100));
+}
+
QTEST_MAIN(tst_qdeclarativeanimations)
#include "tst_qdeclarativeanimations.moc"