summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp')
-rw-r--r--tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp39
1 files changed, 26 insertions, 13 deletions
diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
index c16c46f..4d43c68 100644
--- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
+++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
@@ -194,7 +194,7 @@ void tst_QDeclarativePathView::initValues()
QCOMPARE(obj->model(), QVariant());
QCOMPARE(obj->currentIndex(), 0);
QCOMPARE(obj->offset(), 0.);
- QCOMPARE(obj->snapPosition(), 0.);
+ QCOMPARE(obj->preferredHighlightBegin(), 0.);
QCOMPARE(obj->dragMargin(), 0.);
QCOMPARE(obj->count(), 0);
QCOMPARE(obj->pathItemCount(), -1);
@@ -219,7 +219,7 @@ void tst_QDeclarativePathView::items()
QDeclarativePathView *pathview = findItem<QDeclarativePathView>(canvas->rootObject(), "view");
QVERIFY(pathview != 0);
- QCOMPARE(pathview->childItems().count(), model.count()); // assumes all are visible
+ QCOMPARE(pathview->childItems().count(), model.count()+1); // assumes all are visible, including highlight
for (int i = 0; i < model.count(); ++i) {
QDeclarativeText *name = findItem<QDeclarativeText>(pathview, "textName", i);
@@ -230,6 +230,16 @@ void tst_QDeclarativePathView::items()
QCOMPARE(number->text(), model.number(i));
}
+ QDeclarativePath *path = qobject_cast<QDeclarativePath*>(pathview->path());
+ QVERIFY(path);
+
+ QVERIFY(pathview->highlightItem());
+ QPointF start = path->pointAt(0.0);
+ QPointF offset;
+ offset.setX(pathview->highlightItem()->width()/2);
+ offset.setY(pathview->highlightItem()->height()/2);
+ QCOMPARE(pathview->highlightItem()->pos() + offset, start);
+
delete canvas;
}
@@ -245,7 +255,7 @@ void tst_QDeclarativePathView::pathview2()
QVERIFY(obj->model() != QVariant());
QCOMPARE(obj->currentIndex(), 0);
QCOMPARE(obj->offset(), 0.);
- QCOMPARE(obj->snapPosition(), 0.);
+ QCOMPARE(obj->preferredHighlightBegin(), 0.);
QCOMPARE(obj->dragMargin(), 0.);
QCOMPARE(obj->count(), 8);
QCOMPARE(obj->pathItemCount(), 10);
@@ -262,8 +272,8 @@ void tst_QDeclarativePathView::pathview3()
QVERIFY(obj->delegate() != 0);
QVERIFY(obj->model() != QVariant());
QCOMPARE(obj->currentIndex(), 0);
- QCOMPARE(obj->offset(), 0.5); // ???
- QCOMPARE(obj->snapPosition(), 0.5); // ???
+ QCOMPARE(obj->offset(), 1.0);
+ QCOMPARE(obj->preferredHighlightBegin(), 0.5);
QCOMPARE(obj->dragMargin(), 24.);
QCOMPARE(obj->count(), 8);
QCOMPARE(obj->pathItemCount(), 4);
@@ -422,14 +432,14 @@ void tst_QDeclarativePathView::pathMoved()
offset.setX(firstItem->width()/2);
offset.setY(firstItem->height()/2);
QCOMPARE(firstItem->pos() + offset, start);
- pathview->setOffset(0.1);
+ pathview->setOffset(1.0);
for(int i=0; i<model.count(); i++){
QDeclarativeRectangle *curItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", i);
- QCOMPARE(curItem->pos() + offset, path->pointAt(0.1 + i*0.25));
+ QCOMPARE(curItem->pos() + offset, path->pointAt(0.25 + i*0.25));
}
- pathview->setOffset(1.0);
+ pathview->setOffset(0.0);
QCOMPARE(firstItem->pos() + offset, start);
delete canvas;
@@ -524,22 +534,25 @@ void tst_QDeclarativePathView::propertyChanges()
QDeclarativePathView *pathView = canvas->rootObject()->findChild<QDeclarativePathView*>("pathView");
QVERIFY(pathView);
- QSignalSpy snapPositionSpy(pathView, SIGNAL(snapPositionChanged()));
+ QSignalSpy snapPositionSpy(pathView, SIGNAL(preferredHighlightBeginChanged()));
QSignalSpy dragMarginSpy(pathView, SIGNAL(dragMarginChanged()));
- QCOMPARE(pathView->snapPosition(), 0.1);
+ QCOMPARE(pathView->preferredHighlightBegin(), 0.1);
QCOMPARE(pathView->dragMargin(), 5.0);
- pathView->setSnapPosition(0.4);
+ pathView->setPreferredHighlightBegin(0.4);
+ pathView->setPreferredHighlightEnd(0.4);
pathView->setDragMargin(20.0);
- QCOMPARE(pathView->snapPosition(), 0.4);
+ QCOMPARE(pathView->preferredHighlightBegin(), 0.4);
+ QCOMPARE(pathView->preferredHighlightEnd(), 0.4);
QCOMPARE(pathView->dragMargin(), 20.0);
QCOMPARE(snapPositionSpy.count(), 1);
QCOMPARE(dragMarginSpy.count(), 1);
- pathView->setSnapPosition(0.4);
+ pathView->setPreferredHighlightBegin(0.4);
+ pathView->setPreferredHighlightEnd(0.4);
pathView->setDragMargin(20.0);
QCOMPARE(snapPositionSpy.count(), 1);