summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativestates
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-04-08 01:13:33 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-04-08 01:15:13 (GMT)
commit80cd83d3b09b2271d183a51d2e6453924c535dce (patch)
treebbb354da77507be6a73d03073aa37393b30013f4 /tests/auto/declarative/qdeclarativestates
parent979ad950e257c0c90463ab6c2db7fea4aece3331 (diff)
downloadQt-80cd83d3b09b2271d183a51d2e6453924c535dce.zip
Qt-80cd83d3b09b2271d183a51d2e6453924c535dce.tar.gz
Qt-80cd83d3b09b2271d183a51d2e6453924c535dce.tar.bz2
Document behavior of conflicting when clauses.
Task-number: QTBUG-9371
Diffstat (limited to 'tests/auto/declarative/qdeclarativestates')
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/whenOrdering.qml11
-rw-r--r--tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp23
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativestates/data/whenOrdering.qml b/tests/auto/declarative/qdeclarativestates/data/whenOrdering.qml
new file mode 100644
index 0000000..7369c63
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/data/whenOrdering.qml
@@ -0,0 +1,11 @@
+import Qt 4.6
+
+Rectangle {
+ property bool condition1: false
+ property bool condition2: false
+
+ states: [
+ State { name: "state1"; when: condition1 },
+ State { name: "state2"; when: condition2 }
+ ]
+}
diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
index e7c595a..f0b6759 100644
--- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
+++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
@@ -108,6 +108,7 @@ private slots:
void nonExistantProperty();
void reset();
void illegalObjectCreation();
+ void whenOrdering();
};
void tst_qdeclarativestates::initTestCase()
@@ -993,6 +994,28 @@ void tst_qdeclarativestates::illegalObjectCreation()
QCOMPARE(error.description().toUtf8().constData(), "PropertyChanges does not support creating state-specific objects.");
}
+void tst_qdeclarativestates::whenOrdering()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, SRCDIR "/data/whenOrdering.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->state(), QLatin1String(""));
+ rect->setProperty("condition2", true);
+ QCOMPARE(rect->state(), QLatin1String("state2"));
+ rect->setProperty("condition1", true);
+ QCOMPARE(rect->state(), QLatin1String("state1"));
+ rect->setProperty("condition2", false);
+ QCOMPARE(rect->state(), QLatin1String("state1"));
+ rect->setProperty("condition2", true);
+ QCOMPARE(rect->state(), QLatin1String("state1"));
+ rect->setProperty("condition1", false);
+ rect->setProperty("condition2", false);
+ QCOMPARE(rect->state(), QLatin1String(""));
+}
+
QTEST_MAIN(tst_qdeclarativestates)
#include "tst_qdeclarativestates.moc"