summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-11-30 05:54:25 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-11-30 05:54:25 (GMT)
commit840ffbd6187fe2573d8c00481120d4cf30aed351 (patch)
treeb65be7919d3eb5e0b6fd63c6127234a79bd9e262 /tests/auto/declarative
parentfe3cfced940f41d078380ef7bdebe40d85aa49a2 (diff)
downloadQt-840ffbd6187fe2573d8c00481120d4cf30aed351.zip
Qt-840ffbd6187fe2573d8c00481120d4cf30aed351.tar.gz
Qt-840ffbd6187fe2573d8c00481120d4cf30aed351.tar.bz2
Ensure header is considered when positioning content with snapping.
When snapping is enabled the header was ignored and content would be aligned with the first item rather than the header, when at the top of the view. Task-number: QTBUG-15710 Reviewed-by: Bea Lam
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/header.qml31
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp31
3 files changed, 63 insertions, 1 deletions
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index 327bba2..7998e30 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -1263,7 +1263,7 @@ void tst_QDeclarativeGridView::header()
QDeclarativeView *canvas = createView();
TestModel model;
- for (int i = 0; i < 7; i++)
+ for (int i = 0; i < 30; i++)
model.addItem("Item" + QString::number(i), "");
QDeclarativeContext *ctxt = canvas->rootContext();
diff --git a/tests/auto/declarative/qdeclarativelistview/data/header.qml b/tests/auto/declarative/qdeclarativelistview/data/header.qml
new file mode 100644
index 0000000..6da996e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistview/data/header.qml
@@ -0,0 +1,31 @@
+import QtQuick 1.0
+
+Rectangle {
+ width: 240
+ height: 320
+ color: "#ffffff"
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+ objectName: "wrapper"
+ height: 30
+ width: 240
+ Text {
+ text: index
+ }
+ color: ListView.isCurrentItem ? "lightsteelblue" : "white"
+ }
+ }
+ ListView {
+ id: list
+ objectName: "list"
+ focus: true
+ width: 240
+ height: 320
+ snapMode: ListView.SnapToItem
+ model: testModel
+ delegate: myDelegate
+ header: Text { objectName: "header"; text: "Header"; height: 10 }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index 37d836d..295a75d 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -98,6 +98,7 @@ private slots:
void QTBUG_9791();
void manualHighlight();
void QTBUG_11105();
+ void header();
void footer();
void resizeView();
void sizeLessThan1();
@@ -1661,6 +1662,36 @@ void tst_QDeclarativeListView::QTBUG_11105()
delete canvas;
}
+void tst_QDeclarativeListView::header()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 30; 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();
+
+ 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);
+}
+
void tst_QDeclarativeListView::footer()
{
QDeclarativeView *canvas = createView();