diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-09 01:47:04 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-09 01:47:04 (GMT) |
commit | 9a32c5940f259f101f13b91dcb95d9861fb9043d (patch) | |
tree | af73f5081e20002fab7319a05ce5bccf48e6c302 /tests | |
parent | 2580b9b646586de0844d120d41f7240d75bc1a07 (diff) | |
parent | 147b11193618c954f41625b469a113f202362468 (diff) | |
download | Qt-9a32c5940f259f101f13b91dcb95d9861fb9043d.zip Qt-9a32c5940f259f101f13b91dcb95d9861fb9043d.tar.gz Qt-9a32c5940f259f101f13b91dcb95d9861fb9043d.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml:
Move pixmapChanged signal to QDeclarativeImage
Minor cleanup.
Add highlightRangeMode and snapMode to GridView.
Minor anchors.fill optimization.
Use one thread for all instances.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativegridview/data/gridview-enforcerange.qml | 56 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp | 48 |
2 files changed, 104 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativegridview/data/gridview-enforcerange.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview-enforcerange.qml new file mode 100644 index 0000000..e45c4c3 --- /dev/null +++ b/tests/auto/declarative/qdeclarativegridview/data/gridview-enforcerange.qml @@ -0,0 +1,56 @@ +import Qt 4.6 + +Rectangle { + width: 240 + height: 320 + color: "#ffffff" + Component { + id: myDelegate + Item { + id: wrapper + objectName: "wrapper" + height: 100 + width: 100 + Text { + text: index + } + Text { + y: 25 + id: textName + objectName: "textName" + text: name + } + Text { + y: 50 + id: textNumber + objectName: "textNumber" + text: number + } + Text { + y: 75 + text: wrapper.y + } + } + } + + Component { + id: myHighlight + Rectangle { + color: "lightsteelblue" + } + } + + GridView { + id: grid + objectName: "grid" + width: 240 + height: 320 + model: testModel + delegate: myDelegate + highlight: myHighlight + preferredHighlightBegin: 100 + preferredHighlightEnd: 100 + highlightRangeMode: "StrictlyEnforceRange" + focus: true + } +} diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index aeefea1..a1edc53 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -72,6 +72,7 @@ private slots: void modelChanges(); void positionViewAtIndex(); void resetModel(); + void enforceRange(); void QTBUG_8456(); private: @@ -1042,6 +1043,53 @@ void tst_QDeclarativeGridView::resetModel() } } +void tst_QDeclarativeGridView::enforceRange() +{ + 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/gridview-enforcerange.qml")); + qApp->processEvents(); + + QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); + QVERIFY(gridview != 0); + + QCOMPARE(gridview->preferredHighlightBegin(), 100.0); + QCOMPARE(gridview->preferredHighlightEnd(), 100.0); + QCOMPARE(gridview->highlightRangeMode(), QDeclarativeGridView::StrictlyEnforceRange); + + QDeclarativeItem *viewport = gridview->viewport(); + QVERIFY(viewport != 0); + + // view should be positioned at the top of the range. + QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", 0); + QVERIFY(item); + QCOMPARE(gridview->contentY(), -100.0); + + QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 0); + QVERIFY(name != 0); + QCOMPARE(name->text(), model.name(0)); + QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 0); + QVERIFY(number != 0); + QCOMPARE(number->text(), model.number(0)); + + // Check currentIndex is updated when viewport moves + gridview->setContentY(0); + QCOMPARE(gridview->currentIndex(), 2); + + gridview->setCurrentIndex(5); + QTest::qWait(500); + QCOMPARE(gridview->contentY(), 100.); + + delete canvas; +} + void tst_QDeclarativeGridView::QTBUG_8456() { QDeclarativeView *canvas = createView(); |