diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-11-30 01:29:39 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-11-30 01:30:36 (GMT) |
commit | 68e3cab8a8183a5a88e5be092471a05692e05afe (patch) | |
tree | be1dabee49f3d8444298778fd440daa5a2a7c052 /tests | |
parent | 85b3e8fab4a644f94a2953885f1e68369b070e64 (diff) | |
download | Qt-68e3cab8a8183a5a88e5be092471a05692e05afe.zip Qt-68e3cab8a8183a5a88e5be092471a05692e05afe.tar.gz Qt-68e3cab8a8183a5a88e5be092471a05692e05afe.tar.bz2 |
Support disabling a Behavior.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/behaviors/data/disabled.qml | 27 | ||||
-rw-r--r-- | tests/auto/declarative/behaviors/tst_behaviors.cpp | 15 |
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/declarative/behaviors/data/disabled.qml b/tests/auto/declarative/behaviors/data/disabled.qml new file mode 100644 index 0000000..e7b8d51 --- /dev/null +++ b/tests/auto/declarative/behaviors/data/disabled.qml @@ -0,0 +1,27 @@ +import Qt 4.6 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + x: Behavior { + objectName: "MyBehavior"; + enabled: false + NumberAnimation { duration: 200; } + } + } + MouseRegion { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: 200 + } + } +} diff --git a/tests/auto/declarative/behaviors/tst_behaviors.cpp b/tests/auto/declarative/behaviors/tst_behaviors.cpp index 6343968..e1376ce 100644 --- a/tests/auto/declarative/behaviors/tst_behaviors.cpp +++ b/tests/auto/declarative/behaviors/tst_behaviors.cpp @@ -64,6 +64,7 @@ private slots: void emptyBehavior(); void nonSelectingBehavior(); void reassignedAnimation(); + void disabled(); }; void tst_behaviors::simpleBehavior() @@ -243,6 +244,20 @@ void tst_behaviors::reassignedAnimation() rect->findChild<QmlBehavior*>("MyBehavior"))->animation())->duration(), 200); } +void tst_behaviors::disabled() +{ + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/disabled.qml")); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); + QVERIFY(rect); + QCOMPARE(rect->findChild<QmlBehavior*>("MyBehavior")->enabled(), false); + + rect->setState("moved"); + qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x(); + QCOMPARE(x, qreal(200)); //should change immediately + +} + QTEST_MAIN(tst_behaviors) #include "tst_behaviors.moc" |