diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-11-06 06:15:17 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-11-06 06:15:17 (GMT) |
commit | dc7acac9552ce556d0388a11f6c5584ea8e10ae3 (patch) | |
tree | b62f780acdf1408885792da282025fcdbf68aeda /tests | |
parent | 3a051866fb139afa08fcf1a0c17a171bce567480 (diff) | |
download | Qt-dc7acac9552ce556d0388a11f6c5584ea8e10ae3.zip Qt-dc7acac9552ce556d0388a11f6c5584ea8e10ae3.tar.gz Qt-dc7acac9552ce556d0388a11f6c5584ea8e10ae3.tar.bz2 |
Better section testing... and bug fixing.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qmlgraphicslistview/data/listview-sections.qml | 2 | ||||
-rw-r--r-- | tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp | 32 |
2 files changed, 32 insertions, 2 deletions
diff --git a/tests/auto/declarative/qmlgraphicslistview/data/listview-sections.qml b/tests/auto/declarative/qmlgraphicslistview/data/listview-sections.qml index 56700be..2edc0bd 100644 --- a/tests/auto/declarative/qmlgraphicslistview/data/listview-sections.qml +++ b/tests/auto/declarative/qmlgraphicslistview/data/listview-sections.qml @@ -54,6 +54,6 @@ Rectangle { height: 320 model: testModel delegate: myDelegate - sectionExpression: "Math.floor(index/5)" + sectionExpression: "Math.floor(number/5)" } } diff --git a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp index 9f904b8..0015c48 100644 --- a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp +++ b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp @@ -702,7 +702,7 @@ void tst_QmlGraphicsListView::sections() TestModel model; for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); + model.addItem("Item" + QString::number(i), QString::number(i)); QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); @@ -724,6 +724,36 @@ void tst_QmlGraphicsListView::sections() QCOMPARE(item->y(), qreal(i*20 + ((i+4)/5) * 20)); } + // Remove section boundary + model.removeItem(5); + + // New section header created + QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", 5); + QVERIFY(item); + QCOMPARE(item->height(), 40.0); + + model.insertItem(3, "New Item", "3"); + + // Section header moved + item = findItem<QmlGraphicsItem>(viewport, "wrapper", 5); + QVERIFY(item); + QCOMPARE(item->height(), 20.0); + + item = findItem<QmlGraphicsItem>(viewport, "wrapper", 6); + QVERIFY(item); + QCOMPARE(item->height(), 40.0); + + // insert item which will become a section header + model.insertItem(6, "Replace header", "5"); + + item = findItem<QmlGraphicsItem>(viewport, "wrapper", 6); + QVERIFY(item); + QCOMPARE(item->height(), 40.0); + + item = findItem<QmlGraphicsItem>(viewport, "wrapper", 7); + QVERIFY(item); + QCOMPARE(item->height(), 20.0); + QVERIFY(listview->currentSection() == "0"); listview->setViewportY(140); |