summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-04-07 01:53:16 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-04-07 02:38:42 (GMT)
commit973cfce37fcdd1ce330f237eaa76930db55a73f6 (patch)
tree96480cb291d6e5d2e0a9bf78bf1127a693ab2930 /tests/auto
parent32fdd579afc2933ccc5fc658553cf18cf2057ff2 (diff)
downloadQt-973cfce37fcdd1ce330f237eaa76930db55a73f6.zip
Qt-973cfce37fcdd1ce330f237eaa76930db55a73f6.tar.gz
Qt-973cfce37fcdd1ce330f237eaa76930db55a73f6.tar.bz2
Add QListModelInterface::modelReset() signal and emit this in
XmlListModel when all data has changed.
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp54
1 files changed, 20 insertions, 34 deletions
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
index 74da79e..ba0f9a7 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
@@ -378,17 +378,16 @@ void tst_qdeclarativexmllistmodel::reload()
QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
QSignalSpy spyCount(model, SIGNAL(countChanged()));
+ QSignalSpy spyReset(model, SIGNAL(modelReset()));
model->reload();
- QTRY_COMPARE(spyCount.count(), 1);
- QTRY_COMPARE(spyInsert.count(), 1);
- QTRY_COMPARE(spyRemove.count(), 1);
-
- QCOMPARE(spyInsert[0][0].toInt(), 0);
- QCOMPARE(spyInsert[0][1].toInt(), 9);
+ QTRY_COMPARE(spyReset.count(), 1);
+ QCOMPARE(spyCount.count(), 0);
+ QCOMPARE(spyInsert.count(), 0);
+ QCOMPARE(spyRemove.count(), 0);
- QCOMPARE(spyRemove[0][0].toInt(), 0);
- QCOMPARE(spyRemove[0][1].toInt(), 9);
+ QCOMPARE(model->data(0, model->roles().first()).toString(), QString("Polly"));
+ QCOMPARE(model->data(model->count()-1, model->roles().first()).toString(), QString("Tiny"));
delete model;
}
@@ -416,15 +415,15 @@ void tst_qdeclarativexmllistmodel::useKeys()
QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
QSignalSpy spyCount(model, SIGNAL(countChanged()));
+ QSignalSpy spyReset(model, SIGNAL(modelReset()));
model->setXml(newXml);
- if (oldCount != newData.count()) {
- QTRY_COMPARE(model->count(), newData.count());
- QCOMPARE(spyCount.count(), 1);
+ if (insertRanges.isEmpty() && removeRanges.isEmpty()) {
+ QTRY_COMPARE(spyReset.count(), 1);
} else {
QTRY_VERIFY(spyInsert.count() > 0 || spyRemove.count() > 0);
- QCOMPARE(spyCount.count(), 0);
+ QCOMPARE(spyCount.count() == 0, oldCount == newData.count());
}
QList<int> roles = model->roles();
@@ -513,21 +512,14 @@ void tst_qdeclarativexmllistmodel::useKeys_data()
<< makeItemXmlAndData("", &modelData)
<< modelData
<< QList<QDeclarativeXmlListRange>()
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 3));
+ << QList<QDeclarativeXmlListRange>();
QTest::newRow("replace item")
<< makeItemXmlAndData("name=A,age=25,sport=Football") << 1
<< makeItemXmlAndData("name=ZZZ,age=25,sport=Football", &modelData)
<< modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1))
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1));
-
- QTest::newRow("add and remove simultaneously, in different spots")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf") << 4
- << makeItemXmlAndData("name=B,age=35,sport=Athletics;name=E,age=65,sport=Fencing", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 1))
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1) << qMakePair(2,2));
+ << QList<QDeclarativeXmlListRange>()
+ << QList<QDeclarativeXmlListRange>();
QTest::newRow("insert at start, remove at end i.e. rss feed")
<< makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing") << 3
@@ -547,8 +539,8 @@ void tst_qdeclarativexmllistmodel::useKeys_data()
<< makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35") << 2
<< makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData)
<< modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 2))
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 2));
+ << QList<QDeclarativeXmlListRange>()
+ << QList<QDeclarativeXmlListRange>();
}
void tst_qdeclarativexmllistmodel::noKeysValueChanges()
@@ -608,20 +600,14 @@ void tst_qdeclarativexmllistmodel::keysChanged()
QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
QSignalSpy spyCount(model, SIGNAL(countChanged()));
+ QSignalSpy spyReset(model, SIGNAL(modelReset()));
QVERIFY(QMetaObject::invokeMethod(model, "disableNameKey"));
model->setXml(xml);
- QTRY_VERIFY(spyInsert.count() > 0 && spyRemove.count() > 0);
-
- QCOMPARE(spyInsert.count(), 1);
- QCOMPARE(spyInsert[0][0].toInt(), 0);
- QCOMPARE(spyInsert[0][1].toInt(), 2);
-
- QCOMPARE(spyRemove.count(), 1);
- QCOMPARE(spyRemove[0][0].toInt(), 0);
- QCOMPARE(spyRemove[0][1].toInt(), 2);
-
+ QTRY_COMPARE(spyReset.count(), 1);
+ QCOMPARE(spyInsert.count(), 0);
+ QCOMPARE(spyRemove.count(), 0);
QCOMPARE(spyCount.count(), 0);
delete model;