aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qml/qqmllistreference/data/propertyList.qml12
-rw-r--r--tests/auto/qml/qqmllistreference/qqmllistreference.pro2
-rw-r--r--tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp24
3 files changed, 37 insertions, 1 deletions
diff --git a/tests/auto/qml/qqmllistreference/data/propertyList.qml b/tests/auto/qml/qqmllistreference/data/propertyList.qml
new file mode 100644
index 0000000000..c791c6dcf0
--- /dev/null
+++ b/tests/auto/qml/qqmllistreference/data/propertyList.qml
@@ -0,0 +1,12 @@
+import QtQuick 2.7
+
+Item {
+ id:root
+
+ Component.onCompleted : {
+ var st1 = Qt.createQmlObject( "import QtQuick 2.7; State{ name: 'MyState1' }", root, "dynamicState1" );
+ var st2 = Qt.createQmlObject( "import QtQuick 2.7; State{ name: 'MyState2' }", root, "dynamicState2" );
+ root.states.push( st1, st2 );
+ root.state = "MyState2";
+ }
+}
diff --git a/tests/auto/qml/qqmllistreference/qqmllistreference.pro b/tests/auto/qml/qqmllistreference/qqmllistreference.pro
index dceb7d1133..110d0d9c81 100644
--- a/tests/auto/qml/qqmllistreference/qqmllistreference.pro
+++ b/tests/auto/qml/qqmllistreference/qqmllistreference.pro
@@ -8,4 +8,4 @@ include (../../shared/util.pri)
TESTDATA = data/*
-QT += core-private gui-private qml-private testlib
+QT += core-private gui-private quick-private qml-private testlib
diff --git a/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp b/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp
index 4d33359eaa..5c16a48378 100644
--- a/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp
+++ b/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp
@@ -36,6 +36,7 @@
#include <QtQml/qqmlprivate.h>
#include <QtQml/qqmlproperty.h>
#include <QDebug>
+#include <private/qquickstate_p.h>
#include "../../shared/util.h"
class tst_qqmllistreference : public QQmlDataTest
@@ -65,6 +66,7 @@ private slots:
void qmlmetaproperty();
void engineTypes();
void variantToList();
+ void listProperty();
};
class TestType : public QObject
@@ -618,6 +620,28 @@ void tst_qqmllistreference::variantToList()
delete o;
}
+void tst_qqmllistreference::listProperty()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("propertyList.qml"));
+
+ QScopedPointer<QObject> object( component.create() );
+ QVERIFY(object != 0);
+
+ QCOMPARE( object->property("state").toString(), QStringLiteral("MyState2") );
+ QQmlListReference list( object.data(), "states");
+ QCOMPARE( list.count(), 2 );
+
+ QQuickState* state1 = dynamic_cast<QQuickState*>( list.at( 0 ) );
+ QVERIFY(state1 != 0);
+ QCOMPARE( state1->name(), QStringLiteral("MyState1") );
+ QQuickState* state2 = dynamic_cast<QQuickState*>( list.at( 1 ) );
+ QVERIFY(state2 != 0);
+
+ QCOMPARE( state2->name(), QStringLiteral("MyState2") );
+}
+
+
QTEST_MAIN(tst_qqmllistreference)
#include "tst_qqmllistreference.moc"