phonebookengines/contactsmodel/tsrc/Integration/CntPerfTest/inc/ContactViewsThread.h
changeset 0 e686773b3f54
child 24 0ba2181d7c28
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /**
       
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __CONTACTVIEWS_THREAD_H__
       
    21 #define __CONTACTVIEWS_THREAD_H__
       
    22 
       
    23 // System Includes
       
    24 #include <test/testexecutestepbase.h>
       
    25 #include <cntdb.h>
       
    26 #include <cntitem.h>
       
    27 #include <cntviewbase.h>
       
    28 #include <cntfldst.h>
       
    29 #include <cntfilt.h>
       
    30 #include <e32math.h>
       
    31 
       
    32 // User Includes
       
    33 #include "ContactUtilitiesCollection.h"
       
    34 #include "ClientServer.h"
       
    35 #include "TestContactViewDatabaseUtilitiesStep.h"
       
    36 
       
    37 // Literals used
       
    38 _LIT(KChunkName, 	 "ContactViewsChunk");
       
    39 _LIT(KSemaphoreName, "ContactViewsSemaphore");
       
    40 
       
    41 // Global Methods
       
    42 GLDEF_C TInt RunContactViewsThreadL(TAny* aArgs);
       
    43 
       
    44 /**
       
    45  * This class facilitates construction of contact view validation objects, used for verifying the
       
    46  * behaviour of contact views when CRUD operations are performed on the contacts database. Basically
       
    47  * information regarding different contact CRUD Operations performed and expected view behaviour in terms of
       
    48  * view count, view notifications are specified in the ini file. These details are validated against
       
    49  * actual results.
       
    50  */
       
    51 class TContactViewValidationData
       
    52 	{
       
    53 	public:
       
    54 
       
    55 		enum TContactViewNotificationType
       
    56 			{
       
    57  			EUnAvailableNotifications,
       
    58 			EViewReadyNotifications,
       
    59 			EViewSortOrderChangedNotifications,
       
    60 			EViewSortErrorNotifications,
       
    61 			EContactServerErrorNotifications,
       
    62 			EViewIndexingErrorNotifications,
       
    63 			EItemAddedNotifications,
       
    64 			EItemRemovedNotifications,
       
    65 			EGroupChangedNotifications,
       
    66 			};
       
    67 
       
    68 		enum TContactViewCurrentOperation
       
    69 			{
       
    70 			EViewConstructionOperations,
       
    71 			EAddContactOperations,
       
    72 			ERemoveContactsOperations,
       
    73 			EUpdateContactOperations,
       
    74 			ESortOrderChangeOperations,
       
    75 			EServerRelatedOperations,
       
    76 			EGroupChangedOperations,
       
    77 			ENone,
       
    78 			};
       
    79 
       
    80 		TContactViewValidationData();
       
    81 
       
    82 		// Increment view notification functions are useful while incrementing the
       
    83 		// TContactViewNotificationGroup member varibales i.e TContactViewNotificationGroup object
       
    84 		// the member variables as and when notifications are recieved by the view observers
       
    85 		void IncrementNotificationCount(TContactViewNotificationType aContactViewNotificationType);
       
    86 
       
    87 		// Get View Notification functions are useful while comparing the notifications received against expected
       
    88 		// notification information specified in the ini file
       
    89 		TInt NotificationsCount(TContactViewNotificationType aContactViewNotificationType);
       
    90 
       
    91 		// Set View Notification functions are useful while updating TContactViewNotificationGroup objects
       
    92 		// with data read from the ini file
       
    93 		void SetNotificationsCount(TContactViewNotificationType aContactViewNotificationType,
       
    94 																 TInt aNumOfExpectedNotifications);																
       
    95 		void NotificationType (TContactViewEvent aEvent,
       
    96 										 TContactViewValidationData::TContactViewNotificationType& aNotificationType);																
       
    97 		void SetCurrentOperation(const TPtrC& aCurrentOperation);
       
    98 		void SetCurrentOperation(TContactViewValidationData::TContactViewCurrentOperation aCurrentOperation);				
       
    99 		TDesC& TContactViewValidationData::CurrentOperationInfoInStringFormatL();
       
   100 		TContactViewValidationData::TContactViewCurrentOperation CurrentOperation();				
       
   101 		void ConvertStringToTContactViewValidationDataFormat(const TPtrC& aCurrentOperation);		
       
   102 		void SetViewCount(TInt aViewCount);
       
   103 		TInt ViewCount();
       
   104 
       
   105 		
       
   106 
       
   107 	private:
       
   108 		TInt iViewCount;
       
   109  		TInt iNumOfUnAvailableNotifications;
       
   110  		TInt iNumOfReadyNotifications;
       
   111  		TInt iNumOfSortOrderChangedNotifications;
       
   112  		TInt iNumOfSortErrorNotifications;
       
   113  		TInt iNumOfServerErrorNotifications;
       
   114  		TInt iNumOfIndexingErrorNotifications;
       
   115  		TInt iNumOfItemAddedNotifications;
       
   116  		TInt iNumOfItemRemovedNotifications;
       
   117  		TInt iNumOfGroupChangedNotifications;
       
   118 		TContactViewValidationData::TContactViewCurrentOperation iCurrentOperation;
       
   119 		TBuf<256>  	iCurrentOperationInStringFormat;		
       
   120 
       
   121 	};
       
   122 
       
   123 
       
   124 /**
       
   125  * This class facilitates construction of desired contact views based on the ini data. Listen for contact view
       
   126  * notifications, validate the contact view count at the end of each CRUD Operation. 
       
   127  */
       
   128 class CContactViews : public CBase
       
   129 	{
       
   130 	public:
       
   131 		static 		CContactViews*  NewL(CTestStep& aTestStep);
       
   132 		void 		RunTestL();
       
   133 					~CContactViews();
       
   134 
       
   135 	private:
       
   136 		CContactViews(CTestStep& aTestStep);
       
   137 		void 		ConstructL();		
       
   138 		void 		InstallActiveSchedularL();
       
   139 		void 		UnInstallActiveSchedularL();
       
   140 		void 		OpenDatabaseL();
       
   141 		void 		CloseDatabaseL();
       
   142 		void 		SetupChunk();
       
   143 		void 		SetCurrentOperation(TContactViewValidationData& aValidationData);		
       
   144 		void 		ReadDataFromIniAndConstructValidationObjectsL();
       
   145 		void 		IterateThroValidationSectionAndUpdateValidationData(const TPtrC& aValidationSection, TContactViewValidationData& aValidationData);
       
   146 		void 		ConstructViewsL();		
       
   147 		void 		SetViewOfInterest();
       
   148  		void		ListenForContactViewEvents(CContactViewEventQueue& aViewObserver, TContactViewValidationData& aActualData);
       
   149 		void 		UpdateActualNotificationCollectionObjectL (TContactViewEvent aEvent, TContactViewValidationData& aActualData);
       
   150 		TBool 		Compare(TContactViewValidationData& aDesiredData, TContactViewValidationData& aActualData);
       
   151 		TPtrC& 		SemaphoreName();
       
   152 		CTestStep&  TestStepReference();
       
   153 		TBool 		ExecutionCompleted();
       
   154 		void 		PrintDetailsL(TContactViewValidationData& aDesiredData, TContactViewValidationData& aActualData);		
       
   155 		CContactDatabase& DatabaseReference();
       
   156 		CContactViewCollection& ViewCollectionReference();
       
   157 		CContactViewEventQueue& RetrieveDesiredViewObserverL();
       
   158 		TContactViewValidationData RetrieveValidationData(TContactViewValidationData::TContactViewCurrentOperation aCurrentOperation);		
       
   159 			
       
   160 	private:
       
   161 		CTestStep& 													iTestStep;
       
   162 		TBool*														iExecutionCompleted;
       
   163 		CContactUtilitiesCollection*								iContactUtility;
       
   164 		CContactDatabase* 											iDb;
       
   165 		CContactViewCollection* 									iContactViewCollection;
       
   166 		CActiveScheduler* 											iScheduler;
       
   167 		CContactViewBase* 											iContactView;
       
   168 		RSemaphore													iSemaphore;
       
   169 		RArray<TContactViewValidationData> 							iExpectedData;
       
   170 		RArray<TContactViewValidationData> 							iActualData;
       
   171 		RChunk														iChunk;		
       
   172 		TPtrC*														iCurrentOperation;
       
   173 	};
       
   174 	
       
   175 #endif