aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp
diff options
context:
space:
mode:
authorIonut Alexandrescu <ionut.alexandrescu@qt.io>2017-02-20 13:27:22 +0100
committerIonut Alexandrescu <ionut.alexandrescu@qt.io>2017-02-21 12:30:30 +0000
commitbf1bd3abc9a2d990014fa8be451e0239fe12e198 (patch)
tree2d635481c7f3d92a686282c55c0d916e19b99dad /tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp
parent3e537dd3dcf5608241282d8437fb1593d2e6fa17 (diff)
Add a javascript push method binding to QQmlListProperty
Create a PropertyList prototype, and add the push method to QQmlListProperty that call the append function if it has been defined. Added a unit test and updated the documentation. Change-Id: I2647766e98b60bf0546f6d6ed1422a616e0d3a07 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp')
-rw-r--r--tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp24
1 files changed, 24 insertions, 0 deletions
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"