diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativelistview/data/header1.qml | 33 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp | 67 |
2 files changed, 82 insertions, 18 deletions
diff --git a/tests/auto/declarative/qdeclarativelistview/data/header1.qml b/tests/auto/declarative/qdeclarativelistview/data/header1.qml new file mode 100644 index 0000000..f2ab4c1 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelistview/data/header1.qml @@ -0,0 +1,33 @@ +import QtQuick 1.0 + +Rectangle { + width: 240 + height: 320 + color: "#ffffff" + + ListModel { id: testModel } + + ListView { + id: list + objectName: "list" + width: parent.width + anchors.top: parent.top + anchors.bottom: parent.bottom + model: testModel + delegate: Text { + objectName: "wrapper" + font.pointSize: 20 + text: index + } + footer: Rectangle { + width: parent.width + height: 40 + color: "green" + } + header: Text { objectName: "header"; text: "Header" } + } + + Component.onCompleted: { + for (var i=0; i<30; i++) testModel.append({"name" : i, "val": i}) + } +} diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 295a75d..759caf2 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -1664,32 +1664,63 @@ void tst_QDeclarativeListView::QTBUG_11105() void tst_QDeclarativeListView::header() { - QDeclarativeView *canvas = createView(); + { + QDeclarativeView *canvas = createView(); - TestModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); + TestModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); + QDeclarativeContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header.qml")); - qApp->processEvents(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header.qml")); + qApp->processEvents(); - QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); + QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); - QDeclarativeText *header = findItem<QDeclarativeText>(contentItem, "header"); - QVERIFY(header); - QCOMPARE(header->y(), 0.0); + QDeclarativeText *header = findItem<QDeclarativeText>(contentItem, "header"); + QVERIFY(header); + QCOMPARE(header->y(), 0.0); - QCOMPARE(listview->contentY(), 0.0); + QCOMPARE(listview->contentY(), 0.0); - model.clear(); - QTRY_COMPARE(header->y(), 0.0); + model.clear(); + QTRY_COMPARE(header->y(), 0.0); + + delete canvas; + } + { + QDeclarativeView *canvas = createView(); + + TestModel model; + + QDeclarativeContext *ctxt = canvas->rootContext(); + + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header1.qml")); + qApp->processEvents(); + + QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QDeclarativeText *header = findItem<QDeclarativeText>(contentItem, "header"); + QVERIFY(header); + QCOMPARE(header->y(), 0.0); + + QCOMPARE(listview->contentY(), 0.0); + + model.clear(); + QTRY_COMPARE(header->y(), 0.0); + + delete canvas; + } } void tst_QDeclarativeListView::footer() |