From d489f2f6549a86b3949004d1c8ec68487fc2adb7 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 26 Nov 2013 09:18:10 -0600 Subject: 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 Reviewed-by: Gunnar Sletta Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com> --- .../quick/qquickbehaviors/tst_qquickbehaviors.cpp | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp') 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(), value); } +//QTBUG-21549 +void tst_qquickbehaviors::currentValue() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("qtbug21549.qml")); + QQuickItem *item = qobject_cast(c.create()); + QVERIFY(item); + + QQuickRectangle *target = item->findChild("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" -- cgit v1.2.3