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>
This commit is contained in:
parent
2449999ba1
commit
880ce02104
|
@ -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
|
||||
}
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue