aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@jollamobile.com>2013-12-11 12:28:53 -0600
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-12 21:29:35 +0100
commita2dad3ddee9c4bf274a7c6469342e4104605ceeb (patch)
treeb56f831cd3fd2b9609efdd4b9656c416b4e4e9b9 /tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp
parentf1997ba4d6e47cc13811630caeb4cc0cf7442401 (diff)
Fix SpringAnimation in Behavior when current value is set.
Fixes regression introduced by d489f2f6549a86b3949004d1c8ec68487fc2adb7. We now only avoid running the animation if the Behavior wasn't already mid-animation. This ensure correct behavior for SpringAnimation, and also correct state for 'running'. Task-number: QTBUG-21549 Change-Id: I0f97813294cca22fb7a273e222fa0549c6de9ca7 Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
Diffstat (limited to 'tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp')
-rw-r--r--tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp60
1 files changed, 42 insertions, 18 deletions
diff --git a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp
index 8ec76c94e9..5deda2d96b 100644
--- a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp
+++ b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp
@@ -499,30 +499,54 @@ void tst_qquickbehaviors::multipleChangesToValueType()
//QTBUG-21549
void tst_qquickbehaviors::currentValue()
{
- QQmlEngine engine;
- QQmlComponent c(&engine, testFileUrl("qtbug21549.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
- QVERIFY(item);
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("qtbug21549.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
+ QVERIFY(item);
- QQuickRectangle *target = item->findChild<QQuickRectangle*>("myRect");
- QVERIFY(target);
+ QQuickRectangle *target = item->findChild<QQuickRectangle*>("myRect");
+ QVERIFY(target);
- QCOMPARE(target->x(), qreal(0));
+ QCOMPARE(target->x(), qreal(0));
- target->setProperty("x", 50);
- QCOMPARE(item->property("behaviorCount").toInt(), 1);
- QCOMPARE(target->x(), qreal(50));
+ target->setProperty("x", 50);
+ QCOMPARE(item->property("behaviorCount").toInt(), 1);
+ QCOMPARE(target->x(), qreal(50));
- target->setProperty("x", 50);
- QCOMPARE(item->property("behaviorCount").toInt(), 1);
- QCOMPARE(target->x(), qreal(50));
+ target->setProperty("x", 50);
+ QCOMPARE(item->property("behaviorCount").toInt(), 1);
+ QCOMPARE(target->x(), qreal(50));
- target->setX(100);
- target->setProperty("x", 100);
- QCOMPARE(item->property("behaviorCount").toInt(), 1);
- QCOMPARE(target->x(), qreal(100));
+ target->setX(100);
+ target->setProperty("x", 100);
+ QCOMPARE(item->property("behaviorCount").toInt(), 1);
+ QCOMPARE(target->x(), qreal(100));
+
+ delete item;
+ }
- delete item;
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("qtbug21549-2.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
+ QVERIFY(item);
+
+ QQuickRectangle *target = item->findChild<QQuickRectangle*>("myRect");
+ QVERIFY(target);
+
+ QCOMPARE(target->x(), qreal(0));
+
+ target->setProperty("x", 100);
+
+ // the spring animation should smoothly transition to the new value triggered
+ // in the QML (which should be between 50 and 80);
+ QTRY_COMPARE(item->property("animRunning").toBool(), true);
+ QTRY_COMPARE(item->property("animRunning").toBool(), false);
+ QVERIFY(target->x() > qreal(50) && target->x() < qreal(80));
+
+ delete item;
+ }
}
QTEST_MAIN(tst_qquickbehaviors)