aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktableview
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-08-24 10:18:06 +0200
committerAapo Keskimolo <aapo.keskimolo@qt.io>2018-08-27 08:49:52 +0000
commit9fa76b8a0551d49870fe87be75af64440bb07212 (patch)
tree7e11b82d56c9a20a2959f008ebd52412b58417f9 /tests/auto/quick/qquicktableview
parentbf136379521d543c54d5c0ce377471ff76dce35e (diff)
QQuickTableView: only preload to pool if reuseItems is true
We move preloaded items into the pool. But this is pointless if we're not reusing items in the first place. Change-Id: I2274b0d29c98162da5fa4859c810c42093875836 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/quick/qquicktableview')
-rw-r--r--tests/auto/quick/qquicktableview/tst_qquicktableview.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
index 5e1c21fce8..99534ddb50 100644
--- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
+++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
@@ -85,6 +85,7 @@ private slots:
void setAndGetModel();
void emptyModel_data();
void emptyModel();
+ void checkPreload_data();
void checkPreload();
void checkZeroSizedDelegate();
void checkImplicitSizeDelegate();
@@ -195,20 +196,34 @@ void tst_QQuickTableView::emptyModel()
QCOMPARE(tableViewPrivate->loadedItems.count(), 0);
}
+void tst_QQuickTableView::checkPreload_data()
+{
+ QTest::addColumn<bool>("reuseItems");
+
+ QTest::newRow("reuse") << true;
+ QTest::newRow("not reuse") << false;
+}
+
void tst_QQuickTableView::checkPreload()
{
// Check that the reuse pool is filled up with one extra row and
- // column (pluss corner) after rebuilding the table.
+ // column (pluss corner) after rebuilding the table, but only if we reuse items.
+ QFETCH(bool, reuseItems);
LOAD_TABLEVIEW("plaintableview.qml");
auto model = TestModelAsVariant(100, 100);
tableView->setModel(model);
+ tableView->setReuseItems(reuseItems);
WAIT_UNTIL_POLISHED;
- QSize visibleTableSize = tableViewPrivate->loadedTable.size();
- int expectedPoolSize = visibleTableSize.height() + visibleTableSize.width() + 1;
- QCOMPARE(tableViewPrivate->tableModel->poolSize(), expectedPoolSize);
+ if (reuseItems) {
+ QSize visibleTableSize = tableViewPrivate->loadedTable.size();
+ int expectedPoolSize = visibleTableSize.height() + visibleTableSize.width() + 1;
+ QCOMPARE(tableViewPrivate->tableModel->poolSize(), expectedPoolSize);
+ } else {
+ QCOMPARE(tableViewPrivate->tableModel->poolSize(), 0);
+ }
}
void tst_QQuickTableView::checkZeroSizedDelegate()