117 |
117 |
118 void tst_SimCMAsync::init() |
118 void tst_SimCMAsync::init() |
119 { |
119 { |
120 // remove all contacts |
120 // remove all contacts |
121 QList<QContactLocalId> ids = m_cm->contactIds(); |
121 QList<QContactLocalId> ids = m_cm->contactIds(); |
122 m_cm->removeContacts(&ids, 0); |
122 m_cm->removeContacts(ids, 0); |
123 } |
123 } |
124 |
124 |
125 void tst_SimCMAsync::cleanup() |
125 void tst_SimCMAsync::cleanup() |
126 { |
126 { |
127 // remove all contacts |
127 // remove all contacts |
128 QList<QContactLocalId> ids = m_cm->contactIds(); |
128 QList<QContactLocalId> ids = m_cm->contactIds(); |
129 m_cm->removeContacts(&ids, 0); |
129 m_cm->removeContacts(ids, 0); |
130 } |
130 } |
131 |
131 |
132 void tst_SimCMAsync::initTestCase() |
132 void tst_SimCMAsync::initTestCase() |
133 { |
133 { |
134 initManager(QString()); |
134 initManager(QString()); |
228 QVERIFY(resultSpy.count() == 0); |
228 QVERIFY(resultSpy.count() == 0); |
229 QVERIFY(req.state() == QContactAbstractRequest::CanceledState); |
229 QVERIFY(req.state() == QContactAbstractRequest::CanceledState); |
230 |
230 |
231 // Remove all contacts |
231 // Remove all contacts |
232 QList<QContactLocalId> ids = m_cm->contactIds(); |
232 QList<QContactLocalId> ids = m_cm->contactIds(); |
233 m_cm->removeContacts(&ids, 0); |
233 m_cm->removeContacts(ids, 0); |
234 |
234 |
235 // Test fetching nothing |
235 // Test fetching nothing |
236 stateSpy.clear(); |
236 stateSpy.clear(); |
237 resultSpy.clear(); |
237 resultSpy.clear(); |
238 QVERIFY(req.start()); |
238 QVERIFY(req.start()); |
288 QVERIFY(resultSpy.count() == 0); |
288 QVERIFY(resultSpy.count() == 0); |
289 QVERIFY(req.state() == QContactAbstractRequest::CanceledState); |
289 QVERIFY(req.state() == QContactAbstractRequest::CanceledState); |
290 |
290 |
291 // Remove all contacts |
291 // Remove all contacts |
292 QList<QContactLocalId> ids = m_cm->contactIds(); |
292 QList<QContactLocalId> ids = m_cm->contactIds(); |
293 m_cm->removeContacts(&ids, 0); |
293 m_cm->removeContacts(ids, 0); |
294 |
294 |
295 // Start again |
295 // Start again |
296 stateSpy.clear(); |
296 stateSpy.clear(); |
297 resultSpy.clear(); |
297 resultSpy.clear(); |
298 QVERIFY(req.start()); |
298 QVERIFY(req.start()); |
383 QVERIFY(req.contacts().at(1).localId() == c2.localId()); |
383 QVERIFY(req.contacts().at(1).localId() == c2.localId()); |
384 c = req.contacts().at(0); |
384 c = req.contacts().at(0); |
385 QVERIFY(c.details(QContactPhoneNumber::DefinitionName).count() == 0); |
385 QVERIFY(c.details(QContactPhoneNumber::DefinitionName).count() == 0); |
386 QVERIFY(c.detail<QContactName>().customLabel() == c1.detail<QContactName>().customLabel()); |
386 QVERIFY(c.detail<QContactName>().customLabel() == c1.detail<QContactName>().customLabel()); |
387 QVERIFY(m_cm->contactIds().count() == 2); |
387 QVERIFY(m_cm->contactIds().count() == 2); |
388 c = m_cm->contact(c1.localId(), QStringList()); |
388 c = m_cm->contact(c1.localId()); |
389 QVERIFY(c.details(QContactPhoneNumber::DefinitionName).count() == 0); |
389 QVERIFY(c.details(QContactPhoneNumber::DefinitionName).count() == 0); |
390 QVERIFY(c.detail<QContactName>().customLabel() == c1.detail<QContactName>().customLabel()); |
390 QVERIFY(c.detail<QContactName>().customLabel() == c1.detail<QContactName>().customLabel()); |
391 } |
391 } |
392 |
392 |
393 void tst_SimCMAsync::removeContactReq() |
393 void tst_SimCMAsync::removeContactReq() |
437 QVERIFY(req.start()); |
437 QVERIFY(req.start()); |
438 QVERIFY(req.state() == QContactAbstractRequest::ActiveState); |
438 QVERIFY(req.state() == QContactAbstractRequest::ActiveState); |
439 QVERIFY(stateSpy.count() == 1); |
439 QVERIFY(stateSpy.count() == 1); |
440 QTRY_COMPARE(resultSpy.count(), 1); |
440 QTRY_COMPARE(resultSpy.count(), 1); |
441 QVERIFY(req.state() == QContactAbstractRequest::FinishedState); |
441 QVERIFY(req.state() == QContactAbstractRequest::FinishedState); |
442 #ifndef __WINS__ |
442 // NOTE: In emulator removing a nonexisting contact will return DoesNotExistError |
443 QWARN("This test fails in hardware!"); |
443 // and in hardware there will be no error. |
444 QWARN("In hardware removing SIM contacts which do not exist the etel server will return KErrNone instead of KErrNotFound"); |
444 QVERIFY(req.error() == QContactManager::DoesNotExistError || req.error() == QContactManager::NoError); |
445 #endif |
445 if (req.errorMap().count()) { |
446 QVERIFY(req.error() == QContactManager::DoesNotExistError); |
446 QVERIFY(req.errorMap().count() == 2); |
447 QVERIFY(req.errorMap().count() == 2); |
447 QVERIFY(req.errorMap().value(0) == QContactManager::DoesNotExistError); |
448 QVERIFY(req.errorMap().value(0) == QContactManager::DoesNotExistError); |
448 QVERIFY(req.errorMap().value(1) == QContactManager::DoesNotExistError); |
449 QVERIFY(req.errorMap().value(1) == QContactManager::DoesNotExistError); |
449 } |
450 } |
450 } |
451 |
451 |
452 void tst_SimCMAsync::detailDefinitionFetchReq() |
452 void tst_SimCMAsync::detailDefinitionFetchReq() |
453 { |
453 { |
454 QContactDetailDefinitionFetchRequest req; |
454 QContactDetailDefinitionFetchRequest req; |