summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativelistmodel
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-04-01 05:07:56 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-04-01 05:12:06 (GMT)
commit47b33bcb65b642d808251bed7e38fc36a3e89bfc (patch)
tree062b5f9c3af8cf290d6a7b8b02912ce2277c3fa4 /tests/auto/declarative/qdeclarativelistmodel
parent919ee9dd93ad382ddd813d58a356fd3f8d179046 (diff)
downloadQt-47b33bcb65b642d808251bed7e38fc36a3e89bfc.zip
Qt-47b33bcb65b642d808251bed7e38fc36a3e89bfc.tar.gz
Qt-47b33bcb65b642d808251bed7e38fc36a3e89bfc.tar.bz2
ModelNode::setObjectValue() must update the object cache.
Task-number: QTBUG-9509
Diffstat (limited to 'tests/auto/declarative/qdeclarativelistmodel')
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
index 12000d0..d02f54f 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
@@ -41,6 +41,7 @@
#include <qtest.h>
#include <QtDeclarative/private/qdeclarativeitem_p.h>
#include <QtDeclarative/private/qdeclarativetext_p.h>
+#include <QtDeclarative/private/qdeclarativeengine_p.h>
#include <QtDeclarative/private/qdeclarativelistmodel_p.h>
#include <QtDeclarative/private/qdeclarativeexpression_p.h>
#include <QDeclarativeComponent>
@@ -77,6 +78,7 @@ private slots:
void convertNestedToFlat_ok_data();
void error_data();
void error();
+ void set();
};
QScriptValue tst_QDeclarativeListModel::nestedListValue(QScriptEngine *eng) const
@@ -550,6 +552,30 @@ void tst_QDeclarativeListModel::error()
}
}
+void tst_QDeclarativeListModel::set()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeListModel model;
+ QDeclarativeEngine::setContextForObject(&model,engine.rootContext());
+ engine.rootContext()->setContextObject(&model);
+ QScriptEngine *seng = QDeclarativeEnginePrivate::getScriptEngine(&engine);
+
+ QScriptValue sv = seng->newObject();
+ sv.setProperty("test", QScriptValue(false));
+ model.append(sv);
+
+ sv.setProperty("test", QScriptValue(true));
+ model.set(0, sv);
+ QCOMPARE(model.get(0).property("test").toBool(), true); // triggers creation of model cache
+ QCOMPARE(model.data(0, model.roles()[0]), qVariantFromValue(true));
+
+ sv.setProperty("test", QScriptValue(false));
+ model.set(0, sv);
+ QCOMPARE(model.get(0).property("test").toBool(), false); // tests model cache is updated
+ QCOMPARE(model.data(0, model.roles()[0]), qVariantFromValue(false));
+}
+
+
QTEST_MAIN(tst_QDeclarativeListModel)
#include "tst_qdeclarativelistmodel.moc"