diff options
author | Nils Jeisecke <jeisecke@saltation.de> | 2013-02-15 18:00:15 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-18 14:55:39 +0100 |
commit | d31f965b72a1bb8aba0b846471780e90fcc895ba (patch) | |
tree | 889e80147509527885f5dfba0f84966f3af2ca90 /tests | |
parent | ae764c678c78c1e3530a6d0dc2de2a17c5d4815a (diff) |
Fix QDeclarativeListView currentSection property update
Model modifications that did not trigger the refill logic caused
the view's currentSection property to contain an outdated value.
A new autotest has been added to catch the bug.
Task-number: QTBUG-29712
Change-Id: I88cf1295ac55dad7596b6ba1fe475ebf98a31026
Reviewed-by: Alan Alpert <aalpert@rim.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 5c00ac95..eb0e0948 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -85,6 +85,7 @@ private slots: void enforceRange(); void spacing(); void sections(); + void currentSection(); void sectionsDelegate(); void cacheBuffer(); void positionViewAtIndex(); @@ -1049,6 +1050,36 @@ void tst_QDeclarativeListView::sections() delete canvas; } +void tst_QDeclarativeListView::currentSection() +{ + // QTBUG-29712 + // update currentSection correctly if model modifications + // do not trigger a refill + QDeclarativeView *canvas = createView(); + + TestModel model; + for (int i = 0; i < 5; i++) + model.addItem("Item" + QString::number(i), QString::number(i)); + + QDeclarativeContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview-sections.qml")); + qApp->processEvents(); + + QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + // make sure the listView won't trigger refill when removing the first row + QTRY_VERIFY(listview->height() > model.count() * 40); + + QTRY_COMPARE(listview->currentSection(), QString("0")); + model.removeItem(0); + QTRY_COMPARE(listview->currentSection(), QString("1")); + + delete canvas; +} + void tst_QDeclarativeListView::sectionsDelegate() { QDeclarativeView *canvas = createView(); |