diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2012-04-11 16:22:52 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-13 08:07:16 +0200 |
commit | 96c0e7e576b4b9a31bf7df362e26ebbc64f726f9 (patch) | |
tree | 0cae848593288b6db2c304a323aeb84671e33a80 /tests/auto/quick/qquickgridview | |
parent | f24f682c83ee08f1ceffc935def477e8a649e38a (diff) |
Don't ignore model changes when the ListView scroll position changes.
If there are pending changes when the ListView viewport changes then
do a full layout instead of a refill. Likewise for GridView and when
animations finish or the cacheBuffer size changes.
Change-Id: I57a2b01fee5729381558af366dad24ba26c223ef
Reviewed-by: Bea Lam <bea.lam@nokia.com>
Diffstat (limited to 'tests/auto/quick/qquickgridview')
-rw-r--r-- | tests/auto/quick/qquickgridview/tst_qquickgridview.cpp | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp index f154e6eb5d..5399a0409c 100644 --- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp @@ -89,8 +89,10 @@ private slots: void clear(); void moved(); void moved_data(); - void multipleChanges(); - void multipleChanges_data(); + void multipleChanges_condensed() { multipleChanges(true); } + void multipleChanges_condensed_data() { multipleChanges_data(); } + void multipleChanges_uncondensed() { multipleChanges(false); } + void multipleChanges_uncondensed_data() { multipleChanges_data(); } void swapWithFirstItem(); void changeFlow(); void currentIndex(); @@ -154,6 +156,9 @@ private: void matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes); void matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems); + void multipleChanges(bool condensed); + void multipleChanges_data(); + #ifdef SHARE_VIEWS QQuickView *getView() { if (m_view) { @@ -1323,7 +1328,7 @@ void tst_QQuickGridView::moved_data() << -1.0; // 16,17,18 move to above item 0, all items move up by 1 row } -void tst_QQuickGridView::multipleChanges() +void tst_QQuickGridView::multipleChanges(bool condensed) { QFETCH(int, startCount); QFETCH(QList<ListChange>, changes); @@ -1361,26 +1366,26 @@ void tst_QQuickGridView::multipleChanges() } case ListChange::Removed: model.removeItems(changes[i].index, changes[i].count); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); break; case ListChange::Moved: model.moveItems(changes[i].index, changes[i].to, changes[i].count); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); break; case ListChange::SetCurrent: gridview->setCurrentIndex(changes[i].index); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); break; case ListChange::SetContentY: gridview->setContentY(changes[i].pos); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); break; } + if (condensed) { + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + } } + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - QTRY_COMPARE(gridview->count(), newCount); + QCOMPARE(gridview->count(), newCount); QCOMPARE(gridview->count(), model.count()); - QTRY_COMPARE(gridview->currentIndex(), newCurrentIndex); + QCOMPARE(gridview->currentIndex(), newCurrentIndex); QQuickText *name; QQuickText *number; @@ -1549,6 +1554,28 @@ void tst_QQuickGridView::multipleChanges_data() << ListChange::remove(0, 5) << ListChange::insert(0, 5) ) << 5 << -1; + + QTest::newRow("remove, scroll") << 30 << (QList<ListChange>() + << ListChange::remove(20, 5) + << ListChange::setContentY(20) + ) << 25 << 0; + + QTest::newRow("insert, scroll") << 10 << (QList<ListChange>() + << ListChange::insert(9, 5) + << ListChange::setContentY(20) + ) << 15 << 0; + + QTest::newRow("move, scroll") << 20 << (QList<ListChange>() + << ListChange::move(15, 8, 3) + << ListChange::setContentY(0) + ) << 20 << 0; + + QTest::newRow("clear, insert, scroll") << 30 << (QList<ListChange>() + << ListChange::setContentY(20) + << ListChange::remove(0, 30) + << ListChange::insert(0, 2) + << ListChange::setContentY(0) + ) << 2 << 0; } |