diff -r 000000000000 -r e686773b3f54 pimprotocols/phonebooksync/Test/TE_cntsync/te_cntsyncadd.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pimprotocols/phonebooksync/Test/TE_cntsync/te_cntsyncadd.cpp Tue Feb 02 10:12:17 2010 +0200 @@ -0,0 +1,1090 @@ +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include + +#include "te_cntsyncbase.h" +#include "te_cntsyncadd.h" +#include +#include + +_LIT(KTestEmpty,""); +_LIT(KBoundaryTestName,"B"); +_LIT(KBoundaryTestNumber,"2"); +_LIT(KTestCompany,"Company A"); +_LIT(KTestNumberWithDTMF,"020788p98w8548"); +_LIT(KTestAddNumber,"12345678"); + + +/** + * Factory construction method. + * @return Pointer to CPhbkAddICCContactTest object + */ +CPhbkAddICCContactTest* CPhbkAddICCContactTest::NewL() + { + CPhbkAddICCContactTest* self = new(ELeave) CPhbkAddICCContactTest(); + return self; + } + +/** + * Default constructor. Each test step initialises it's own name. + */ +CPhbkAddICCContactTest::CPhbkAddICCContactTest() + { + SetTestStepName(_L("AddICCContactTest")); + } + +/** Add an ICC entry to each of the supported phonebooks - normal case */ +enum TVerdict CPhbkAddICCContactTest::doTestStepL() + { + SetSyncModeL(RPhoneBookSession::EManual); + CheckSyncModeL(RPhoneBookSession::EManual); + SetSimTsyTestNumberL(19); + DoSyncL(); + + AddContactL(KTestName,KTestNumber,KUidIccGlobalAdnPhonebook,KTestEMail); + AddContactL(KTestName,KTestNumber,KUidIccGlobalSdnPhonebook); + AddContactL(KTestName,KTestNumber,KUidIccGlobalLndPhonebook); + AddContactL(KTestName,KTestNumber,KUidUsimAppAdnPhonebook,KTestEMail); + AddContactL(KTestName,KTestNumber,KUidIccGlobalFdnPhonebook); + + return TestStepResult(); + } + + +/** + * Factory construction method. + * @return Pointer to CPhbkAddEntryEmptyNameTest object + */ +CPhbkAddEntryEmptyNameTest* CPhbkAddEntryEmptyNameTest::NewL() + { + CPhbkAddEntryEmptyNameTest* self = new(ELeave) CPhbkAddEntryEmptyNameTest(); + return self; + } + +/** + * Default constructor. Each test step initialises it's own name. + */ +CPhbkAddEntryEmptyNameTest::CPhbkAddEntryEmptyNameTest() + { + SetTestStepName(_L("AddEntryEmptyNameTest")); + } + +/** Add an ICC entry to each of the supported phonebooks - name field is empty */ +enum TVerdict CPhbkAddEntryEmptyNameTest::doTestStepL() + { + SetSimTsyTestNumberL(19); + DoSyncL(); + + TRAPD(err, AddContactL(KTestEmpty,KTestNumber,KUidIccGlobalAdnPhonebook)); + TESTCHECKL(err, KErrNone); + + TRAP(err, AddContactL(KTestEmpty,KTestNumber,KUidIccGlobalSdnPhonebook)); + TESTCHECKL(err, KErrNone); + + TRAP(err, AddContactL(KTestEmpty,KTestNumber,KUidIccGlobalLndPhonebook)); + TESTCHECKL(err, KErrNone); + + TRAP(err, AddContactL(KTestEmpty,KTestNumber,KUidUsimAppAdnPhonebook,KTestEMail)); + TESTCHECKL(err, KErrNone); + + TRAP(err, AddContactL(KTestEmpty,KTestNumber,KUidIccGlobalFdnPhonebook)); + TESTCHECKL(err, KErrNone); + + return TestStepResult(); + } + + +/** + * Factory construction method. + * @return Pointer to CPhbkAddEntryEmptyNumberTest object + */ +CPhbkAddEntryEmptyNumberTest* CPhbkAddEntryEmptyNumberTest::NewL() + { + CPhbkAddEntryEmptyNumberTest* self = new(ELeave) CPhbkAddEntryEmptyNumberTest(); + return self; + } + +/** + * Default constructor. Each test step initialises it's own name. + */ +CPhbkAddEntryEmptyNumberTest::CPhbkAddEntryEmptyNumberTest() + { + SetTestStepName(_L("AddEntryEmptyNumberTest")); + } + +/** Add an ICC entry to each of the supported phonebooks - number field is empty */ +enum TVerdict CPhbkAddEntryEmptyNumberTest::doTestStepL() + { + SetSimTsyTestNumberL(19); + DoSyncL(); + + TRAPD(err, AddContactL(KTestName,KTestEmpty,KUidIccGlobalAdnPhonebook)); + TESTCHECKL(err, KErrNone); + + TRAP(err, AddContactL(KTestName,KTestEmpty,KUidIccGlobalSdnPhonebook)); + TESTCHECKL(err, KErrNone); + + TRAP(err, AddContactL(KTestName,KTestEmpty,KUidIccGlobalLndPhonebook)); + TESTCHECKL(err, KErrNone); + + TRAP(err, AddContactL(KTestName,KTestEmpty,KUidUsimAppAdnPhonebook,KTestEMail)); + TESTCHECKL(err, KErrNone); + + TRAP(err, AddContactL(KTestName,KTestEmpty,KUidIccGlobalFdnPhonebook)); + TESTCHECKL(err, KErrNone); + + return TestStepResult(); + } + +/** + * Factory construction method. + * @return Pointer to CPhbkAddEntryEmptyEmailTest object + */ +CPhbkAddEntryEmptyEmailTest* CPhbkAddEntryEmptyEmailTest::NewL() + { + CPhbkAddEntryEmptyEmailTest* self = new(ELeave) CPhbkAddEntryEmptyEmailTest(); + return self; + } + +/** + * Default constructor. Each test step initialises it's own name. + */ +CPhbkAddEntryEmptyEmailTest::CPhbkAddEntryEmptyEmailTest() + { + SetTestStepName(_L("AddEntryEmptyEmailTest")); + } + +/** Add an ICC entry to each of the supported phonebooks - first email field is empty, second one is valid */ +enum TVerdict CPhbkAddEntryEmptyEmailTest::doTestStepL() + { + SetSyncModeL(RPhoneBookSession::EManual); + CheckSyncModeL(RPhoneBookSession::EManual); + + TRequestStatus status; + + // Loading a bunch of entries from the SIM (one of them contains the dodgy entry) + SetSimTsyTestNumberL(27); + + // Sync + iSession.DoSynchronisation(status, KUidUsimAppAdnPhonebook); + User::WaitForRequest(status); + TESTCHECKL(status.Int(), KErrNone); + + // Resetting the phone + SetSimTsyTestNumberL(28); + + // Sync again + iSession.DoSynchronisation(status, KUidUsimAppAdnPhonebook); + User::WaitForRequest(status); + TESTCHECKL(status.Int(), KErrNone); + + // look for contact in the synchronised database + CContactItemFieldDef* fieldDef = new(ELeave) CContactItemFieldDef; + CleanupStack::PushL(fieldDef); + fieldDef->AppendL(KUidContactFieldEMail); // define subset of fields to search + CContactIdArray* array = iDb->FindLC(KTestEMail,fieldDef); + TESTCHECKL(array->Count(),1); + TContactItemId entryId = (*array)[0]; + + // now read it back + CContactItem* entryItem = iDb->ReadContactLC(entryId); + CContactICCEntry* newEntry = CContactICCEntry::NewL(*entryItem); + CleanupStack::PushL(newEntry); + + // now checking the entry + CContactItemFieldSet& fieldset = newEntry->CardFields(); + CheckEmptyEmailFieldContentL(fieldset,KUidContactFieldEMail,KTestEMail); + + CleanupStack::PopAndDestroy(newEntry); + CleanupStack::PopAndDestroy(entryItem); + CleanupStack::PopAndDestroy(array); + CleanupStack::PopAndDestroy(fieldDef); + + return TestStepResult(); + } + +/** + * Check that the field of type aFieldType has the same content as + * aExpectedContent + * @param aFieldset Contact item fieldset + * @param aFieldType Field type to test + * @param aExpectedContent Expected data + */ +void CPhbkAddIntegrationTestBase::CheckEmptyEmailFieldContentL(CContactItemFieldSet& aFieldset, TFieldType aFieldType, const TDesC& aExpectedContent) + { + // Look for up to two entries with that label + TInt pos1 = aFieldset.FindNext(aFieldType,KContactFieldSetSearchAll); + TInt pos2 = aFieldset.FindNext(aFieldType,pos1+1); + + TBool match1 = EFalse; + TBool match2 = EFalse; + + // There must be exactly two email fields + TESTCHECKCONDITION((pos1!=KErrNotFound)&&(pos2!=KErrNotFound)); + + // Checking the value of the first match + if(pos1 != KErrNotFound) + { + CContactItemField& field1 = aFieldset[pos1]; + CContactTextField* textField1 = field1.TextStorage(); + if(textField1 != NULL) + { + match1 = (textField1->Text() == aExpectedContent); // Flips to ETrue + } + } + + // Checking the value of the second match + if(pos2 != KErrNotFound) + { + CContactItemField& field2 = aFieldset[pos2]; + CContactTextField* textField2 = field2.TextStorage(); + if(textField2 != NULL) + { + match2 = (textField2->Text() == aExpectedContent); // Flips to ETrue + } + } + + // One (and only one) of the entries must match the expected value + TESTCHECKCONDITIONL( (match1 && !match2) || (!match1 && match2) ); + } + +/** + * Factory construction method. + * @return Pointer to CPhbkAddPhonebookFullTest object + */ +CPhbkAddPhonebookFullTest* CPhbkAddPhonebookFullTest::NewL() + { + CPhbkAddPhonebookFullTest* self = new(ELeave) CPhbkAddPhonebookFullTest(); + return self; + } + +/** + * Default constructor. Each test step initialises it's own name. + */ +CPhbkAddPhonebookFullTest::CPhbkAddPhonebookFullTest() + { + SetTestStepName(_L("AddPhonebookFullTest")); + } + +/** Add an ICC entry to each of the supported phonebooks - fails because phonebook is full */ +enum TVerdict CPhbkAddPhonebookFullTest::doTestStepL() + { + SetSimTsyTestNumberL(16); + DoSyncL(); + + TRAPD(error,AddContactL(KTestName,KTestNumber,KUidIccGlobalAdnPhonebook)); + TESTCHECKL(error, KErrNoMemory); // TSY reports "no free slots as KErrNoMemory" + + TRAP(error,AddContactL(KTestName,KTestNumber,KUidIccGlobalSdnPhonebook)); + TESTCHECKL(error, KErrNoMemory); // TSY reports "no free slots as KErrNoMemory" + + TRAP(error,AddContactL(KTestName,KTestNumber,KUidIccGlobalLndPhonebook)); + TESTCHECKL(error, KErrNoMemory); // TSY reports "no free slots as KErrNoMemory" + + TRAP(error,AddContactL(KTestName,KTestNumber,KUidUsimAppAdnPhonebook,KTestEMail)); + TESTCHECKL(error, KErrNoMemory); // TSY reports "no free slots as KErrNoMemory" + + TRAP(error,AddContactL(KTestName,KTestNumber,KUidIccGlobalFdnPhonebook)); + TESTCHECKL(error, KErrNoMemory); // TSY reports "no free slots as KErrNoMemory" + + return TestStepResult(); + } + + +/** + * Factory construction method. + * @return Pointer to CPhbkAddBoundaryConditionsTest object + */ +CPhbkAddBoundaryConditionsTest* CPhbkAddBoundaryConditionsTest::NewL() + { + CPhbkAddBoundaryConditionsTest* self = new(ELeave) CPhbkAddBoundaryConditionsTest(); + return self; + } + +/** + * Default constructor. Each test step initialises it's own name. + */ +CPhbkAddBoundaryConditionsTest::CPhbkAddBoundaryConditionsTest() + { + SetTestStepName(_L("AddBoundaryConditionsTest")); + } + +/* Add an ICC entry to each of the supported phonebooks - boundary conditions met */ +enum TVerdict CPhbkAddBoundaryConditionsTest::doTestStepL() + { + SetSimTsyTestNumberL(19); + DoSyncL(); + RPhoneBookSession::TContactFieldsV1 fields; + RPhoneBookSession::TContactFieldsV1Pckg fieldsPckg(fields); + iSession.GetContactFormat(fieldsPckg); + + TInt i(0); + + TBuf16 name; + TBuf16 number; + + // Check Condition when length of fields are less than max length defined in config + name.Format(KBoundaryTestName); + number.Format(KBoundaryTestNumber); + + // value of i=2 because name field already contains 1 char + for(i=2; i name; + name.Format(KBoundaryTestName); + TBuf16 number; + number.Format(KBoundaryTestNumber); + + TInt i(0); + for(i=0; i<(fields.iNameField.iLength+10); i++) + name.Append(KBoundaryTestName); // name boundary exceeded by 10 characters + + TESTCHECKL(fields.iNameField.iCount, 1); + TESTCHECKCONDITIONL(fields.iNameField.iDisplayed); + + for(i=1; i name; + name.Format(KBoundaryTestName); + TBuf16 number; + number.Format(KBoundaryTestNumber); + + TInt i(0); + for(i=1; iICCTemplateIdL(aPhonebook); + CContactItem* iccTemplate = iDb->ReadContactLC(templateId); + CContactICCEntry* entry = CContactICCEntry::NewL(*iccTemplate); + CleanupStack::PopAndDestroy(iccTemplate); + CleanupStack::PushL(entry); + + AddTextFieldL(KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN, KTestName, *entry); + AddTextFieldL(KUidContactFieldPhoneNumber,KUidContactFieldVCardMapTEL, KTestNumber, *entry); + AddTextFieldL(KUidContactFieldCompanyName,KUidContactFieldVCardMapUnusedN, KTestCompany, *entry); // invalid field + TContactItemId id(KNullContactId); + TRAPD(err, id=iDb->AddNewContactL(*entry)); + CleanupStack::PopAndDestroy(entry); + TESTCHECKL(id, KNullContactId); + TESTCHECKL(err, KErrNotSupported); + } + +/** + * Factory construction method. + * @return Pointer to CPhbkAddEntryNumberWithDTMFTest object + */ +CPhbkAddEntryNumberWithDTMFTest* CPhbkAddEntryNumberWithDTMFTest::NewL() + { + CPhbkAddEntryNumberWithDTMFTest* self = new(ELeave) CPhbkAddEntryNumberWithDTMFTest(); + return self; + } + +/** + * Default constructor. Each test step initialises it's own name. + */ +CPhbkAddEntryNumberWithDTMFTest::CPhbkAddEntryNumberWithDTMFTest() + { + SetTestStepName(_L("AddEntryNumberWithDTMFTest")); + } + +/* Add sequence of ICC entries - Fill ICC */ +enum TVerdict CPhbkAddEntryNumberWithDTMFTest::doTestStepL() + { + SetSimTsyTestNumberL(19); + DoSyncL(); + TRAPD(err,AddContactL(KTestName,KTestNumberWithDTMF,KUidIccGlobalAdnPhonebook)); + TESTCHECKL(err, KErrNone); + TRAP(err,AddContactL(KTestName,KTestNumberWithDTMF,KUidIccGlobalSdnPhonebook)); + TESTCHECKL(err, KErrNone); + TRAP(err,AddContactL(KTestName,KTestNumberWithDTMF,KUidIccGlobalLndPhonebook)); + TESTCHECKL(err, KErrNone); + TRAP(err,AddContactL(KTestName,KTestNumberWithDTMF,KUidUsimAppAdnPhonebook,KTestEMail)); + TESTCHECKL(err, KErrNone); + TRAP(err,AddContactL(KTestName,KTestNumberWithDTMF,KUidIccGlobalFdnPhonebook)); + TESTCHECKL(err, KErrNone); + + return TestStepResult(); + } + + +/** + * Factory construction method. + * @return Pointer to CPhbkAddEntryReadOnlyAccessTest object + */ +CPhbkAddEntryReadOnlyAccessTest* CPhbkAddEntryReadOnlyAccessTest::NewL() + { + CPhbkAddEntryReadOnlyAccessTest* self = new(ELeave) CPhbkAddEntryReadOnlyAccessTest(); + return self; + } + +/** + * Default constructor. Each test step initialises it's own name. + */ +CPhbkAddEntryReadOnlyAccessTest::CPhbkAddEntryReadOnlyAccessTest() + { + SetTestStepName(_L("AddEntryReadOnlyAccessTest")); + } + +/* Add an ICC entry to each of the supported phonebooks - read-only phonebook */ +enum TVerdict CPhbkAddEntryReadOnlyAccessTest::doTestStepL() + { + SetSimTsyTestNumberL(20); + DoSyncL(); + TRAPD(err,AddContactL(KTestName,KTestNumber,KUidIccGlobalAdnPhonebook)); // valid fields + TESTCHECKL(err, KErrAccessDenied); // read-only access + TRAP(err,AddContactL(KTestName,KTestNumber,KUidIccGlobalSdnPhonebook)); // valid fields + TESTCHECKL(err, KErrAccessDenied); // read-only access + TRAP(err,AddContactL(KTestName,KTestNumber,KUidIccGlobalLndPhonebook)); // valid fields + TESTCHECKL(err, KErrAccessDenied); // read-only access + TRAP(err,AddContactL(KTestName,KTestNumber,KUidUsimAppAdnPhonebook,KTestEMail)); // valid fields + TESTCHECKL(err, KErrAccessDenied); // read-only access + TRAP(err,AddContactL(KTestName,KTestNumber,KUidIccGlobalFdnPhonebook)); // valid fields + TESTCHECKL(err, KErrAccessDenied); // read-only access + + return TestStepResult(); + } + + +/** + * Add a contact to the ICC & database. + * @param aName Name + * @param aNumber Phone number + * @param aPhonebook Phonebook + * @param aEMail Email address - only added to Usim phonebook + */ +void CPhbkAddIntegrationTestBase::AddContactL(const TDesC& aName, const TDesC& aNumber, const TUid aPhonebook, const TDesC& aEMail) + { + TContactItemId templateId(iDb->ICCTemplateIdL(aPhonebook)); + CContactItem* iccTemplate = iDb->ReadContactLC(templateId); + CContactICCEntry* entry = CContactICCEntry::NewL(*iccTemplate); + CleanupStack::PopAndDestroy(iccTemplate); + CleanupStack::PushL(entry); + AddTextFieldL(KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN,aName,*entry); + AddTextFieldL(KUidContactFieldPhoneNumber,KUidContactFieldVCardMapTEL,aNumber,*entry); + if ((aPhonebook == KUidUsimAppAdnPhonebook) || (aPhonebook == KUidIccGlobalAdnPhonebook)) + { + AddTextFieldL(KUidContactFieldEMail,KUidContactFieldVCardMapUnusedN,aEMail,*entry); + } + TContactItemId id(iDb->AddNewContactL(*entry)); + CleanupStack::PopAndDestroy(entry); + TESTCHECKCONDITIONL(id != KNullContactId); + } + +/** + * Add a new text field (aField) to the CContactICCEntry supplied by aIccEntry. + * @param aFieldType Field type + * @param aMapping Mapping for the field's content type + * @param aField Field data + * @param aIccEntry CContactICCEntry item + */ +void CPhbkAddIntegrationTestBase::AddTextFieldL(TFieldType aFieldType, TUid aMapping, const TDesC& aField, CContactICCEntry& aIccEntry) + { + CContactItemFieldSet& fieldSet = aIccEntry.CardFields(); + TInt pos = fieldSet.Find(aFieldType); + if (pos!=KErrNotFound) + { + CContactItemField& field=fieldSet[pos]; + field.TextStorage()->SetTextL(aField); + } + else + { + CContactItemField* field=CContactItemField::NewLC(KStorageTypeText, aFieldType); + field->SetMapping(aMapping); + field->AddFieldTypeL(aFieldType); + field->TextStorage()->SetTextL(aField); + aIccEntry.AddFieldL(*field); + CleanupStack::Pop(field); + } + } + +/** + * Factory construction method. + * @return Pointer to CPhbkAddAdditionalNumWithTagTest object + */ +CPhbkAddAdditionalNumWithTagTest* CPhbkAddAdditionalNumWithTagTest::NewL() + { + CPhbkAddAdditionalNumWithTagTest* self = new(ELeave) CPhbkAddAdditionalNumWithTagTest(); + return self; + } + +/** + * Default constructor. Each test step initialises it's own name. + */ +CPhbkAddAdditionalNumWithTagTest::CPhbkAddAdditionalNumWithTagTest() + { + SetTestStepName(_L("AddAdditionalNumWithTagTest")); + } + +/** + * Add contacts to the ICC & database with additional number plus alpha tag. + */ +enum TVerdict CPhbkAddAdditionalNumWithTagTest::doTestStepL() + { + SetSimTsyTestNumberL(22); + DoSyncL(); + + // add additional entry for each type of number alpha tag + AddAdditionalNumEntryL(KTestAddNumber, KUidContactFieldVCardMapMSG); + AddAdditionalNumEntryL(KTestAddNumber, KUidContactFieldVCardMapVOICE); + AddAdditionalNumEntryL(KTestAddNumber, KUidContactFieldVCardMapFAX); + AddAdditionalNumEntryL(KTestAddNumber, KUidContactFieldVCardMapPREF); + AddAdditionalNumEntryL(KTestAddNumber, KUidContactFieldVCardMapCELL); + AddAdditionalNumEntryL(KTestAddNumber, KUidContactFieldVCardMapPAGER); + AddAdditionalNumEntryL(KTestAddNumber, KUidContactFieldVCardMapBBS); + AddAdditionalNumEntryL(KTestAddNumber, KUidContactFieldVCardMapMODEM); + AddAdditionalNumEntryL(KTestAddNumber, KUidContactFieldVCardMapCAR); + AddAdditionalNumEntryL(KTestAddNumber, KUidContactFieldVCardMapISDN); + AddAdditionalNumEntryL(KTestAddNumber, KUidContactFieldVCardMapVIDEO); + + return TestStepResult(); + } + + +/** + * Add a contact with additional number plus alpha tag. + */ +void CPhbkAddIntegrationTestBase::AddAdditionalNumEntryL(const TDesC& aFieldNum, const TUid aFieldType) + { + TContactItemId templateId(iDb->ICCTemplateIdL(KUidUsimAppAdnPhonebook)); + CContactItem* iccTemplate = iDb->ReadContactLC(templateId); + CContactICCEntry* entry = CContactICCEntry::NewL(*iccTemplate); + CleanupStack::PopAndDestroy(iccTemplate); + CleanupStack::PushL(entry); + + // create typical USIM App entry + AddTextFieldL(KUidContactFieldFamilyName, KUidContactFieldVCardMapUnusedN, KTestName, *entry); + AddTextFieldL(KUidContactFieldPhoneNumber, KUidContactFieldVCardMapTEL, KTestNumber, *entry); + AddTextFieldL(KUidContactFieldEMail, KUidContactFieldVCardMapUnusedN, KTestEMail, *entry); + + // add additional number with alpha tag + CContactItemField* field=CContactItemField::NewLC(KStorageTypeText, KUidContactFieldPhoneNumber); + field->SetMapping(KUidContactFieldVCardMapTEL); + field->AddFieldTypeL(KUidContactFieldPhoneNumber); + field->TextStorage()->SetTextL(aFieldNum); + field->AddFieldTypeL(aFieldType); + entry->AddFieldL(*field); + CleanupStack::Pop(field); + + TContactItemId id(iDb->AddNewContactL(*entry)); + CleanupStack::PopAndDestroy(entry); + TESTCHECKCONDITIONL(id != KNullContactId); + + // check additional entry has the additional number + CContactItem* newEntry = static_cast (iDb->ReadContactLC(id)); + TESTCHECKCONDITIONL(newEntry != NULL); + CContactItemFieldSet& fieldSet = newEntry->CardFields(); + TInt pos = fieldSet.Find(aFieldType); + TESTCHECKCONDITIONL(pos != KErrNotFound); + CleanupStack::PopAndDestroy(newEntry); + + } + + +/** + * Factory construction method. + * @return Pointer to CPhbkAddEntryWithNoTemplateTest object + */ +CPhbkAddEntryWithNoTemplateTest* CPhbkAddEntryWithNoTemplateTest::NewL() + { + CPhbkAddEntryWithNoTemplateTest* self = new(ELeave) CPhbkAddEntryWithNoTemplateTest(); + return self; + } + +/** + * Default constructor. Each test step initialises its own name. + */ +CPhbkAddEntryWithNoTemplateTest::CPhbkAddEntryWithNoTemplateTest() + { + SetTestStepName(_L("AddEntryWithNoTemplateTest")); + } + +/** + * Create contact group with zero as template ID, and add a contact to it. + */ +enum TVerdict CPhbkAddEntryWithNoTemplateTest::doTestStepL() + { + + // + // delete ini file + // + + INFO_PRINTF1(_L("Deleting phonefile")); + _LIT(KPhbkSyncIniFile,"C:\\Private\\102030A1\\Phbksync.ini"); + RFs fs; + TInt err = fs.Connect(); + TESTCHECKL(err, KErrNone); + err=fs.Delete(KPhbkSyncIniFile); + fs.Close(); + + // + // add a new contact to a group with template id zero + // + CContactItem* group = iDb->CreateContactGroupLC(); + group->SetTemplateRefId(0); + + CContactICCEntry* contact = NULL; + CreateContactLC(contact, KUidIccGlobalAdnPhonebook,KTestName,KTestNumber, KTestEMail); + + iDb->AddContactToGroupL(*contact,*group); + + CleanupStack::PopAndDestroy(2,group); + + // + // force a creation of the phonebooks (including a call to CSyncEngineServer::CreateGroupIdL) + // + ConfigurePhbkSyncToIdleL(); + ConfigurePhbkSyncToFullL(); + + return TestStepResult(); +} + +void CPhbkAddIntegrationTestBase::CreateContactLC(CContactICCEntry*& aEntry, const TUid aPhonebook, const TDesC& aName, const TDesC& aNumber, const TDesC& aEmail) + { + TContactItemId templateId(iDb->ICCTemplateIdL(aPhonebook)); + CContactItem* iccTemplate = iDb->ReadContactLC(templateId); + aEntry = CContactICCEntry::NewL(*iccTemplate); + CleanupStack::PopAndDestroy(iccTemplate); + CleanupStack::PushL(aEntry); + + AddTextFieldL(KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN,aName,*aEntry); + AddTextFieldL(KUidContactFieldPhoneNumber,KUidContactFieldVCardMapTEL,aNumber,*aEntry); + if ((aPhonebook == KUidUsimAppAdnPhonebook) || (aPhonebook == KUidIccGlobalAdnPhonebook)) + { + AddTextFieldL(KUidContactFieldEMail,KUidContactFieldVCardMapUnusedN,aEmail,*aEntry); + } + }