summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qmlgraphicslistview
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-11-09 00:51:21 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-11-09 00:51:21 (GMT)
commit76c1d526022220f487bee0384eca586d680e5eb2 (patch)
treed2901f553ba5b1bde318b5884a14e9e775dc7808 /tests/auto/declarative/qmlgraphicslistview
parentb61a413e592e2d47ff158e2451ae54cd0cc35230 (diff)
downloadQt-76c1d526022220f487bee0384eca586d680e5eb2.zip
Qt-76c1d526022220f487bee0384eca586d680e5eb2.tar.gz
Qt-76c1d526022220f487bee0384eca586d680e5eb2.tar.bz2
Fix initialization of currentIndex and add test.
Diffstat (limited to 'tests/auto/declarative/qmlgraphicslistview')
-rw-r--r--tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp
index 4a33770..de26635 100644
--- a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp
+++ b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp
@@ -69,10 +69,10 @@ private slots:
void qListModelInterface_moved();
void qAbstractItemModel_moved();
+ void currentIndex();
void enforceRange();
void spacing();
void sections();
- void currentIndex();
private:
template <class T> void items();
@@ -766,15 +766,22 @@ void tst_QmlGraphicsListView::sections()
void tst_QmlGraphicsListView::currentIndex()
{
- QmlView *canvas = createView(SRCDIR "/data/listview-initCurrent.qml");
-
TestModel model;
for (int i = 0; i < 30; i++)
model.addItem("Item" + QString::number(i), QString::number(i));
+ QmlView *canvas = new QmlView(0);
+ canvas->setFixedSize(240,320);
+
QmlContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
+ QString filename(SRCDIR "/data/listview-initCurrent.qml");
+ QFile file(filename);
+ file.open(QFile::ReadOnly);
+ QString qml = file.readAll();
+ canvas->setQml(qml, filename);
+
canvas->execute();
qApp->processEvents();
@@ -785,6 +792,7 @@ void tst_QmlGraphicsListView::currentIndex()
QVERIFY(viewport != 0);
// current item should be third item
+ QCOMPARE(listview->currentIndex(), 3);
QCOMPARE(listview->currentItem(), findItem<QmlGraphicsItem>(viewport, "wrapper", 3));
// no wrap