aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qquicktableview/tst_qquicktableview.cpp')
-rw-r--r--tests/auto/quick/qquicktableview/tst_qquicktableview.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
index 889175a228..1b5be0232c 100644
--- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
+++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
@@ -120,6 +120,7 @@ private slots:
void checkRowHeightProviderNotCallable();
void checkForceLayoutFunction();
void checkForceLayoutEndUpDoingALayout();
+ void checkForceLayoutDuringModelChange();
void checkContentWidthAndHeight();
void checkPageFlicking();
void checkExplicitContentWidthAndHeight();
@@ -587,6 +588,29 @@ void tst_QQuickTableView::checkForceLayoutEndUpDoingALayout()
QCOMPARE(fxItem->item->height(), newDelegateSize);
}
+void tst_QQuickTableView::checkForceLayoutDuringModelChange()
+{
+ // Check that TableView doesn't assert if we call
+ // forceLayout() in the middle of a model change.
+ LOAD_TABLEVIEW("plaintableview.qml");
+
+ const int initialRowCount = 10;
+ TestModel model(initialRowCount, 10);
+ tableView->setModel(QVariant::fromValue(&model));
+
+ connect(&model, &QAbstractItemModel::rowsInserted, [=](){
+ QCOMPARE(tableView->rows(), initialRowCount);
+ tableView->forceLayout();
+ QCOMPARE(tableView->rows(), initialRowCount + 1);
+ });
+
+ WAIT_UNTIL_POLISHED;
+
+ QCOMPARE(tableView->rows(), initialRowCount);
+ model.addRow(0);
+ QCOMPARE(tableView->rows(), initialRowCount + 1);
+}
+
void tst_QQuickTableView::checkContentWidthAndHeight()
{
// Check that contentWidth/Height reports the correct size of the