summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/declarative.pro1
-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
-rw-r--r--tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp14
-rw-r--r--tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp8
-rw-r--r--tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp42
-rw-r--r--tests/auto/declarative/qmllanguage/data/interfaceQmlList.qml7
-rw-r--r--tests/auto/declarative/qmllanguage/data/listAssignment.1.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/listAssignment.1.qml4
-rw-r--r--tests/auto/declarative/qmllanguage/testtypes.h21
-rw-r--r--tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp47
-rw-r--r--tests/auto/declarative/qmllist/data/MyType.qml5
-rw-r--r--tests/auto/declarative/qmllist/data/engineTypes.qml9
-rw-r--r--tests/auto/declarative/qmllist/data/variantToList.qml10
-rw-r--r--tests/auto/declarative/qmllist/tst_qmllist.cpp528
-rw-r--r--tests/auto/declarative/qmllistaccessor/qmllistaccessor.pro5
-rw-r--r--tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp452
-rw-r--r--tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp35
-rw-r--r--tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp81
-rw-r--r--tests/auto/declarative/qmlstates/tst_qmlstates.cpp48
21 files changed, 643 insertions, 720 deletions
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index 2c58f7c..9dc7230 100644
--- a/tests/auto/declarative/declarative.pro
+++ b/tests/auto/declarative/declarative.pro
@@ -40,7 +40,6 @@ SUBDIRS += \
qmlinstruction \ # Cover
qmllanguage \ # Cover
qmllist \ # Cover
- qmllistaccessor \ # Cover
qmllistmodel \ # Cover
qmlmetaproperty \ # Cover
qmlmetatype \ # Cover
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;
}
diff --git a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp b/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp
index 072f740..b986a64 100644
--- a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp
+++ b/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp
@@ -268,31 +268,31 @@ void tst_QmlGraphicsPathView::path()
QCOMPARE(obj->startY(), 100.);
QVERIFY(obj->path() != QPainterPath());
- QList<QmlGraphicsPathElement*> *list = obj->pathElements();
- QCOMPARE(list->count(), 5);
+ QmlListReference list(obj, "pathElements");
+ QCOMPARE(list.count(), 5);
- QmlGraphicsPathAttribute* attr = qobject_cast<QmlGraphicsPathAttribute*>(list->at(0));
+ QmlGraphicsPathAttribute* attr = qobject_cast<QmlGraphicsPathAttribute*>(list.at(0));
QVERIFY(attr != 0);
QCOMPARE(attr->name(), QString("scale"));
QCOMPARE(attr->value(), 1.0);
- QmlGraphicsPathQuad* quad = qobject_cast<QmlGraphicsPathQuad*>(list->at(1));
+ QmlGraphicsPathQuad* quad = qobject_cast<QmlGraphicsPathQuad*>(list.at(1));
QVERIFY(quad != 0);
QCOMPARE(quad->x(), 120.);
QCOMPARE(quad->y(), 25.);
QCOMPARE(quad->controlX(), 260.);
QCOMPARE(quad->controlY(), 75.);
- QmlGraphicsPathPercent* perc = qobject_cast<QmlGraphicsPathPercent*>(list->at(2));
+ QmlGraphicsPathPercent* perc = qobject_cast<QmlGraphicsPathPercent*>(list.at(2));
QVERIFY(perc != 0);
QCOMPARE(perc->value(), 0.3);
- QmlGraphicsPathLine* line = qobject_cast<QmlGraphicsPathLine*>(list->at(3));
+ QmlGraphicsPathLine* line = qobject_cast<QmlGraphicsPathLine*>(list.at(3));
QVERIFY(line != 0);
QCOMPARE(line->x(), 120.);
QCOMPARE(line->y(), 100.);
- QmlGraphicsPathCubic* cubic = qobject_cast<QmlGraphicsPathCubic*>(list->at(4));
+ QmlGraphicsPathCubic* cubic = qobject_cast<QmlGraphicsPathCubic*>(list.at(4));
QVERIFY(cubic != 0);
QCOMPARE(cubic->x(), 180.);
QCOMPARE(cubic->y(), 0.);
diff --git a/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp b/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp
index 9e3a028..c971840 100644
--- a/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp
+++ b/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp
@@ -188,14 +188,14 @@ void tst_QmlGraphicsRepeater::objectList()
{
QmlView *canvas = createView(SRCDIR "/data/objlist.qml");
- QObjectList* data = new QObjectList;
+ QObjectList data;
for(int i=0; i<100; i++){
- *data << new QObject();
- data->back()->setProperty("idx", i);
+ data << new QObject();
+ data.back()->setProperty("idx", i);
}
QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testData", QVariant::fromValue<QObjectList*>(data));
+ ctxt->setContextProperty("testData", QVariant::fromValue(data));
canvas->execute();
qApp->processEvents();
diff --git a/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp b/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp
index 9c753ce..38d024a 100644
--- a/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp
+++ b/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp
@@ -421,13 +421,6 @@ void tst_qmlinstruction::dump()
{
QmlInstruction i;
- i.line = 37;
- i.type = QmlInstruction::StoreObjectQmlList;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
i.line = 38;
i.type = QmlInstruction::StoreObjectQList;
data->bytecode << i;
@@ -450,15 +443,6 @@ void tst_qmlinstruction::dump()
{
QmlInstruction i;
- i.line = 41;
- i.type = QmlInstruction::FetchQmlList;
- i.fetchQmlList.property = 31;
- i.fetchQmlList.type = 3;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
i.line = 42;
i.type = QmlInstruction::FetchQList;
i.fetch.property = 32;
@@ -569,20 +553,18 @@ void tst_qmlinstruction::dump()
<< "34\t\t34\tSTORE_VALUE_SOURCE\t29\t4"
<< "35\t\t35\tSTORE_VALUE_INTERCEPTOR\t30\t-4"
<< "36\t\t36\tBEGIN\t\t\t4"
- << "37\t\t37\tSTORE_OBJECT_QMLLIST"
- << "38\t\t38\tSTORE_OBJECT_QLIST"
- << "39\t\t39\tASSIGN_OBJECT_LIST"
- << "40\t\t40\tFETCH_ATTACHED\t\t23"
- << "41\t\t41\tFETCH_QMLLIST\t\t31\t3"
- << "42\t\t42\tFETCH_QLIST\t\t32"
- << "43\t\t43\tFETCH\t\t\t33"
- << "44\t\t44\tFETCH_VALUE\t\t34\t6"
- << "45\t\t45\tPOP"
- << "46\t\t46\tPOP_QLIST"
- << "47\t\t47\tPOP_VALUE\t\t35\t8"
- << "48\t\t48\tDEFER\t\t\t7"
- << "49\t\tNA\tDEFER\t\t\t7"
- << "50\t\t50\tXXX UNKOWN INSTRUCTION\t49"
+ << "37\t\t38\tSTORE_OBJECT_QLIST"
+ << "38\t\t39\tASSIGN_OBJECT_LIST"
+ << "39\t\t40\tFETCH_ATTACHED\t\t23"
+ << "40\t\t42\tFETCH_QLIST\t\t32"
+ << "41\t\t43\tFETCH\t\t\t33"
+ << "42\t\t44\tFETCH_VALUE\t\t34\t6"
+ << "43\t\t45\tPOP"
+ << "44\t\t46\tPOP_QLIST"
+ << "45\t\t47\tPOP_VALUE\t\t35\t8"
+ << "46\t\t48\tDEFER\t\t\t7"
+ << "47\t\tNA\tDEFER\t\t\t7"
+ << "48\t\t50\tXXX UNKOWN INSTRUCTION\t47"
<< "-------------------------------------------------------------------------------";
messages = QStringList();
diff --git a/tests/auto/declarative/qmllanguage/data/interfaceQmlList.qml b/tests/auto/declarative/qmllanguage/data/interfaceQmlList.qml
deleted file mode 100644
index 8392bea..0000000
--- a/tests/auto/declarative/qmllanguage/data/interfaceQmlList.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import Test 1.0
-MyContainer {
- qmllistInterfaces: [
- MyQmlObject {},
- MyQmlObject {}
- ]
-}
diff --git a/tests/auto/declarative/qmllanguage/data/listAssignment.1.errors.txt b/tests/auto/declarative/qmllanguage/data/listAssignment.1.errors.txt
deleted file mode 100644
index d68d487..0000000
--- a/tests/auto/declarative/qmllanguage/data/listAssignment.1.errors.txt
+++ /dev/null
@@ -1 +0,0 @@
-3:24:Cannot assign primitives to lists
diff --git a/tests/auto/declarative/qmllanguage/data/listAssignment.1.qml b/tests/auto/declarative/qmllanguage/data/listAssignment.1.qml
deleted file mode 100644
index 4240425..0000000
--- a/tests/auto/declarative/qmllanguage/data/listAssignment.1.qml
+++ /dev/null
@@ -1,4 +0,0 @@
-import Test 1.0
-MyContainer {
- qmllistInterfaces: 1
-}
diff --git a/tests/auto/declarative/qmllanguage/testtypes.h b/tests/auto/declarative/qmllanguage/testtypes.h
index 0dc957f..27b45e4 100644
--- a/tests/auto/declarative/qmllanguage/testtypes.h
+++ b/tests/auto/declarative/qmllanguage/testtypes.h
@@ -447,22 +447,19 @@ QML_DECLARE_TYPE(MyTypeObject);
class MyContainer : public QObject
{
Q_OBJECT
- Q_PROPERTY(QList<QObject*>* children READ children)
- Q_PROPERTY(QList<MyInterface*>* qlistInterfaces READ qlistInterfaces)
- Q_PROPERTY(QmlList<MyInterface*>* qmllistInterfaces READ qmllistInterfaces)
+ Q_PROPERTY(QmlListProperty<QObject> children READ children)
+ Q_PROPERTY(QmlListProperty<MyInterface> qlistInterfaces READ qlistInterfaces)
Q_CLASSINFO("DefaultProperty", "children");
public:
MyContainer() {}
- QList<QObject*> *children() { return &m_children; }
- QList<MyInterface *> *qlistInterfaces() { return &m_interfaces; }
- QmlList<MyInterface *> *qmllistInterfaces() { return &m_qmlinterfaces; }
- const QmlConcreteList<MyInterface *> &qmllistAccessor() const { return m_qmlinterfaces; }
+ QmlListProperty<QObject> children() { return QmlListProperty<QObject>(this, m_children); }
+ QList<QObject *> *getChildren() { return &m_children; }
+ QmlListProperty<MyInterface> qlistInterfaces() { return QmlListProperty<MyInterface>(this, m_interfaces); }
+ QList<MyInterface *> *getQListInterfaces() { return &m_interfaces; }
-private:
QList<QObject*> m_children;
QList<MyInterface *> m_interfaces;
- QmlConcreteList<MyInterface *> m_qmlinterfaces;
};
QML_DECLARE_TYPE(MyContainer);
@@ -534,12 +531,12 @@ namespace MyNamespace {
class MySecondNamespacedType : public QObject
{
Q_OBJECT
- Q_PROPERTY(QmlList<MyNamespace::MyNamespacedType *> *list READ list);
+ Q_PROPERTY(QmlListProperty<MyNamespace::MyNamespacedType> list READ list);
public:
- QmlList<MyNamespacedType *> *list() { return &m_list; }
+ QmlListProperty<MyNamespacedType> list() { return QmlListProperty<MyNamespacedType>(this, m_list); }
private:
- QmlConcreteList<MyNamespacedType *> m_list;
+ QList<MyNamespacedType *> m_list;
};
}
QML_DECLARE_TYPE(MyNamespace::MyNamespacedType);
diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
index c4636f3..4090e1d 100644
--- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
+++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
@@ -76,7 +76,6 @@ private slots:
void simpleObject();
void simpleContainer();
void interfaceProperty();
- void interfaceQmlList();
void interfaceQList();
void assignObjectToSignal();
void assignObjectToVariant();
@@ -233,7 +232,6 @@ void tst_qmllanguage::errors_data()
QTest::newRow("readOnly.2") << "readOnly.2.qml" << "readOnly.2.errors.txt" << false;
QTest::newRow("readOnly.3") << "readOnly.3.qml" << "readOnly.3.errors.txt" << false;
- QTest::newRow("listAssignment.1") << "listAssignment.1.qml" << "listAssignment.1.errors.txt" << false;
QTest::newRow("listAssignment.2") << "listAssignment.2.qml" << "listAssignment.2.errors.txt" << false;
QTest::newRow("listAssignment.3") << "listAssignment.3.qml" << "listAssignment.3.errors.txt" << false;
@@ -354,7 +352,7 @@ void tst_qmllanguage::simpleContainer()
VERIFY_ERRORS(0);
MyContainer *container= qobject_cast<MyContainer*>(component.create());
QVERIFY(container != 0);
- QCOMPARE(container->children()->count(),2);
+ QCOMPARE(container->getChildren()->count(),2);
}
void tst_qmllanguage::interfaceProperty()
@@ -367,26 +365,15 @@ void tst_qmllanguage::interfaceProperty()
QVERIFY(object->interface()->id == 913);
}
-void tst_qmllanguage::interfaceQmlList()
-{
- QmlComponent component(&engine, TEST_FILE("interfaceQmlList.qml"));
- VERIFY_ERRORS(0);
- MyContainer *container= qobject_cast<MyContainer*>(component.create());
- QVERIFY(container != 0);
- QVERIFY(container->qmllistAccessor().count() == 2);
- for(int ii = 0; ii < 2; ++ii)
- QVERIFY(container->qmllistAccessor().at(ii)->id == 913);
-}
-
void tst_qmllanguage::interfaceQList()
{
QmlComponent component(&engine, TEST_FILE("interfaceQList.qml"));
VERIFY_ERRORS(0);
MyContainer *container= qobject_cast<MyContainer*>(component.create());
QVERIFY(container != 0);
- QVERIFY(container->qlistInterfaces()->count() == 2);
+ QVERIFY(container->getQListInterfaces()->count() == 2);
for(int ii = 0; ii < 2; ++ii)
- QVERIFY(container->qlistInterfaces()->at(ii)->id == 913);
+ QVERIFY(container->getQListInterfaces()->at(ii)->id == 913);
}
void tst_qmllanguage::assignObjectToSignal()
@@ -425,8 +412,8 @@ void tst_qmllanguage::assignQmlComponent()
VERIFY_ERRORS(0);
MyContainer *object = qobject_cast<MyContainer *>(component.create());
QVERIFY(object != 0);
- QVERIFY(object->children()->count() == 1);
- QObject *child = object->children()->at(0);
+ QVERIFY(object->getChildren()->count() == 1);
+ QObject *child = object->getChildren()->at(0);
QCOMPARE(child->property("x"), QVariant(10));
QCOMPARE(child->property("y"), QVariant(11));
}
@@ -504,7 +491,7 @@ void tst_qmllanguage::rootAsQmlComponent()
MyContainer *object = qobject_cast<MyContainer *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->property("x"), QVariant(11));
- QCOMPARE(object->children()->count(), 2);
+ QCOMPARE(object->getChildren()->count(), 2);
}
// Tests that components can be specified inline
@@ -514,8 +501,8 @@ void tst_qmllanguage::inlineQmlComponents()
VERIFY_ERRORS(0);
MyContainer *object = qobject_cast<MyContainer *>(component.create());
QVERIFY(object != 0);
- QCOMPARE(object->children()->count(), 1);
- QmlComponent *comp = qobject_cast<QmlComponent *>(object->children()->at(0));
+ QCOMPARE(object->getChildren()->count(), 1);
+ QmlComponent *comp = qobject_cast<QmlComponent *>(object->getChildren()->at(0));
QVERIFY(comp != 0);
MyQmlObject *compObject = qobject_cast<MyQmlObject *>(comp->create());
QVERIFY(compObject != 0);
@@ -529,9 +516,9 @@ void tst_qmllanguage::idProperty()
VERIFY_ERRORS(0);
MyContainer *object = qobject_cast<MyContainer *>(component.create());
QVERIFY(object != 0);
- QCOMPARE(object->children()->count(), 1);
+ QCOMPARE(object->getChildren()->count(), 1);
MyTypeObject *child =
- qobject_cast<MyTypeObject *>(object->children()->at(0));
+ qobject_cast<MyTypeObject *>(object->getChildren()->at(0));
QVERIFY(child != 0);
QCOMPARE(child->id(), QString("myObjectId"));
QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child));
@@ -1034,13 +1021,13 @@ void tst_qmllanguage::defaultPropertyListOrder()
MyContainer *container = qobject_cast<MyContainer *>(component.create());
QVERIFY(container != 0);
- QCOMPARE(container->children()->count(), 6);
- QCOMPARE(container->children()->at(0)->property("index"), QVariant(0));
- QCOMPARE(container->children()->at(1)->property("index"), QVariant(1));
- QCOMPARE(container->children()->at(2)->property("index"), QVariant(2));
- QCOMPARE(container->children()->at(3)->property("index"), QVariant(3));
- QCOMPARE(container->children()->at(4)->property("index"), QVariant(4));
- QCOMPARE(container->children()->at(5)->property("index"), QVariant(5));
+ QCOMPARE(container->getChildren()->count(), 6);
+ QCOMPARE(container->getChildren()->at(0)->property("index"), QVariant(0));
+ QCOMPARE(container->getChildren()->at(1)->property("index"), QVariant(1));
+ QCOMPARE(container->getChildren()->at(2)->property("index"), QVariant(2));
+ QCOMPARE(container->getChildren()->at(3)->property("index"), QVariant(3));
+ QCOMPARE(container->getChildren()->at(4)->property("index"), QVariant(4));
+ QCOMPARE(container->getChildren()->at(5)->property("index"), QVariant(5));
}
void tst_qmllanguage::declaredPropertyValues()
diff --git a/tests/auto/declarative/qmllist/data/MyType.qml b/tests/auto/declarative/qmllist/data/MyType.qml
new file mode 100644
index 0000000..d08f35b
--- /dev/null
+++ b/tests/auto/declarative/qmllist/data/MyType.qml
@@ -0,0 +1,5 @@
+import Qt 4.6
+
+QtObject {
+ property int a
+}
diff --git a/tests/auto/declarative/qmllist/data/engineTypes.qml b/tests/auto/declarative/qmllist/data/engineTypes.qml
new file mode 100644
index 0000000..670aee4
--- /dev/null
+++ b/tests/auto/declarative/qmllist/data/engineTypes.qml
@@ -0,0 +1,9 @@
+import Qt 4.6
+
+QtObject {
+ property list<MyType> myList
+
+ myList: [ MyType { a: 1 },
+ MyType { a: 9 } ]
+
+}
diff --git a/tests/auto/declarative/qmllist/data/variantToList.qml b/tests/auto/declarative/qmllist/data/variantToList.qml
new file mode 100644
index 0000000..0c2d0aa
--- /dev/null
+++ b/tests/auto/declarative/qmllist/data/variantToList.qml
@@ -0,0 +1,10 @@
+import Qt 4.6
+
+QtObject {
+ property list<QtObject> myList;
+ myList: QtObject {}
+
+ property var value: myList
+ property int test: value.length
+}
+
diff --git a/tests/auto/declarative/qmllist/tst_qmllist.cpp b/tests/auto/declarative/qmllist/tst_qmllist.cpp
index 4ffbbb8..76def1c 100644
--- a/tests/auto/declarative/qmllist/tst_qmllist.cpp
+++ b/tests/auto/declarative/qmllist/tst_qmllist.cpp
@@ -38,9 +38,27 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+
#include <qtest.h>
+#include <QUrl>
+#include <QFileInfo>
+#include <QDir>
+#include <QmlEngine>
+#include <QmlComponent>
#include <QtDeclarative/qml.h>
#include <QtDeclarative/qmlprivate.h>
+#include <QDebug>
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ QFileInfo fileInfo(__FILE__);
+ return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath("data/" + filename));
+}
+
+inline QUrl TEST_FILE(const char *filename)
+{
+ return TEST_FILE(QLatin1String(filename));
+}
class tst_QmlList : public QObject
{
@@ -49,28 +67,506 @@ public:
tst_QmlList() {}
private slots:
- void interface();
+ void qmllistreference();
+ void qmllistreference_invalid();
+ void isValid();
+ void object();
+ void listElementType();
+ void canAppend();
+ void canAt();
+ void canClear();
+ void canCount();
+ void append();
+ void at();
+ void clear();
+ void count();
+ void copy();
+ void qmlmetaproperty();
+ void engineTypes();
+ void variantToList();
};
-void tst_QmlList::interface()
+class TestType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QmlListProperty<TestType> data READ dataProperty);
+ Q_PROPERTY(int intProperty READ intProperty);
+
+public:
+ TestType() : property(this, data) {}
+ QmlListProperty<TestType> dataProperty() { return property; }
+ int intProperty() const { return 10; }
+
+ QList<TestType *> data;
+ QmlListProperty<TestType> property;
+};
+QML_DECLARE_TYPE(TestType);
+QML_DEFINE_NOCREATE_TYPE(TestType);
+
+void tst_QmlList::qmllistreference()
+{
+ TestType tt;
+
+ QmlListReference r(&tt, "data");
+ QVERIFY(r.isValid() == true);
+ QCOMPARE(r.count(), 0);
+
+ tt.data.append(&tt);
+ QCOMPARE(r.count(), 1);
+}
+
+void tst_QmlList::qmllistreference_invalid()
+{
+ TestType tt;
+
+ // Invalid
+ {
+ QmlListReference r;
+ QVERIFY(r.isValid() == false);
+ QVERIFY(r.object() == 0);
+ QVERIFY(r.listElementType() == 0);
+ QVERIFY(r.canAt() == false);
+ QVERIFY(r.canClear() == false);
+ QVERIFY(r.canCount() == false);
+ QVERIFY(r.append(0) == false);
+ QVERIFY(r.at(10) == 0);
+ QVERIFY(r.clear() == false);
+ QVERIFY(r.count() == 0);
+ }
+
+ // Non-property
+ {
+ QmlListReference r(&tt, "blah");
+ QVERIFY(r.isValid() == false);
+ QVERIFY(r.object() == 0);
+ QVERIFY(r.listElementType() == 0);
+ QVERIFY(r.canAt() == false);
+ QVERIFY(r.canClear() == false);
+ QVERIFY(r.canCount() == false);
+ QVERIFY(r.append(0) == false);
+ QVERIFY(r.at(10) == 0);
+ QVERIFY(r.clear() == false);
+ QVERIFY(r.count() == 0);
+ }
+
+ // Non-list property
+ {
+ QmlListReference r(&tt, "intProperty");
+ QVERIFY(r.isValid() == false);
+ QVERIFY(r.object() == 0);
+ QVERIFY(r.listElementType() == 0);
+ QVERIFY(r.canAt() == false);
+ QVERIFY(r.canClear() == false);
+ QVERIFY(r.canCount() == false);
+ QVERIFY(r.append(0) == false);
+ QVERIFY(r.at(10) == 0);
+ QVERIFY(r.clear() == false);
+ QVERIFY(r.count() == 0);
+ }
+}
+
+void tst_QmlList::isValid()
+{
+ TestType *tt = new TestType;
+
+ {
+ QmlListReference ref;
+ QVERIFY(ref.isValid() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "blah");
+ QVERIFY(ref.isValid() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "data");
+ QVERIFY(ref.isValid() == true);
+ delete tt;
+ QVERIFY(ref.isValid() == false);
+ }
+}
+
+void tst_QmlList::object()
+{
+ TestType *tt = new TestType;
+
+ {
+ QmlListReference ref;
+ QVERIFY(ref.object() == 0);
+ }
+
+ {
+ QmlListReference ref(tt, "blah");
+ QVERIFY(ref.object() == 0);
+ }
+
+ {
+ QmlListReference ref(tt, "data");
+ QVERIFY(ref.object() == tt);
+ delete tt;
+ QVERIFY(ref.object() == 0);
+ }
+}
+
+void tst_QmlList::listElementType()
+{
+ TestType *tt = new TestType;
+
+ {
+ QmlListReference ref;
+ QVERIFY(ref.listElementType() == 0);
+ }
+
+ {
+ QmlListReference ref(tt, "blah");
+ QVERIFY(ref.listElementType() == 0);
+ }
+
+ {
+ QmlListReference ref(tt, "data");
+ QVERIFY(ref.listElementType() == &TestType::staticMetaObject);
+ delete tt;
+ QVERIFY(ref.listElementType() == 0);
+ }
+}
+
+void tst_QmlList::canAppend()
+{
+ TestType *tt = new TestType;
+
+ {
+ QmlListReference ref;
+ QVERIFY(ref.canAppend() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "blah");
+ QVERIFY(ref.canAppend() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "data");
+ QVERIFY(ref.canAppend() == true);
+ delete tt;
+ QVERIFY(ref.canAppend() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.append = 0;
+ QmlListReference ref(&tt, "data");
+ QVERIFY(ref.canAppend() == false);
+ }
+}
+
+void tst_QmlList::canAt()
+{
+ TestType *tt = new TestType;
+
+ {
+ QmlListReference ref;
+ QVERIFY(ref.canAt() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "blah");
+ QVERIFY(ref.canAt() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "data");
+ QVERIFY(ref.canAt() == true);
+ delete tt;
+ QVERIFY(ref.canAt() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.at = 0;
+ QmlListReference ref(&tt, "data");
+ QVERIFY(ref.canAt() == false);
+ }
+}
+
+void tst_QmlList::canClear()
+{
+ TestType *tt = new TestType;
+
+ {
+ QmlListReference ref;
+ QVERIFY(ref.canClear() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "blah");
+ QVERIFY(ref.canClear() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "data");
+ QVERIFY(ref.canClear() == true);
+ delete tt;
+ QVERIFY(ref.canClear() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.clear = 0;
+ QmlListReference ref(&tt, "data");
+ QVERIFY(ref.canClear() == false);
+ }
+}
+
+void tst_QmlList::canCount()
+{
+ TestType *tt = new TestType;
+
+ {
+ QmlListReference ref;
+ QVERIFY(ref.canCount() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "blah");
+ QVERIFY(ref.canCount() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "data");
+ QVERIFY(ref.canCount() == true);
+ delete tt;
+ QVERIFY(ref.canCount() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.count = 0;
+ QmlListReference ref(&tt, "data");
+ QVERIFY(ref.canCount() == false);
+ }
+}
+
+void tst_QmlList::append()
+{
+ TestType *tt = new TestType;
+ QObject object;
+
+ {
+ QmlListReference ref;
+ QVERIFY(ref.append(tt) == false);
+ }
+
+ {
+ QmlListReference ref(tt, "blah");
+ QVERIFY(ref.append(tt) == false);
+ }
+
+ {
+ QmlListReference ref(tt, "data");
+ QVERIFY(ref.append(tt) == true);
+ QVERIFY(tt->data.count() == 1);
+ QVERIFY(tt->data.at(0) == tt);
+ QVERIFY(ref.append(&object) == false);
+ QVERIFY(tt->data.count() == 1);
+ QVERIFY(tt->data.at(0) == tt);
+ QVERIFY(ref.append(0) == true);
+ QVERIFY(tt->data.count() == 2);
+ QVERIFY(tt->data.at(0) == tt);
+ QVERIFY(tt->data.at(1) == 0);
+ delete tt;
+ QVERIFY(ref.append(0) == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.append = 0;
+ QmlListReference ref(&tt, "data");
+ QVERIFY(ref.append(&tt) == false);
+ }
+}
+
+void tst_QmlList::at()
+{
+ TestType *tt = new TestType;
+ tt->data.append(tt);
+ tt->data.append(0);
+ tt->data.append(tt);
+
+ {
+ QmlListReference ref;
+ QVERIFY(ref.at(0) == 0);
+ }
+
+ {
+ QmlListReference ref(tt, "blah");
+ QVERIFY(ref.at(0) == 0);
+ }
+
+ {
+ QmlListReference ref(tt, "data");
+ QVERIFY(ref.at(0) == tt);
+ QVERIFY(ref.at(1) == 0);
+ QVERIFY(ref.at(2) == tt);
+ delete tt;
+ QVERIFY(ref.at(0) == 0);
+ }
+
+ {
+ TestType tt;
+ tt.data.append(&tt);
+ tt.property.at = 0;
+ QmlListReference ref(&tt, "data");
+ QVERIFY(ref.at(0) == 0);
+ }
+}
+
+void tst_QmlList::clear()
+{
+ TestType *tt = new TestType;
+ tt->data.append(tt);
+ tt->data.append(0);
+ tt->data.append(tt);
+
+ {
+ QmlListReference ref;
+ QVERIFY(ref.clear() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "blah");
+ QVERIFY(ref.clear() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "data");
+ QVERIFY(ref.clear() == true);
+ QVERIFY(tt->data.count() == 0);
+ delete tt;
+ QVERIFY(ref.clear() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.clear = 0;
+ QmlListReference ref(&tt, "data");
+ QVERIFY(ref.clear() == false);
+ }
+}
+
+void tst_QmlList::count()
+{
+ TestType *tt = new TestType;
+ tt->data.append(tt);
+ tt->data.append(0);
+ tt->data.append(tt);
+
+ {
+ QmlListReference ref;
+ QVERIFY(ref.count() == 0);
+ }
+
+ {
+ QmlListReference ref(tt, "blah");
+ QVERIFY(ref.count() == 0);
+ }
+
+ {
+ QmlListReference ref(tt, "data");
+ QVERIFY(ref.count() == 3);
+ tt->data.removeAt(1);
+ QVERIFY(ref.count() == 2);
+ delete tt;
+ QVERIFY(ref.count() == 0);
+ }
+
+ {
+ TestType tt;
+ tt.data.append(&tt);
+ tt.property.count = 0;
+ QmlListReference ref(&tt, "data");
+ QVERIFY(ref.count() == 0);
+ }
+}
+
+void tst_QmlList::copy()
+{
+ TestType tt;
+ tt.data.append(&tt);
+ tt.data.append(0);
+ tt.data.append(&tt);
+
+ QmlListReference *r1 = new QmlListReference(&tt, "data");
+ QVERIFY(r1->count() == 3);
+
+ QmlListReference r2(*r1);
+ QmlListReference r3;
+ r3 = *r1;
+
+ QVERIFY(r2.count() == 3);
+ QVERIFY(r3.count() == 3);
+
+ delete r1;
+
+ QVERIFY(r2.count() == 3);
+ QVERIFY(r3.count() == 3);
+
+ tt.data.removeAt(2);
+
+ QVERIFY(r2.count() == 2);
+ QVERIFY(r3.count() == 2);
+}
+
+void tst_QmlList::qmlmetaproperty()
+{
+ TestType tt;
+ tt.data.append(&tt);
+ tt.data.append(0);
+ tt.data.append(&tt);
+
+ QmlMetaProperty prop(&tt, QLatin1String("data"));
+ QVariant v = prop.read();
+ QVERIFY(v.userType() == qMetaTypeId<QmlListReference>());
+ QmlListReference ref = qvariant_cast<QmlListReference>(v);
+ QVERIFY(ref.count() == 3);
+ QVERIFY(ref.listElementType() == &TestType::staticMetaObject);
+}
+
+void tst_QmlList::engineTypes()
+{
+ QmlEngine engine;
+ QmlComponent component(&engine, TEST_FILE("engineTypes.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o);
+
+ QmlMetaProperty p1(o, QLatin1String("myList"));
+ QVERIFY(p1.propertyCategory() == QmlMetaProperty::Normal);
+
+ QmlMetaProperty p2(o, QLatin1String("myList"), engine.rootContext());
+ QVERIFY(p2.propertyCategory() == QmlMetaProperty::List);
+ QVariant v = p2.read();
+ QVERIFY(v.userType() == qMetaTypeId<QmlListReference>());
+ QmlListReference ref = qvariant_cast<QmlListReference>(v);
+ QVERIFY(ref.count() == 2);
+ QVERIFY(ref.listElementType());
+ QVERIFY(ref.listElementType() != &QObject::staticMetaObject);
+
+ delete o;
+}
+
+void tst_QmlList::variantToList()
{
- QmlConcreteList<QObject*> list;
- QObject *obj = new QObject;
- obj->setObjectName("foo");
- list.append(obj);
- QVERIFY(list.count() == 1);
- QCOMPARE(list.at(0), obj);
+ QmlEngine engine;
+ QmlComponent component(&engine, TEST_FILE("variantToList.qml"));
- QmlPrivate::ListInterface *li = (QmlPrivate::ListInterface*)&list;
+ QObject *o = component.create();
+ QVERIFY(o);
- void *ptr[1];
- li->at(0, ptr);
- QVERIFY(li->count() == 1);
- QCOMPARE(ptr[0], obj);
+ QVERIFY(o->property("value").userType() == qMetaTypeId<QmlListReference>());
+ QCOMPARE(o->property("test").toInt(), 1);
- li->removeAt(0);
- QVERIFY(li->count() == 0);
- QVERIFY(list.count() == 0);
+ delete o;
}
QTEST_MAIN(tst_QmlList)
diff --git a/tests/auto/declarative/qmllistaccessor/qmllistaccessor.pro b/tests/auto/declarative/qmllistaccessor/qmllistaccessor.pro
deleted file mode 100644
index ce2915e..0000000
--- a/tests/auto/declarative/qmllistaccessor/qmllistaccessor.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmllistaccessor.cpp
diff --git a/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp b/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp
deleted file mode 100644
index 3efe847..0000000
--- a/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp
+++ /dev/null
@@ -1,452 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qml.h>
-#include <private/qmllistaccessor_p.h>
-#include <QDebug>
-
-class tst_QmlListAccessor : public QObject
-{
- Q_OBJECT
-public:
- tst_QmlListAccessor() {}
-
-private slots:
- void invalid();
- void qmllist();
- void qlist();
- void qstringlist();
- void qvariantlist();
- void qobject();
- void instance();
- void integer();
-};
-
-void tst_QmlListAccessor::invalid()
-{
- QmlListAccessor accessor;
-
- QCOMPARE(accessor.list(), QVariant());
- QVERIFY(!accessor.isValid());
- QCOMPARE(accessor.type(), QmlListAccessor::Invalid);
-
- QCOMPARE(accessor.count(), 0);
- QVERIFY(!accessor.append(QVariant(10)));
- QVERIFY(!accessor.insert(0, QVariant(10)));
- QVERIFY(!accessor.removeAt(0));
- QVERIFY(!accessor.clear());
-
- accessor.setList(QVariant());
-
- QCOMPARE(accessor.list(), QVariant());
- QVERIFY(!accessor.isValid());
- QCOMPARE(accessor.type(), QmlListAccessor::Invalid);
-
- QCOMPARE(accessor.count(), 0);
- QVERIFY(!accessor.append(QVariant(10)));
- QVERIFY(!accessor.insert(0, QVariant(10)));
- QVERIFY(!accessor.removeAt(0));
- QVERIFY(!accessor.clear());
-}
-
-void tst_QmlListAccessor::qmllist()
-{
- QmlConcreteList<QObject*> list;
- QObject *obj = new QObject(this);
- QObject *obj2 = new QObject(this);
- QObject *obj3 = new QObject(this);
-
- list.append(obj);
- QVERIFY(list.count() == 1);
- QCOMPARE(list.at(0), obj);
-
- QmlListAccessor accessor;
- accessor.setList(qVariantFromValue((QmlList<QObject*>*)&list));
- QCOMPARE(accessor.list(), qVariantFromValue((QmlList<QObject*>*)&list));
-
- // type
- QCOMPARE(accessor.type(), QmlListAccessor::QmlList);
-
- // isValid
- QVERIFY(accessor.isValid());
-
- // count
- QCOMPARE(accessor.count(), 1);
-
- // at
- QCOMPARE(qvariant_cast<QObject*>(accessor.at(0)), obj);
-
- // append
- accessor.append(qVariantFromValue(obj2));
- QVERIFY(accessor.isValid());
- QCOMPARE(accessor.count(), 2);
- QCOMPARE(qvariant_cast<QObject*>(accessor.at(1)), obj2);
- QCOMPARE(list.count(), 2);
- QCOMPARE(list.at(0), obj);
- QCOMPARE(list.at(1), obj2);
-
- // insert
- accessor.insert(1, qVariantFromValue(obj3));
- QVERIFY(accessor.isValid());
- QCOMPARE(accessor.count(), 3);
- QCOMPARE(qvariant_cast<QObject*>(accessor.at(1)), obj3);
- QCOMPARE(list.count(), 3);
- QCOMPARE(list.at(0), obj);
- QCOMPARE(list.at(1), obj3);
- QCOMPARE(list.at(2), obj2);
-
- // removeAt
- accessor.removeAt(1);
- QVERIFY(accessor.isValid());
- QCOMPARE(accessor.count(), 2);
- QCOMPARE(qvariant_cast<QObject*>(accessor.at(1)), obj2);
- QCOMPARE(list.count(), 2);
- QCOMPARE(list.at(0), obj);
- QCOMPARE(list.at(1), obj2);
-
- // clear
- accessor.clear();
- QVERIFY(accessor.isValid());
- QCOMPARE(accessor.count(), 0);
- QCOMPARE(list.count(), 0);
-}
-
-void tst_QmlListAccessor::qlist()
-{
- QList<QObject*> list;
- QObject *obj = new QObject(this);
- QObject *obj2 = new QObject(this);
- QObject *obj3 = new QObject(this);
-
- list.append(obj);
- QVERIFY(list.count() == 1);
- QCOMPARE(list.at(0), obj);
-
- QmlListAccessor accessor;
- accessor.setList(qVariantFromValue((QList<QObject*>*)&list));
- QCOMPARE(accessor.list(), qVariantFromValue((QList<QObject*>*)&list));
-
- // type
- QCOMPARE(accessor.type(), QmlListAccessor::QListPtr);
-
- // isValid
- QVERIFY(accessor.isValid());
-
- // count
- QCOMPARE(accessor.count(), 1);
-
- // at
- QCOMPARE(qvariant_cast<QObject*>(accessor.at(0)), obj);
-
- // append
- accessor.append(qVariantFromValue(obj2));
- QVERIFY(accessor.isValid());
- QCOMPARE(accessor.count(), 2);
- QCOMPARE(qvariant_cast<QObject*>(accessor.at(1)), obj2);
- QCOMPARE(list.count(), 2);
- QCOMPARE(list.at(0), obj);
- QCOMPARE(list.at(1), obj2);
-
- // insert
- accessor.insert(1, qVariantFromValue(obj3));
- QVERIFY(accessor.isValid());
- QCOMPARE(accessor.count(), 3);
- QCOMPARE(qvariant_cast<QObject*>(accessor.at(1)), obj3);
- QCOMPARE(list.count(), 3);
- QCOMPARE(list.at(0), obj);
- QCOMPARE(list.at(1), obj3);
- QCOMPARE(list.at(2), obj2);
-
- // removeAt
- accessor.removeAt(1);
- QVERIFY(accessor.isValid());
- QCOMPARE(accessor.count(), 2);
- QCOMPARE(qvariant_cast<QObject*>(accessor.at(1)), obj2);
- QCOMPARE(list.count(), 2);
- QCOMPARE(list.at(0), obj);
- QCOMPARE(list.at(1), obj2);
-
- // clear
- accessor.clear();
- QVERIFY(accessor.isValid());
- QCOMPARE(accessor.count(), 0);
- QCOMPARE(list.count(), 0);
-}
-
-void tst_QmlListAccessor::qstringlist()
-{
- QStringList list;
- list.append(QLatin1String("Item1"));
- list.append(QLatin1String("Item2"));
- QVERIFY(list.count() == 2);
-
- QmlListAccessor accessor;
- accessor.setList(list);
-
- // type
- QCOMPARE(accessor.type(), QmlListAccessor::StringList);
-
- // isValid
- QVERIFY(accessor.isValid());
-
- // count
- QVERIFY(accessor.count() == 2);
-
- // at
- QCOMPARE(qvariant_cast<QString>(accessor.at(0)), QLatin1String("Item1"));
- QCOMPARE(qvariant_cast<QString>(accessor.at(1)), QLatin1String("Item2"));
-
- // append
- QVERIFY(!accessor.append(QVariant("Item3")));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 2);
- QCOMPARE(qvariant_cast<QString>(accessor.at(0)), QLatin1String("Item1"));
- QCOMPARE(qvariant_cast<QString>(accessor.at(1)), QLatin1String("Item2"));
-
- // insert
- QVERIFY(!accessor.insert(1, QVariant("MiddleItem")));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 2);
- QCOMPARE(qvariant_cast<QString>(accessor.at(0)), QLatin1String("Item1"));
- QCOMPARE(qvariant_cast<QString>(accessor.at(1)), QLatin1String("Item2"));
-
- // removeAt
- QVERIFY(!accessor.removeAt(1));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 2);
- QCOMPARE(qvariant_cast<QString>(accessor.at(0)), QLatin1String("Item1"));
- QCOMPARE(qvariant_cast<QString>(accessor.at(1)), QLatin1String("Item2"));
-
- // clear
- QVERIFY(!accessor.clear());
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 2);
- QCOMPARE(qvariant_cast<QString>(accessor.at(0)), QLatin1String("Item1"));
- QCOMPARE(qvariant_cast<QString>(accessor.at(1)), QLatin1String("Item2"));
-}
-
-void tst_QmlListAccessor::qvariantlist()
-{
- QVariantList list;
- list.append(QLatin1String("Item1"));
- list.append(QLatin1String("Item2"));
- QVERIFY(list.count() == 2);
-
- QmlListAccessor accessor;
- accessor.setList(list);
-
- // type
- QCOMPARE(accessor.type(), QmlListAccessor::VariantList);
-
- // isValid
- QVERIFY(accessor.isValid());
-
- // count
- QVERIFY(accessor.count() == 2);
-
- // at
- QCOMPARE(qvariant_cast<QString>(accessor.at(0)), QLatin1String("Item1"));
- QCOMPARE(qvariant_cast<QString>(accessor.at(1)), QLatin1String("Item2"));
-
- // append
- QVERIFY(!accessor.append(QVariant("Item3")));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 2);
- QCOMPARE(qvariant_cast<QString>(accessor.at(0)), QLatin1String("Item1"));
- QCOMPARE(qvariant_cast<QString>(accessor.at(1)), QLatin1String("Item2"));
-
- // insert
- QVERIFY(!accessor.insert(1, QVariant("MiddleItem")));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 2);
- QCOMPARE(qvariant_cast<QString>(accessor.at(0)), QLatin1String("Item1"));
- QCOMPARE(qvariant_cast<QString>(accessor.at(1)), QLatin1String("Item2"));
-
- // removeAt
- QVERIFY(!accessor.removeAt(1));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 2);
- QCOMPARE(qvariant_cast<QString>(accessor.at(0)), QLatin1String("Item1"));
- QCOMPARE(qvariant_cast<QString>(accessor.at(1)), QLatin1String("Item2"));
-
- // clear
- QVERIFY(!accessor.clear());
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 2);
- QCOMPARE(qvariant_cast<QString>(accessor.at(0)), QLatin1String("Item1"));
- QCOMPARE(qvariant_cast<QString>(accessor.at(1)), QLatin1String("Item2"));
-}
-
-void tst_QmlListAccessor::qobject()
-{
- QObject *obj = new QObject(this);
-
- QmlListAccessor accessor;
- accessor.setList(qVariantFromValue(obj));
-
- // type
- QCOMPARE(accessor.type(), QmlListAccessor::Instance);
-
- // isValid
- QVERIFY(accessor.isValid());
-
- // count
- QVERIFY(accessor.count() == 1);
-
- // at
- QCOMPARE(accessor.at(0), qVariantFromValue(obj));
-
- // append
- QVERIFY(!accessor.append(qVariantFromValue((QObject *)0)));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 1);
- QCOMPARE(accessor.at(0), qVariantFromValue(obj));
-
- // insert
- QVERIFY(!accessor.insert(0, qVariantFromValue((QObject *)0)));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 1);
- QCOMPARE(accessor.at(0), qVariantFromValue(obj));
-
- // removeAt
- QVERIFY(!accessor.removeAt(0));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 1);
- QCOMPARE(accessor.at(0), qVariantFromValue(obj));
-
- // clear
- QVERIFY(!accessor.clear());
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 1);
- QCOMPARE(accessor.at(0), qVariantFromValue(obj));
-}
-
-void tst_QmlListAccessor::instance()
-{
- QRect r;
-
- QmlListAccessor accessor;
- accessor.setList(r);
-
- // type
- QCOMPARE(accessor.type(), QmlListAccessor::Instance);
-
- // isValid
- QVERIFY(accessor.isValid());
-
- // count
- QVERIFY(accessor.count() == 1);
-
- // at
- QCOMPARE(accessor.at(0), qVariantFromValue(r));
-
- // append
- QVERIFY(!accessor.append(qVariantFromValue(r)));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 1);
- QCOMPARE(accessor.at(0), qVariantFromValue(r));
-
- // insert
- QVERIFY(!accessor.insert(0, qVariantFromValue(r)));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 1);
- QCOMPARE(accessor.at(0), qVariantFromValue(r));
-
- // removeAt
- QVERIFY(!accessor.removeAt(0));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 1);
- QCOMPARE(accessor.at(0), qVariantFromValue(r));
-
- // clear
- QVERIFY(!accessor.clear());
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 1);
- QCOMPARE(accessor.at(0), qVariantFromValue(r));
-}
-
-void tst_QmlListAccessor::integer()
-{
- int r = 13;
-
- QmlListAccessor accessor;
- accessor.setList(r);
-
- // type
- QCOMPARE(accessor.type(), QmlListAccessor::Integer);
-
- // isValid
- QVERIFY(accessor.isValid());
-
- // count
- QVERIFY(accessor.count() == 13);
-
- // at
- QCOMPARE(accessor.at(4), qVariantFromValue(4));
-
- // append
- QVERIFY(!accessor.append(qVariantFromValue(r)));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 13);
- QCOMPARE(accessor.at(4), qVariantFromValue(4));
-
- // insert
- QVERIFY(!accessor.insert(0, qVariantFromValue(r)));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 13);
- QCOMPARE(accessor.at(4), qVariantFromValue(4));
-
- // removeAt
- QVERIFY(!accessor.removeAt(0));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 13);
- QCOMPARE(accessor.at(4), qVariantFromValue(4));
-
- // clear
- QVERIFY(!accessor.clear());
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 13);
- QCOMPARE(accessor.at(4), qVariantFromValue(4));
-}
-
-QTEST_MAIN(tst_QmlListAccessor)
-
-#include "tst_qmllistaccessor.moc"
diff --git a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
index 91ff727..050cd3f 100644
--- a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
+++ b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
@@ -73,13 +73,11 @@ private:
class MyContainer : public QObject
{
Q_OBJECT
- Q_PROPERTY(QList<MyQmlObject*>* children READ children)
- Q_PROPERTY(QmlList<MyQmlObject*>* qmlChildren READ qmlChildren)
+ Q_PROPERTY(QmlListProperty<MyQmlObject> children READ children)
public:
MyContainer() {}
- QList<MyQmlObject*> *children() { return &m_children; }
- QmlConcreteList<MyQmlObject *> *qmlChildren() { return &m_qmlChildren; }
+ QmlListProperty<MyQmlObject> children() { return QmlListProperty<MyQmlObject>(this, m_children); }
static MyAttached *qmlAttachedProperties(QObject *o) {
return new MyAttached(o);
@@ -87,7 +85,6 @@ public:
private:
QList<MyQmlObject*> m_children;
- QmlConcreteList<MyQmlObject *> m_qmlChildren;
};
QML_DECLARE_TYPE(MyContainer);
@@ -118,7 +115,6 @@ private slots:
// Functionality
void writeObjectToList();
void writeListToList();
- void writeObjectToQmlList();
//writeToReadOnly();
@@ -1078,13 +1074,14 @@ void tst_qmlmetaproperty::writeObjectToList()
containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl());
MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
QVERIFY(container != 0);
- QVERIFY(container->children()->size() == 1);
+ QmlListReference list(container, "children");
+ QVERIFY(list.count() == 1);
MyQmlObject *object = new MyQmlObject;
QmlMetaProperty prop(container, "children");
prop.write(qVariantFromValue(object));
- QCOMPARE(container->children()->size(), 2);
- QCOMPARE(container->children()->at(1), object);
+ QCOMPARE(list.count(), 1);
+ QCOMPARE(list.at(0), object);
}
Q_DECLARE_METATYPE(QList<QObject *>);
@@ -1094,13 +1091,14 @@ void tst_qmlmetaproperty::writeListToList()
containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl());
MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
QVERIFY(container != 0);
- QVERIFY(container->children()->size() == 1);
+ QmlListReference list(container, "children");
+ QVERIFY(list.count() == 1);
QList<QObject*> objList;
objList << new MyQmlObject() << new MyQmlObject() << new MyQmlObject() << new MyQmlObject();
QmlMetaProperty prop(container, "children");
prop.write(qVariantFromValue(objList));
- QCOMPARE(container->children()->size(), 4);
+ QCOMPARE(list.count(), 4);
//XXX need to try this with read/write prop (for read-only it correctly doesn't write)
/*QList<MyQmlObject*> typedObjList;
@@ -1109,21 +1107,6 @@ void tst_qmlmetaproperty::writeListToList()
QCOMPARE(container->children()->size(), 1);*/
}
-void tst_qmlmetaproperty::writeObjectToQmlList()
-{
- QmlComponent containerComponent(&engine);
- containerComponent.setData("import Test 1.0\nMyContainer { qmlChildren: MyQmlObject {} }", QUrl());
- MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
- QVERIFY(container != 0);
- QVERIFY(container->qmlChildren()->size() == 1);
-
- MyQmlObject *object = new MyQmlObject;
- QmlMetaProperty prop(container, "qmlChildren");
- prop.write(qVariantFromValue(object));
- QCOMPARE(container->qmlChildren()->size(), 2);
- QCOMPARE(container->qmlChildren()->at(1), object);
-}
-
void tst_qmlmetaproperty::crashOnValueProperty()
{
QmlEngine *engine = new QmlEngine;
diff --git a/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp b/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp
index 6d1887f..750ccf8 100644
--- a/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp
+++ b/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp
@@ -67,10 +67,6 @@ private slots:
void qmlPropertyValueInterceptorCast();
void isList();
- void isQmlList();
-
- void listCount();
- void listAt();
void defaultObject();
};
@@ -346,85 +342,12 @@ void tst_qmlmetatype::qmlPropertyValueInterceptorCast()
void tst_qmlmetatype::isList()
{
- QCOMPARE(QmlMetaType::isList(QVariant()), false);
QCOMPARE(QmlMetaType::isList(QVariant::Invalid), false);
QCOMPARE(QmlMetaType::isList(QVariant::Int), false);
- QCOMPARE(QmlMetaType::isList(QVariant(10)), false);
-
- QList<TestType *> list;
- QmlConcreteList<TestType *> qmllist;
-
- QCOMPARE(QmlMetaType::isList(qMetaTypeId<QList<TestType *>*>()), true);
- QCOMPARE(QmlMetaType::isList(QVariant::fromValue(&list)), true);
- QCOMPARE(QmlMetaType::isList(qMetaTypeId<QmlList<TestType *>*>()), false);
- QCOMPARE(QmlMetaType::isList(QVariant::fromValue((QmlList<TestType *>*)&qmllist)), false);
-}
-void tst_qmlmetatype::isQmlList()
-{
- QCOMPARE(QmlMetaType::isQmlList(QVariant::Invalid), false);
- QCOMPARE(QmlMetaType::isQmlList(QVariant::Int), false);
-
- QCOMPARE(QmlMetaType::isQmlList(qMetaTypeId<QList<TestType *>*>()), false);
- QCOMPARE(QmlMetaType::isQmlList(qMetaTypeId<QmlList<TestType *>*>()), true);
-}
+ QmlListProperty<TestType> list;
-void tst_qmlmetatype::listCount()
-{
- QCOMPARE(QmlMetaType::listCount(QVariant()), 0);
- QCOMPARE(QmlMetaType::listCount(QVariant(10)), 0);
-
- QList<TestType *> list;
- QVariant listVar = QVariant::fromValue(&list);
- QmlConcreteList<TestType *> qmllist;
- QVariant qmllistVar = QVariant::fromValue((QmlList<TestType *>*)&qmllist);
-
- QCOMPARE(QmlMetaType::listCount(listVar), 0);
- QCOMPARE(QmlMetaType::listCount(qmllistVar), 0);
-
- list.append(0); list.append(0); list.append(0);
- qmllist.append(0); qmllist.append(0); qmllist.append(0);
-
- QCOMPARE(QmlMetaType::listCount(listVar), 3);
- QCOMPARE(QmlMetaType::listCount(qmllistVar), 0);
-}
-
-void tst_qmlmetatype::listAt()
-{
- QCOMPARE(QmlMetaType::listAt(QVariant(), 0), QVariant());
- QCOMPARE(QmlMetaType::listAt(QVariant(10), 0), QVariant());
- QCOMPARE(QmlMetaType::listAt(QVariant(), 10), QVariant());
- QCOMPARE(QmlMetaType::listAt(QVariant(10), 10), QVariant());
- QCOMPARE(QmlMetaType::listAt(QVariant(), -10), QVariant());
- QCOMPARE(QmlMetaType::listAt(QVariant(10), -10), QVariant());
-
- QList<TestType *> list;
- QVariant listVar = QVariant::fromValue(&list);
- QmlConcreteList<TestType *> qmllist;
- QVariant qmllistVar = QVariant::fromValue((QmlList<TestType *>*)&qmllist);
-
- QCOMPARE(QmlMetaType::listAt(listVar, 0), QVariant());
- QCOMPARE(QmlMetaType::listAt(listVar, 2), QVariant());
- QCOMPARE(QmlMetaType::listAt(listVar, -1), QVariant());
-
- QCOMPARE(QmlMetaType::listAt(qmllistVar, 0), QVariant());
- QCOMPARE(QmlMetaType::listAt(qmllistVar, 2), QVariant());
- QCOMPARE(QmlMetaType::listAt(qmllistVar, -1), QVariant());
-
- TestType ttype;
- QVariant ttypeVar = QVariant::fromValue(&ttype);
- QVariant nullttypeVar = QVariant::fromValue((TestType *)0);
-
- list.append(0); list.append(&ttype); list.append(0);
- qmllist.append(0); qmllist.append(&ttype); qmllist.append(0);
-
- QCOMPARE(QmlMetaType::listAt(listVar, 0), nullttypeVar);
- QCOMPARE(QmlMetaType::listAt(listVar, 1), ttypeVar);
- QCOMPARE(QmlMetaType::listAt(listVar, -1), QVariant());
-
- QCOMPARE(QmlMetaType::listAt(qmllistVar, 0), QVariant());
- QCOMPARE(QmlMetaType::listAt(qmllistVar, 2), QVariant());
- QCOMPARE(QmlMetaType::listAt(qmllistVar, -1), QVariant());
+ QCOMPARE(QmlMetaType::isList(qMetaTypeId<QmlListProperty<TestType> >()), true);
}
void tst_qmlmetatype::defaultObject()
diff --git a/tests/auto/declarative/qmlstates/tst_qmlstates.cpp b/tests/auto/declarative/qmlstates/tst_qmlstates.cpp
index 81145a8..b910c85 100644
--- a/tests/auto/declarative/qmlstates/tst_qmlstates.cpp
+++ b/tests/auto/declarative/qmlstates/tst_qmlstates.cpp
@@ -407,8 +407,12 @@ void tst_qmlstates::parentChange()
QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
QVERIFY(innerRect != 0);
- qmlExecuteDeferred(rect->states()->at(0));
- QmlParentChange *pChange = qobject_cast<QmlParentChange*>(rect->states()->at(0)->changes()->at(0));
+ QmlListReference list(rect, "states");
+ QmlState *state = qobject_cast<QmlState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QmlParentChange *pChange = qobject_cast<QmlParentChange*>(state->operationAt(0));
QVERIFY(pChange != 0);
QmlGraphicsItem *nParent = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("NewParent"));
QVERIFY(nParent != 0);
@@ -510,8 +514,12 @@ void tst_qmlstates::anchorChanges()
QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
QVERIFY(innerRect != 0);
- qmlExecuteDeferred(rect->states()->at(0));
- QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(rect->states()->at(0)->changes()->at(0));
+ QmlListReference list(rect, "states");
+ QmlState *state = qobject_cast<QmlState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(state->operationAt(0));
QVERIFY(aChanges != 0);
rect->setState("right");
@@ -565,8 +573,12 @@ void tst_qmlstates::anchorChanges3()
QmlGraphicsItem *bottomGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("BottomGuideline"));
QVERIFY(bottomGuideline != 0);
- qmlExecuteDeferred(rect->states()->at(0));
- QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(rect->states()->at(0)->changes()->at(0));
+ QmlListReference list(rect, "states");
+ QmlState *state = qobject_cast<QmlState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(state->operationAt(0));
QVERIFY(aChanges != 0);
rect->setState("reanchored");
@@ -611,8 +623,12 @@ void tst_qmlstates::anchorChanges4()
QmlGraphicsItem *bottomGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("BottomGuideline"));
QVERIFY(bottomGuideline != 0);
- qmlExecuteDeferred(rect->states()->at(0));
- QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(rect->states()->at(0)->changes()->at(0));
+ QmlListReference list(rect, "states");
+ QmlState *state = qobject_cast<QmlState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(state->operationAt(0));
QVERIFY(aChanges != 0);
rect->setState("reanchored");
@@ -642,8 +658,12 @@ void tst_qmlstates::anchorChanges5()
QmlGraphicsItem *bottomGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("BottomGuideline"));
QVERIFY(bottomGuideline != 0);
- qmlExecuteDeferred(rect->states()->at(0));
- QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(rect->states()->at(0)->changes()->at(0));
+ QmlListReference list(rect, "states");
+ QmlState *state = qobject_cast<QmlState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(state->operationAt(0));
QVERIFY(aChanges != 0);
rect->setState("reanchored");
@@ -700,7 +720,11 @@ void tst_qmlstates::explicitChanges()
QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
- qmlExecuteDeferred(rect->states()->at(0));
+ QmlListReference list(rect, "states");
+ QmlState *state = qobject_cast<QmlState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
QmlPropertyChanges *changes = qobject_cast<QmlPropertyChanges*>(rect->findChild<QmlPropertyChanges*>("changes"));
QVERIFY(changes != 0);
QVERIFY(changes->isExplicit());
@@ -802,7 +826,7 @@ void tst_qmlstates::deletingChange()
QmlState *state = rect->findChild<QmlState*>();
QVERIFY(state != 0);
qmlExecuteDeferred(state);
- QCOMPARE(state->changes()->count(), 1);
+ QCOMPARE(state->operationCount(), 1);
rect->setState("blue");
QCOMPARE(rect->color(),QColor("red"));