コード例 #1
0
/**
 * 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;
	}
コード例 #2
0
ファイル: t_iccentry.cpp プロジェクト: Esclapion/qt-mobility
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();
	}