summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-08-31 02:38:12 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-08-31 02:38:12 (GMT)
commitcfc3564328c9545a9eed4aca02f99dac5e0e4390 (patch)
tree93e8337a555e343b281b62994b6848b4e564fbb4 /tests
parentd01313b94e1eb8f8b9aa088433118459b588a79f (diff)
downloadQt-cfc3564328c9545a9eed4aca02f99dac5e0e4390.zip
Qt-cfc3564328c9545a9eed4aca02f99dac5e0e4390.tar.gz
Qt-cfc3564328c9545a9eed4aca02f99dac5e0e4390.tar.bz2
Ensure Flickable visibleArea is updated when view height changes
Task-number: QTBUG-13095
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml6
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp43
2 files changed, 49 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml b/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml
index 3b2db5e..d5d3365 100644
--- a/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml
+++ b/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml
@@ -4,6 +4,12 @@ Rectangle {
width: 240
height: 320
color: "#ffffff"
+
+ property real hr: list.visibleArea.heightRatio
+ function heightRatio() {
+ return list.visibleArea.heightRatio
+ }
+
function checkProperties() {
testObject.error = false;
if (list.model != testModel) {
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index bf4754d..377a9e5 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -98,6 +98,7 @@ private slots:
void manualHighlight();
void QTBUG_11105();
void footer();
+ void resizeView();
private:
template <class T> void items();
@@ -1591,6 +1592,48 @@ void tst_QDeclarativeListView::footer()
QTRY_COMPARE(footer->y(), 0.0);
}
+void tst_QDeclarativeListView::resizeView()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
+ }
+
+ QVariant heightRatio;
+ QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio));
+ QCOMPARE(heightRatio.toReal(), 0.4);
+
+ listview->setHeight(200);
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio));
+ QCOMPARE(heightRatio.toReal(), 0.25);
+}
+
void tst_QDeclarativeListView::qListModelInterface_items()
{
items<TestModel>();