diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2010-11-15 10:19:33 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2010-11-15 10:19:33 (GMT) |
commit | 6cc85e9884c5cf846dbb3cbf94b6bd4dc787b6f4 (patch) | |
tree | 61f8e9b589e6ab6db1a1e59676dc9f5ca91e890f /tests/auto/declarative | |
parent | 1150f994464719000071f7ef5836c9e1dd695c65 (diff) | |
parent | 153991a45647755c0186f985da255caa09444ff4 (diff) | |
download | Qt-6cc85e9884c5cf846dbb3cbf94b6bd4dc787b6f4.zip Qt-6cc85e9884c5cf846dbb3cbf94b6bd4dc787b6f4.tar.gz Qt-6cc85e9884c5cf846dbb3cbf94b6bd4dc787b6f4.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r-- | tests/auto/declarative/qdeclarativelistview/data/sizelessthan1.qml | 26 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp | 36 |
2 files changed, 62 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativelistview/data/sizelessthan1.qml b/tests/auto/declarative/qdeclarativelistview/data/sizelessthan1.qml new file mode 100644 index 0000000..77bfef8 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelistview/data/sizelessthan1.qml @@ -0,0 +1,26 @@ +import QtQuick 1.0 + +Rectangle { + width: 240 + height: 320 + color: "#ffffff" + Component { + id: myDelegate + Rectangle { + id: wrapper + objectName: "wrapper" + height: 0.5 + width: 240 + color: ((index % 2) == 1 ? "red" : "blue") + } + } + ListView { + id: list + objectName: "list" + focus: true + width: 240 + height: 320 + model: testModel + delegate: myDelegate + } +} diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 79fef7a..a4b4f21 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -100,6 +100,7 @@ private slots: void QTBUG_11105(); void footer(); void resizeView(); + void sizeLessThan1(); private: template <class T> void items(); @@ -1732,6 +1733,41 @@ void tst_QDeclarativeListView::resizeView() QCOMPARE(heightRatio.toReal(), 0.25); } +void tst_QDeclarativeListView::sizeLessThan1() +{ + 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); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/sizelessthan1.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*0.5); + } + + delete canvas; +} + void tst_QDeclarativeListView::qListModelInterface_items() { items<TestModel>(); |