summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-03-09 06:20:45 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-03-09 06:20:45 (GMT)
commitfba8a431a9af215c54b04b5ab23c684621615a94 (patch)
tree16fb557585d20421489c157c6a4c3083fa4b42ab /tests/auto/declarative
parentd660cb7978785e8aeed59bc781f4a3df1289bb84 (diff)
downloadQt-fba8a431a9af215c54b04b5ab23c684621615a94.zip
Qt-fba8a431a9af215c54b04b5ab23c684621615a94.tar.gz
Qt-fba8a431a9af215c54b04b5ab23c684621615a94.tar.bz2
Add QML support for methods returning QList<QObject *>
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/ownership.qml5
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/qlistqobjectMethods.qml6
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp38
3 files changed, 49 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/ownership.qml b/tests/auto/declarative/qdeclarativeecmascript/data/ownership.qml
new file mode 100644
index 0000000..72edf6e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/ownership.qml
@@ -0,0 +1,5 @@
+import Qt 4.6
+
+QtObject {
+ Component.onCompleted: { var a = getObject(); a = null; }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qlistqobjectMethods.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qlistqobjectMethods.qml
new file mode 100644
index 0000000..5897e2a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/qlistqobjectMethods.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+QtObject {
+ property int test: getObjects().length
+ property bool test2: getObjects()[0].trueProperty
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 16086cd..bdd2c93 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -127,6 +127,7 @@ private slots:
void scriptConnect();
void scriptDisconnect();
void ownership();
+ void qlistqobjectMethods();
void bug1();
@@ -1945,6 +1946,43 @@ void tst_qdeclarativeecmascript::ownership()
}
}
+class QListQObjectMethodsObject : public QObject
+{
+ Q_OBJECT
+public:
+ QListQObjectMethodsObject() {
+ m_objects.append(new MyQmlObject());
+ m_objects.append(new MyQmlObject());
+ }
+
+ ~QListQObjectMethodsObject() {
+ qDeleteAll(m_objects);
+ }
+
+public slots:
+ QList<QObject *> getObjects() { return m_objects; }
+
+private:
+ QList<QObject *> m_objects;
+};
+
+// Tests that returning a QList<QObject*> from a method works
+void tst_qdeclarativeecmascript::qlistqobjectMethods()
+{
+ QListQObjectMethodsObject obj;
+ QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext());
+ context->addDefaultObject(&obj);
+
+ QDeclarativeComponent component(&engine, TEST_FILE("qlistqobjectMethods.qml"));
+
+ QObject *object = component.create(context);
+
+ QCOMPARE(object->property("test").toInt(), 2);
+ QCOMPARE(object->property("test2").toBool(), true);
+
+ delete object;
+}
+
QTEST_MAIN(tst_qdeclarativeecmascript)
#include "tst_qdeclarativeecmascript.moc"