summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-12-01 07:30:52 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-12-01 07:30:52 (GMT)
commit1337a3e031477aa4d628d01252557dee622629ff (patch)
tree806bfbd9aa75ed94adddac06d4213e820b8a3eaf /tests
parente46bf51f830dcc80932b9219fe608d1bc1a388ad (diff)
downloadQt-1337a3e031477aa4d628d01252557dee622629ff.zip
Qt-1337a3e031477aa4d628d01252557dee622629ff.tar.gz
Qt-1337a3e031477aa4d628d01252557dee622629ff.tar.bz2
ListView header is not visible initially.
If the header size was not set explicitly, but determined implicitly from Text height, the view was not positioned so that the header was visible when first shown. Task-number: QTBUG-15599 Reviewed-by: Bea Lam
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/header1.qml33
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp67
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()