diff options
author | Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> | 2016-02-01 17:23:42 -0800 |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> | 2016-02-13 00:15:37 +0000 |
commit | 13f94c38695b94bff86a8ae2aace8a6140faf2d4 (patch) | |
tree | 5863ed43782de162de178a4b0ce495c7e27f7471 /tests/auto/quick/qquicklistview | |
parent | 2a36495cde3f60b3782c277490638e274216a869 (diff) |
Factor out testing code for QTBUG_48870_fastModelUpdates
This is going to be reused for QQuickGridview's counterpart.
Change-Id: I3eaf272229b0e45dfc8c0b78ba94d57c72f9cc5d
Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
Diffstat (limited to 'tests/auto/quick/qquicklistview')
-rw-r--r-- | tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | 92 |
1 files changed, 1 insertions, 91 deletions
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 0153d40b50..19f4010f8c 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -8202,99 +8202,9 @@ void tst_QQuickListView::QTBUG_48044_currentItemNotVisibleAfterTransition() QVERIFY(!currentPriv->culled); } -static bool testVisibleItems(const QQuickItemViewPrivate *priv, bool *nonUnique, FxViewItem **failItem, int *expectedIdx) -{ - QHash<QQuickItem*, int> uniqueItems; - - int skip = 0; - for (int i = 0; i < priv->visibleItems.count(); ++i) { - FxViewItem *item = priv->visibleItems.at(i); - if (!item) { - *failItem = Q_NULLPTR; - return false; - } -#if 0 - qDebug() << "\t" << item->index - << item->item - << item->position() - << (!item->item || QQuickItemPrivate::get(item->item)->culled ? "hidden" : "visible"); -#endif - if (item->index == -1) { - ++skip; - } else if (item->index != priv->visibleIndex + i - skip) { - *nonUnique = false; - *failItem = item; - *expectedIdx = priv->visibleIndex + i - skip; - return false; - } else if (uniqueItems.contains(item->item)) { - *nonUnique = true; - *failItem = item; - *expectedIdx = uniqueItems.find(item->item).value(); - return false; - } - - uniqueItems.insert(item->item, item->index); - } - - return true; -} - -class QTBUG_48870_Model : public QAbstractListModel -{ - Q_OBJECT - -public: - - QTBUG_48870_Model() - : QAbstractListModel() - , m_rowCount(20) - { - QTimer *t = new QTimer(this); - t->setInterval(500); - t->start(); - - qsrand(qHash(QDateTime::currentDateTime())); - connect(t, &QTimer::timeout, this, &QTBUG_48870_Model::updateModel); - } - - int rowCount(const QModelIndex &) const - { - return m_rowCount; - } - - QVariant data(const QModelIndex &, int) const - { - return QVariant(); - } - -public Q_SLOTS: - void updateModel() - { - if (m_rowCount > 10) { - for (int i = 0; i < 10; ++i) { - int rnum = qrand() % m_rowCount; - beginRemoveRows(QModelIndex(), rnum, rnum); - m_rowCount--; - endRemoveRows(); - } - } - if (m_rowCount < 20) { - for (int i = 0; i < 10; ++i) { - int rnum = qrand() % m_rowCount; - beginInsertRows(QModelIndex(), rnum, rnum); - m_rowCount++; - endInsertRows(); - } - } - } - -private: - int m_rowCount; -}; - void tst_QQuickListView::QTBUG_48870_fastModelUpdates() { - QTBUG_48870_Model model; + StressTestModel model; QScopedPointer<QQuickView> window(createView()); QQmlContext *ctxt = window->rootContext(); |