diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2014-10-29 13:59:46 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2014-10-29 21:50:12 +0100 |
commit | cf959b4b4ea3d2dfd5243022fea393fadfd95b0d (patch) | |
tree | 15191c98807e379e57267cfb5bf7a28bd53d4c83 /tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | |
parent | 4b7dc1cf59da656be1f51a5a7bdac01b1ae8219a (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/qquicklistview/tst_qquicklistview.cpp')
-rw-r--r-- | tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 5122b6aa38..9e8a813d54 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -239,6 +239,8 @@ private slots: void QTBUG_39492_data(); void QTBUG_39492(); + void jsArrayChange(); + private: template <class T> void items(const QUrl &source); template <class T> void changed(const QUrl &source); @@ -7945,6 +7947,33 @@ void tst_QQuickListView::QTBUG_39492() releaseView(window); } +void tst_QQuickListView::jsArrayChange() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import QtQuick 2.4; ListView {}", QUrl()); + + QScopedPointer<QQuickListView> view(qobject_cast<QQuickListView *>(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_QQuickListView) #include "tst_qquicklistview.moc" |