summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-12-13 07:33:13 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-12-13 07:36:46 (GMT)
commit95ddfa13737164c93c58ce3694ce59ec68a016d9 (patch)
tree2b0b2bca8394e72771d4334378a03c64b3d57a1e /tests/auto/declarative
parent2e2f26072647b08292955ebad631c34d58c828f9 (diff)
downloadQt-95ddfa13737164c93c58ce3694ce59ec68a016d9.zip
Qt-95ddfa13737164c93c58ce3694ce59ec68a016d9.tar.gz
Qt-95ddfa13737164c93c58ce3694ce59ec68a016d9.tar.bz2
Ensure ListView contentHeight is set to a valid size.
If the view height is 0 no items will be created so the contentHeight can not be estimated. The currentItem is usually created, so it is possible to use that to estimate. Task-number: QTBUG-16037 Reviewed-by: Bea Lam
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/qtbug16037.qml37
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp20
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativelistview/data/qtbug16037.qml b/tests/auto/declarative/qdeclarativelistview/data/qtbug16037.qml
new file mode 100644
index 0000000..0756618
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistview/data/qtbug16037.qml
@@ -0,0 +1,37 @@
+import QtQuick 1.0
+
+Item {
+ width: 640
+ height: 480
+
+ function setModel() {
+ listView.model = listModel1
+ }
+
+ ListModel {
+ id: listModel1
+ ListElement { text: "Apple" }
+ ListElement { text: "Banana" }
+ ListElement { text: "Orange" }
+ ListElement { text: "Coconut" }
+ }
+
+ Rectangle {
+ width: 200
+ height: listView.contentHeight
+ color: "yellow"
+ anchors.centerIn: parent
+
+ ListView {
+ id: listView
+ objectName: "listview"
+ anchors.fill: parent
+
+ delegate: Item {
+ width: 200
+ height: 20
+ Text { text: model.text; anchors.centerIn: parent }
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index ff90d32..b834d46 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -104,6 +104,7 @@ private slots:
void sizeLessThan1();
void QTBUG_14821();
void resizeDelegate();
+ void QTBUG_16037();
private:
template <class T> void items();
@@ -1944,6 +1945,25 @@ void tst_QDeclarativeListView::resizeDelegate()
delete canvas;
}
+void tst_QDeclarativeListView::QTBUG_16037()
+{
+ QDeclarativeView *canvas = createView();
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/qtbug16037.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "listview");
+ QTRY_VERIFY(listview != 0);
+
+ QVERIFY(listview->contentHeight() <= 0.0);
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "setModel");
+
+ QTRY_COMPARE(listview->contentHeight(), 80.0);
+
+ delete canvas;
+}
+
void tst_QDeclarativeListView::qListModelInterface_items()
{
items<TestModel>();