diff options
Diffstat (limited to 'tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp')
-rw-r--r-- | tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp index c40abbd55f..5deda2d96b 100644 --- a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp +++ b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp @@ -81,6 +81,7 @@ private slots: void delayedRegistration(); void startOnCompleted(); void multipleChangesToValueType(); + void currentValue(); }; void tst_qquickbehaviors::simpleBehavior() @@ -495,6 +496,59 @@ void tst_qquickbehaviors::multipleChangesToValueType() QTRY_COMPARE(text->property("font").value<QFont>(), value); } +//QTBUG-21549 +void tst_qquickbehaviors::currentValue() +{ + { + 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); + + 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->setX(100); + target->setProperty("x", 100); + QCOMPARE(item->property("behaviorCount").toInt(), 1); + QCOMPARE(target->x(), qreal(100)); + + 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) #include "tst_qquickbehaviors.moc" |