summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativelistmodel
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-11-10 04:43:11 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-11-23 02:03:31 (GMT)
commite64535b227599b5adb8847dfda0b2516ae7e5625 (patch)
tree2eb7cb58bdd49b65790f87b4223cd91a5a9977c5 /tests/auto/declarative/qdeclarativelistmodel
parent7d17956316ac786516f67ba9be511975ff42d898 (diff)
downloadQt-e64535b227599b5adb8847dfda0b2516ae7e5625.zip
Qt-e64535b227599b5adb8847dfda0b2516ae7e5625.tar.gz
Qt-e64535b227599b5adb8847dfda0b2516ae7e5625.tar.bz2
Fix ListModel::set() to update the model cache when setting a list value
Task-number: QTBUG-15190
Diffstat (limited to 'tests/auto/declarative/qdeclarativelistmodel')
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/data/setmodelcachelist.qml20
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp12
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/setmodelcachelist.qml b/tests/auto/declarative/qdeclarativelistmodel/data/setmodelcachelist.qml
new file mode 100644
index 0000000..ffe417a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistmodel/data/setmodelcachelist.qml
@@ -0,0 +1,20 @@
+import QtQuick 1.0
+
+ListModel {
+ id: model
+ property bool ok : false
+
+ Component.onCompleted: {
+ model.append({"attrs": []})
+ model.get(0)
+ model.set(0, {"attrs": [{'abc': 123, 'def': 456}] } )
+ ok = ( model.get(0).attrs.get(0).abc == 123
+ && model.get(0).attrs.get(0).def == 456 )
+
+ model.set(0, {"attrs": [{'abc': 789, 'def': 101}] } )
+ ok = ( model.get(0).attrs.get(0).abc == 789
+ && model.get(0).attrs.get(0).def == 101 )
+
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
index 4b8d772..55f7421 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
@@ -100,6 +100,7 @@ private slots:
void get_nested();
void get_nested_data();
void crash_model_with_multiple_roles();
+ void set_model_cache();
};
int tst_qdeclarativelistmodel::roleFromName(const QDeclarativeListModel *model, const QString &roleName)
{
@@ -928,6 +929,17 @@ void tst_qdeclarativelistmodel::crash_model_with_multiple_roles()
model->setProperty(0, "black", true);
}
+//QTBUG-15190
+void tst_qdeclarativelistmodel::set_model_cache()
+{
+ QDeclarativeEngine eng;
+ QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/setmodelcachelist.qml"));
+ QObject *model = component.create();
+ QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString()));
+ QVERIFY(model != 0);
+ QVERIFY(model->property("ok").toBool());
+}
+
QTEST_MAIN(tst_qdeclarativelistmodel)
#include "tst_qdeclarativelistmodel.moc"