diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-11-24 04:19:46 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-11-24 04:19:46 (GMT) |
commit | e3ec86e388a35b850573b8fd8b58c93113bb8bd3 (patch) | |
tree | 9ef24f9ba783fa9c46ec3841dc60a99fb3c9649c /tests | |
parent | 3d2b0d622908fe2c89ac1c2d5a5cb7ed96a24b6a (diff) | |
download | Qt-e3ec86e388a35b850573b8fd8b58c93113bb8bd3.zip Qt-e3ec86e388a35b850573b8fd8b58c93113bb8bd3.tar.gz Qt-e3ec86e388a35b850573b8fd8b58c93113bb8bd3.tar.bz2 |
Prevent state changes within PropertyChanges.
Task-number: QT-2358
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/states/data/illegalTempState.qml | 21 | ||||
-rw-r--r-- | tests/auto/declarative/states/data/legalTempState.qml | 23 | ||||
-rw-r--r-- | tests/auto/declarative/states/tst_states.cpp | 29 |
3 files changed, 73 insertions, 0 deletions
diff --git a/tests/auto/declarative/states/data/illegalTempState.qml b/tests/auto/declarative/states/data/illegalTempState.qml new file mode 100644 index 0000000..2702be4 --- /dev/null +++ b/tests/auto/declarative/states/data/illegalTempState.qml @@ -0,0 +1,21 @@ +import Qt 4.6 + +Rectangle { + id: card + width: 100; height: 100 + + states: [ + State { + name: "placed" + PropertyChanges { target: card; state: "idle" } + }, + State { + name: "idle" + } + ] + + MouseRegion { + anchors.fill: parent + onClicked: card.state = "placed" + } +} diff --git a/tests/auto/declarative/states/data/legalTempState.qml b/tests/auto/declarative/states/data/legalTempState.qml new file mode 100644 index 0000000..54c97b9 --- /dev/null +++ b/tests/auto/declarative/states/data/legalTempState.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +Rectangle { + id: card + width: 100; height: 100 + + states: [ + State { + name: "placed" + onCompleted: card.state = "idle" + StateChangeScript { script: console.log("entering placed") } + }, + State { + name: "idle" + StateChangeScript { script: console.log("entering idle") } + } + ] + + MouseRegion { + anchors.fill: parent + onClicked: card.state = "placed" + } +} diff --git a/tests/auto/declarative/states/tst_states.cpp b/tests/auto/declarative/states/tst_states.cpp index 4847535..17d9263 100644 --- a/tests/auto/declarative/states/tst_states.cpp +++ b/tests/auto/declarative/states/tst_states.cpp @@ -72,6 +72,8 @@ private slots: void incorrectRestoreBug(); void deletingChange(); void deletingState(); + void tempState(); + void illegalTempState(); }; void tst_states::basicChanges() @@ -803,6 +805,33 @@ void tst_states::deletingState() delete rect; } +void tst_states::tempState() +{ + QmlEngine engine; + + QmlComponent rectComponent(&engine, SRCDIR "/data/legalTempState.qml"); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create()); + QVERIFY(rect != 0); + + QTest::ignoreMessage(QtDebugMsg, "entering placed"); + QTest::ignoreMessage(QtDebugMsg, "entering idle"); + rect->setState("placed"); + QCOMPARE(rect->state(), QLatin1String("idle")); +} + +void tst_states::illegalTempState() +{ + QmlEngine engine; + + QmlComponent rectComponent(&engine, SRCDIR "/data/illegalTempState.qml"); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create()); + QVERIFY(rect != 0); + + QTest::ignoreMessage(QtWarningMsg, "Can't apply a state change as part of a state definition. "); + rect->setState("placed"); + QCOMPARE(rect->state(), QLatin1String("placed")); +} + QTEST_MAIN(tst_states) #include "tst_states.moc" |