phonebookengines/contactsmodel/tsrc/Integration/CntPerfTest/src/ContactViewsThread.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "ContactViewsThread.h"
       
    17 
       
    18 /**
       
    19  * The Contact Views thread entry point
       
    20  * @param aArgs - Command line parameters for the contact views thread
       
    21  * @return TInt - exit reason
       
    22  */
       
    23 GLDEF_C TInt RunContactViewsThreadL(TAny* aArgs)
       
    24     {
       
    25 	TInt err;
       
    26 	CContactViews* contactViews = NULL;
       
    27 	CTrapCleanup* trapCleanup = CTrapCleanup::New();
       
    28 	CTestStep* testStep = static_cast<CTestStep*>(aArgs);
       
    29 	CActiveScheduler*	scheduler = new(ELeave) CActiveScheduler;
       
    30 
       
    31 	if (scheduler)
       
    32 		{
       
    33 		CActiveScheduler::Install(scheduler);
       
    34     	TRAP(err, contactViews = CContactViews::NewL(*testStep));
       
    35 
       
    36     	if (err == KErrNone)
       
    37 			{
       
    38 			TRAP(err, contactViews->RunTestL());
       
    39 			}
       
    40 
       
    41 		RSemaphore semaphoreStop;
       
    42 		semaphoreStop.OpenGlobal(KSemaphoreName);
       
    43 
       
    44 		delete contactViews;
       
    45 		contactViews = NULL;
       
    46 		delete scheduler;
       
    47 		scheduler = NULL;
       
    48 		delete trapCleanup;
       
    49 		trapCleanup = NULL;
       
    50 
       
    51 		semaphoreStop.Signal();
       
    52 		semaphoreStop.Close();
       
    53 		}
       
    54 
       
    55 	return err;
       
    56 	}
       
    57 
       
    58 /**
       
    59  * Class CContactViews constructor
       
    60  * @param aTestStep - Reference to current test step, used for retrieveing data from the ini file
       
    61  *                  and logging of results
       
    62  */
       
    63 CContactViews::CContactViews(CTestStep& aTestStep)
       
    64 :iTestStep(aTestStep)
       
    65 	{
       
    66 	}
       
    67 
       
    68 /**
       
    69  * Class CContactViews destructor
       
    70  */
       
    71 CContactViews::~CContactViews()
       
    72 	{
       
    73 	iExpectedData.Close();
       
    74 	iActualData.Close();
       
    75 	delete iContactViewCollection;
       
    76 	delete iContactUtility;
       
    77 	delete iDb;
       
    78 	delete iScheduler;
       
    79 	iChunk.Close();
       
    80 	iSemaphore.Close();
       
    81 	}
       
    82 
       
    83 /**
       
    84  * Allocates CContactViews object on heap
       
    85  * @param aTestStep - Test Step Reference, used for reading data from ini and logging purpose
       
    86  * @return pointer to newly constructed CContactViews object
       
    87  */
       
    88 CContactViews* CContactViews::NewL(CTestStep& aTestStep)
       
    89 	{
       
    90 	CContactViews* self = new(ELeave) CContactViews(aTestStep);
       
    91 	CleanupStack::PushL(self);
       
    92 	self->ConstructL();
       
    93 	CleanupStack::Pop(self);
       
    94 	return self;
       
    95 	}
       
    96 
       
    97 /**
       
    98  * Second level CContactViews constructors
       
    99  * Obtains handle to the global semaphore used for synchronizations with main thread
       
   100  * Obtains handle to the Global chunk used for exchanging data across threads
       
   101  * Allocates CContactUtilitiesCollection object used for contact views operations
       
   102  * Allocates CContactViewCollection used for holding the newly constructed contact views
       
   103  */
       
   104 void CContactViews::ConstructL()
       
   105 	{
       
   106 	iSemaphore.OpenGlobal(KSemaphoreName);
       
   107 	SetupChunk();
       
   108 	OpenDatabaseL();
       
   109 	iContactViewCollection = CContactViewCollection::NewL();
       
   110 	iContactUtility = CContactUtilitiesCollection::NewL(iTestStep, DatabaseReference(), ViewCollectionReference());
       
   111     iContactUtility->ConstructViewsL();
       
   112 	ReadDataFromIniAndConstructValidationObjectsL();
       
   113     SetViewOfInterest();    
       
   114 	}
       
   115 
       
   116 /**
       
   117  * Helps to obtain reference to current database handle
       
   118  * @return Reference to current database handle
       
   119  */
       
   120 CContactDatabase& CContactViews::DatabaseReference()
       
   121 	{
       
   122 	return *iDb;
       
   123 	}
       
   124 
       
   125 /**
       
   126  * Helps to obtain reference to current view collection
       
   127  * @return Reference to current view collection
       
   128  */
       
   129 CContactViewCollection& CContactViews::ViewCollectionReference()
       
   130 	{
       
   131 	return *iContactViewCollection;
       
   132 	}
       
   133 
       
   134 /**
       
   135  * Helps to obtain reference to current test step used for reading data from ini and logging the results
       
   136  * @return Reference to current view collection
       
   137  */
       
   138 
       
   139 CTestStep& CContactViews::TestStepReference()
       
   140 	{
       
   141  	return iTestStep;
       
   142 	}
       
   143 
       
   144 /**
       
   145  * Setups global chunk used for exchanging data across threads
       
   146  */
       
   147 void CContactViews::SetupChunk()
       
   148 	{
       
   149 	iChunk.OpenGlobal(KChunkName(), EFalse);
       
   150 	iExecutionCompleted = reinterpret_cast<TBool*>(iChunk.Base());
       
   151 	iCurrentOperation = sizeof(TBool) + reinterpret_cast<TPtrC*>(iChunk.Base());
       
   152 	}
       
   153 
       
   154 /**
       
   155  * Installs Active Schedular for the current thread
       
   156  */
       
   157 void CContactViews::InstallActiveSchedularL()
       
   158 	{
       
   159 	iScheduler = new (ELeave) CActiveScheduler;
       
   160 	CActiveScheduler::Install(iScheduler);
       
   161 	}
       
   162 
       
   163 
       
   164 /**
       
   165  * Opens an existing contacts database file based on the data mentioned in the ini file
       
   166  */
       
   167 void CContactViews::OpenDatabaseL()
       
   168 	{
       
   169 	TPtrC databaseFileName;
       
   170 	_LIT(KDatabaseName, "dbname");
       
   171 	TestStepReference().GetStringFromConfig(TestStepReference().ConfigSection(), KDatabaseName, databaseFileName);
       
   172 	TRAPD(err, iDb = CContactDatabase::OpenL(databaseFileName));
       
   173 	User::LeaveIfError(err);
       
   174 	}
       
   175 
       
   176 
       
   177 /**
       
   178  * Set the desired view to be validated for its content
       
   179  * There can be n number of view constructed. It is a good idea to concentrate on a specific view
       
   180  * and validate the view content at the end of each contact view operation
       
   181  */
       
   182 void CContactViews::SetViewOfInterest()
       
   183 	{
       
   184 	TInt desiredViewIndex = 0;
       
   185 	_LIT(KDesiredViewIndex, "DesiredViewIndex");
       
   186 	TestStepReference().GetIntFromConfig(TestStepReference().ConfigSection(), KDesiredViewIndex, desiredViewIndex);
       
   187 
       
   188 	TPtrC desiredViewType;
       
   189 	_LIT(KDesiredViewType, "DesiredViewType");
       
   190 	TestStepReference().GetStringFromConfig(TestStepReference().ConfigSection(), KDesiredViewType, desiredViewType);
       
   191 
       
   192 	iContactView = iContactViewCollection->GetDesiredView(desiredViewType, desiredViewIndex);	
       
   193 	}
       
   194 
       
   195 /**
       
   196  * Returns indication whether the execution is completed or not
       
   197  * @return TBool - Information whether execution is completed or not
       
   198  */
       
   199 TBool CContactViews::ExecutionCompleted()
       
   200 	{
       
   201 	return *iExecutionCompleted;
       
   202 	}
       
   203 
       
   204 /**
       
   205  * Loop Function which validates the contact views after each CRUD operation is performed in the main thread
       
   206  */
       
   207 void CContactViews::RunTestL()
       
   208 	{
       
   209 	// Suspend the current thread, will be resumed at a later stage by the main thread at the
       
   210 	// end of each CRUD Operation
       
   211 	iSemaphore.Signal();
       
   212 	RThread().Suspend();
       
   213 	
       
   214 
       
   215 	while (!ExecutionCompleted())
       
   216 		{
       
   217 		TContactViewValidationData actualValidationData;
       
   218 		SetCurrentOperation(actualValidationData);
       
   219 		CContactViewEventQueue& desiredViewObserver = ViewCollectionReference().RetrieveDesiredViewObserverL(TestStepReference());
       
   220 		ListenForContactViewEvents(desiredViewObserver, actualValidationData);
       
   221 		TInt viewCount = iContactView->CountL();
       
   222 		actualValidationData.SetViewCount(viewCount);		
       
   223 		iActualData.AppendL(actualValidationData);
       
   224 		iSemaphore.Signal();
       
   225 		RThread().Suspend();
       
   226 		}
       
   227 
       
   228 	for(TInt i = 0; i < iExpectedData.Count(); ++i)
       
   229 		{
       
   230 		TContactViewValidationData::TContactViewCurrentOperation currentOperation = iExpectedData[i].CurrentOperation();
       
   231 		TContactViewValidationData actualResult = RetrieveValidationData(currentOperation);
       
   232 		TBool result = Compare(iExpectedData[i], actualResult);
       
   233 		if(!result)
       
   234 			{ 
       
   235 			PrintDetailsL(iExpectedData[i], actualResult);									
       
   236 			const TInt KNullCount = 0;
       
   237 			if(actualResult.ViewCount() == KNullCount)
       
   238 				{
       
   239 				return;
       
   240 				}
       
   241 			_LIT(KValidationFailed, "The actual data doesnt match with the expected data");
       
   242 			TestStepReference().ERR_PRINTF1(KValidationFailed);
       
   243 			TestStepReference().SetTestStepResult(EFail);
       
   244 			} 
       
   245 		}
       
   246 	}
       
   247 
       
   248 /**
       
   249  * Initally view validation objects are constructed based on data specified in the ini file.
       
   250  * They are retrieved from the collection abd further used for validation against actual results
       
   251  * @param - aCurrentOperation Current Operation to be validated
       
   252  * @return TContactViewValidationData - Object which contains expected results for the current Operation
       
   253  */
       
   254 TContactViewValidationData CContactViews::RetrieveValidationData
       
   255 							(TContactViewValidationData::TContactViewCurrentOperation aCurrentOperation)
       
   256 	{
       
   257 	TContactViewValidationData viewValidationData;
       
   258 	for(TInt i = 0; i < iActualData.Count(); ++i)
       
   259 		{
       
   260 		TContactViewValidationData::TContactViewCurrentOperation currentOperation =	iActualData[i].CurrentOperation();
       
   261 		if(aCurrentOperation == currentOperation)
       
   262 			{
       
   263 			viewValidationData = iActualData[i];
       
   264 			}
       
   265 		}
       
   266 	return viewValidationData;
       
   267 	}
       
   268 
       
   269 /**
       
   270  * Sets the current CRUD Operation being performed in the main thread
       
   271  * @param - aValidationData on return contains information about current CRUD operation being performed in the main thread
       
   272  */
       
   273 void CContactViews::SetCurrentOperation(TContactViewValidationData& aValidationData)
       
   274 	{
       
   275 	aValidationData.SetCurrentOperation(*iCurrentOperation);
       
   276 	}
       
   277 
       
   278 /**
       
   279  * Reads data from the ini file and constructs all the view validation objects
       
   280  * and uploads them in a collection
       
   281  */
       
   282 void CContactViews::ReadDataFromIniAndConstructValidationObjectsL()
       
   283 	{
       
   284 	_LIT(KListOfValidationSectionsString, "ListOfValidationSections");
       
   285 	TPtrC listOfValidationSectionsString;
       
   286 	TestStepReference().GetStringFromConfig(TestStepReference().ConfigSection(), KListOfValidationSectionsString, listOfValidationSectionsString);
       
   287 
       
   288 	RArray<TPtrC>	listOfValidationSections;
       
   289 	CleanupClosePushL(listOfValidationSections);
       
   290 	iContactUtility->TokenizeStringL(listOfValidationSectionsString, listOfValidationSections);
       
   291 
       
   292 	for(TInt i = 0; i < listOfValidationSections.Count(); ++i)
       
   293 		{
       
   294 		TContactViewValidationData viewValidationData;
       
   295 		IterateThroValidationSectionAndUpdateValidationData(listOfValidationSections[i], viewValidationData);
       
   296 		iExpectedData.AppendL(viewValidationData);
       
   297 		}
       
   298 
       
   299 	CleanupStack::PopAndDestroy(&listOfValidationSections);
       
   300 	}
       
   301 
       
   302 /**
       
   303  * Reads a specific section in the ini file and constructs all the view validation objects
       
   304  * @param aValidationSection  desired section in the ini file
       
   305  * @param aValidationData contact view validation object to be updated
       
   306  */
       
   307 void CContactViews::IterateThroValidationSectionAndUpdateValidationData
       
   308 									(const TPtrC& aValidationSection, TContactViewValidationData& aValidationData)
       
   309 	{
       
   310 	_LIT(KUnAvailableNotifications,			"UnAvailableNotifications");
       
   311 	_LIT(KReadyNotifications,				"ReadyNotifications");
       
   312 	_LIT(KSortOrderChangedNotifications, 	"SortOrderChangedNotifications");
       
   313 	_LIT(KSortErrorNotifications,			"SortErrorNotifications");
       
   314 	_LIT(KServerErrorNotifications,			"ServerErrorNotifications");
       
   315 	_LIT(KIndexingErrorNotifications,		"IndexingErrorNotifications");
       
   316 	_LIT(KItemAddedNotifications, 			"ItemAddedNotifications");
       
   317 	_LIT(KItemRemovedNotifications,			"ItemRemovedNotifications");
       
   318 	_LIT(KGroupChangedNotifications,		"GroupChangedNotifications");
       
   319 
       
   320 
       
   321 	TInt unAvailableNotifications = 0;
       
   322 	TestStepReference().GetIntFromConfig(aValidationSection, KUnAvailableNotifications, unAvailableNotifications);
       
   323 	aValidationData.SetNotificationsCount(TContactViewValidationData::EUnAvailableNotifications, unAvailableNotifications);
       
   324 
       
   325 	TInt viewReadyNotifications = 0;
       
   326 	TestStepReference().GetIntFromConfig(aValidationSection, KReadyNotifications, viewReadyNotifications);
       
   327 	aValidationData.SetNotificationsCount(TContactViewValidationData::EViewReadyNotifications, viewReadyNotifications);
       
   328 
       
   329 	TInt sortOrderChangedNotifications = 0;
       
   330 	TestStepReference().GetIntFromConfig(aValidationSection, KSortOrderChangedNotifications, sortOrderChangedNotifications);
       
   331 	aValidationData.SetNotificationsCount(TContactViewValidationData::EViewSortOrderChangedNotifications, sortOrderChangedNotifications);
       
   332 
       
   333 	TInt sortErrorNotifications = 0;
       
   334 	TestStepReference().GetIntFromConfig(aValidationSection, KSortErrorNotifications, sortErrorNotifications);
       
   335 	aValidationData.SetNotificationsCount(TContactViewValidationData::EViewSortErrorNotifications, sortErrorNotifications);
       
   336 
       
   337 	TInt serverErrorNotifications = 0;
       
   338 	TestStepReference().GetIntFromConfig(aValidationSection, KServerErrorNotifications, serverErrorNotifications);
       
   339 	aValidationData.SetNotificationsCount(TContactViewValidationData::EContactServerErrorNotifications, serverErrorNotifications);
       
   340 
       
   341 	TInt indexingErrorNotifications = 0;
       
   342 	TestStepReference().GetIntFromConfig(aValidationSection, KIndexingErrorNotifications, indexingErrorNotifications);
       
   343 	aValidationData.SetNotificationsCount(TContactViewValidationData::EViewIndexingErrorNotifications, indexingErrorNotifications);
       
   344 
       
   345 	TInt itemAddedNotifications = 0;
       
   346 	TestStepReference().GetIntFromConfig(aValidationSection, KItemAddedNotifications, itemAddedNotifications);
       
   347 	aValidationData.SetNotificationsCount(TContactViewValidationData::EItemAddedNotifications, itemAddedNotifications);
       
   348 
       
   349 	TInt itemRemovedNotifications = 0;
       
   350 	TestStepReference().GetIntFromConfig(aValidationSection, KItemRemovedNotifications, itemRemovedNotifications);
       
   351 	aValidationData.SetNotificationsCount(TContactViewValidationData::EItemRemovedNotifications, itemRemovedNotifications);
       
   352 
       
   353 	TInt groupChangedNotifications = 0;
       
   354 	TestStepReference().GetIntFromConfig(aValidationSection, KGroupChangedNotifications, groupChangedNotifications);
       
   355 	aValidationData.SetNotificationsCount(TContactViewValidationData::EGroupChangedNotifications, groupChangedNotifications);
       
   356 
       
   357 	TPtrC currentOperationTypeString;
       
   358 	_LIT(KCurrentOperationType, "currentOperationType");
       
   359 	TestStepReference().GetStringFromConfig(aValidationSection, KCurrentOperationType, currentOperationTypeString);
       
   360 	aValidationData.SetCurrentOperation(currentOperationTypeString);
       
   361 
       
   362 	TInt viewCount = 0;
       
   363 	_LIT(KViewCount, "viewcount");
       
   364 	TestStepReference().GetIntFromConfig(aValidationSection, KViewCount, viewCount);
       
   365 	aValidationData.SetViewCount(viewCount);
       
   366 	}
       
   367 
       
   368 
       
   369 /**
       
   370  * Listen for contact view notifications and update the actual view validation information
       
   371  * @param aViewObserver  desired contact view observer
       
   372  * @param aActualData contact view validation object that will be updated with actual results
       
   373  */
       
   374 void CContactViews::ListenForContactViewEvents(CContactViewEventQueue& aViewObserver,
       
   375  														TContactViewValidationData& aActualData)
       
   376 	{
       
   377 	const TInt KViewEventTimeOut = 20; // ms
       
   378 	TContactViewEvent viewEvent;
       
   379 	while(aViewObserver.ListenForEvent(KViewEventTimeOut,viewEvent))
       
   380          {
       
   381 		 TContactViewValidationData::TContactViewNotificationType notificationType;
       
   382 		 aActualData.NotificationType(viewEvent, notificationType);
       
   383 		 aActualData.IncrementNotificationCount(notificationType);
       
   384          }
       
   385 	}
       
   386 
       
   387 /**
       
   388  * Compares the desired results against actual view update results
       
   389  * @param aDesiredData  desired view update information
       
   390  * @param aActualData actual view update information
       
   391  */
       
   392 TBool CContactViews::Compare(TContactViewValidationData& aDesiredData, TContactViewValidationData& aActualData)
       
   393 	{
       
   394 	if(((aDesiredData.NotificationsCount(TContactViewValidationData::EUnAvailableNotifications)) != (aActualData.NotificationsCount(TContactViewValidationData::EUnAvailableNotifications)))
       
   395 	|| ((aDesiredData.NotificationsCount(TContactViewValidationData::EViewReadyNotifications)) != (aActualData.NotificationsCount(TContactViewValidationData::EViewReadyNotifications)))
       
   396 	|| ((aDesiredData.NotificationsCount(TContactViewValidationData::EViewSortOrderChangedNotifications))	!= (aActualData.NotificationsCount(TContactViewValidationData::EViewSortOrderChangedNotifications)))
       
   397 	|| ((aDesiredData.NotificationsCount(TContactViewValidationData::EViewSortErrorNotifications))		!= (aActualData.NotificationsCount(TContactViewValidationData::EViewSortErrorNotifications)))
       
   398 	|| ((aDesiredData.NotificationsCount(TContactViewValidationData::EContactServerErrorNotifications))	!= (aActualData.NotificationsCount(TContactViewValidationData::EContactServerErrorNotifications)))
       
   399 	|| ((aDesiredData.NotificationsCount(TContactViewValidationData::EViewIndexingErrorNotifications))	!= (aActualData.NotificationsCount(TContactViewValidationData::EViewIndexingErrorNotifications)))
       
   400 	|| ((aDesiredData.NotificationsCount(TContactViewValidationData::EItemAddedNotifications))		!= (aActualData.NotificationsCount(TContactViewValidationData::EItemAddedNotifications)))
       
   401 	|| ((aDesiredData.NotificationsCount(TContactViewValidationData::EItemRemovedNotifications))		!= (aActualData.NotificationsCount(TContactViewValidationData::EItemRemovedNotifications)))
       
   402 	|| ((aDesiredData.NotificationsCount(TContactViewValidationData::EGroupChangedNotifications))    != (aActualData.NotificationsCount(TContactViewValidationData::EGroupChangedNotifications)))
       
   403 	||  (aDesiredData.ViewCount() != aActualData.ViewCount()))
       
   404 		{
       
   405 		return EFalse;
       
   406 		}
       
   407 	return ETrue;
       
   408 	}
       
   409 
       
   410 /**
       
   411  * Prints the desired results and actual view update results
       
   412  * @param aDesiredData  desired view update information
       
   413  * @param aActualData actual view update information
       
   414  */
       
   415 void CContactViews::PrintDetailsL(TContactViewValidationData& aDesiredData, TContactViewValidationData& aActualData)
       
   416 	{
       
   417 	_LIT(KCurrentOperation, "The current CRUD operations being performed is ::::: %S \n");
       
   418 	_LIT(KDesiredViewCount, "The desired view count %d \n");
       
   419 	_LIT(KActualViewCount, "The actual view count is %d \n");
       
   420 	_LIT(KDesiredViewUnAvailableNotifications, "The total number of desired view unavailable notifications are %d \n");
       
   421 	_LIT(KActualViewUnAvailableNotifications,  "The total number of actual view unavailable notifications are %d \n");
       
   422 	_LIT(KDesiredViewReadyNotifications, "The total number of desired view ready notifications are %d \n");
       
   423 	_LIT(KActualViewReadyNotifications,  "The total number of actual view ready notifications are %d \n");
       
   424 	_LIT(KDesiredViewSortOrderChangedNotifications, "The total number of desired view sort order changed notifications are %d \n");
       
   425 	_LIT(KActualViewSortOrderChangedNotifications,  "The total number of actual view sort order changed notifications are %d \n");
       
   426 	_LIT(KDesiredViewSortErrorNotifications, "The total number of desired View Sort ErrorNotifications are %d \n");
       
   427 	_LIT(KActualViewSortErrorNotifications, "The total number of actual View Sort Error Notifications are %d \n");
       
   428 	_LIT(KDesiredContactServerErrorNotifications, "The total number of desired Contact Server Error Notificationsare %d \n");
       
   429 	_LIT(KActualContactServerErrorNotifications, "The total number of actual Contact Server Error Notifications are %d \n");
       
   430 	_LIT(KDesiredViewIndexingErrorNotifications, "The total number of desired view indexing notifications are %d \n");
       
   431 	_LIT(KActualViewIndexingErrorNotifications, "The total number of actual view indexing notifications are %d \n");
       
   432 	_LIT(KDesiredItemAddedNotifications, "The total number of desired item added notifications are %d \n");
       
   433 	_LIT(KActualItemAddedNotifications, "The total number of actual item added notifications are %d \n");
       
   434 	_LIT(KDesiredItemRemovedNotifications, "The total number of desired item removed notifications are %d \n");
       
   435 	_LIT(KActualItemRemovedNotifications, "The total number of actual item removed notifications are %d \n");
       
   436 	_LIT(KDesiredGroupChangedNotifications, "The total number of desired group changed notifications are %d \n");
       
   437 	_LIT(KActualGroupChangedNotifications, "The total number of actual group changed notifications are %d \n");
       
   438 
       
   439 	TPtrC currentOperation(aDesiredData.CurrentOperationInfoInStringFormatL()); 
       
   440 	TestStepReference().INFO_PRINTF2(KCurrentOperation, &currentOperation);
       
   441 
       
   442 	TestStepReference().INFO_PRINTF2(KDesiredViewCount, aDesiredData.ViewCount());
       
   443 	TestStepReference().INFO_PRINTF2(KActualViewCount, aActualData.ViewCount());
       
   444 
       
   445 	TestStepReference().INFO_PRINTF2(KDesiredViewUnAvailableNotifications, aDesiredData.NotificationsCount(TContactViewValidationData::EUnAvailableNotifications));
       
   446 	TestStepReference().INFO_PRINTF2(KActualViewUnAvailableNotifications, aActualData.NotificationsCount(TContactViewValidationData::EUnAvailableNotifications));
       
   447 
       
   448 	TestStepReference().INFO_PRINTF2(KDesiredViewReadyNotifications, aDesiredData.NotificationsCount(TContactViewValidationData::EViewReadyNotifications));
       
   449 	TestStepReference().INFO_PRINTF2(KActualViewReadyNotifications, aActualData.NotificationsCount(TContactViewValidationData::EViewReadyNotifications));
       
   450 
       
   451 	TestStepReference().INFO_PRINTF2(KDesiredViewSortOrderChangedNotifications, aDesiredData.NotificationsCount(TContactViewValidationData::EViewSortOrderChangedNotifications));
       
   452 	TestStepReference().INFO_PRINTF2(KActualViewSortOrderChangedNotifications, aActualData.NotificationsCount(TContactViewValidationData::EViewSortOrderChangedNotifications));
       
   453 
       
   454 	TestStepReference().INFO_PRINTF2(KDesiredViewSortErrorNotifications, aDesiredData.NotificationsCount(TContactViewValidationData::EViewSortErrorNotifications));
       
   455 	TestStepReference().INFO_PRINTF2(KActualViewSortErrorNotifications, aActualData.NotificationsCount(TContactViewValidationData::EViewSortErrorNotifications));
       
   456 
       
   457 	TestStepReference().INFO_PRINTF2(KDesiredContactServerErrorNotifications, aDesiredData.NotificationsCount(TContactViewValidationData::EContactServerErrorNotifications));
       
   458 	TestStepReference().INFO_PRINTF2(KActualContactServerErrorNotifications, aActualData.NotificationsCount(TContactViewValidationData::EContactServerErrorNotifications));
       
   459 
       
   460 	TestStepReference().INFO_PRINTF2(KDesiredViewIndexingErrorNotifications, aDesiredData.NotificationsCount(TContactViewValidationData::EViewIndexingErrorNotifications));
       
   461 	TestStepReference().INFO_PRINTF2(KActualViewIndexingErrorNotifications, aActualData.NotificationsCount(TContactViewValidationData::EViewIndexingErrorNotifications));
       
   462 
       
   463 
       
   464 	TestStepReference().INFO_PRINTF2(KDesiredItemAddedNotifications, aDesiredData.NotificationsCount(TContactViewValidationData::EItemAddedNotifications));
       
   465 	TestStepReference().INFO_PRINTF2(KActualItemAddedNotifications, aActualData.NotificationsCount(TContactViewValidationData::EItemAddedNotifications));
       
   466 
       
   467 	TestStepReference().INFO_PRINTF2(KDesiredItemRemovedNotifications, aDesiredData.NotificationsCount(TContactViewValidationData::EItemRemovedNotifications));
       
   468 	TestStepReference().INFO_PRINTF2(KActualItemRemovedNotifications, aActualData.NotificationsCount(TContactViewValidationData::EItemRemovedNotifications));
       
   469 
       
   470 	TestStepReference().INFO_PRINTF2(KDesiredGroupChangedNotifications, aDesiredData.NotificationsCount(TContactViewValidationData::EGroupChangedNotifications));
       
   471 	TestStepReference().INFO_PRINTF2(KActualGroupChangedNotifications, aActualData.NotificationsCount(TContactViewValidationData::EGroupChangedNotifications));
       
   472 	}
       
   473 
       
   474 
       
   475 /**
       
   476  * Class TContactViewValidationData constructor
       
   477  * Initializes all member variables
       
   478  */
       
   479 TContactViewValidationData::TContactViewValidationData()
       
   480 :iViewCount(0),
       
   481  iNumOfUnAvailableNotifications(0),
       
   482  iNumOfReadyNotifications(0),
       
   483  iNumOfSortOrderChangedNotifications(0),
       
   484  iNumOfSortErrorNotifications(0),
       
   485  iNumOfServerErrorNotifications(0),
       
   486  iNumOfIndexingErrorNotifications(0),
       
   487  iNumOfItemAddedNotifications(0),
       
   488  iNumOfItemRemovedNotifications(0),
       
   489  iNumOfGroupChangedNotifications(0),
       
   490  iCurrentOperation(TContactViewValidationData::ENone)
       
   491 	{
       
   492 	}
       
   493 
       
   494 /**
       
   495  * The following set of functions belong to class TContactViewValidationData
       
   496  * Constructor is available to initialize the member variables
       
   497  * Get/Set functions are available to retrieve and update the TContactViewValidationData member
       
   498  * variables Functions are available to increment the relevant member variables
       
   499  * Necessary Conversion functions are also available
       
   500  */
       
   501 
       
   502 /**
       
   503  * Set the desired view contact item count data
       
   504  */
       
   505 void TContactViewValidationData::SetViewCount(TInt aViewCount)
       
   506 	{
       
   507 	iViewCount = aViewCount;
       
   508 	}
       
   509 
       
   510 /**
       
   511  * Get the view contact item count information
       
   512  */
       
   513 TInt TContactViewValidationData::ViewCount()
       
   514 	{
       
   515 	return iViewCount;
       
   516 	}
       
   517 
       
   518 /**
       
   519  * Set the desired contact view operation based on information available in string format
       
   520  */
       
   521 void TContactViewValidationData::SetCurrentOperation(const TPtrC& aCurrentOperation)
       
   522 	{
       
   523 	iCurrentOperationInStringFormat.Copy(aCurrentOperation);
       
   524 	ConvertStringToTContactViewValidationDataFormat(aCurrentOperation);
       
   525 	}
       
   526 
       
   527 /**
       
   528  * Get the contact view operation information in string format
       
   529  */
       
   530 TDesC& TContactViewValidationData::CurrentOperationInfoInStringFormatL()
       
   531 	{
       
   532 	return iCurrentOperationInStringFormat;
       
   533 	}
       
   534 
       
   535 /**
       
   536  * Set the desired contact view operation based on information available in TContactViewValidationData::TContactViewCurrentOperation format
       
   537  */
       
   538 void TContactViewValidationData::SetCurrentOperation(TContactViewValidationData::TContactViewCurrentOperation aCurrentOperation)
       
   539 	{
       
   540 	iCurrentOperation = aCurrentOperation;
       
   541 	}
       
   542 
       
   543 /**
       
   544  * Get the contact view operation information in TContactViewValidationData::TContactViewCurrentOperation format
       
   545  */
       
   546 TContactViewValidationData::TContactViewCurrentOperation TContactViewValidationData::CurrentOperation()
       
   547 	{
       
   548 	return iCurrentOperation;
       
   549 	}
       
   550 
       
   551 /**
       
   552  * Converts String to View Validation Internal Format
       
   553  * @param aCurrentOperation String containing information about current operation being performed
       
   554  */
       
   555 void TContactViewValidationData::ConvertStringToTContactViewValidationDataFormat(const TPtrC& aCurrentOperation)
       
   556 	{
       
   557 	_LIT(KViewConstructionOperations,	"ViewConstructionOperations");
       
   558 	_LIT(KAddContactOperations,			"AddContactOperations");
       
   559 	_LIT(KRemoveContactsOperations,		"RemoveContactsOperations");
       
   560 	_LIT(KUpdateContactOperations,		"UpdateContactOperations");
       
   561 	_LIT(KSortOrderChangeOperations,	"SortOrderChangeOperations");
       
   562 	_LIT(KServerRelatedOperations,		"ServerRelatedOperations");
       
   563 	_LIT(KGroupChangedOperations,		"GroupChangedOperations");
       
   564 
       
   565 
       
   566 	if ( aCurrentOperation.Compare(KViewConstructionOperations) == 0)
       
   567 		{
       
   568 		iCurrentOperation = TContactViewValidationData::EViewConstructionOperations;
       
   569 		}
       
   570 	else if ( aCurrentOperation.Compare(KAddContactOperations) == 0)
       
   571 		{
       
   572 		iCurrentOperation = TContactViewValidationData::EAddContactOperations;
       
   573 		}
       
   574 	else if ( aCurrentOperation.Compare(KRemoveContactsOperations) == 0)
       
   575 		{
       
   576 		iCurrentOperation = TContactViewValidationData::ERemoveContactsOperations;
       
   577 		}
       
   578 	else if ( aCurrentOperation.Compare(KUpdateContactOperations) == 0)
       
   579 		{
       
   580 		iCurrentOperation = TContactViewValidationData::EUpdateContactOperations;
       
   581 		}
       
   582 	else if ( aCurrentOperation.Compare(KSortOrderChangeOperations) == 0)
       
   583 		{
       
   584 		iCurrentOperation = TContactViewValidationData::ESortOrderChangeOperations;
       
   585 		}
       
   586 	else if ( aCurrentOperation.Compare(KServerRelatedOperations) == 0)
       
   587 		{
       
   588 		iCurrentOperation = TContactViewValidationData::EServerRelatedOperations;
       
   589 		}
       
   590 	else if ( aCurrentOperation.Compare(KGroupChangedOperations) == 0)
       
   591 		{
       
   592 		iCurrentOperation = TContactViewValidationData::EGroupChangedOperations;
       
   593 		}
       
   594 	}
       
   595 
       
   596 /**
       
   597  * Convert TContactViewEvent to TContactViewValidationData::TContactViewNotificationType format
       
   598  * @param aEvent - Contact View Event information in TContactViewEvent format
       
   599  * @param aNotificationType - Contact View Event information in TContactViewValidationData::TContactViewNotificationType format
       
   600  */
       
   601  void TContactViewValidationData::NotificationType (TContactViewEvent aEvent, TContactViewValidationData::TContactViewNotificationType& aNotificationType)
       
   602 	{
       
   603 	if(aEvent.iEventType == TContactViewEvent::EUnavailable)
       
   604 		{
       
   605 		aNotificationType = 	TContactViewValidationData::EUnAvailableNotifications;
       
   606 		}
       
   607 	else if(aEvent.iEventType ==  TContactViewEvent::EReady)
       
   608 		{
       
   609 		aNotificationType = 	TContactViewValidationData::EViewReadyNotifications;
       
   610 		}
       
   611 	else if(aEvent.iEventType ==  TContactViewEvent::ESortOrderChanged )
       
   612 		{
       
   613 		aNotificationType = 	TContactViewValidationData::EViewSortOrderChangedNotifications;
       
   614 		}
       
   615 	else if(aEvent.iEventType ==  TContactViewEvent::ESortError)
       
   616 		{
       
   617 		aNotificationType = 	TContactViewValidationData::EViewSortErrorNotifications;
       
   618 		}
       
   619 	else if(aEvent.iEventType == TContactViewEvent::EServerError )
       
   620 		{
       
   621 		aNotificationType = 	TContactViewValidationData::EContactServerErrorNotifications;
       
   622 		}
       
   623 	else if(aEvent.iEventType == TContactViewEvent::EIndexingError)
       
   624 		{
       
   625 		aNotificationType = 	TContactViewValidationData::EViewIndexingErrorNotifications;
       
   626 		}
       
   627 	else if(aEvent.iEventType == TContactViewEvent::EItemAdded)
       
   628 		{
       
   629 		aNotificationType = 	TContactViewValidationData::EItemAddedNotifications;
       
   630 		}
       
   631 	else if(aEvent.iEventType == TContactViewEvent::EItemRemoved)
       
   632 		{
       
   633 		aNotificationType = 	TContactViewValidationData::EItemRemovedNotifications;
       
   634 		}
       
   635 	else if(aEvent.iEventType == TContactViewEvent::EGroupChanged)
       
   636 		{
       
   637 		aNotificationType= 	TContactViewValidationData::EGroupChangedNotifications;
       
   638 		}
       
   639 	}
       
   640 
       
   641  /**
       
   642   * Sets the total number of expected notifications of desired type
       
   643   * @param aNotificationType - Desired type of Contact View Event Notification
       
   644   * @param aNumOfExpectedNotifications - Total number of notifications expected
       
   645   */
       
   646   void TContactViewValidationData::SetNotificationsCount( TContactViewNotificationType aNotificationType,
       
   647  																				TInt aNumOfExpectedNotifications)
       
   648  	{
       
   649  	if(aNotificationType ==	TContactViewValidationData::EUnAvailableNotifications)
       
   650  		{
       
   651  		iNumOfUnAvailableNotifications = aNumOfExpectedNotifications;
       
   652  		}
       
   653  	else if(aNotificationType ==  TContactViewValidationData::EViewReadyNotifications)
       
   654  		{
       
   655  		iNumOfReadyNotifications = aNumOfExpectedNotifications;
       
   656  		}
       
   657  	else if(aNotificationType ==  TContactViewValidationData::EViewSortOrderChangedNotifications)
       
   658  		{
       
   659  		iNumOfSortOrderChangedNotifications = aNumOfExpectedNotifications;
       
   660  		}
       
   661  	else if(aNotificationType ==  TContactViewValidationData::EContactServerErrorNotifications)
       
   662  		{
       
   663  		iNumOfServerErrorNotifications = aNumOfExpectedNotifications;
       
   664  		}
       
   665  	else if(aNotificationType == TContactViewValidationData::EViewIndexingErrorNotifications)
       
   666  		{
       
   667  		iNumOfIndexingErrorNotifications = aNumOfExpectedNotifications;
       
   668  		}
       
   669  	else if(aNotificationType == TContactViewValidationData::EItemAddedNotifications)
       
   670  		{
       
   671  		iNumOfItemAddedNotifications = aNumOfExpectedNotifications;
       
   672  		}
       
   673  	else if(aNotificationType == TContactViewValidationData::EItemRemovedNotifications)
       
   674  		{
       
   675  		iNumOfItemRemovedNotifications = aNumOfExpectedNotifications;
       
   676  		}
       
   677  	else if(aNotificationType == TContactViewValidationData::EGroupChangedNotifications)
       
   678  		{
       
   679  		iNumOfGroupChangedNotifications = aNumOfExpectedNotifications;
       
   680  		}
       
   681  	}
       
   682 
       
   683  /**
       
   684   * Retrieve the expected notifications count
       
   685   * @param aNotificationType - Desired type of Contact View Event Notification
       
   686   * @return TInt - Count of number of notifications
       
   687   */
       
   688   TInt TContactViewValidationData::NotificationsCount(TContactViewNotificationType aNotificationType)
       
   689  	{
       
   690  	TInt numOfNotifications = 0;
       
   691  	if(aNotificationType ==	TContactViewValidationData::EUnAvailableNotifications)
       
   692  		{
       
   693  		numOfNotifications = iNumOfUnAvailableNotifications;
       
   694  		}
       
   695  	else if(aNotificationType ==  TContactViewValidationData::EViewReadyNotifications)
       
   696  		{
       
   697  		numOfNotifications = iNumOfReadyNotifications;
       
   698  		}
       
   699  	else if(aNotificationType ==  TContactViewValidationData::EViewSortOrderChangedNotifications)
       
   700  		{
       
   701  		numOfNotifications = iNumOfSortOrderChangedNotifications;
       
   702  		}
       
   703  	else if(aNotificationType ==  TContactViewValidationData::EContactServerErrorNotifications)
       
   704  		{
       
   705  		numOfNotifications = iNumOfServerErrorNotifications;
       
   706  		}
       
   707  	else if(aNotificationType == TContactViewValidationData::EViewIndexingErrorNotifications)
       
   708  		{
       
   709  		numOfNotifications = iNumOfIndexingErrorNotifications;
       
   710  		}
       
   711  	else if(aNotificationType == TContactViewValidationData::EItemAddedNotifications)
       
   712  		{
       
   713  		numOfNotifications = iNumOfItemAddedNotifications;
       
   714  		}
       
   715  	else if(aNotificationType == TContactViewValidationData::EItemRemovedNotifications)
       
   716  		{
       
   717  		numOfNotifications = iNumOfItemRemovedNotifications;
       
   718  		}
       
   719  	else if(aNotificationType == TContactViewValidationData::EGroupChangedNotifications)
       
   720  		{
       
   721  		numOfNotifications = iNumOfGroupChangedNotifications;
       
   722  		}
       
   723  	return numOfNotifications;
       
   724  	}
       
   725 
       
   726 /**
       
   727  * Increment the expected notifications count
       
   728  * @param aNotificationType - Desired type of Contact View Event Notification
       
   729  */
       
   730  void TContactViewValidationData::IncrementNotificationCount
       
   731 				(TContactViewValidationData::TContactViewNotificationType aNotificationType)
       
   732 	{
       
   733 	if(aNotificationType ==	TContactViewValidationData::EUnAvailableNotifications)
       
   734 		{
       
   735 		++iNumOfUnAvailableNotifications;
       
   736 		}
       
   737 	else if(aNotificationType ==  TContactViewValidationData::EViewReadyNotifications)
       
   738 		{
       
   739 		++iNumOfReadyNotifications;
       
   740 		}
       
   741 	else if(aNotificationType ==  TContactViewValidationData::EViewSortOrderChangedNotifications)
       
   742 		{
       
   743 		++iNumOfSortOrderChangedNotifications;
       
   744 		}
       
   745 	else if(aNotificationType ==  TContactViewValidationData::EContactServerErrorNotifications)
       
   746 		{
       
   747 		++iNumOfServerErrorNotifications;
       
   748 		}
       
   749 	else if(aNotificationType == TContactViewValidationData::EViewIndexingErrorNotifications)
       
   750 		{
       
   751 		++iNumOfIndexingErrorNotifications;
       
   752 		}
       
   753 	else if(aNotificationType == TContactViewValidationData::EItemAddedNotifications)
       
   754 		{
       
   755 		++iNumOfItemAddedNotifications;
       
   756 		}
       
   757 	else if(aNotificationType == TContactViewValidationData::EItemRemovedNotifications)
       
   758 		{
       
   759 		++iNumOfItemRemovedNotifications;
       
   760 		}
       
   761 	else if(aNotificationType == TContactViewValidationData::EGroupChangedNotifications)
       
   762 		{
       
   763 		++iNumOfGroupChangedNotifications;
       
   764 		}
       
   765 	}
       
   766 
       
   767