diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-03-25 04:44:35 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-03-25 23:18:02 (GMT) |
commit | 778e1fd21f5a6c94656dfbb99a7613656d0569a1 (patch) | |
tree | d941bb172f1c33a77377e625495f9e2c6b41c538 /tests/auto | |
parent | 7b42ee836b8cc1ae345d1d24d4419f0c6b77c97d (diff) | |
download | Qt-778e1fd21f5a6c94656dfbb99a7613656d0569a1.zip Qt-778e1fd21f5a6c94656dfbb99a7613656d0569a1.tar.gz Qt-778e1fd21f5a6c94656dfbb99a7613656d0569a1.tar.bz2 |
Fix where data() is called before xml is loaded. Also add status tests.
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp index 81cc922..e3aa5cc 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp +++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp @@ -69,6 +69,8 @@ private slots: void roles(); void roleErrors(); void uniqueRoleNames(); + void status(); + void data(); void reload(); void useKeys(); void useKeys_data(); @@ -247,6 +249,47 @@ void tst_qdeclarativexmllistmodel::uniqueRoleNames() delete model; } +void tst_qdeclarativexmllistmodel::status() +{ + QDeclarativeXmlListModel *model; + model = new QDeclarativeXmlListModel; + QCOMPARE(model->status(), QDeclarativeXmlListModel::Null); + + model->setXml("<data></data>"); + QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready); + delete model; + + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + model = qobject_cast<QDeclarativeXmlListModel*>(component.create()); + QVERIFY(model != 0); + QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading); + + QTRY_COMPARE(model->count(), 9); + QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready); + + delete model; +} + +void tst_qdeclarativexmllistmodel::data() +{ + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create()); + QVERIFY(model != 0); + + QHash<int,QVariant> blank; + for (int i=0; i<model->roles().count(); i++) + blank.insert(model->roles()[i], QVariant()); + for (int i=0; i<9; i++) { + QCOMPARE(model->data(i, model->roles()), blank); + for (int j=0; j<model->roles().count(); j++) { + QCOMPARE(model->data(i, j), QVariant()); + } + } + QTRY_COMPARE(model->count(), 9); + + delete model; +} + void tst_qdeclarativexmllistmodel::reload() { // If no keys are used, the model should be rebuilt from scratch when |