diff options
Diffstat (limited to 'tests/auto/quick/qquickrepeater')
-rw-r--r-- | tests/auto/quick/qquickrepeater/data/package.qml | 35 | ||||
-rw-r--r-- | tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp | 24 |
2 files changed, 59 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickrepeater/data/package.qml b/tests/auto/quick/qquickrepeater/data/package.qml new file mode 100644 index 0000000000..1f9eb0d970 --- /dev/null +++ b/tests/auto/quick/qquickrepeater/data/package.qml @@ -0,0 +1,35 @@ +import QtQuick 2.0 +import QtQml.Models 2.2 +import QtQuick.Window 2.0 + +Window { + width: 300 + height: 300 + visible: true + DelegateModel { + id: mdl + + model: 1 + delegate: Package { + Item { + id: first + Package.name: "first" + objectName: "firstItem" + } + Item{ + id: second + Package.name: "second" + objectName: "secondItem" + } + } + } + + Repeater { + id: repeater1 + model: mdl.parts.first + } + Repeater { + id: repeater2 + model: mdl.parts.second + } +} diff --git a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp index 0499e2f9a6..791c3ae19a 100644 --- a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp +++ b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp @@ -76,6 +76,7 @@ private slots: void stackingOrder(); void objectModel(); void QTBUG54859_asynchronousMove(); + void package(); }; class TestObject : public QObject @@ -1014,6 +1015,29 @@ void tst_QQuickRepeater::QTBUG54859_asynchronousMove() QTRY_COMPARE(item->property("finished"), QVariant(true)); } +void tst_QQuickRepeater::package() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("package.qml")); + + QScopedPointer<QObject>o(component.create()); // don't crash! + QVERIFY(o != nullptr); + + { + QQuickRepeater *repeater1 = qobject_cast<QQuickRepeater*>(qmlContext(o.data())->contextProperty("repeater1").value<QObject*>()); + QVERIFY(repeater1); + QCOMPARE(repeater1->count(), 1); + QCOMPARE(repeater1->itemAt(0)->objectName(), "firstItem"); + } + + { + QQuickRepeater *repeater2 = qobject_cast<QQuickRepeater*>(qmlContext(o.data())->contextProperty("repeater2").value<QObject*>()); + QVERIFY(repeater2); + QCOMPARE(repeater2->count(), 1); + QCOMPARE(repeater2->itemAt(0)->objectName(), "secondItem"); + } +} + QTEST_MAIN(tst_QQuickRepeater) #include "tst_qquickrepeater.moc" |