summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-03-08 03:05:22 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-03-08 03:05:22 (GMT)
commitb35bc4ba38992dde4c35c138caa52c018d80b350 (patch)
treebe333c1957d1d4a8d41164476d5a3e34164d10dc /tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
parent364dcc0b434fedd18adea73ee99ffad44ca4442a (diff)
parenteb45d1cc264dbec26575b2bd6cd23b09e3ade653 (diff)
downloadQt-b35bc4ba38992dde4c35c138caa52c018d80b350.zip
Qt-b35bc4ba38992dde4c35c138caa52c018d80b350.tar.gz
Qt-b35bc4ba38992dde4c35c138caa52c018d80b350.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp')
-rw-r--r--tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp46
1 files changed, 44 insertions, 2 deletions
diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
index fa4e9d3..62eb8c3 100644
--- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
+++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
@@ -71,6 +71,7 @@ private slots:
void pathview3();
void path();
void pathMoved();
+ void setCurrentIndex();
void resetModel();
void propertyChanges();
void pathChanges();
@@ -207,6 +208,7 @@ void tst_QDeclarativePathView::items()
model.addItem("Fred", "12345");
model.addItem("John", "2345");
model.addItem("Bob", "54321");
+ model.addItem("Bill", "4321");
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
@@ -421,7 +423,6 @@ void tst_QDeclarativePathView::pathMoved()
offset.setY(firstItem->height()/2);
QCOMPARE(firstItem->pos() + offset, start);
pathview->setOffset(10);
- QTest::qWait(1000);//Moving is animated?
for(int i=0; i<model.count(); i++){
QDeclarativeRectangle *curItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", i);
@@ -429,12 +430,53 @@ void tst_QDeclarativePathView::pathMoved()
}
pathview->setOffset(100);
- QTest::qWait(1000);//Moving is animated?
QCOMPARE(firstItem->pos() + offset, start);
delete canvas;
}
+void tst_QDeclarativePathView::setCurrentIndex()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ model.addItem("Ben", "12345");
+ model.addItem("Bohn", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Bill", "4321");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview.qml"));
+ qApp->processEvents();
+
+ QDeclarativePathView *pathview = findItem<QDeclarativePathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ QDeclarativeRectangle *firstItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QDeclarativePath *path = qobject_cast<QDeclarativePath*>(pathview->path());
+ QVERIFY(path);
+ QPointF start = path->pointAt(0.0);
+ QPointF offset;//Center of item is at point, but pos is from corner
+ offset.setX(firstItem->width()/2);
+ offset.setY(firstItem->height()/2);
+ QCOMPARE(firstItem->pos() + offset, start);
+ QCOMPARE(canvas->rootObject()->property("currentA").toInt(), 0);
+ QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 0);
+
+ pathview->setCurrentIndex(2);
+ QTest::qWait(1000);
+
+ firstItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 2);
+ QCOMPARE(firstItem->pos() + offset, start);
+ QCOMPARE(canvas->rootObject()->property("currentA").toInt(), 2);
+ QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 2);
+
+ delete canvas;
+}
+
void tst_QDeclarativePathView::resetModel()
{
QDeclarativeView *canvas = createView();