diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qquicktableview/data/replaceModelTableView.qml | 13 | ||||
-rw-r--r-- | tests/auto/quick/qquicktableview/tst_qquicktableview.cpp | 14 |
2 files changed, 13 insertions, 14 deletions
diff --git a/tests/auto/quick/qquicktableview/data/replaceModelTableView.qml b/tests/auto/quick/qquicktableview/data/replaceModelTableView.qml index 1b6074f5d5..cc109bb469 100644 --- a/tests/auto/quick/qquicktableview/data/replaceModelTableView.qml +++ b/tests/auto/quick/qquicktableview/data/replaceModelTableView.qml @@ -8,6 +8,9 @@ Item { height: 480 property alias tableView: tv + property alias objectModel: om + property alias listModel: lm + property alias delegateModel: dm ObjectModel { id: om @@ -38,16 +41,6 @@ Item { id: tv visible: true anchors.fill: parent - property int modelId: 0 - - model: { - switch (modelId) { - case 0: return lm; - case 1: return om; - case 2: return dm; - default: return null; - } - } delegate: Rectangle { id: dlg diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp index 09d1b8ca7c..405524b704 100644 --- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp +++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp @@ -2705,14 +2705,20 @@ void tst_QQuickTableView::replaceModel() { LOAD_TABLEVIEW("replaceModelTableView.qml"); - tableView->setProperty("modelId", 0); + const auto objectModel = view->rootObject()->property("objectModel"); + const auto listModel = view->rootObject()->property("listModel"); + const auto delegateModel = view->rootObject()->property("delegateModel"); + + tableView->setModel(listModel); QTRY_COMPARE(tableView->rows(), 2); - tableView->setProperty("modelId", 1); + tableView->setModel(objectModel); QTRY_COMPARE(tableView->rows(), 3); - tableView->setProperty("modelId", 2); + tableView->setModel(delegateModel); QTRY_COMPARE(tableView->rows(), 2); - tableView->setProperty("modelId", 0); + tableView->setModel(listModel); QTRY_COMPARE(tableView->rows(), 2); + tableView->setModel(QVariant()); + QTRY_COMPARE(tableView->rows(), 0); } QTEST_MAIN(tst_QQuickTableView) |