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 QtQuick 2.15
|
||||||
import QtQml.Models 2.1
|
import QtQml.Models 2.15
|
||||||
|
import Qt.treemodel
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: root
|
id: root
|
||||||
|
@ -7,12 +8,12 @@ Rectangle {
|
||||||
height: 320
|
height: 320
|
||||||
color: "#ffffff"
|
color: "#ffffff"
|
||||||
|
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: myDelegate
|
id: myDelegate
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: wrapper
|
id: wrapper
|
||||||
objectName: "wrapper"
|
objectName: "wrapper"
|
||||||
|
required property string display
|
||||||
height: 20
|
height: 20
|
||||||
width: 240
|
width: 240
|
||||||
Text {
|
Text {
|
||||||
|
@ -26,14 +27,14 @@ Rectangle {
|
||||||
DelegateModel {
|
DelegateModel {
|
||||||
id: delegateModel
|
id: delegateModel
|
||||||
objectName: "delegateModel"
|
objectName: "delegateModel"
|
||||||
model: testModel
|
model: TreeModelCpp
|
||||||
delegate: myDelegate
|
delegate: myDelegate
|
||||||
}
|
}
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
id: list
|
id: list
|
||||||
objectName: "listView"
|
objectName: "listView"
|
||||||
model: delegateModel;
|
model: delegateModel
|
||||||
focus: true
|
focus: true
|
||||||
anchors.fill: parent
|
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/
|
** Contact: https://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
** This file is part of the test suite of the Qt Toolkit.
|
** This file is part of the test suite of the Qt Toolkit.
|
||||||
|
@ -255,8 +255,8 @@ private slots:
|
||||||
|
|
||||||
void layoutChange();
|
void layoutChange();
|
||||||
|
|
||||||
void QTBUG_39492_data();
|
void treeDelegateModelLayoutChange_data();
|
||||||
void QTBUG_39492();
|
void treeDelegateModelLayoutChange();
|
||||||
|
|
||||||
void jsArrayChange();
|
void jsArrayChange();
|
||||||
void objectModel();
|
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);
|
QStandardItemModel *sourceModel = new QStandardItemModel(this);
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i < 5; ++i) {
|
||||||
|
@ -8981,14 +8981,15 @@ void tst_QQuickListView::QTBUG_39492_data()
|
||||||
<< QPersistentModelIndex(sortModel->index(1, 0, rootIndex2));
|
<< QPersistentModelIndex(sortModel->index(1, 0, rootIndex2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QQuickListView::QTBUG_39492()
|
void tst_QQuickListView::treeDelegateModelLayoutChange() // QTBUG-39492
|
||||||
{
|
{
|
||||||
QFETCH(QSortFilterProxyModel*, model);
|
QFETCH(QSortFilterProxyModel*, model);
|
||||||
QFETCH(QPersistentModelIndex, rootIndex);
|
QFETCH(QPersistentModelIndex, rootIndex);
|
||||||
|
|
||||||
|
qmlRegisterSingletonInstance("Qt.treemodel", 1, 0, "TreeModelCpp", model);
|
||||||
|
|
||||||
QQuickView *window = getView();
|
QQuickView *window = getView();
|
||||||
window->rootContext()->setContextProperty("testModel", QVariant::fromValue(model));
|
window->setSource(testFileUrl("treeDelegateModel.qml"));
|
||||||
window->setSource(testFileUrl("qtbug39492.qml"));
|
|
||||||
|
|
||||||
QQuickListView *listview = window->rootObject()->findChild<QQuickListView *>("listView");
|
QQuickListView *listview = window->rootObject()->findChild<QQuickListView *>("listView");
|
||||||
QVERIFY(listview);
|
QVERIFY(listview);
|
||||||
|
|
Loading…
Reference in New Issue