/**
 * 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();    
	}
예제 #3
0
/**
 * Retrieves the desired contact view observer and listens for contact view notifications
 * @param aEvent - A TContactViewEvent object that will be updated with the notification received
 * @return TBool - An indication whether notification was received or not
 */
TBool CTestContactViewDatabaseUtilitiesStep::ListenForViewEventsL(TContactViewEvent& aEvent)
	{
	const TInt KNotificationTimeout = 10; // ms
	TInt desiredViewIndex = 0;
	_LIT(KDesiredViewIndex, "DesiredViewIndex");
	GetIntFromConfig(ConfigSection(), KDesiredViewIndex, desiredViewIndex);

	TPtrC desiredViewType;
	_LIT(KDesiredViewType, "DesiredViewType");
	GetStringFromConfig(ConfigSection(), KDesiredViewType, desiredViewType);

	CContactViewEventQueue&	contactViewObserver =
		ViewCollectionReference().GetDesiredViewObserver(desiredViewType, desiredViewIndex);

    return (contactViewObserver.ListenForEvent(KNotificationTimeout,aEvent));
	}
/**
 * Validates the contact view count against expected data specified in the contact view validation objects
 */
void CTestContactViewUnderlyingViewUpdateStep::ValidateViewCountL()
	{
	for(TInt i = 0; i < iViewValidationArray.Count(); ++i)
		{
		TViewValidationData validationInfo =	iViewValidationArray[i];
		CContactViewBase* contactView = ViewCollectionReference().GetDesiredView(validationInfo.ViewTypeInStringFormat(), validationInfo.ViewIndex());

		if(contactView->CountL() != validationInfo.ExpectedViewCount())
			{
			_LIT(KErrContactViewMisMatch, "The contact view doesnt reflect the desired view count \n");
			ERR_PRINTF1(KErrContactViewMisMatch);
			
			_LIT(KInfoViewCountData, "The expected view count is %d while the actual view count is %d \n");
			INFO_PRINTF3(KInfoViewCountData, validationInfo.ExpectedViewCount(), contactView->CountL());
			
			SetTestStepResult(EFail);
			}
		}
	}
/**
 * Loop Function which validates the contact views after each CRUD operation is performed in the main thread
 */
void CContactViews::RunTestL()
	{
	// Suspend the current thread, will be resumed at a later stage by the main thread at the
	// end of each CRUD Operation
	iSemaphore.Signal();
	RThread().Suspend();
	

	while (!ExecutionCompleted())
		{
		TContactViewValidationData actualValidationData;
		SetCurrentOperation(actualValidationData);
		CContactViewEventQueue& desiredViewObserver = ViewCollectionReference().RetrieveDesiredViewObserverL(TestStepReference());
		ListenForContactViewEvents(desiredViewObserver, actualValidationData);
		TInt viewCount = iContactView->CountL();
		actualValidationData.SetViewCount(viewCount);		
		iActualData.AppendL(actualValidationData);
		iSemaphore.Signal();
		RThread().Suspend();
		}

	for(TInt i = 0; i < iExpectedData.Count(); ++i)
		{
		TContactViewValidationData::TContactViewCurrentOperation currentOperation = iExpectedData[i].CurrentOperation();
		TContactViewValidationData actualResult = RetrieveValidationData(currentOperation);
		TBool result = Compare(iExpectedData[i], actualResult);
		if(!result)
			{ 
			PrintDetailsL(iExpectedData[i], actualResult);									
			const TInt KNullCount = 0;
			if(actualResult.ViewCount() == KNullCount)
				{
				return;
				}
			_LIT(KValidationFailed, "The actual data doesnt match with the expected data");
			TestStepReference().ERR_PRINTF1(KValidationFailed);
			TestStepReference().SetTestStepResult(EFail);
			} 
		}
	}
예제 #6
0
/**
 * Allocates necessary utility objects
 */
void CTestContactViewDatabaseUtilitiesStep::SetupUtilityL()
	{
	iContactViewCollection = CContactViewCollection::NewL();
	CTestStep* self = static_cast<CTestStep*>(this);
	iContactUtility = CContactUtilitiesCollection::NewL(*self, DatabaseReference(), ViewCollectionReference());
	}