summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-11-23 01:12:19 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-11-23 01:12:19 (GMT)
commit60e39093e9bd76b88027863d60873bc82492be50 (patch)
tree1f05a97da1722eb5f83700f3fd897b8a1290ffd8 /tests/auto/declarative
parentb316de95032216a90a8262cce3708f781f8ccbd9 (diff)
parent831d30af205d5125f762696bb6f9a5f9d1e3c5f5 (diff)
downloadQt-60e39093e9bd76b88027863d60873bc82492be50.zip
Qt-60e39093e9bd76b88027863d60873bc82492be50.tar.gz
Qt-60e39093e9bd76b88027863d60873bc82492be50.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/states/data/deleting.qml11
-rw-r--r--tests/auto/declarative/states/data/deletingState.qml13
-rw-r--r--tests/auto/declarative/states/tst_states.cpp65
3 files changed, 89 insertions, 0 deletions
diff --git a/tests/auto/declarative/states/data/deleting.qml b/tests/auto/declarative/states/data/deleting.qml
new file mode 100644
index 0000000..0c512dd
--- /dev/null
+++ b/tests/auto/declarative/states/data/deleting.qml
@@ -0,0 +1,11 @@
+import Qt 4.6
+Rectangle {
+ id: MyRectangle
+ width: 100; height: 100
+ color: "red"
+ states: State {
+ name: "blue"
+ PropertyChanges { target: MyRectangle; color: "blue"; objectName: "pc1" }
+ PropertyChanges { target: MyRectangle; radius: 5; objectName: "pc2" }
+ }
+}
diff --git a/tests/auto/declarative/states/data/deletingState.qml b/tests/auto/declarative/states/data/deletingState.qml
new file mode 100644
index 0000000..9dc46a6
--- /dev/null
+++ b/tests/auto/declarative/states/data/deletingState.qml
@@ -0,0 +1,13 @@
+import Qt 4.6
+Rectangle {
+ id: MyRectangle
+ width: 100; height: 100
+ color: "red"
+ StateGroup {
+ id: stateGroup
+ states: State {
+ name: "blue"
+ PropertyChanges { target: MyRectangle; color: "blue" }
+ }
+ }
+}
diff --git a/tests/auto/declarative/states/tst_states.cpp b/tests/auto/declarative/states/tst_states.cpp
index a4da1f1..4847535 100644
--- a/tests/auto/declarative/states/tst_states.cpp
+++ b/tests/auto/declarative/states/tst_states.cpp
@@ -44,6 +44,7 @@
#include <private/qmlgraphicsanchors_p_p.h>
#include <private/qmlgraphicsrectangle_p.h>
#include <private/qmlpropertychanges_p.h>
+#include <private/qmlstategroup_p.h>
class tst_states : public QObject
{
@@ -69,6 +70,8 @@ private slots:
void explicitChanges();
void propertyErrors();
void incorrectRestoreBug();
+ void deletingChange();
+ void deletingState();
};
void tst_states::basicChanges()
@@ -738,6 +741,68 @@ void tst_states::incorrectRestoreBug()
QCOMPARE(rect->color(),QColor("green"));
}
+void tst_states::deletingChange()
+{
+ QmlEngine engine;
+
+ QmlComponent rectComponent(&engine, SRCDIR "/data/deleting.qml");
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->radius(),qreal(5));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->radius(),qreal(0));
+
+ QmlPropertyChanges *pc = rect->findChild<QmlPropertyChanges*>("pc1");
+ QVERIFY(pc != 0);
+ delete pc;
+
+ QmlState *state = rect->findChild<QmlState*>();
+ QVERIFY(state != 0);
+ QCOMPARE(state->changes()->count(), 1);
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->radius(),qreal(5));
+
+ delete rect;
+}
+
+void tst_states::deletingState()
+{
+ QmlEngine engine;
+
+ QmlComponent rectComponent(&engine, SRCDIR "/data/deletingState.qml");
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QmlStateGroup *sg = rect->findChild<QmlStateGroup*>();
+ QVERIFY(sg != 0);
+ QVERIFY(sg->findState("blue") != 0);
+
+ sg->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ sg->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ QmlState *state = rect->findChild<QmlState*>();
+ QVERIFY(state != 0);
+ delete state;
+
+ QVERIFY(sg->findState("blue") == 0);
+
+ //### should we warn that state doesn't exist
+ sg->setState("blue");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ delete rect;
+}
+
QTEST_MAIN(tst_states)
#include "tst_states.moc"