aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-06-10 13:42:46 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2020-06-10 18:55:37 +0200
commit880ce0210406ff51d9c3a164ae95bcc43e020e8b (patch)
tree213fd12b55f77f9c842ac676637b9e346a252e69
parent2449999ba17c216466ccbefe77b33c790816b771 (diff)
Modernize tst_QQuickListView::QTBUG_39492
- Don't use context properties: a singleton is better - Use required properties to declare dependendencies - Rename to treeDelegateModelLayoutChange() to describe what it's testing rather than just a bug number, and because it's somewhat analogous to tst_QQuickPathView::treeModel() Task-number: QTBUG-39492 Change-Id: I753bbdf625b8d8c82774b6a2b1754fe3c8895823 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--tests/auto/quick/qquicklistview/data/treeDelegateModel.qml (renamed from tests/auto/quick/qquicklistview/data/qtbug39492.qml)11
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp15
2 files changed, 14 insertions, 12 deletions
diff --git a/tests/auto/quick/qquicklistview/data/qtbug39492.qml b/tests/auto/quick/qquicklistview/data/treeDelegateModel.qml
index 4df3a080d7..2c960c0027 100644
--- a/tests/auto/quick/qquicklistview/data/qtbug39492.qml
+++ b/tests/auto/quick/qquicklistview/data/treeDelegateModel.qml
@@ -1,5 +1,6 @@
-import QtQuick 2.0
-import QtQml.Models 2.1
+import QtQuick 2.15
+import QtQml.Models 2.15
+import Qt.treemodel
Rectangle {
id: root
@@ -7,12 +8,12 @@ Rectangle {
height: 320
color: "#ffffff"
-
Component {
id: myDelegate
Rectangle {
id: wrapper
objectName: "wrapper"
+ required property string display
height: 20
width: 240
Text {
@@ -26,14 +27,14 @@ Rectangle {
DelegateModel {
id: delegateModel
objectName: "delegateModel"
- model: testModel
+ model: TreeModelCpp
delegate: myDelegate
}
ListView {
id: list
objectName: "listView"
- model: delegateModel;
+ model: delegateModel
focus: true
anchors.fill: parent
}
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index 349d070a07..46e59d229e 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2018 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -255,8 +255,8 @@ private slots:
void layoutChange();
- void QTBUG_39492_data();
- void QTBUG_39492();
+ void treeDelegateModelLayoutChange_data();
+ void treeDelegateModelLayoutChange();
void jsArrayChange();
void objectModel();
@@ -8945,7 +8945,7 @@ void tst_QQuickListView::layoutChange()
}
}
-void tst_QQuickListView::QTBUG_39492_data()
+void tst_QQuickListView::treeDelegateModelLayoutChange_data()
{
QStandardItemModel *sourceModel = new QStandardItemModel(this);
for (int i = 0; i < 5; ++i) {
@@ -8981,14 +8981,15 @@ void tst_QQuickListView::QTBUG_39492_data()
<< QPersistentModelIndex(sortModel->index(1, 0, rootIndex2));
}
-void tst_QQuickListView::QTBUG_39492()
+void tst_QQuickListView::treeDelegateModelLayoutChange() // QTBUG-39492
{
QFETCH(QSortFilterProxyModel*, model);
QFETCH(QPersistentModelIndex, rootIndex);
+ qmlRegisterSingletonInstance("Qt.treemodel", 1, 0, "TreeModelCpp", model);
+
QQuickView *window = getView();
- window->rootContext()->setContextProperty("testModel", QVariant::fromValue(model));
- window->setSource(testFileUrl("qtbug39492.qml"));
+ window->setSource(testFileUrl("treeDelegateModel.qml"));
QQuickListView *listview = window->rootObject()->findChild<QQuickListView *>("listView");
QVERIFY(listview);