--- a/qtmobility/tests/auto/qcontactmanager/tst_qcontactmanager.cpp Fri Jun 11 14:26:25 2010 +0300
+++ b/qtmobility/tests/auto/qcontactmanager/tst_qcontactmanager.cpp Wed Jun 23 19:08:38 2010 +0300
@@ -1034,6 +1034,10 @@
QVERIFY(contacts.at(1).detail(QContactName::DefinitionName) == nb);
QVERIFY(contacts.at(2).detail(QContactName::DefinitionName) == nc);
+ /* Save again, with a null error map */
+ QVERIFY(cm->saveContacts(&contacts, NULL));
+ QVERIFY(cm->error() == QContactManager::NoError);
+
/* Now make an update to them all */
QContactPhoneNumber number;
number.setNumber("1234567");
@@ -1092,6 +1096,10 @@
QVERIFY(errorMap.values().at(1) == QContactManager::DoesNotExistError);
QVERIFY(errorMap.values().at(2) == QContactManager::DoesNotExistError);
+ /* And again with a null error map */
+ QVERIFY(!cm->removeContacts(ids, NULL));
+ QVERIFY(cm->error() == QContactManager::DoesNotExistError);
+
/* Try adding some new ones again, this time one with an error */
contacts.clear();
a.setId(QContactId());
@@ -1988,11 +1996,11 @@
/* Batch modifies */
QContactName modifiedName = c.detail(QContactName::DefinitionName);
- saveContactName(&c, nameDef, &modifiedName, "This is modified number 1");
+ saveContactName(&c, nameDef, &modifiedName, "Modified number 1");
modifiedName = c2.detail(QContactName::DefinitionName);
- saveContactName(&c2, nameDef, &modifiedName, "This is modified number 2");
+ saveContactName(&c2, nameDef, &modifiedName, "Modified number 2");
modifiedName = c3.detail(QContactName::DefinitionName);
- saveContactName(&c3, nameDef, &modifiedName, "This is modified number 3");
+ saveContactName(&c3, nameDef, &modifiedName, "Modified number 3");
batchAdd.clear();
batchAdd << c << c2 << c3;
@@ -2012,6 +2020,20 @@
QTRY_COMPARE(spyCM.count(), 0);
QScopedPointer<QContactManager> m2(QContactManager::fromUri(uri));
+
+ // During construction SIM backend (m2) will try writing contacts with
+ // nickname, email and additional number to find out if the SIM card
+ // will support these fields. The other backend (m1) will then receive
+ // signals about that. These need to be caught so they don't interfere
+ // with the tests. (This trial and error method is used because existing
+ // API for checking the availability of these fields is not public.)
+ // NOTE: This applies only to pre 10.1 platforms (S60 3.1, 3.2, ect.)
+ if (uri.contains("symbiansim")) {
+ QTest::qWait(0);
+ spyCA.clear();
+ spyCM.clear();
+ spyCR.clear();
+ }
QVERIFY(m1->hasFeature(QContactManager::Anonymous) ==
m2->hasFeature(QContactManager::Anonymous));
@@ -2946,8 +2968,13 @@
}
// Cleanup a bit
- QVERIFY(cm->removeRelationship(customRelationshipOne));
- QVERIFY(cm->removeRelationship(customRelationshipTwo));
+ QMap<int, QContactManager::Error> errorMap;
+ QList<QContactRelationship> moreRels;
+
+ moreRels << customRelationshipOne << customRelationshipTwo;
+ errorMap.insert(5, QContactManager::BadArgumentError);
+ QVERIFY(cm->removeRelationships(moreRels, &errorMap));
+ QVERIFY(errorMap.count() == 0);
// test batch API and ordering in contacts
QList<QContactRelationship> currentRelationships = cm->relationships(source.id(), QContactRelationship::First);
@@ -3057,7 +3084,14 @@
customRelationshipOne.setFirst(source.id());
customRelationshipOne.setSecond(dest2.id());
customRelationshipOne.setRelationshipType(availableRelationshipTypes.at(0));
- QVERIFY(cm->saveRelationship(&customRelationshipOne));
+
+ // Test batch save with an error map
+ moreRels.clear();
+ moreRels << customRelationshipOne;
+ errorMap.insert(0, QContactManager::BadArgumentError);
+ QVERIFY(cm->saveRelationships(&moreRels, &errorMap));
+ QVERIFY(cm->error() == QContactManager::NoError);
+ QVERIFY(errorMap.count() == 0); // should be reset
source = cm->contact(source.localId());
dest2 = cm->contact(dest2.localId());
QVERIFY(cm->removeContact(dest2.localId())); // remove dest2, the relationship should be removed