aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickpathview
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2014-10-29 13:59:46 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2014-10-29 21:50:12 +0100
commitcf959b4b4ea3d2dfd5243022fea393fadfd95b0d (patch)
tree15191c98807e379e57267cfb5bf7a28bd53d4c83 /tests/auto/quick/qquickpathview
parent4b7dc1cf59da656be1f51a5a7bdac01b1ae8219a (diff)
Repeater & itemviews: fix setModel() JS array handling
QVariant comparison in setModel() started failing because JS arrays are now passed as a QJSValue. Re-assigning the same array content should not trigger a model change. This change restores the old behavior it had before, when JS arrays were passed as QVariantLists. Change-Id: I1882b3531f2893b116dbd817edeecab1ae812ce8 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'tests/auto/quick/qquickpathview')
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index 0e9994899f..992b2347dd 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -139,6 +139,7 @@ private slots:
void changePathDuringRefill();
void nestedinFlickable();
void flickableDelegate();
+ void jsArrayChange();
};
class TestObject : public QObject
@@ -2290,6 +2291,33 @@ void tst_QQuickPathView::flickableDelegate()
QCOMPARE(moveStartedSpy.count(), 0);
}
+void tst_QQuickPathView::jsArrayChange()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.4; PathView {}", QUrl());
+
+ QScopedPointer<QQuickPathView> view(qobject_cast<QQuickPathView *>(component.create()));
+ QVERIFY(!view.isNull());
+
+ QSignalSpy spy(view.data(), SIGNAL(modelChanged()));
+ QVERIFY(spy.isValid());
+
+ QJSValue array1 = engine.newArray(3);
+ QJSValue array2 = engine.newArray(3);
+ for (int i = 0; i < 3; ++i) {
+ array1.setProperty(i, i);
+ array2.setProperty(i, i);
+ }
+
+ view->setModel(QVariant::fromValue(array1));
+ QCOMPARE(spy.count(), 1);
+
+ // no change
+ view->setModel(QVariant::fromValue(array2));
+ QCOMPARE(spy.count(), 1);
+}
+
QTEST_MAIN(tst_QQuickPathView)
#include "tst_qquickpathview.moc"