aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickrepeater
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/qquickrepeater
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/qquickrepeater')
-rw-r--r--tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
index 1396dd4783..258eaee981 100644
--- a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
+++ b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
@@ -72,6 +72,7 @@ private slots:
void dynamicModelCrash();
void visualItemModelCrash();
void invalidContextCrash();
+ void jsArrayChange();
};
class TestObject : public QObject
@@ -779,6 +780,33 @@ void tst_QQuickRepeater::invalidContextCrash()
root.reset(0);
}
+void tst_QQuickRepeater::jsArrayChange()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.4; Repeater {}", QUrl());
+
+ QScopedPointer<QQuickRepeater> repeater(qobject_cast<QQuickRepeater *>(component.create()));
+ QVERIFY(!repeater.isNull());
+
+ QSignalSpy spy(repeater.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);
+ }
+
+ repeater->setModel(QVariant::fromValue(array1));
+ QCOMPARE(spy.count(), 1);
+
+ // no change
+ repeater->setModel(QVariant::fromValue(array2));
+ QCOMPARE(spy.count(), 1);
+}
+
QTEST_MAIN(tst_QQuickRepeater)
#include "tst_qquickrepeater.moc"