diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-07-21 00:52:08 (GMT) |
---|---|---|
committer | Toby Tomkins <toby.tomkins@nokia.com> | 2010-07-26 06:31:36 (GMT) |
commit | 6ff23f2b2d96e852ed1fff0ecef0e8ee28ec82e7 (patch) | |
tree | 421ba770d03663807309d3642786f56ed79fda39 /tests/auto | |
parent | be4b912cb5068db2ba40e85c4857e907768264b8 (diff) | |
download | Qt-6ff23f2b2d96e852ed1fff0ecef0e8ee28ec82e7.zip Qt-6ff23f2b2d96e852ed1fff0ecef0e8ee28ec82e7.tar.gz Qt-6ff23f2b2d96e852ed1fff0ecef0e8ee28ec82e7.tar.bz2 |
Only ignore the same target value for a Behavior when it is running.
Otherwise a Behavior may mistakenly not be triggered. This situation
can arise when the property in question has been manipulated via the
property system, followed by a direct function call (which correctly
bypasses the Behavior), followed by a another change via the property
system.
Task-number: QTBUG-12295
(cherry picked from commit 64833c0a648211f3fe7547436f022edc0ceb51ac)
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml | 17 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp | 27 |
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml b/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml new file mode 100644 index 0000000..804559c --- /dev/null +++ b/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml @@ -0,0 +1,17 @@ +import Qt 4.7 + +Rectangle { + width: 200 + height: 200 + color: "blue" + + Rectangle { + id: myRect + objectName: "myRect" + width: 100 + height: 100 + Behavior on x { + NumberAnimation {} + } + } +} diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index 5c2c145..bb7fc7b 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -80,6 +80,7 @@ private slots: void startup(); void groupedPropertyCrash(); void runningTrue(); + void sameValue(); }; void tst_qdeclarativebehaviors::simpleBehavior() @@ -384,6 +385,32 @@ void tst_qdeclarativebehaviors::runningTrue() QTRY_VERIFY(runningSpy.count() > 0); } +//QTBUG-12295 +void tst_qdeclarativebehaviors::sameValue() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/qtbug12295.qml")); + QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); + QVERIFY(rect); + + QDeclarativeRectangle *target = rect->findChild<QDeclarativeRectangle*>("myRect"); + QVERIFY(target); + + target->setX(100); + QCOMPARE(target->x(), qreal(100)); + + target->setProperty("x", 0); + QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100)); + + target->setX(100); + QCOMPARE(target->x(), qreal(100)); + + //this is the main point of the test -- the behavior needs to be triggered again + //even though we set 0 twice in a row. + target->setProperty("x", 0); + QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100)); +} + QTEST_MAIN(tst_qdeclarativebehaviors) #include "tst_qdeclarativebehaviors.moc" |