diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-04-12 16:06:35 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-04-12 16:06:35 (GMT) |
commit | 163a4a4c38453cd4ed32c5a436763e11ce580687 (patch) | |
tree | c9162f4b47571300ea17578401122532139561e9 /tests/auto/declarative/qdeclarativelistmodel | |
parent | 7190c7be34fe0dbcfbb10b232b40977c758d251a (diff) | |
parent | b6f1dd4151c5bbcb7d4367ec972c9026ab9e68be (diff) | |
download | Qt-163a4a4c38453cd4ed32c5a436763e11ce580687.zip Qt-163a4a4c38453cd4ed32c5a436763e11ce580687.tar.gz Qt-163a4a4c38453cd4ed32c5a436763e11ce580687.tar.bz2 |
Merge branch 4.7 into qt-master-from-4.7
Diffstat (limited to 'tests/auto/declarative/qdeclarativelistmodel')
-rw-r--r-- | tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index 45072f3..2f7513f 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -106,6 +106,7 @@ private slots: void property_changes_data(); void property_changes_worker(); void property_changes_worker_data(); + void clear(); }; int tst_qdeclarativelistmodel::roleFromName(const QDeclarativeListModel *model, const QString &roleName) { @@ -1091,6 +1092,47 @@ void tst_qdeclarativelistmodel::property_changes_worker_data() property_changes_data(); } +void tst_qdeclarativelistmodel::clear() +{ + QDeclarativeEngine engine; + QDeclarativeListModel model; + QDeclarativeEngine::setContextForObject(&model, engine.rootContext()); + engine.rootContext()->setContextObject(&model); + + QScriptEngine *seng = QDeclarativeEnginePrivate::getScriptEngine(&engine); + QScriptValue sv = seng->newObject(); + QVariant result; + + model.clear(); + QCOMPARE(model.count(), 0); + + sv.setProperty("propertyA", "value a"); + sv.setProperty("propertyB", "value b"); + model.append(sv); + QCOMPARE(model.count(), 1); + + model.clear(); + QCOMPARE(model.count(), 0); + + model.append(sv); + model.append(sv); + QCOMPARE(model.count(), 2); + + model.clear(); + QCOMPARE(model.count(), 0); + + // clearing does not remove the roles + sv.setProperty("propertyC", "value c"); + model.append(sv); + QList<int> roles = model.roles(); + model.clear(); + QCOMPARE(model.count(), 0); + QCOMPARE(model.roles(), roles); + QCOMPARE(model.toString(roles[0]), QString("propertyA")); + QCOMPARE(model.toString(roles[1]), QString("propertyB")); + QCOMPARE(model.toString(roles[2]), QString("propertyC")); +} + QTEST_MAIN(tst_qdeclarativelistmodel) #include "tst_qdeclarativelistmodel.moc" |