summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-04-08 00:52:14 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-04-08 00:52:14 (GMT)
commit979ad950e257c0c90463ab6c2db7fea4aece3331 (patch)
tree9bd14fb2e786d5a84ae3b5685c46e6e7a5594b59 /tests/auto
parentfac110fd9313972f001bf8b52b0254cc2d67ef66 (diff)
parent9d9161446bfad883c298d54a122e822c5e273a9c (diff)
downloadQt-979ad950e257c0c90463ab6c2db7fea4aece3331.zip
Qt-979ad950e257c0c90463ab6c2db7fea4aece3331.tar.gz
Qt-979ad950e257c0c90463ab6c2db7fea4aece3331.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.1.qml16
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.2.qml17
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.3.qml21
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.4.qml22
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.5.qml35
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.h6
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp75
7 files changed, 192 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.1.qml
new file mode 100644
index 0000000..9c289be
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.1.qml
@@ -0,0 +1,16 @@
+import Qt.test 1.0
+import Qt 4.6
+
+MyQmlObject {
+ id: root
+
+ property bool test1
+ property bool test2
+
+ qlistProperty: root
+
+ Component.onCompleted: {
+ test1 = (qlistProperty.length == 1)
+ test2 = (qlistProperty[0] == root)
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.2.qml
new file mode 100644
index 0000000..8041f5c
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.2.qml
@@ -0,0 +1,17 @@
+import Qt.test 1.0
+import Qt 4.6
+
+MyQmlObject {
+ id: root
+
+ property bool test1
+ property bool test2
+
+ Component.onCompleted: {
+ qlistProperty = root
+
+ test1 = (qlistProperty.length == 1)
+ test2 = (qlistProperty[0] == root)
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.3.qml
new file mode 100644
index 0000000..df44e48
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.3.qml
@@ -0,0 +1,21 @@
+import Qt.test 1.0
+import Qt 4.6
+
+MyQmlObject {
+ id: root
+
+ property bool test1
+ property bool test2
+ property bool test3
+ property bool test4
+
+ objectProperty: QtObject { id: obj }
+ qlistProperty: [ root, obj ]
+
+ Component.onCompleted: {
+ test1 = (qlistProperty.length == 2)
+ test2 = (qlistProperty[0] == root)
+ test3 = (qlistProperty[1] == obj)
+ test4 = (qlistProperty[2] == null)
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.4.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.4.qml
new file mode 100644
index 0000000..33c3576
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.4.qml
@@ -0,0 +1,22 @@
+import Qt.test 1.0
+import Qt 4.6
+
+MyQmlObject {
+ id: root
+
+ property bool test1
+ property bool test2
+ property bool test3
+ property bool test4
+
+ objectProperty: QtObject { id: obj }
+
+ Component.onCompleted: {
+ qlistProperty = [ root, obj ]
+
+ test1 = (qlistProperty.length == 2)
+ test2 = (qlistProperty[0] == root)
+ test3 = (qlistProperty[1] == obj)
+ test4 = (qlistProperty[2] == null)
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.5.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.5.qml
new file mode 100644
index 0000000..3fd497c
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.5.qml
@@ -0,0 +1,35 @@
+import Qt.test 1.0
+import Qt 4.6
+
+MyQmlObject {
+ id: root
+
+ property bool test1
+ property bool test2
+ property bool test3
+ property bool test4
+ property bool test5
+ property bool test6
+ property bool test7
+ property bool test8
+
+ objectProperty: QtObject { id: obj }
+
+ Component.onCompleted: {
+ qlistProperty = [ root, obj ]
+
+ test1 = (qlistProperty.length == 2)
+ test2 = (qlistProperty[0] == root)
+ test3 = (qlistProperty[1] == obj)
+ test4 = (qlistProperty[2] == null)
+
+ var a = qlistProperty;
+ a.reverse();
+ qlistProperty = a
+
+ test5 = (qlistProperty.length == 2)
+ test7 = (qlistProperty[0] == obj)
+ test6 = (qlistProperty[1] == root)
+ test8 = (qlistProperty[2] == null)
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
index faad8b7..d8ec452 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
@@ -91,6 +91,7 @@ class MyQmlObject : public QObject
Q_PROPERTY(QDeclarativeListProperty<QObject> objectListProperty READ objectListProperty CONSTANT)
Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty)
Q_PROPERTY(QRegExp regExp READ regExp WRITE setRegExp)
+ Q_PROPERTY(QList<QObject *> qlistProperty READ qlistProperty WRITE setQListProperty)
public:
MyQmlObject(): m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13) {}
@@ -142,6 +143,9 @@ public:
QRegExp regExp() { return m_regExp; }
void setRegExp(const QRegExp &regExp) { m_regExp = regExp; }
+ QList<QObject *> qlistProperty() const { return m_objectQList2; }
+ void setQListProperty(const QList<QObject *> &v) { m_objectQList2 = v; }
+
signals:
void basicSignal();
void argumentSignal(int a, QString b, qreal c);
@@ -167,6 +171,8 @@ private:
int m_value;
int m_resetProperty;
QRegExp m_regExp;
+
+ QList<QObject *> m_objectQList2;
};
QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 77dd4b8..a2625da 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -130,6 +130,7 @@ private slots:
void qlistqobjectMethods();
void strictlyEquals();
void compiled();
+ void qlistOfQObjects();
void bug1();
void dynamicCreationCrash();
@@ -2065,6 +2066,80 @@ void tst_qdeclarativeecmascript::compiled()
delete object;
}
+// Test manipulating QList<QObject *> properties
+void tst_qdeclarativeecmascript::qlistOfQObjects()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("qlistOfQObjects.1.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("qlistOfQObjects.2.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("qlistOfQObjects.3.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+ QCOMPARE(object->property("test3").toBool(), true);
+ QCOMPARE(object->property("test4").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("qlistOfQObjects.4.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+ QCOMPARE(object->property("test3").toBool(), true);
+ QCOMPARE(object->property("test4").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("qlistOfQObjects.5.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+ QCOMPARE(object->property("test3").toBool(), true);
+ QCOMPARE(object->property("test4").toBool(), true);
+ QCOMPARE(object->property("test5").toBool(), true);
+ QCOMPARE(object->property("test6").toBool(), true);
+ QCOMPARE(object->property("test7").toBool(), true);
+ QCOMPARE(object->property("test8").toBool(), true);
+
+ delete object;
+ }
+}
+
QTEST_MAIN(tst_qdeclarativeecmascript)
#include "tst_qdeclarativeecmascript.moc"