/**
 * Deletes the specified number of contact cards from the database
 */
void CTestContactViewCRUDOperationsStep::DeleteContactCardsL()
	{
	_LIT(KNumOfContactsToBeDeleted, "NumOfContactsToBeDeleted");
	TInt numOfContactsToBeDeleted;
	GetIntFromConfig(ConfigSection(), KNumOfContactsToBeDeleted, numOfContactsToBeDeleted);


	TPtrC deleteContactInGroups;
	_LIT(KDeleteContactInGroups, "grouplist");
	GetStringFromConfig(ConfigSection(), KDeleteContactInGroups, deleteContactInGroups);

	if(deleteContactInGroups != KNullDesC)
		{
		DeleteContactsInGroupL(numOfContactsToBeDeleted, deleteContactInGroups);
		}
	else
		{
		CCntFilter* filter = CCntFilter::NewL();
		CleanupStack::PushL(filter);
		filter->SetContactFilterTypeCard(ETrue);
		DatabaseReference().FilterDatabaseL(*filter);

		for(TInt i = 0; i < numOfContactsToBeDeleted; ++i)
			{
			TContactItemId contactItemId = (*filter->iIds)[i];
			DatabaseReference().DeleteContactL(contactItemId);
			}

		CleanupStack::PopAndDestroy(filter);
		}
	}
示例#2
0
/**
 * Updates the specified group with details like group name, number of contacts in the group
 * @param aGroupSection - section in the ini file contains necessary details for group update
 * @param aGroup - Group to be updated
 */
void CTestContactViewDatabaseUtilitiesStep::UpdateGroupsL(const TPtrC& aGroupSection, CContactGroup& aGroup)
	{
	_LIT(KGroupName, "groupname");
	TPtrC groupName;
	GetStringFromConfig(aGroupSection, KGroupName, groupName);

	aGroup.SetGroupLabelL(groupName);

	_LIT(KNumOfContacts, "numofcontacts");
	TInt numOfContacts;
	GetIntFromConfig(aGroupSection, KNumOfContacts, numOfContacts);

	CCntFilter* filter = CCntFilter::NewL();
	CleanupStack::PushL(filter);
	filter->SetContactFilterTypeCard(ETrue);
	DatabaseReference().FilterDatabaseL(*filter);

	for(TInt i = 0; i < numOfContacts; ++i)
		{
		CContactIdArray* idArray = filter->iIds;
		TContactItemId contactItemId = (*idArray)[i];
		CContactItem* contactItem = DatabaseReference().OpenContactL(contactItemId);
		CleanupStack::PushL(contactItem);
		TRAP_IGNORE(DatabaseReference().RemoveContactFromGroupL(*contactItem, aGroup));
		TRAP_IGNORE(DatabaseReference().AddContactToGroupL(*contactItem, aGroup));
		CleanupStack::PopAndDestroy(contactItem);
		DatabaseReference().CloseContactL(contactItemId);
		}

	CleanupStack::PopAndDestroy(filter);
	}
示例#3
0
/* In this section, we edit the desired number of groups in the database
 * Set label for them and associate them with desired number of groups
 * With this database updation, group views can be constructed and accessed
 */
void CTestContactViewDatabaseUtilitiesStep::IterateThroAllGroupSectionsAndUpdateL()
	{
	_LIT(KListOfGroupsSectionsString, "listofgroupsections");
	TPtrC listOfGroupsSectionsString;
	GetStringFromConfig(ConfigSection(), KListOfGroupsSectionsString, listOfGroupsSectionsString);

	RArray<TPtrC>	listOfGroupsSections;
	CleanupClosePushL(listOfGroupsSections);
	ViewUtilityReference().TokenizeStringL(listOfGroupsSectionsString, listOfGroupsSections);

	CCntFilter* filter = CCntFilter::NewL();
	CleanupStack::PushL(filter);
	filter->SetContactFilterTypeGroup(ETrue);
	DatabaseReference().FilterDatabaseL(*filter);

	for ( TInt i = 0; i < listOfGroupsSections.Count(); ++i )
		{
		CContactIdArray* idArray = filter->iIds;
		TContactItemId groupId = (*idArray)[i];
		CContactItem* group = DatabaseReference().OpenContactL(groupId);
		CleanupStack::PushL(group);
		CContactGroup* newGroup = static_cast<CContactGroup*>(group);
		UpdateGroupsL(listOfGroupsSections[i], *newGroup);
		DatabaseReference().CommitContactL(*group);
		DatabaseReference().CloseContactL(groupId);
		CleanupStack::PopAndDestroy(group);
		}

	CleanupStack::PopAndDestroy(2, &listOfGroupsSections);
	}
/**
* New contact entries are added in the database. The newly added contacts can have fields that meet the sort order
* of some existing views, With the addition of such contact fields, the existing views needs resorting. The newly added
* fields may also meet the filter criteria of some existing views. This is useful while testing filtered views
* The new added contacts can have fields with some predefined string content, this is useful in case of Find Views and Sub Views.
*/
void CTestContactViewCRUDOperationsStep::AddContactEntriesL()
	{
	_LIT(KViewSortOrder, "SortOrder");
	TPtrC viewSortOrderString;
	GetStringFromConfig(ConfigSection(), KViewSortOrder, viewSortOrderString);

	RContactViewSortOrder sortOrder = ViewUtilityReference().ConvertStringToSortOrderL(viewSortOrderString);
	CleanupClosePushL(sortOrder);

	_LIT(KNumOfContactsToBeAdded, "NumOfContactsToBeAdded");
	TInt numOfContactsToBeAdded;
	GetIntFromConfig(ConfigSection(), KNumOfContactsToBeAdded, numOfContactsToBeAdded);


	for(TInt i = 0; i < numOfContactsToBeAdded; ++i)
		{
		CContactCard* contactCard = CContactCard::NewL();
		CleanupStack::PushL(contactCard);
		AddContactFieldL(*contactCard, sortOrder);

		TBool filterBasedFields;
		_LIT(KFilterBasedFields, "FilterBasedFields");
		GetBoolFromConfig(ConfigSection(), KFilterBasedFields, filterBasedFields);
		if(filterBasedFields)
			{
			AddFieldsSpecificToFilterL(*contactCard);
			}

		TBool contactsWithDesiredString;
		_LIT(KContactsWithDesiredString, "ContactsWithDesiredString");
		GetBoolFromConfig(ConfigSection(), KContactsWithDesiredString, contactsWithDesiredString);
		if(contactsWithDesiredString)
			{
			AddMatchingStringToContactL(*contactCard);
			}


		TContactItemId contactId = DatabaseReference().AddNewContactL(*contactCard);

		TPtrC addContactToGroup;
		_LIT(KAddContactToGroup, "grouplist");
		GetStringFromConfig(ConfigSection(), KAddContactToGroup, addContactToGroup);
		if(addContactToGroup != KNullDesC)
			{
			IterateThroAllGroupSectionsAndUpdateContactL(addContactToGroup, *contactCard);
			}

		CleanupStack::PopAndDestroy();// contactCard
		DatabaseReference().CloseContactL(contactId);
		}
	CleanupStack::PopAndDestroy(); // sortOrder
	}
/**
 * Removes contacts from the underlying view based on the data available with contact view update objects
 */ 
void CTestContactViewUnderlyingViewUpdateStep::RemoveContactsFromTheUnderLyingViewsL()
	{
	for(TInt i = 0; i < iViewUpdateArray.Count(); ++i)
		{
		TViewModificationData contactViewValidationObject = iViewUpdateArray[i];		
		CContactViewBase* contactView = ViewCollectionReference().GetDesiredView
							(contactViewValidationObject.ViewTypeInStringFormat(), contactViewValidationObject.ViewIndex());
	

		RArray<TContactItemId> contactItemIdArray;
		CleanupClosePushL(contactItemIdArray);
		
		for(TInt j = 0; j < contactViewValidationObject.NumberOfContactsToBeRemoved(); ++j)
			{
			TContactItemId contactItemId = contactView->AtL(j);
			contactItemIdArray.AppendL(contactItemId);
			}

		for(TInt j = 0; j < contactItemIdArray.Count(); ++j)
			{
			DatabaseReference().DeleteContactL(contactItemIdArray[j]);
			}
			
		CleanupStack::PopAndDestroy(&contactItemIdArray); 
		}
	}
/**
 * Second level CContactViews constructors
 * Obtains handle to the global semaphore used for synchronizations with main thread
 * Obtains handle to the Global chunk used for exchanging data across threads
 * Allocates CContactUtilitiesCollection object used for contact views operations
 * Allocates CContactViewCollection used for holding the newly constructed contact views
 */
void CContactViews::ConstructL()
	{
	iSemaphore.OpenGlobal(KSemaphoreName);
	SetupChunk();
	OpenDatabaseL();
	iContactViewCollection = CContactViewCollection::NewL();
	iContactUtility = CContactUtilitiesCollection::NewL(iTestStep, DatabaseReference(), ViewCollectionReference());
    iContactUtility->ConstructViewsL();
	ReadDataFromIniAndConstructValidationObjectsL();
    SetViewOfInterest();    
	}
示例#7
0
/* Here we are trying add blank groups in the database
 * Say some 1000 thousand groups are added to the database
 */
void CTestContactViewDatabaseUtilitiesStep::AddGroupsInDatabaseL()
	{
	_LIT(KNumOfGroups, "numofgroups");
	TInt numOfGroups = 0;
	GetIntFromConfig(ConfigSection(), KNumOfGroups, numOfGroups);

	for(TInt i = 0; i < numOfGroups; ++i)
		{
		CContactItem* contactGroup = DatabaseReference().CreateContactGroupL();
		delete contactGroup;
		}
	}
/* In this section, we edit the desired number of groups in the database
 * Set label for them and associate them with contacts
 @ param aGroupSection - Desired Group Name
 @ param aContact - Contact to be updated
 */
void CTestContactViewCRUDOperationsStep::DeleteContactsInGroupL(const TInt aNumberOfContactsToBeUpdated, const TPtrC& aGroupSection)
	{
	RArray<TPtrC>	listOfGroupsSections;
	CleanupClosePushL(listOfGroupsSections);
	ViewUtilityReference().TokenizeStringL(aGroupSection, listOfGroupsSections);

	for ( TInt i = 0; i < listOfGroupsSections.Count(); ++i )
		{
		CCntFilter* filter = CCntFilter::NewL();
		CleanupStack::PushL(filter);
		filter->SetContactFilterTypeGroup(ETrue);
		DatabaseReference().FilterDatabaseL(*filter);

		for ( TInt i = 0; i < filter->iIds->Count(); ++i )
			{
			TContactItemId groupId = (*filter->iIds)[i];
			CContactItem* group = DatabaseReference().OpenContactL(groupId);
			CContactGroup* newGroup = static_cast<CContactGroup*>(group);


			if(aGroupSection.Compare(newGroup->GetGroupLabelL())  == 0)
				{
				const CContactIdArray* listOfContacts = newGroup->ItemsContained();
				for(TInt i(0); i < aNumberOfContactsToBeUpdated; i++)
					{
					TRAP_IGNORE(DatabaseReference().DeleteContactL((*listOfContacts)[i]));
					}
				delete listOfContacts;
				DatabaseReference().CloseContactL(groupId);
				break;
				}
			DatabaseReference().CloseContactL(groupId);
			}

    	CleanupStack::PopAndDestroy(filter);
		}

	CleanupStack::PopAndDestroy(&listOfGroupsSections);
	}
/* In this section, we edit the desired number of groups in the database
 * Set label for them and associate them with contacts
 @ param aGroupSection - Desired Group Name
 @ param aContact - Contact to be updated
 */
void CTestContactViewCRUDOperationsStep::IterateThroAllGroupSectionsAndUpdateContactL(const TPtrC& aGroupSection,
																									 CContactCard& aContact)
	{
	RArray<TPtrC>	listOfGroupsSections;
	CleanupClosePushL(listOfGroupsSections);
	ViewUtilityReference().TokenizeStringL(aGroupSection, listOfGroupsSections);

	for ( TInt i = 0; i < listOfGroupsSections.Count(); ++i )
		{
		CCntFilter* filter = CCntFilter::NewL();
		CleanupStack::PushL(filter);
		filter->SetContactFilterTypeGroup(ETrue);
		DatabaseReference().FilterDatabaseL(*filter);

		for ( TInt i = 0; i < filter->iIds->Count(); ++i )
			{
			TContactItemId groupId = (*filter->iIds)[i];
			CContactItem* group = DatabaseReference().OpenContactL(groupId);
			CContactGroup* newGroup = static_cast<CContactGroup*>(group);
			if(aGroupSection.Compare(newGroup->GetGroupLabelL())  == 0)
				{
				TRAP_IGNORE(DatabaseReference().RemoveContactFromGroupL(aContact, *newGroup));
				TRAP_IGNORE(DatabaseReference().AddContactToGroupL(aContact, *newGroup));
				DatabaseReference().CommitContactL(*group);
				const CContactIdArray* listOfContacts = newGroup->ItemsContained();
				const TInt count = listOfContacts->Count();
				delete listOfContacts;
				DatabaseReference().CloseContactL(groupId);
				break;
				}
			DatabaseReference().CloseContactL(groupId);
			}

    	CleanupStack::PopAndDestroy(filter);
		}

	CleanupStack::PopAndDestroy(&listOfGroupsSections);
	}
示例#10
0
/**
 * Allocates necessary utility objects
 */
void CTestContactViewDatabaseUtilitiesStep::SetupUtilityL()
	{
	iContactViewCollection = CContactViewCollection::NewL();
	CTestStep* self = static_cast<CTestStep*>(this);
	iContactUtility = CContactUtilitiesCollection::NewL(*self, DatabaseReference(), ViewCollectionReference());
	}