diff options
author | Michael Brasser <michael.brasser@jollamobile.com> | 2013-11-26 09:18:10 -0600 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-04 15:26:26 +0100 |
commit | d489f2f6549a86b3949004d1c8ec68487fc2adb7 (patch) | |
tree | d3598f928bb8e1672557aba56cbedb2aea4ae23c /tests/auto/quick/qquickbehaviors | |
parent | 6709e2060aff8b792fcc57004222f7de72584831 (diff) |
Behavior should not trigger when the tracked value has not changed.
Behaviors are specifically for animating changes in value. When the
value has not changed, do not trigger the animation. This ensures
the animation system is not unnecessarily woken.
[ChangeLog][QtQuick][Behavior] Do not trigger a Behavior when the
tracked value has not changed.
Task-number: QTBUG-21549
Change-Id: I5b20121ccfb75ea5ebf86705df89891c94cf6e7e
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
Diffstat (limited to 'tests/auto/quick/qquickbehaviors')
-rw-r--r-- | tests/auto/quick/qquickbehaviors/data/qtbug21549.qml | 18 | ||||
-rw-r--r-- | tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp | 30 |
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickbehaviors/data/qtbug21549.qml b/tests/auto/quick/qquickbehaviors/data/qtbug21549.qml new file mode 100644 index 0000000000..db076bca9a --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/qtbug21549.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Item { + width: 200 + height: 200 + + property int behaviorCount: 0 + + Rectangle { + id: myRect + objectName: "myRect" + width: 100 + height: 100 + Behavior on x { + ScriptAction { script: ++behaviorCount } + } + } +} diff --git a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp index c40abbd55f..8ec76c94e9 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,35 @@ 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; +} + QTEST_MAIN(tst_qquickbehaviors) #include "tst_qquickbehaviors.moc" |