diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-02-05 05:58:19 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-02-05 06:02:16 (GMT) |
commit | c5cd42cde88bc4fd630a6044a9d44d29dc3df595 (patch) | |
tree | d297b43bbd93a636182325ab87a773d739861674 /tests | |
parent | 93ac24c12b2272cee75d37b4950baed6615ef1fb (diff) | |
download | Qt-c5cd42cde88bc4fd630a6044a9d44d29dc3df595.zip Qt-c5cd42cde88bc4fd630a6044a9d44d29dc3df595.tar.gz Qt-c5cd42cde88bc4fd630a6044a9d44d29dc3df595.tar.bz2 |
Fix Behaviors for object-type properties.
Task-number: QT-2269
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/behaviors/data/parent.qml | 28 | ||||
-rw-r--r-- | tests/auto/declarative/behaviors/tst_behaviors.cpp | 18 |
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/declarative/behaviors/data/parent.qml b/tests/auto/declarative/behaviors/data/parent.qml new file mode 100644 index 0000000..4f4911b --- /dev/null +++ b/tests/auto/declarative/behaviors/data/parent.qml @@ -0,0 +1,28 @@ +import Qt 4.6 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + parent: Behavior { + SequentialAnimation { + PauseAnimation { duration: 200 } + PropertyAction {} + } + } + } + Item { + id: newParent + objectName: "NewParent" + x: 100 + } + states: State { + name: "reparented" + PropertyChanges { + target: rect + parent: newParent + } + } +} diff --git a/tests/auto/declarative/behaviors/tst_behaviors.cpp b/tests/auto/declarative/behaviors/tst_behaviors.cpp index fe6bc6f..ae1af0e 100644 --- a/tests/auto/declarative/behaviors/tst_behaviors.cpp +++ b/tests/auto/declarative/behaviors/tst_behaviors.cpp @@ -58,6 +58,7 @@ private slots: void cppTriggered(); void loop(); void colorBehavior(); + void parentBehavior(); void replaceBinding(); //void transitionOverrides(); void group(); @@ -134,6 +135,23 @@ void tst_behaviors::colorBehavior() QVERIFY(color != QColor("red") && color != QColor("green")); //i.e. the behavior has been triggered } +void tst_behaviors::parentBehavior() +{ + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/parent.qml")); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); + QVERIFY(rect); + + rect->setState("reparented"); + QTest::qWait(100); + QmlGraphicsItem *newParent = rect->findChild<QmlGraphicsItem*>("NewParent"); + QmlGraphicsItem *parent = rect->findChild<QmlGraphicsRectangle*>("MyRect")->parentItem(); + QVERIFY(parent != newParent); + QTest::qWait(300); + parent = rect->findChild<QmlGraphicsRectangle*>("MyRect")->parentItem(); + QVERIFY(parent == newParent); +} + void tst_behaviors::replaceBinding() { QmlEngine engine; |