diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-10-08 06:12:31 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-10-08 06:12:31 (GMT) |
commit | 11536f150887266b6a6f5cf00b22f9d1fcc1aaeb (patch) | |
tree | 529b7577371d359c3f9bf573e2b8c2de3e52513c /tests/auto/declarative/qdeclarativegridview | |
parent | fd2d104988955e4e94252abd8d90507aa33dc10d (diff) | |
download | Qt-11536f150887266b6a6f5cf00b22f9d1fcc1aaeb.zip Qt-11536f150887266b6a6f5cf00b22f9d1fcc1aaeb.tar.gz Qt-11536f150887266b6a6f5cf00b22f9d1fcc1aaeb.tar.bz2 |
Ensure GridView header is visible at the top of the view.
The view was scrolled to the top of the first item, rather than
the top of the header.
Task-number: QTBUG-13906
Reviewed-by: Michael Brasser
Diffstat (limited to 'tests/auto/declarative/qdeclarativegridview')
-rw-r--r-- | tests/auto/declarative/qdeclarativegridview/data/header.qml | 32 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp | 35 |
2 files changed, 67 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativegridview/data/header.qml b/tests/auto/declarative/qdeclarativegridview/data/header.qml new file mode 100644 index 0000000..99baacd --- /dev/null +++ b/tests/auto/declarative/qdeclarativegridview/data/header.qml @@ -0,0 +1,32 @@ +import QtQuick 1.0 + +Rectangle { + width: 240 + height: 320 + color: "#ffffff" + Component { + id: myDelegate + Rectangle { + id: wrapper + objectName: "wrapper" + width: 80 + height: 60 + border.color: "blue" + Text { + text: index + } + color: GridView.isCurrentItem ? "lightsteelblue" : "white" + } + } + GridView { + id: grid + objectName: "grid" + width: 240 + height: 320 + cellWidth: 80 + cellHeight: 60 + model: testModel + delegate: myDelegate + header: Text { objectName: "header"; text: "Header"; height: 30 } + } +} diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index 975cf8f..f7acd87 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -82,6 +82,7 @@ private slots: void QTBUG_8456(); void manualHighlight(); void footer(); + void header(); private: QDeclarativeView *createView(); @@ -1214,6 +1215,40 @@ void tst_QDeclarativeGridView::footer() QTRY_COMPARE(footer->y(), 0.0); } +void tst_QDeclarativeGridView::header() +{ + QDeclarativeView *canvas = createView(); + + TestModel model; + for (int i = 0; i < 7; i++) + model.addItem("Item" + QString::number(i), ""); + + QDeclarativeContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header.qml")); + qApp->processEvents(); + + QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + + QDeclarativeItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QDeclarativeText *header = findItem<QDeclarativeText>(contentItem, "header"); + QVERIFY(header); + + QCOMPARE(header->y(), 0.0); + QCOMPARE(gridview->contentY(), 0.0); + + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", 0); + QVERIFY(item); + QCOMPARE(item->y(), 30.0); + + model.clear(); + QTRY_COMPARE(header->y(), 0.0); +} + QDeclarativeView *tst_QDeclarativeGridView::createView() { |