aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2012-06-27 14:05:38 +1000
committerQt by Nokia <qt-info@nokia.com>2012-06-27 08:49:46 +0200
commit7722786a1305d9fdd4e0e8856322352c806de25c (patch)
tree99b9c3097b5e143112d7fb454ea1f3cc6b06b75c /tests
parent9b527b0122abc68368574063af2175852cdcb328 (diff)
Changing PathView offset doesn't set currentIndex appropriately
If the highlightRangeMode is StrictlyEnforceRange then the currentIndex should always be updated when the path offset changes. Task-number: QTBUG-19835 Change-Id: I2371e5abd430e770bbb8f9f9d5f4e1d17e0d8ff5 Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp39
1 files changed, 37 insertions, 2 deletions
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index 5c0df1612f..d164563b93 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -108,6 +108,8 @@ private slots:
void consecutiveModelChanges();
void path();
void pathMoved();
+ void offset_data();
+ void offset();
void setCurrentIndex();
void resetModel();
void propertyChanges();
@@ -267,7 +269,7 @@ void tst_QQuickPathView::pathview3()
QVERIFY(obj->path() != 0);
QVERIFY(obj->delegate() != 0);
QVERIFY(obj->model() != QVariant());
- QCOMPARE(obj->currentIndex(), 0);
+ QCOMPARE(obj->currentIndex(), 7);
QCOMPARE(obj->offset(), 1.0);
QCOMPARE(obj->preferredHighlightBegin(), 0.5);
QCOMPARE(obj->dragMargin(), 24.);
@@ -801,7 +803,7 @@ void tst_QQuickPathView::dataModel()
QVERIFY(testItem == 0);
pathview->setCurrentIndex(1);
- QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 1));
+ QTRY_COMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 1));
QTest::qWait(100);
model.insertItem(2, "pink", "2");
@@ -836,6 +838,7 @@ void tst_QQuickPathView::dataModel()
QCOMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
pathview->setCurrentIndex(model.count()-1);
+ QTRY_COMPARE(pathview->offset(), 1.0);
model.removeItem(model.count()-1);
QCOMPARE(pathview->currentIndex(), model.count()-1);
@@ -880,8 +883,11 @@ void tst_QQuickPathView::pathMoved()
QCOMPARE(curItem->pos() + offset, QPointF(itemPos.x(), itemPos.y()));
}
+ QCOMPARE(pathview->currentIndex(), 3);
+
pathview->setOffset(0.0);
QCOMPARE(firstItem->pos() + offset, start);
+ QCOMPARE(pathview->currentIndex(), 0);
// Change delegate size
pathview->setOffset(0.1);
@@ -900,6 +906,35 @@ void tst_QQuickPathView::pathMoved()
delete canvas;
}
+void tst_QQuickPathView::offset_data()
+{
+ QTest::addColumn<qreal>("offset");
+ QTest::addColumn<int>("currentIndex");
+
+ QTest::newRow("0.0") << 0.0 << 0;
+ QTest::newRow("1.0") << 7.0 << 1;
+ QTest::newRow("5.0") << 5.0 << 3;
+ QTest::newRow("4.6") << 4.6 << 3;
+ QTest::newRow("4.4") << 4.4 << 4;
+ QTest::newRow("5.4") << 5.4 << 3;
+ QTest::newRow("5.6") << 5.6 << 2;
+}
+
+void tst_QQuickPathView::offset()
+{
+ QFETCH(qreal, offset);
+ QFETCH(int, currentIndex);
+
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathview3.qml"));
+ QQuickPathView *view = qobject_cast<QQuickPathView*>(c.create());
+
+ view->setOffset(offset);
+ QCOMPARE(view->currentIndex(), currentIndex);
+
+ delete view;
+}
+
void tst_QQuickPathView::setCurrentIndex()
{
QQuickView *canvas = createView();