aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickgridview
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/qquickgridview
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/qquickgridview')
-rw-r--r--tests/auto/quick/qquickgridview/tst_qquickgridview.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
index b65aad543d..123d7f5032 100644
--- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
+++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
@@ -204,6 +204,8 @@ private slots:
void displayMargin();
void negativeDisplayMargin();
+ void jsArrayChange();
+
private:
QList<int> toIntList(const QVariantList &list);
void matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes);
@@ -6430,6 +6432,33 @@ void tst_QQuickGridView::negativeDisplayMargin()
delete window;
}
+void tst_QQuickGridView::jsArrayChange()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.4; GridView {}", QUrl());
+
+ QScopedPointer<QQuickGridView> view(qobject_cast<QQuickGridView *>(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_QQuickGridView)
#include "tst_qquickgridview.moc"