summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/states/data/ExtendedRectangle.qml19
-rw-r--r--tests/auto/declarative/states/data/signalOverride.qml18
-rw-r--r--tests/auto/declarative/states/data/signalOverride2.qml9
-rw-r--r--tests/auto/declarative/states/tst_states.cpp51
4 files changed, 97 insertions, 0 deletions
diff --git a/tests/auto/declarative/states/data/ExtendedRectangle.qml b/tests/auto/declarative/states/data/ExtendedRectangle.qml
new file mode 100644
index 0000000..8d64663
--- /dev/null
+++ b/tests/auto/declarative/states/data/ExtendedRectangle.qml
@@ -0,0 +1,19 @@
+import Qt 4.6
+Rectangle {
+ id: extendedRect
+ objectName: "extendedRect"
+ property color extendedColor: "orange"
+
+ width: 100; height: 100
+ color: "red"
+ states: State {
+ name: "green"
+ PropertyChanges {
+ target: rect
+ onDidSomething: {
+ extendedRect.color = "green"
+ extendedColor = "green"
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/states/data/signalOverride.qml b/tests/auto/declarative/states/data/signalOverride.qml
new file mode 100644
index 0000000..5ba1566
--- /dev/null
+++ b/tests/auto/declarative/states/data/signalOverride.qml
@@ -0,0 +1,18 @@
+import Qt 4.6
+import Qt.test 1.0
+
+MyRectangle {
+ id: rect
+
+ onDidSomething: color = "blue"
+
+ width: 100; height: 100
+ color: "red"
+ states: State {
+ name: "green"
+ PropertyChanges {
+ target: rect
+ onDidSomething: color = "green"
+ }
+ }
+}
diff --git a/tests/auto/declarative/states/data/signalOverride2.qml b/tests/auto/declarative/states/data/signalOverride2.qml
new file mode 100644
index 0000000..527e165
--- /dev/null
+++ b/tests/auto/declarative/states/data/signalOverride2.qml
@@ -0,0 +1,9 @@
+import Qt 4.6
+import Qt.test 1.0
+
+MyRectangle {
+ id: rect
+ onDidSomething: color = "blue"
+ width: 100; height: 100
+ ExtendedRectangle {}
+}
diff --git a/tests/auto/declarative/states/tst_states.cpp b/tests/auto/declarative/states/tst_states.cpp
index 3a61bd6..b2532a2 100644
--- a/tests/auto/declarative/states/tst_states.cpp
+++ b/tests/auto/declarative/states/tst_states.cpp
@@ -13,6 +13,7 @@ private slots:
void basicChanges();
void basicExtension();
void basicBinding();
+ void signalOverride();
};
void tst_states::basicChanges()
@@ -262,6 +263,56 @@ void tst_states::basicBinding()
}
}
+class MyRect : public QFxRect
+{
+ Q_OBJECT
+public:
+ MyRect() {}
+ void doSomething() { emit didSomething(); }
+Q_SIGNALS:
+ void didSomething();
+};
+
+QML_DECLARE_TYPE(MyRect)
+QML_DEFINE_TYPE(Qt.test, 1, 0, 0, MyRectangle,MyRect);
+
+void tst_states::signalOverride()
+{
+ QmlEngine engine;
+
+ {
+ QmlComponent rectComponent(&engine, SRCDIR "/data/signalOverride.qml");
+ MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->doSomething();
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("green");
+ rect->doSomething();
+ QCOMPARE(rect->color(),QColor("green"));
+ }
+
+ {
+ QmlComponent rectComponent(&engine, SRCDIR "/data/signalOverride2.qml");
+ MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("white"));
+ rect->doSomething();
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ QFxRect *innerRect = qobject_cast<QFxRect*>(rect->findChild<QFxRect*>("extendedRect"));
+
+ innerRect->setState("green");
+ rect->doSomething();
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(innerRect->color(),QColor("green"));
+ QCOMPARE(innerRect->property("extendedColor").value<QColor>(),QColor("green"));
+ }
+}
+
QTEST_MAIN(tst_states)
#include "tst_states.moc"