summaryrefslogtreecommitdiffstats
path: root/plugins/contacts/symbian/contactsmodel/tsrc/integration/cntperftest/inc/contactviewsthread.h
blob: a82349e9b54860e4b58775906d2d0c35d737750d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/*
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*
*/




#ifndef __CONTACTVIEWS_THREAD_H__
#define __CONTACTVIEWS_THREAD_H__

// System Includes
#include <test/testexecutestepbase.h>
#include <cntdb.h>
#include <cntitem.h>
#include <cntviewbase.h>
#include <cntfldst.h>
#include <cntfilt.h>
#include <e32math.h>

// User Includes
#include "contactutilitiescollection.h"
#include "clientserver.h"
#include "testcontactviewdatabaseutilitiesstep.h"

// Literals used
_LIT(KChunkName, 	 "ContactViewsChunk");
_LIT(KSemaphoreName, "ContactViewsSemaphore");

// Global Methods
GLDEF_C TInt RunContactViewsThreadL(TAny* aArgs);

/**
 * This class facilitates construction of contact view validation objects, used for verifying the
 * behaviour of contact views when CRUD operations are performed on the contacts database. Basically
 * information regarding different contact CRUD Operations performed and expected view behaviour in terms of
 * view count, view notifications are specified in the ini file. These details are validated against
 * actual results.
 */
class TContactViewValidationData
	{
	public:

		enum TContactViewNotificationType
			{
 			EUnAvailableNotifications,
			EViewReadyNotifications,
			EViewSortOrderChangedNotifications,
			EViewSortErrorNotifications,
			EContactServerErrorNotifications,
			EViewIndexingErrorNotifications,
			EItemAddedNotifications,
			EItemRemovedNotifications,
			EGroupChangedNotifications,
			};

		enum TContactViewCurrentOperation
			{
			EViewConstructionOperations,
			EAddContactOperations,
			ERemoveContactsOperations,
			EUpdateContactOperations,
			ESortOrderChangeOperations,
			EServerRelatedOperations,
			EGroupChangedOperations,
			ENone,
			};

		TContactViewValidationData();

		// Increment view notification functions are useful while incrementing the
		// TContactViewNotificationGroup member varibales i.e TContactViewNotificationGroup object
		// the member variables as and when notifications are recieved by the view observers
		void IncrementNotificationCount(TContactViewNotificationType aContactViewNotificationType);

		// Get View Notification functions are useful while comparing the notifications received against expected
		// notification information specified in the ini file
		TInt NotificationsCount(TContactViewNotificationType aContactViewNotificationType);

		// Set View Notification functions are useful while updating TContactViewNotificationGroup objects
		// with data read from the ini file
		void SetNotificationsCount(TContactViewNotificationType aContactViewNotificationType,
																 TInt aNumOfExpectedNotifications);																
		void NotificationType (TContactViewEvent aEvent,
										 TContactViewValidationData::TContactViewNotificationType& aNotificationType);																
		void SetCurrentOperation(const TPtrC& aCurrentOperation);
		void SetCurrentOperation(TContactViewValidationData::TContactViewCurrentOperation aCurrentOperation);				
		TDesC& TContactViewValidationData::CurrentOperationInfoInStringFormatL();
		TContactViewValidationData::TContactViewCurrentOperation CurrentOperation();				
		void ConvertStringToTContactViewValidationDataFormat(const TPtrC& aCurrentOperation);		
		void SetViewCount(TInt aViewCount);
		TInt ViewCount();

		

	private:
		TInt iViewCount;
 		TInt iNumOfUnAvailableNotifications;
 		TInt iNumOfReadyNotifications;
 		TInt iNumOfSortOrderChangedNotifications;
 		TInt iNumOfSortErrorNotifications;
 		TInt iNumOfServerErrorNotifications;
 		TInt iNumOfIndexingErrorNotifications;
 		TInt iNumOfItemAddedNotifications;
 		TInt iNumOfItemRemovedNotifications;
 		TInt iNumOfGroupChangedNotifications;
		TContactViewValidationData::TContactViewCurrentOperation iCurrentOperation;
		TBuf<256>  	iCurrentOperationInStringFormat;		

	};


/**
 * This class facilitates construction of desired contact views based on the ini data. Listen for contact view
 * notifications, validate the contact view count at the end of each CRUD Operation. 
 */
class CContactViews : public CBase
	{
	public:
		static 		CContactViews*  NewL(CTestStep& aTestStep);
		void 		RunTestL();
					~CContactViews();

	private:
		CContactViews(CTestStep& aTestStep);
		void 		ConstructL();		
		void 		InstallActiveSchedularL();
		void 		UnInstallActiveSchedularL();
		void 		OpenDatabaseL();
		void 		CloseDatabaseL();
		void 		SetupChunk();
		void 		SetCurrentOperation(TContactViewValidationData& aValidationData);		
		void 		ReadDataFromIniAndConstructValidationObjectsL();
		void 		IterateThroValidationSectionAndUpdateValidationData(const TPtrC& aValidationSection, TContactViewValidationData& aValidationData);
		void 		ConstructViewsL();		
		void 		SetViewOfInterest();
 		void		ListenForContactViewEvents(CContactViewEventQueue& aViewObserver, TContactViewValidationData& aActualData);
		void 		UpdateActualNotificationCollectionObjectL (TContactViewEvent aEvent, TContactViewValidationData& aActualData);
		TBool 		Compare(TContactViewValidationData& aDesiredData, TContactViewValidationData& aActualData);
		TPtrC& 		SemaphoreName();
		CTestStep&  TestStepReference();
		TBool 		ExecutionCompleted();
		void 		PrintDetailsL(TContactViewValidationData& aDesiredData, TContactViewValidationData& aActualData);		
		CContactDatabase& DatabaseReference();
		CContactViewCollection& ViewCollectionReference();
		CContactViewEventQueue& RetrieveDesiredViewObserverL();
		TContactViewValidationData RetrieveValidationData(TContactViewValidationData::TContactViewCurrentOperation aCurrentOperation);		
			
	private:
		CTestStep& 													iTestStep;
		TBool*														iExecutionCompleted;
		CContactUtilitiesCollection*								iContactUtility;
		CContactDatabase* 											iDb;
		CContactViewCollection* 									iContactViewCollection;
		CActiveScheduler* 											iScheduler;
		CContactViewBase* 											iContactView;
		RSemaphore													iSemaphore;
		RArray<TContactViewValidationData> 							iExpectedData;
		RArray<TContactViewValidationData> 							iActualData;
		RChunk														iChunk;		
		TPtrC*														iCurrentOperation;
	};
	
#endif