summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/qmlbindengine/enums.1.qml20
-rw-r--r--tests/auto/declarative/qmlbindengine/testtypes.h19
-rw-r--r--tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp19
-rw-r--r--tests/auto/declarative/simplecanvasitem/data/test.qml60
-rw-r--r--tests/auto/declarative/simplecanvasitem/tst_simplecanvasitem.cpp79
-rw-r--r--tests/auto/declarative/states/data/basicBinding.qml12
-rw-r--r--tests/auto/declarative/states/data/basicBinding2.qml12
-rw-r--r--tests/auto/declarative/states/data/basicBinding3.qml13
-rw-r--r--tests/auto/declarative/states/data/basicBinding4.qml17
-rw-r--r--tests/auto/declarative/states/data/basicChanges.qml10
-rw-r--r--tests/auto/declarative/states/data/basicChanges2.qml15
-rw-r--r--tests/auto/declarative/states/data/basicChanges3.qml15
-rw-r--r--tests/auto/declarative/states/data/basicExtension.qml16
-rw-r--r--tests/auto/declarative/states/data/fakeExtension.qml16
-rw-r--r--tests/auto/declarative/states/states.pro (renamed from tests/auto/declarative/simplecanvasitem/simplecanvasitem.pro)3
-rw-r--r--tests/auto/declarative/states/tst_states.cpp267
16 files changed, 452 insertions, 141 deletions
diff --git a/tests/auto/declarative/qmlbindengine/enums.1.qml b/tests/auto/declarative/qmlbindengine/enums.1.qml
new file mode 100644
index 0000000..6351823
--- /dev/null
+++ b/tests/auto/declarative/qmlbindengine/enums.1.qml
@@ -0,0 +1,20 @@
+import Qt.test 1.0
+import Qt.test 1.0 as Namespace
+
+MyQmlObject {
+ // Enums from non-namespaced type
+ property int a: MyQmlObject.EnumValue1
+ property int b: MyQmlObject.EnumValue2
+ property int c: MyQmlObject.EnumValue3
+ property int d: MyQmlObject.EnumValue4
+
+ // Enums from namespaced type
+ property int e: Namespace.MyQmlObject.EnumValue1
+ property int f: Namespace.MyQmlObject.EnumValue2
+ property int g: Namespace.MyQmlObject.EnumValue3
+ property int h: Namespace.MyQmlObject.EnumValue4
+
+ // Test that enums don't mask attached properties
+ property int i: MyQmlObject.value
+ property int j: Namespace.MyQmlObject.value
+}
diff --git a/tests/auto/declarative/qmlbindengine/testtypes.h b/tests/auto/declarative/qmlbindengine/testtypes.h
index f5b309e..f27c0b0 100644
--- a/tests/auto/declarative/qmlbindengine/testtypes.h
+++ b/tests/auto/declarative/qmlbindengine/testtypes.h
@@ -5,9 +5,21 @@
#include <QtDeclarative/qml.h>
#include <QtDeclarative/qmlexpression.h>
+class MyQmlAttachedObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value CONSTANT)
+public:
+ MyQmlAttachedObject(QObject *parent) : QObject(parent) {}
+
+ int value() const { return 19; }
+};
+
class MyQmlObject : public QObject
{
Q_OBJECT
+ Q_ENUMS(MyEnum)
+ Q_ENUMS(MyEnum2)
Q_PROPERTY(bool trueProperty READ trueProperty CONSTANT)
Q_PROPERTY(bool falseProperty READ falseProperty CONSTANT)
Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged)
@@ -15,6 +27,9 @@ class MyQmlObject : public QObject
public:
MyQmlObject(): m_methodCalled(false), m_methodIntCalled(false), m_object(0) {}
+ enum MyEnum { EnumValue1 = 0, EnumValue2 = 1 };
+ enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3 };
+
bool trueProperty() const { return true; }
bool falseProperty() const { return false; }
@@ -39,6 +54,10 @@ public:
bool methodIntCalled() const { return m_methodIntCalled; }
QString string() const { return m_string; }
+
+ static MyQmlAttachedObject *qmlAttachedProperties(QObject *o) {
+ return new MyQmlAttachedObject(o);
+ }
signals:
void basicSignal();
void argumentSignal(int a, QString b, qreal c);
diff --git a/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp b/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp
index 01cb54b..80373fe 100644
--- a/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp
+++ b/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp
@@ -38,6 +38,7 @@ private slots:
void objectPropertiesTriggerReeval();
void deferredProperties();
void extensionObjects();
+ void enums();
private:
QmlEngine engine;
@@ -366,6 +367,24 @@ void tst_qmlbindengine::extensionObjects()
QCOMPARE(object->baseProperty(), 92);
}
+void tst_qmlbindengine::enums()
+{
+ QmlComponent component(&engine, TEST_FILE("enums.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("a").toInt(), 0);
+ QCOMPARE(object->property("b").toInt(), 1);
+ QCOMPARE(object->property("c").toInt(), 2);
+ QCOMPARE(object->property("d").toInt(), 3);
+ QCOMPARE(object->property("e").toInt(), 0);
+ QCOMPARE(object->property("f").toInt(), 1);
+ QCOMPARE(object->property("g").toInt(), 2);
+ QCOMPARE(object->property("h").toInt(), 3);
+ QCOMPARE(object->property("i").toInt(), 19);
+ QCOMPARE(object->property("j").toInt(), 19);
+}
+
QTEST_MAIN(tst_qmlbindengine)
#include "tst_qmlbindengine.moc"
diff --git a/tests/auto/declarative/simplecanvasitem/data/test.qml b/tests/auto/declarative/simplecanvasitem/data/test.qml
deleted file mode 100644
index 8fbbc2e..0000000
--- a/tests/auto/declarative/simplecanvasitem/data/test.qml
+++ /dev/null
@@ -1,60 +0,0 @@
-import Qt 4.6
-
-Item {
- width: 320
- height: 480
- Rect {
- color: "blue"
- x: 20
- y: 20
- width: 20
- height: 20
- Rect {
- color: "black"
- x: 20
- y: 20
- width: 10
- height: 10
- }
- }
- Rect {
- color: "red"
- x: 40
- y: 20
- width: 20
- height: 20
- }
- Rect {
- color: "green"
- x: 60
- y: 20
- width: 20
- height: 20
- }
- Rect {
- color: "yellow"
- x: 20
- y: 40
- width: 20
- height: 20
- }
- Rect {
- color: "purple"
- x: 20
- y: 60
- width: 20
- height: 20
- }
- Rect {
- color: "white"
- x: 40
- y: 40
- width: 20
- height: 20
- }
- Rect {
- anchors.fill: parent
- color: "gray"
- z: -1
- }
-}
diff --git a/tests/auto/declarative/simplecanvasitem/tst_simplecanvasitem.cpp b/tests/auto/declarative/simplecanvasitem/tst_simplecanvasitem.cpp
deleted file mode 100644
index cce4df1..0000000
--- a/tests/auto/declarative/simplecanvasitem/tst_simplecanvasitem.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-#include <QtTest/QtTest>
-#include <qfxview.h>
-#include <qfxitem.h>
-#include <qsimplecanvasitem.h>
-
-/*
- Note: this autotest is specifically to test SimpleCanvasItem as a component of
- Qt Declarative, and therefore will have all items created in XML.
-*/
-class tst_SimpleCanvasItem : public QObject
-{
- Q_OBJECT
-public:
- tst_SimpleCanvasItem();
-
-private slots:
- void test_pos();
- void test_scenePos();
-private:
- QFxView *createView(const QString &filename);
-};
-
-tst_SimpleCanvasItem::tst_SimpleCanvasItem()
-{
-}
-
-void tst_SimpleCanvasItem::test_pos()
-{
- QFxView *canvas = createView(SRCDIR "/data/test.qml");
- canvas->execute();
- qApp->processEvents();
- QSimpleCanvasItem* root = qobject_cast<QSimpleCanvasItem*>(canvas->root());
- QVERIFY(root);
-
- QCOMPARE(root->pos(), QPointF(0,0));
- QCOMPARE(root->children().at(0)->pos(), QPointF(20,20));
- QCOMPARE(root->children().at(0)->children().at(0)->pos(), QPointF(20,20));
- QCOMPARE(root->children().at(2)->pos(), QPointF(60,20));
- QCOMPARE(root->children().at(3)->pos(), QPointF(20,40));
- QCOMPARE(root->children().at(5)->pos(), QPointF(40,40));
-}
-
-void tst_SimpleCanvasItem::test_scenePos()
-{
- QFxView *canvas = createView(SRCDIR "/data/test.qml");
- canvas->execute();
- qApp->processEvents();
- QSimpleCanvasItem* root = qobject_cast<QSimpleCanvasItem*>(canvas->root());
- QVERIFY(root);
-
-#ifdef CANVAS_GL
- QCOMPARE(root->transform(), QMatrix4x4());
-#else
- QCOMPARE(root->transform(), QTransform());
-#endif
- QCOMPARE(root->scenePos(), QPointF(0,0));
- QCOMPARE(root->children().at(0)->scenePos(), QPointF(20,20));
- QCOMPARE(root->children().at(0)->children().at(0)->scenePos(), QPointF(40,40));
- QCOMPARE(root->children().at(2)->scenePos(), QPointF(60,20));
- QCOMPARE(root->children().at(3)->scenePos(), QPointF(20,40));
- QCOMPARE(root->children().at(5)->scenePos(), QPointF(40,40));
-}
-
-QFxView *tst_SimpleCanvasItem::createView(const QString &filename)
-{
- QFxView *canvas = new QFxView(0);
- canvas->setFixedSize(240,320);
-
- QFile file(filename);
- file.open(QFile::ReadOnly);
- QString xml = file.readAll();
- canvas->setQml(xml, filename);
-
- return canvas;
-}
-
-QTEST_MAIN(tst_SimpleCanvasItem)
-
-#include "tst_simplecanvasitem.moc"
diff --git a/tests/auto/declarative/states/data/basicBinding.qml b/tests/auto/declarative/states/data/basicBinding.qml
new file mode 100644
index 0000000..930a6b2
--- /dev/null
+++ b/tests/auto/declarative/states/data/basicBinding.qml
@@ -0,0 +1,12 @@
+import Qt 4.6
+Rectangle {
+ id: MyRectangle
+
+ property color sourceColor: "blue"
+ width: 100; height: 100
+ color: "red"
+ states: State {
+ name: "blue"
+ PropertyChanges { target: MyRectangle; color: sourceColor }
+ }
+}
diff --git a/tests/auto/declarative/states/data/basicBinding2.qml b/tests/auto/declarative/states/data/basicBinding2.qml
new file mode 100644
index 0000000..6bfaf5a
--- /dev/null
+++ b/tests/auto/declarative/states/data/basicBinding2.qml
@@ -0,0 +1,12 @@
+import Qt 4.6
+Rectangle {
+ id: MyRectangle
+
+ property color sourceColor: "red"
+ width: 100; height: 100
+ color: sourceColor
+ states: State {
+ name: "blue"
+ PropertyChanges { target: MyRectangle; color: "blue" }
+ }
+} \ No newline at end of file
diff --git a/tests/auto/declarative/states/data/basicBinding3.qml b/tests/auto/declarative/states/data/basicBinding3.qml
new file mode 100644
index 0000000..344bfae
--- /dev/null
+++ b/tests/auto/declarative/states/data/basicBinding3.qml
@@ -0,0 +1,13 @@
+import Qt 4.6
+Rectangle {
+ id: MyRectangle
+
+ property color sourceColor: "red"
+ property color sourceColor2: "blue"
+ width: 100; height: 100
+ color: sourceColor
+ states: State {
+ name: "blue"
+ PropertyChanges { target: MyRectangle; color: sourceColor2 }
+ }
+} \ No newline at end of file
diff --git a/tests/auto/declarative/states/data/basicBinding4.qml b/tests/auto/declarative/states/data/basicBinding4.qml
new file mode 100644
index 0000000..f0b72bd
--- /dev/null
+++ b/tests/auto/declarative/states/data/basicBinding4.qml
@@ -0,0 +1,17 @@
+import Qt 4.6
+Rectangle {
+ id: MyRectangle
+
+ property color sourceColor: "blue"
+ width: 100; height: 100
+ color: "red"
+ states: [
+ State {
+ name: "blue"
+ PropertyChanges { target: MyRectangle; color: sourceColor }
+ },
+ State {
+ name: "green"
+ PropertyChanges { target: MyRectangle; color: "green" }
+ }]
+}
diff --git a/tests/auto/declarative/states/data/basicChanges.qml b/tests/auto/declarative/states/data/basicChanges.qml
new file mode 100644
index 0000000..8d560c6
--- /dev/null
+++ b/tests/auto/declarative/states/data/basicChanges.qml
@@ -0,0 +1,10 @@
+import Qt 4.6
+Rectangle {
+ id: MyRectangle
+ width: 100; height: 100
+ color: "red"
+ states: State {
+ name: "blue"
+ PropertyChanges { target: MyRectangle; color: "blue" }
+ }
+} \ No newline at end of file
diff --git a/tests/auto/declarative/states/data/basicChanges2.qml b/tests/auto/declarative/states/data/basicChanges2.qml
new file mode 100644
index 0000000..0f8783a
--- /dev/null
+++ b/tests/auto/declarative/states/data/basicChanges2.qml
@@ -0,0 +1,15 @@
+import Qt 4.6
+Rectangle {
+ id: MyRectangle
+ width: 100; height: 100
+ color: "red"
+ states: [
+ State {
+ name: "blue"
+ PropertyChanges { target: MyRectangle; color: "blue" }
+ },
+ State {
+ name: "green"
+ PropertyChanges { target: MyRectangle; color: "green" }
+ }]
+} \ No newline at end of file
diff --git a/tests/auto/declarative/states/data/basicChanges3.qml b/tests/auto/declarative/states/data/basicChanges3.qml
new file mode 100644
index 0000000..2a5ca5d
--- /dev/null
+++ b/tests/auto/declarative/states/data/basicChanges3.qml
@@ -0,0 +1,15 @@
+import Qt 4.6
+Rectangle {
+ id: MyRectangle
+ width: 100; height: 100
+ color: "red"
+ states: [
+ State {
+ name: "blue"
+ PropertyChanges { target: MyRectangle; color: "blue" }
+ },
+ State {
+ name: "bordered"
+ PropertyChanges { target: MyRectangle; border.width: 2 }
+ }]
+}
diff --git a/tests/auto/declarative/states/data/basicExtension.qml b/tests/auto/declarative/states/data/basicExtension.qml
new file mode 100644
index 0000000..230e00b
--- /dev/null
+++ b/tests/auto/declarative/states/data/basicExtension.qml
@@ -0,0 +1,16 @@
+import Qt 4.6
+Rectangle {
+ id: MyRectangle
+ width: 100; height: 100
+ color: "red"
+ states: [
+ State {
+ name: "blue"
+ PropertyChanges { target: MyRectangle; color: "blue" }
+ },
+ State {
+ name: "bordered"
+ extend: "blue"
+ PropertyChanges { target: MyRectangle; border.width: 2 }
+ }]
+} \ No newline at end of file
diff --git a/tests/auto/declarative/states/data/fakeExtension.qml b/tests/auto/declarative/states/data/fakeExtension.qml
new file mode 100644
index 0000000..3d85c4f
--- /dev/null
+++ b/tests/auto/declarative/states/data/fakeExtension.qml
@@ -0,0 +1,16 @@
+import Qt 4.6
+Rectangle {
+ id: MyRectangle
+ width: 100; height: 100
+ color: "red"
+ states: [
+ State {
+ name: "blue"
+ PropertyChanges { target: MyRectangle; color: "blue" }
+ },
+ State {
+ name: "green"
+ extend: "blue"
+ PropertyChanges { target: MyRectangle; color: "green" }
+ }]
+} \ No newline at end of file
diff --git a/tests/auto/declarative/simplecanvasitem/simplecanvasitem.pro b/tests/auto/declarative/states/states.pro
index f4aea32..0474ea5 100644
--- a/tests/auto/declarative/simplecanvasitem/simplecanvasitem.pro
+++ b/tests/auto/declarative/states/states.pro
@@ -1,7 +1,6 @@
load(qttest_p4)
contains(QT_CONFIG,declarative): QT += declarative
-contains(QT_CONFIG, opengles2)|contains(QT_CONFIG, opengles1): QT += opengl
-SOURCES += tst_simplecanvasitem.cpp
+SOURCES += tst_states.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/states/tst_states.cpp b/tests/auto/declarative/states/tst_states.cpp
new file mode 100644
index 0000000..3a61bd6
--- /dev/null
+++ b/tests/auto/declarative/states/tst_states.cpp
@@ -0,0 +1,267 @@
+#include <qtest.h>
+#include <QtDeclarative/qmlengine.h>
+#include <QtDeclarative/qmlcomponent.h>
+#include <QtDeclarative/qfxrect.h>
+
+class tst_states : public QObject
+{
+ Q_OBJECT
+public:
+ tst_states() {}
+
+private slots:
+ void basicChanges();
+ void basicExtension();
+ void basicBinding();
+};
+
+void tst_states::basicChanges()
+{
+ QmlEngine engine;
+
+ {
+ QmlComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml");
+ QFxRect *rect = qobject_cast<QFxRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ }
+
+ {
+ QmlComponent rectComponent(&engine, SRCDIR "/data/basicChanges2.qml");
+ QFxRect *rect = qobject_cast<QFxRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+ }
+
+ {
+ QmlComponent rectComponent(&engine, SRCDIR "/data/basicChanges3.qml");
+ QFxRect *rect = qobject_cast<QFxRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1);
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),1);
+
+ rect->setState("bordered");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),2);
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1);
+ //### we should be checking that this is an implicit rather than explicit 1 (which currently fails)
+
+ rect->setState("bordered");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),2);
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),1);
+
+ }
+}
+
+void tst_states::basicExtension()
+{
+ QmlEngine engine;
+
+ {
+ QmlComponent rectComponent(&engine, SRCDIR "/data/basicExtension.qml");
+ QFxRect *rect = qobject_cast<QFxRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1);
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),1);
+
+ rect->setState("bordered");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),2);
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),1);
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1);
+
+ rect->setState("bordered");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),2);
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1);
+ }
+
+ {
+ QmlComponent rectComponent(&engine, SRCDIR "/data/fakeExtension.qml");
+ QFxRect *rect = qobject_cast<QFxRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+ }
+}
+
+void tst_states::basicBinding()
+{
+ QmlEngine engine;
+
+ {
+ QmlComponent rectComponent(&engine, SRCDIR "/data/basicBinding.qml");
+ QFxRect *rect = qobject_cast<QFxRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor", QColor("green"));
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("yellow"));
+ }
+
+ {
+ QmlComponent rectComponent(&engine, SRCDIR "/data/basicBinding2.qml");
+ QFxRect *rect = qobject_cast<QFxRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor", QColor("green"));
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("green"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("yellow"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("yellow"));
+ }
+
+ {
+ QmlComponent rectComponent(&engine, SRCDIR "/data/basicBinding3.qml");
+ QFxRect *rect = qobject_cast<QFxRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->setProperty("sourceColor", QColor("green"));
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor", QColor("red"));
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor2", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("yellow"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->setProperty("sourceColor2", QColor("green"));
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("yellow"));
+ }
+
+ {
+ QmlComponent rectComponent(&engine, SRCDIR "/data/basicBinding4.qml");
+ QFxRect *rect = qobject_cast<QFxRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("yellow"));
+
+ rect->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+ rect->setProperty("sourceColor", QColor("purple"));
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("purple"));
+
+ rect->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ }
+}
+
+QTEST_MAIN(tst_states)
+
+#include "tst_states.moc"