void TestCreationL(CContactDatabase& aDb) { _LIT(KTestCreation,"Create CContactICCEntry item"); test.Start(_L("@SYMTESTCaseID:PIM-T-ICCENTRY-0001 Create CContactICCEntry item")); //System Template TContactItemId systemTemplateId = aDb.TemplateId(); CContactItem* systemTemplate = aDb.ReadContactLC(systemTemplateId); CContactICCEntry* entry = CContactICCEntry::NewL(*systemTemplate); CleanupStack::PopAndDestroy(systemTemplate); CleanupStack::PushL(entry); //Test CContactICCEntry items can be identified from normal contact cards test(entry->Type() == KUidContactICCEntry); test(entry->TemplateRefId() == systemTemplateId); CleanupStack::PopAndDestroy(entry); //Create user defined template for ICC contacts test.Next(_L("CContactDatabase::ICCTemplateL()")); TContactItemId templateId = CreateICCTemplateL(aDb); test(KErrNone == syncChecker->UpdatePhonebookEntryL(KUidIccGlobalAdnPhonebook, templateId, KNullContactId)); //Check that contacts model calls the plug-in when asked for the //template ID. TInt callCount = syncChecker->ValidateMethodCallCountL(); test(callCount==0); TContactItemId templateIdFromCntmodel; templateIdFromCntmodel = aDb.ICCTemplateIdL(KUidIccGlobalAdnPhonebook); test(syncChecker->ValidateMethodCallCountL() == 1); test(templateId == templateIdFromCntmodel); CContactItem* iccTemplate = aDb.ReadContactLC(templateId); CheckTemplateL(*iccTemplate); //create ICC contact CContactICCEntry* iccentry = CContactICCEntry::NewL(*iccTemplate); CleanupStack::PopAndDestroy(iccTemplate); CleanupStack::PushL(iccentry); test(iccentry->Type() == KUidContactICCEntry); test(iccentry->TemplateRefId() == templateId); CleanupStack::PopAndDestroy(iccentry); test.End(); }
TInt CContactTestSynchroniser::ValidateWriteContact(CContactICCEntry& aContactItem) { TRAPD(err, iContactSyncChecker->ValidateMethodCalledL() ); __ASSERT_ALWAYS(err == KErrNone, User::Invariant() ); TBool verboseLoggingEnabled(EFalse); TRAP(err, verboseLoggingEnabled = iContactSyncChecker->VerboseLoggingEnabledL() ); __ASSERT_ALWAYS(err == KErrNone, User::Invariant() ); if (verboseLoggingEnabled) { User::InfoPrint(_L("ValidateWriteContact")); } // Set the phonebook field, if the field doesn't exist, it should be added CContactItemFieldSet& fieldset = aContactItem.CardFields(); TInt n = fieldset.Find(KUidContactFieldICCPhonebook); if(n == KErrNotFound) { CContactItemField* field(NULL); TRAP_IGNORE(field = CContactItemField::NewL(KStorageTypeText, KUidContactFieldICCPhonebook) ); TRAP(err, aContactItem.AddFieldL(*field) ); CContactItemFieldSet& fieldset = aContactItem.CardFields(); n = fieldset.Find(KUidContactFieldICCPhonebook); __ASSERT_ALWAYS(err == KErrNone && n != KErrNotFound, User::Invariant() ); } CContactItemField& field = fieldset[n]; CContactTextField* textField = field.TextStorage(); TUid phonebookUid(TUid::Null() ); TRAP(err, phonebookUid = iContactSyncChecker->PhonebookUidL(aContactItem.TemplateRefId() ) ); __ASSERT_ALWAYS(err == KErrNone, User::Invariant() ); TBuf<128> buf; if(phonebookUid != KUidIccPhonebookNotFound) { TInt phonebookUidNum = phonebookUid.iUid; buf.AppendNum(phonebookUidNum); TRAP(err, textField->SetTextL(buf)); __ASSERT_ALWAYS(err == KErrNone, User::Invariant() ); } TBool validateWriteResponse(EFalse); TRAP(err, validateWriteResponse = iContactSyncChecker->ValidateWriteResponseL() ); __ASSERT_ALWAYS(err == KErrNone, User::Invariant() ); return validateWriteResponse; }