diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-12-21 00:57:44 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-12-21 00:57:44 (GMT) |
commit | 7d2dc192477c0d10b2c5c9f144e2a37a270093f0 (patch) | |
tree | e32216e51c35bc68dc47a863094fc7ffad7bd194 /tests/auto/declarative/qdeclarativelistview | |
parent | 197ec350e4014330851a013501c6dde3068ac26f (diff) | |
download | Qt-7d2dc192477c0d10b2c5c9f144e2a37a270093f0.zip Qt-7d2dc192477c0d10b2c5c9f144e2a37a270093f0.tar.gz Qt-7d2dc192477c0d10b2c5c9f144e2a37a270093f0.tar.bz2 |
Add tests for ListView.indexAt() and GridView.IndexAt()
Diffstat (limited to 'tests/auto/declarative/qdeclarativelistview')
-rw-r--r-- | tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index b834d46..3df10a9 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -105,6 +105,7 @@ private slots: void QTBUG_14821(); void resizeDelegate(); void QTBUG_16037(); + void indexAt(); private: template <class T> void items(); @@ -1964,6 +1965,38 @@ void tst_QDeclarativeListView::QTBUG_16037() delete canvas; } +void tst_QDeclarativeListView::indexAt() +{ + 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/listviewtest.qml")); + qApp->processEvents(); + + QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QCOMPARE(listview->indexAt(0,0), 0); + QCOMPARE(listview->indexAt(0,19), 0); + QCOMPARE(listview->indexAt(239,19), 0); + QCOMPARE(listview->indexAt(0,20), 1); + QCOMPARE(listview->indexAt(240,20), -1); + + delete canvas; +} + void tst_QDeclarativeListView::qListModelInterface_items() { items<TestModel>(); |