aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
diff options
context:
space:
mode:
authorAlan Alpert <416365416c@gmail.com>2015-05-06 22:56:03 -0700
committerAlan Alpert <aalpert@blackberry.com>2015-05-18 16:16:44 +0000
commitfa785edbec74bd9201ed80c25ba582978c05a803 (patch)
treeb7ddea1bb8482fe90dca391bbacbf75d69a4856d /tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
parentf52025af7a1c62f4c0f580c39ce255a798e91655 (diff)
Remove ordered list assumptions in PathView
When flicking fast or jumping around on paths with some items not seen, the current algorithm makes assumptions about list ordering which are hard to maintain. Specifically that it has the index of the first item in the list cached and that all changed will be to either prepend or append an item to the current ordered set. This patch removes that assumption, leading to a little more work each time to identify where new elements will go. There is still a slightly faster path for the common case of adding elements to the beginning or end of the path. Task-number: QTBUG-42716 Change-Id: Ief76c93967d254d405e6656ef27d06b4ecc470c8 Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'tests/auto/quick/qquickpathview/tst_qquickpathview.cpp')
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index 7db15522b5..0910f6cb2e 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -140,6 +140,7 @@ private slots:
void nestedinFlickable();
void flickableDelegate();
void jsArrayChange();
+ void qtbug42716();
};
class TestObject : public QObject
@@ -2322,6 +2323,54 @@ void tst_QQuickPathView::jsArrayChange()
QCOMPARE(spy.count(), 1);
}
+/* This bug was one where if you jump the list such that the sole missing item needed to be
+ * added in the middle of the list, it would instead move an item somewhere else in the list
+ * to the middle (messing it up very badly).
+ *
+ * The test checks correct visual order both before and after the jump.
+ */
+void tst_QQuickPathView::qtbug42716()
+{
+ QScopedPointer<QQuickView> window(createView());
+
+ window->setSource(testFileUrl("qtbug42716.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+ QCOMPARE(window.data(), qGuiApp->focusWindow());
+
+ QQuickPathView *pathView = findItem<QQuickPathView>(window->rootObject(), "pathView");
+ QVERIFY(pathView != 0);
+
+ int order1[] = {5,6,7,0,1,2,3};
+ int missing1 = 4;
+ int order2[] = {0,1,2,3,4,5,6};
+ int missing2 = 7;
+
+ qreal lastY = 0.0;
+ for (int i = 0; i<7; i++) {
+ QQuickItem *item = findItem<QQuickItem>(pathView, QString("delegate%1").arg(order1[i]));
+ QVERIFY(item);
+ QVERIFY(item->y() > lastY);
+ lastY = item->y();
+ }
+ QQuickItem *itemMiss = findItem<QQuickItem>(pathView, QString("delegate%1").arg(missing1));
+ QVERIFY(!itemMiss);
+
+ pathView->setOffset(0.0882353);
+ //Note refill is delayed, needs time to take effect
+ QTest::qWait(100);
+
+ lastY = 0.0;
+ for (int i = 0; i<7; i++) {
+ QQuickItem *item = findItem<QQuickItem>(pathView, QString("delegate%1").arg(order2[i]));
+ QVERIFY(item);
+ QVERIFY(item->y() > lastY);
+ lastY = item->y();
+ }
+ itemMiss = findItem<QQuickItem>(pathView, QString("delegate%1").arg(missing2));
+ QVERIFY(!itemMiss);
+}
+
QTEST_MAIN(tst_QQuickPathView)
#include "tst_qquickpathview.moc"