summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativegridview
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-12-23 10:11:11 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-12-23 10:11:11 (GMT)
commita315c693d0f3dd64711b8459d86b89ddc48e8c1a (patch)
tree8f966269d797f97d41847c5bb7283297cee20b47 /tests/auto/declarative/qdeclarativegridview
parentd37a3529ec883985b2967265f0797d749db74308 (diff)
parente6694ebe4081b807b1bb0946e17e73840019ec6d (diff)
downloadQt-a315c693d0f3dd64711b8459d86b89ddc48e8c1a.zip
Qt-a315c693d0f3dd64711b8459d86b89ddc48e8c1a.tar.gz
Qt-a315c693d0f3dd64711b8459d86b89ddc48e8c1a.tar.bz2
Merge remote branch 'origin/4.7' into qt-master-from-4.7
Conflicts: src/s60main/newallocator_hook.cpp tools/runonphone/serenum_unix.cpp
Diffstat (limited to 'tests/auto/declarative/qdeclarativegridview')
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index fd5d140..a2dcf1c 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -84,6 +84,7 @@ private slots:
void manualHighlight();
void footer();
void header();
+ void indexAt();
private:
QDeclarativeView *createView();
@@ -1299,6 +1300,42 @@ void tst_QDeclarativeGridView::header()
QTRY_COMPARE(header->y(), 0.0);
}
+void tst_QDeclarativeGridView::indexAt()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Billy", "22345");
+ model.addItem("Sam", "2945");
+ model.addItem("Ben", "04321");
+ model.addItem("Jim", "0780");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QTRY_COMPARE(gridview->count(), model.count());
+
+ QCOMPARE(gridview->indexAt(0, 0), 0);
+ QCOMPARE(gridview->indexAt(79, 59), 0);
+ QCOMPARE(gridview->indexAt(80, 0), 1);
+ QCOMPARE(gridview->indexAt(0, 60), 3);
+ QCOMPARE(gridview->indexAt(240, 0), -1);
+
+ delete canvas;
+}
QDeclarativeView *tst_QDeclarativeGridView::createView()
{