summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qmlecmascript
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative/qmlecmascript')
-rw-r--r--tests/auto/declarative/qmlecmascript/data/listProperties.qml21
-rw-r--r--tests/auto/declarative/qmlecmascript/testtypes.h11
-rw-r--r--tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp13
3 files changed, 11 insertions, 34 deletions
diff --git a/tests/auto/declarative/qmlecmascript/data/listProperties.qml b/tests/auto/declarative/qmlecmascript/data/listProperties.qml
index cae1721..810f9b6 100644
--- a/tests/auto/declarative/qmlecmascript/data/listProperties.qml
+++ b/tests/auto/declarative/qmlecmascript/data/listProperties.qml
@@ -9,12 +9,6 @@ MyQmlObject {
QtObject { property int a: 11 }
]
- objectQmlListProperty: [
- QtObject { property int a: 10 },
- QtObject { property int a: 1 },
- QtObject { property int a: 39 }
- ]
-
Script {
function calcTest1() {
var rv = 0;
@@ -24,21 +18,10 @@ MyQmlObject {
return rv;
}
- function calcTest2() {
- var rv = 0;
- for (var ii = 0; ii < root.objectQmlListProperty.length; ++ii) {
- rv += root.objectQmlListProperty[ii].a;
- }
- return rv;
- }
}
property int test1: calcTest1();
property int test2: root.objectListProperty.length
- property int test3: calcTest2();
- property int test4: root.objectQmlListProperty.length
- property bool test5: root.objectQmlListProperty[1] != undefined
- property bool test6: root.objectQmlListProperty[100] == undefined
- property bool test7: root.objectListProperty[1] != undefined
- property bool test8: root.objectListProperty[100] == undefined
+ property bool test3: root.objectListProperty[1] != undefined
+ property bool test4: root.objectListProperty[100] == undefined
}
diff --git a/tests/auto/declarative/qmlecmascript/testtypes.h b/tests/auto/declarative/qmlecmascript/testtypes.h
index 330664f..0af72cb 100644
--- a/tests/auto/declarative/qmlecmascript/testtypes.h
+++ b/tests/auto/declarative/qmlecmascript/testtypes.h
@@ -77,8 +77,7 @@ class MyQmlObject : public QObject
Q_PROPERTY(int value READ value WRITE setValue)
Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged)
Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged)
- Q_PROPERTY(QmlList<QObject *> *objectQmlListProperty READ objectQmlListProperty CONSTANT)
- Q_PROPERTY(QList<QObject *> *objectListProperty READ objectListProperty CONSTANT)
+ Q_PROPERTY(QmlListProperty<QObject> objectListProperty READ objectListProperty CONSTANT)
Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty)
public:
@@ -107,8 +106,7 @@ public:
emit objectChanged();
}
- QmlList<QObject *> *objectQmlListProperty() { return &m_objectQmlList; }
- QList<QObject *> *objectListProperty() { return &m_objectQList; }
+ QmlListProperty<QObject> objectListProperty() { return QmlListProperty<QObject>(this, m_objectQList); }
bool methodCalled() const { return m_methodCalled; }
bool methodIntCalled() const { return m_methodIntCalled; }
@@ -150,7 +148,6 @@ private:
QObject *m_object;
QString m_string;
- QmlConcreteList<QObject *> m_objectQmlList;
QList<QObject *> m_objectQList;
int m_value;
int m_resetProperty;
@@ -162,11 +159,11 @@ QML_DECLARE_TYPE(MyQmlObject);
class MyQmlContainer : public QObject
{
Q_OBJECT
- Q_PROPERTY(QList<MyQmlObject*>* children READ children CONSTANT)
+ Q_PROPERTY(QmlListProperty<MyQmlObject> children READ children CONSTANT)
public:
MyQmlContainer() {}
- QList<MyQmlObject*> *children() { return &m_children; }
+ QmlListProperty<MyQmlObject> children() { return QmlListProperty<MyQmlObject>(this, m_children); }
private:
QList<MyQmlObject*> m_children;
diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
index 0ef836f..b30ad1c 100644
--- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
+++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
@@ -365,7 +365,6 @@ void tst_qmlecmascript::basicExpressions()
QCOMPARE(expr.value(), result);
}
-Q_DECLARE_METATYPE(QList<QObject *>);
void tst_qmlecmascript::arrayExpressions()
{
QObject obj1;
@@ -985,12 +984,8 @@ void tst_qmlecmascript::listProperties()
QCOMPARE(object->property("test1").toInt(), 21);
QCOMPARE(object->property("test2").toInt(), 2);
- QCOMPARE(object->property("test3").toInt(), 50);
- QCOMPARE(object->property("test4").toInt(), 3);
- QCOMPARE(object->property("test5").toBool(), true);
- QCOMPARE(object->property("test6").toBool(), true);
- QCOMPARE(object->property("test7").toBool(), true);
- QCOMPARE(object->property("test8").toBool(), true);
+ QCOMPARE(object->property("test3").toBool(), true);
+ QCOMPARE(object->property("test4").toBool(), true);
}
void tst_qmlecmascript::exceptionClearsOnReeval()
@@ -1612,7 +1607,9 @@ void tst_qmlecmascript::listToVariant()
QObject *object = component.create(&context);
QVERIFY(object != 0);
- QCOMPARE(object->property("test"), QVariant::fromValue(container.children()));
+ QVariant v = object->property("test");
+ QCOMPARE(v.userType(), qMetaTypeId<QmlListReference>());
+ QVERIFY(qvariant_cast<QmlListReference>(v).object() == &container);
delete object;
}