/**
 * Verify that the template id returned by CContactDatabase::ICCTemplateIdL is the
 * same as that returned directly from the plugin
 * @param aDb Contact database
 */
void VerifyPhonebookTemplateIdsL(CContactDatabase& aDb)
	{
	test.Next(_L("Verify template ids"));
	syncChecker->ResetMethodCallCountsL();
	test(aDb.ICCTemplateIdL() == syncChecker->ICCTemplateIdL(KUidIccGlobalAdnPhonebook));
	test(aDb.ICCTemplateIdL(KUidIccGlobalAdnPhonebook) == syncChecker->ICCTemplateIdL(KUidIccGlobalAdnPhonebook));
	test(aDb.ICCTemplateIdL(KUidIccGlobalSdnPhonebook) == syncChecker->ICCTemplateIdL(KUidIccGlobalSdnPhonebook));
	test(aDb.ICCTemplateIdL(KUidIccGlobalLndPhonebook) == syncChecker->ICCTemplateIdL(KUidIccGlobalLndPhonebook));
	test(aDb.ICCTemplateIdL(KUidUsimAppAdnPhonebook) == syncChecker->ICCTemplateIdL(KUidUsimAppAdnPhonebook));
	test(aDb.ICCTemplateIdL(KNullUid) == KNullContactId);
	test(syncChecker->ValidateMethodCallCountL() == 6);
	}
/**
 * Create an entry based on the template for this specific phonebook, and add
 * the entry to the contact database
 * @param aDb Contact database
 * @param aPhonebookUid The phonebook uid
 * @return TContactItemId Id of the newly created icc entry
 */
TContactItemId doAddIccEntryL(CContactDatabase& aDb,TUid aPhonebookUid)
	{
	syncChecker->ResetMethodCallCountsL();
	TContactItemId templateId = aDb.ICCTemplateIdL(aPhonebookUid);
	test(syncChecker->ValidateMethodCallCountL() == 1);
	CContactItem* iccTemplate = aDb.ReadContactLC(templateId);
	CContactICCEntry* entry = CContactICCEntry::NewL(*iccTemplate);
	CleanupStack::PopAndDestroy(iccTemplate);
	CleanupStack::PushL(entry);
	// Add to the database
	CheckPhonebookField(*entry,aPhonebookUid, EFalse);
	syncChecker->ResetMethodCallCountsL();
	TContactItemId id = aDb.AddNewContactL(*entry); 
	test(syncChecker->ValidateMethodCallCountL() == 3);
	CleanupStack::PopAndDestroy(entry);
	test(id!=KNullContactId);
	// Check group membership
	syncChecker->ResetMethodCallCountsL();
	CContactICCEntry* fetchedItem = static_cast<CContactICCEntry*>(aDb.ReadContactL(id));
	test(syncChecker->ValidateMethodCallCountL() == 1);
	CleanupStack::PushL(fetchedItem);	
	const CContactIdArray* owned = fetchedItem->GroupsJoined();
	test(owned!=NULL && owned->Count() == 1);
	test((*owned)[0]==syncChecker->GroupIdL(aPhonebookUid));
	test(fetchedItem->Type() == KUidContactICCEntry);
	// Verify that the phonebook field has been set
	CheckPhonebookField(*fetchedItem,aPhonebookUid, ETrue);
	CleanupStack::PopAndDestroy(fetchedItem);	

	return id;
	}
예제 #3
0
/** 
 * Test addition to database without adding to a group
 * @param aDb Contact database
 */
void TestAddingWithoutGroupL(CContactDatabase& aDb)
	{
	TContactItemId templateId = aDb.ICCTemplateIdL(KUidIccGlobalAdnPhonebook);
	CContactItem* iccTemplate = aDb.ReadContactLC(templateId);
	CContactICCEntry* entry = CContactICCEntry::NewL(*iccTemplate);
	CleanupStack::PopAndDestroy(iccTemplate);
	CleanupStack::PushL(entry);
	SetNameL(*entry,KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN,KGivenName,EFalse);
	SetNameL(*entry,KUidContactFieldPhoneNumber,KUidContactFieldVCardMapTEL,KTelephoneNum,EFalse);

	syncChecker->ResetMethodCallCountsL();
	syncChecker->SetValidateWriteResponseL(KErrNone);
	TInt oldGroupId = syncChecker->GroupIdL(KUidIccGlobalAdnPhonebook);
	test(KErrNone == syncChecker->UpdatePhonebookGroupIdL(KUidIccGlobalAdnPhonebook, KNullContactId));
	TContactItemId id = aDb.AddNewContactL(*entry); 	
	test(syncChecker->ValidateMethodCallCountL() == 3);
	CleanupStack::PopAndDestroy(entry);

	CContactICCEntry* fetchedItem = static_cast<CContactICCEntry*>(aDb.ReadContactL(id));
	CleanupStack::PushL(fetchedItem);
	//Check group membership	
	const CContactIdArray* owned = fetchedItem->GroupsJoined();
	test(owned==NULL || owned->Count() == 0);
	CleanupStack::PopAndDestroy(fetchedItem);
		
	test(KErrNone == syncChecker->UpdatePhonebookGroupIdL(KUidIccGlobalAdnPhonebook, oldGroupId));
	}
예제 #4
0
/** 
 * Test successful addition to database.
 * @param aDb Contact database
 */
void TestSuccessfulAddL(CContactDatabase& aDb)
	{
	//Create group 
	TContactItemId groupId = CreatePhonebookGroupL(aDb);
	test(KErrNone == syncChecker->UpdatePhonebookGroupIdL(KUidIccGlobalAdnPhonebook, groupId));
	//Create item and add fields
	TContactItemId templateId = aDb.ICCTemplateIdL(KUidIccGlobalAdnPhonebook);
	CContactItem* iccTemplate = aDb.ReadContactLC(templateId);
	CContactICCEntry* entry = CContactICCEntry::NewL(*iccTemplate);
	CleanupStack::PopAndDestroy(iccTemplate);
	CleanupStack::PushL(entry);
	SetNameL(*entry,KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN,KGivenName,EFalse);
	SetNameL(*entry,KUidContactFieldPhoneNumber,KUidContactFieldVCardMapTEL,KTelephoneNum,EFalse);

	//Add to database
	syncChecker->ResetMethodCallCountsL();
	syncChecker->SetValidateWriteResponseL(KErrNone);
	syncChecker->SetValidateResponseL(MContactSynchroniser::ERead,KErrNone);

	test(syncChecker->ValidateMethodCallCountL() == 0);
	TContactItemId id = aDb.AddNewContactL(*entry); 
	CleanupStack::PopAndDestroy(entry);	
	test(syncChecker->ValidateMethodCallCountL() == 3);
	test(id!=KNullContactId);

	CContactICCEntry* fetchedItem = static_cast<CContactICCEntry*>(aDb.ReadContactL(id));
	CleanupStack::PushL(fetchedItem);
	//Check group membership	
	const CContactIdArray* owned = fetchedItem->GroupsJoined();
	test(owned!=NULL && owned->Count() == 1);
	test((*owned)[0]==groupId);
	
	//Check number of fields and content
	
	CContactItemFieldSet& fieldset = fetchedItem->CardFields();
	TInt pos = fieldset.Find(KUidContactFieldTemplateLabel);
	test(pos==KErrNotFound);
	
//	test(fieldset.Count() == 3); 
	
/*	for (TInt i=0; i<fieldset.Count(); i++)
		{
		CContactItemField& field = fieldset[i];
		TInt count = field.ContentType().FieldTypeCount();
		for (TInt j=0; j<count; j++)
			{
			TFieldType ft= field.ContentType().FieldType(j);
			}


		TUid mapping = field.ContentType().Mapping();
		}
*/	
	CheckFieldContentL(fieldset,KUidContactFieldFamilyName,KGivenName);
//	CheckFieldContentL(fieldset,KUidContactFieldPhoneNumber,KTelephoneNum);

	CleanupStack::PopAndDestroy(fetchedItem);
	}
예제 #5
0
/** 
 * Test an unsuccessful addition to the database
 * @param aDb Contact database
 */
void TestUnsuccessfulAddL(CContactDatabase& aDb)
	{
	TContactItemId templateId = aDb.ICCTemplateIdL(KUidIccGlobalAdnPhonebook);
	CContactItem* iccTemplate = aDb.ReadContactLC(templateId);
	CContactICCEntry* entry = CContactICCEntry::NewL(*iccTemplate);
	CleanupStack::PopAndDestroy(iccTemplate);
	CleanupStack::PushL(entry);
	SetNameL(*entry,KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN,KGivenName,EFalse);
	SetNameL(*entry,KUidContactFieldPhoneNumber,KUidContactFieldVCardMapTEL,KTelephoneNum,EFalse);

	syncChecker->ResetMethodCallCountsL();
	syncChecker->SetValidateWriteResponseL(KErrAccessDenied);
	TRAPD(error, aDb.AddNewContactL(*entry)); 	
	test(error==KErrAccessDenied);
	test(syncChecker->ValidateMethodCallCountL() == 1);
	CleanupStack::PopAndDestroy(entry);
	}
예제 #6
0
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();
	}
예제 #7
0
/** 
 * Create example ICC Entry 
 * @param aDb Contact database
 */
TContactItemId CreateTestICCEntryL(CContactDatabase& aDb)
	{
	TContactItemId templateId = aDb.ICCTemplateIdL(KUidIccGlobalAdnPhonebook);
	CContactItem* iccTemplate = aDb.ReadContactLC(templateId);
	CContactICCEntry* entry = CContactICCEntry::NewL(*iccTemplate);
	CleanupStack::PopAndDestroy(iccTemplate);
	CleanupStack::PushL(entry);
	SetNameL(*entry,KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN,KGivenName,EFalse);
	SetNameL(*entry,KUidContactFieldPhoneNumber,KUidContactFieldVCardMapTEL,KTelephoneNum,EFalse);

	//Add to database
	syncChecker->SetValidateWriteResponseL(KErrNone);
	syncChecker->SetValidateResponseL(MContactSynchroniser::ERead,KErrNone);
	syncChecker->SetDeleteContactResponseL(KErrNone);

	TContactItemId id = aDb.AddNewContactL(*entry); 

	CleanupStack::PopAndDestroy(entry);	
	test(id!=KNullContactId);
	return id;
	}