|
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 * Utility Class which construct different type of views like local view, remote view, |
|
16 * named remote view, find view, filtered view, group view, concatenated view and sub view. |
|
17 * It is a collection of different classes like CContactViewCollection, CContactViewApiTest and |
|
18 * CContactViewValidation |
|
19 * CContactViewCollection - It is the collection of the arrays which contains pointers to the |
|
20 * constructed views. Depending upon the requirement, the views can be retrieved. |
|
21 * CContactViewApiTest - It is set of test functions which calls the View API's and return |
|
22 * the value. |
|
23 * CContactViewValidation - It is set of validation functions which validates the result |
|
24 * returned by the functions in the CContactViewApiTest and the expected results from ini. |
|
25 * |
|
26 * |
|
27 */ |
|
28 |
|
29 |
|
30 |
|
31 #ifndef CONTACT_UTILITIES_COLLECTION_H |
|
32 #define CONTACT_UTILITIES_COLLECTION_H |
|
33 |
|
34 // User Includes |
|
35 #include "CntPerfServer.h" |
|
36 #include "CContactViewEventQueue.h" |
|
37 #include "ClientServer.h" |
|
38 |
|
39 // System Includes |
|
40 #include <e32base.h> |
|
41 #include <e32cmn.h> |
|
42 #include <cntview.h> |
|
43 #include <cntdb.h> |
|
44 #include <cntitem.h> |
|
45 #include <cntviewbase.h> |
|
46 #include <test/testexecutestepbase.h> |
|
47 |
|
48 // Constant Literals |
|
49 |
|
50 // CContactUtilitiesCollection |
|
51 _LIT(KLocalView, "localview"); |
|
52 _LIT(KRemoteView, "remoteview"); |
|
53 _LIT(KNamedRemoteView, "namedremoteview"); |
|
54 _LIT(KFindView, "findview"); |
|
55 _LIT(KFilteredView, "filteredview"); |
|
56 _LIT(KGroupView, "groupview"); |
|
57 _LIT(KConcatenatedView, "concatenatedview"); |
|
58 _LIT(KSubView, "subview"); |
|
59 _LIT(KViewSortOrder, "viewsortorder"); |
|
60 _LIT(KViewPreferences, "viewpreferences"); |
|
61 _LIT(KLocalViewSortPlugin, "localviewsortplugin"); |
|
62 _LIT(KViewNotReady, "viewnotready"); |
|
63 _LIT(KAllocTestForLocalView, "alloctestforlocalview"); |
|
64 _LIT(KRemoteViewSortPlugin, "remoteviewsortplugin"); |
|
65 _LIT(KAllocTestForRemoteView, "alloctestforremoteview"); |
|
66 _LIT(KNamedRemoteViewName, "name"); |
|
67 _LIT(KNamedViewSortPlugin, "namedviewsortplugin"); |
|
68 _LIT(KAllocTestForNamedRemoteView, "alloctestfornamedremoteview"); |
|
69 _LIT(KSearchWords, "searchwords"); |
|
70 _LIT(KFindViewSortPlugin, "findviewsortplugin"); |
|
71 _LIT(KSearchType, "searchtype"); |
|
72 _LIT(KAllocTestForFindView, "alloctestfornamedremoteview"); |
|
73 _LIT(KGroupType, "grouptype"); |
|
74 _LIT(KGroupName, "groupname"); |
|
75 _LIT(KGroupId, "groupid"); |
|
76 _LIT(KGroupVersion, "groupviewversion"); |
|
77 _LIT(KAllocTestForGroupView, "alloctestforgroupview"); |
|
78 _LIT(KViewFilter, "viewfilter"); |
|
79 _LIT(KAllocTestForFilteredView, "alloctestforfilteredview"); |
|
80 _LIT(KLowerBoundary, "lowerboundary"); |
|
81 _LIT(KHigherBoundary, "higherboundary"); |
|
82 _LIT(KBoundary, "boundary"); |
|
83 _LIT(KAllocTestForSubView, "alloctestforsubview"); |
|
84 _LIT(KViewBase, "viewbase"); |
|
85 _LIT(KIndexOfViews, "indexofview"); |
|
86 _LIT(KComponentViews, "componentviews"); |
|
87 _LIT(KViewType, "viewtype"); |
|
88 _LIT(KAllocTest, "alloctest"); |
|
89 _LIT(KIndexOfView, "indexofview"); |
|
90 |
|
91 _LIT(KErrInCreateDataBase, "Error in creating database"); |
|
92 _LIT(KErrInOpen, "Error in opening database"); |
|
93 _LIT(KErrInDeleteDataBase, "Error in deleting database"); |
|
94 _LIT(KErrSortPlugin, "Error No Sort Plugin available"); |
|
95 _LIT(KContactNotFound, "No of contact found : %d"); |
|
96 _LIT(KErrorNone, "ErrNone"); |
|
97 |
|
98 |
|
99 |
|
100 // CContactViewCollection |
|
101 _LIT(KAtLIndex, "atlindex"); |
|
102 _LIT(KContactAtLIndex, "contactatlindex"); |
|
103 _LIT(KContactItemId, "contactitemid"); |
|
104 _LIT(KAllFieldsIndex, "allfieldsindex"); |
|
105 _LIT(KFieldSeparator, "fieldseparator"); |
|
106 _LIT(KErrInRefineFindView, "Error while refining the find view"); |
|
107 |
|
108 // CContactViewApiTest |
|
109 _LIT(KError, "The actual result is %d while the desired result is %d "); |
|
110 _LIT(KDiskFull, "diskfull"); |
|
111 _LIT(KDiskNotReady, "disknotready"); |
|
112 _LIT(KNoError, "errornone"); |
|
113 |
|
114 // CContactViewValidation |
|
115 _LIT(KDesiredContactItemId, "desiredcontactitemid"); |
|
116 _LIT(KDesiredContactId, "desiredcontactid"); |
|
117 _LIT(KDesiredContactType, "desiredcontacttype"); |
|
118 _LIT(KDesiredContactFilter, "desiredcontactfilter"); |
|
119 _LIT(KDesiredCount, "desiredcount"); |
|
120 _LIT(KDesiredIndex, "desiredindex"); |
|
121 _LIT(KIndex, "index"); |
|
122 |
|
123 _LIT(KErrInContactId, "Error in Contact Item id"); |
|
124 _LIT(KErrInContactType, "Error in Contact type"); |
|
125 _LIT(KErrExpectedAndRetrievedFields,"Expected and retrieved fields is %S, %S"); |
|
126 _LIT(KErrExpectedAndRetrievedViewPreferences,"Expected and retrieved viewpreferences is %d, %d"); |
|
127 _LIT(KErrExpectedAndRetrievedUid, "Expected and retrieved uid is %d, %d"); |
|
128 _LIT(KErrExpectedAndRetrievedCount, "Expected and retrieved count is %d, %d"); |
|
129 _LIT(KErrExpectedAndRetrievedIndex, "Expected and retrieved index is %d, %d"); |
|
130 _LIT(KErrExpectedAndRetrivedContactItemId,"Expected and retrieved Contact Item Id is %d, %d"); |
|
131 |
|
132 |
|
133 const TUint KFsAccessCount = 1; |
|
134 const TUint KEventWaitTime = 30; |
|
135 const TInt KMaxLengthString = 100; |
|
136 |
|
137 class CContactViewCollection; |
|
138 class CContactUtilitiesCollection : public CBase |
|
139 { |
|
140 public: |
|
141 static CContactUtilitiesCollection* NewL(CTestStep& aTestStep, CContactDatabase& aDb, CContactViewCollection& aViewCollection); |
|
142 ~CContactUtilitiesCollection(); |
|
143 |
|
144 private: |
|
145 CContactUtilitiesCollection(CTestStep& aTestStep, CContactDatabase& aDb, CContactViewCollection& aViewCollection); |
|
146 |
|
147 public: |
|
148 CTestStep& BaseTestStepReference(); |
|
149 CContactDatabase& DatabaseReference(); |
|
150 CContactViewCollection& ViewCollectionReference(); |
|
151 void GetDataAndConstructLocalViewL(const TDesC& aSection); |
|
152 void GetDataAndConstructRemoteViewL(const TDesC& aSection); |
|
153 void GetDataAndConstructNamedRemoteViewL(const TDesC& aSection); |
|
154 void GetDataAndConstructFindViewL(const TDesC& aSection); |
|
155 void GetDataAndConstructGroupViewL(const TDesC& aSection); |
|
156 void GetDataAndConstructFilteredViewL(const TDesC& aSection); |
|
157 void GetDataAndConstructSubViewL(const TDesC& aSection); |
|
158 void ConstructLocalViewL(const TDesC& aSortOrder, const TDesC& aViewPreferences, const TDesC& aSortPlugin, |
|
159 TBool aViewNotReady); |
|
160 void ConstructRemoteViewL(const TDesC& aSortOrder, const TDesC& aViewPreferences, const TDesC& aSortPlugin, |
|
161 TBool aViewNotReady); |
|
162 void ConstructNamedRemoteViewL(const TDesC& aName, const TDesC& aSortOrder, const TDesC& aViewPreferences, |
|
163 const TDesC& aSortPlugin, TBool aViewNotReady); |
|
164 void ConstructFindViewL(const TDesC& aSearchWords, const TDesC& aSearchType, |
|
165 CContactViewBase* aViewBase, TBool aViewNotReady); |
|
166 void ConstructGroupViewL(const TDesC& aGroupType, const TDesC& aGroupName, const TInt& aGroupId, |
|
167 CContactViewBase* aViewBase, TBool aViewNotReady, TInt& aGroupVersion); |
|
168 void ConstructFilteredViewL(const TDesC& aViewFilter, CContactViewBase* aViewBase, TBool aViewNotReady); |
|
169 void ConstructConcatenatedViewL(const TDesC& aSection); |
|
170 void ConstructSubViewL(const TDesC& aLowerBoundary, const TDesC& aHigherBoundary, const TDesC& aBoundary, |
|
171 CContactViewBase* aViewBase, TBool aViewNotReady); |
|
172 void ConstructViewsL(RArray<TPtrC> aSections); |
|
173 void TokenizeStringL(const TDesC& aString, RArray<TPtrC>& aList, TChar aSeparator = ','); |
|
174 void DeleteDataBase(TBool aDeleteDataBase, const TDesC& aDbName); |
|
175 void CreateViewUnderOOMConditionL(const TDesC& aSection, const TDesC& aViewType, const TDesC& aAllocTest ); |
|
176 void OOMTestForViewsL(const TDesC& aSection, const TDesC& aViewType, const TDesC& aAllocTest); |
|
177 void ImportVcardContactsL(const TPtrC& aImportFileName, TBool aPbapBased); |
|
178 RPointerArray<CContactViewBase>& GetComponentViewsL(const TDesC& aSection); |
|
179 CContactViewBase* GetDesiredView(const TDesC& aSection); |
|
180 RContactViewSortOrder ConvertStringToSortOrderL(const TDesC& aSortOrder); |
|
181 TContactViewPreferences ConvertStringToContactViewPreferencesL(const TDesC& aViewPreferences); |
|
182 CContactViewBase::TSearchType GetSearchType(const TDesC& aSearchType); |
|
183 CContactGroupView::TGroupType GetGroupType(const TDesC& aGroupType); |
|
184 CContactDatabase::TContactViewFilter GetContactViewFilterL(const TDesC& aFilter); |
|
185 void ConstructViewsL(); |
|
186 TUid CContactUtilitiesCollection::GetContactFieldType(const TDesC& aContactFieldString); |
|
187 void WaitForViewReady(CContactViewEventQueue*& aViewEventQueue); |
|
188 void ImportContactsL(); |
|
189 |
|
190 |
|
191 private: |
|
192 CTestStep& iBaseTestStep; |
|
193 CContactDatabase& iDb; |
|
194 CContactViewCollection& iViewCollection; |
|
195 }; |
|
196 |
|
197 |
|
198 // CContactViewCollection |
|
199 class CContactViewCollection : public CBase |
|
200 { |
|
201 public: |
|
202 static CContactViewCollection* NewL(); |
|
203 ~CContactViewCollection(); |
|
204 |
|
205 private: |
|
206 CContactViewCollection(); |
|
207 |
|
208 public: |
|
209 RPointerArray<CContactLocalView>& GetLocalViewArray(); |
|
210 RPointerArray<CContactRemoteView>& GetRemoteViewArray(); |
|
211 RPointerArray<CContactNamedRemoteView>& GetNamedRemoteViewArray(); |
|
212 RPointerArray<CContactFindView>& GetFindViewArray(); |
|
213 RPointerArray<CContactFilteredView>& GetFilteredViewArray(); |
|
214 RPointerArray<CContactGroupView>& GetGroupViewArray(); |
|
215 RPointerArray<CContactConcatenatedView>& GetConcatenatedViewArray(); |
|
216 RPointerArray<CContactSubView>& GetSubViewArray(); |
|
217 RPointerArray<CContactViewBase>& GetComponentViews(); |
|
218 RPointerArray<CContactViewEventQueue>& GetContactViewEventsQueueL(const TDesC& aTypeOfView); |
|
219 CContactLocalView* GetDesiredLocalView(TInt indexOfView); |
|
220 CContactRemoteView* GetDesiredRemoteView(TInt indexOfView); |
|
221 CContactNamedRemoteView* GetDesiredNamedRemoteView(TInt indexOfView); |
|
222 CContactFindView* GetDesiredFindView(TInt indexOfView); |
|
223 CContactFilteredView* GetDesiredFilteredView(TInt indexOfView); |
|
224 CContactGroupView* GetDesiredGroupView(TInt indexOfView); |
|
225 CContactConcatenatedView* GetDesiredConcatenatedView(TInt indexOfView); |
|
226 CContactSubView* GetDesiredSubView(TInt indexOfView); |
|
227 CContactViewEventQueue* GetDesiredViewEventL(TInt indexOfView, const TDesC& aTypeOfView); |
|
228 void CloseLocalViewAndEventQueue(); |
|
229 void CloseRemoteViewAndEventQueue(); |
|
230 void CloseNamedRemoteViewAndEventQueue(); |
|
231 void CloseFindViewAndEventQueue(); |
|
232 void CloseFilteredViewAndEventQueue(); |
|
233 void CloseGroupViewAndEventQueue(); |
|
234 void CloseConcatenatedViewAndEventQueue(); |
|
235 void CloseSubViewAndEventQueue(); |
|
236 |
|
237 CContactViewEventQueue& GetDesiredViewObserver(const TDesC& aTypeOfView, const TInt aViewIndex); |
|
238 CContactViewBase* GetDesiredView(const TDesC& aTypeOfView, const TInt aViewIndex); |
|
239 CContactViewEventQueue& RetrieveDesiredViewObserverL(CTestStep& aTestStepReference); |
|
240 |
|
241 |
|
242 public: |
|
243 RPointerArray<CContactLocalView> iArrayOfLocalViews; |
|
244 RPointerArray<CContactRemoteView> iArrayOfRemoteViews; |
|
245 RPointerArray<CContactNamedRemoteView> iArrayOfNamedRemoteViews; |
|
246 RPointerArray<CContactFindView> iArrayOfFindViews; |
|
247 RPointerArray<CContactFilteredView> iArrayOfFilteredViews; |
|
248 RPointerArray<CContactGroupView> iArrayOfGroupViews; |
|
249 RPointerArray<CContactConcatenatedView> iArrayOfConcatenatedViews; |
|
250 RPointerArray<CContactSubView> iArrayOfSubViews; |
|
251 RPointerArray<CContactViewBase> iArrayOfViewBase; |
|
252 RPointerArray<CContactViewEventQueue> iArrayOfLocalViewEvents; |
|
253 RPointerArray<CContactViewEventQueue> iArrayOfRemoteViewEvents; |
|
254 RPointerArray<CContactViewEventQueue> iArrayOfNamedRemoteViewEvents; |
|
255 RPointerArray<CContactViewEventQueue> iArrayOfGroupViewEvents; |
|
256 RPointerArray<CContactViewEventQueue> iArrayOfFindViewEvents; |
|
257 RPointerArray<CContactViewEventQueue> iArrayOfFilteredViewEvents; |
|
258 RPointerArray<CContactViewEventQueue> iArrayOfConcatenatedViewEvents; |
|
259 RPointerArray<CContactViewEventQueue> iArrayOfSubViewEvents; |
|
260 RPointerArray<CContactViewEventQueue> iArrayViewEvents; |
|
261 |
|
262 }; |
|
263 |
|
264 |
|
265 // CContactViewApiTest |
|
266 class CContactViewApiTest : public CBase |
|
267 { |
|
268 public: |
|
269 |
|
270 static CContactViewApiTest* CContactViewApiTest::NewL(CTestStep* aTestStep); |
|
271 ~CContactViewApiTest(); |
|
272 |
|
273 private: |
|
274 CContactViewApiTest(CTestStep* aTestStep); |
|
275 |
|
276 public: |
|
277 CTestStep& TestStepReference(); |
|
278 RFs& GetFsSessionL(); |
|
279 TInt GetAtLApiDataFromIni(const TDesC& aSection); |
|
280 TInt GetContactAtLApiDataFromIni(const TDesC& aSection); |
|
281 TInt GetFindLApiDataFromIni(const TPtrC& aSection); |
|
282 TInt FindL(TContactItemId aId, CContactViewBase* aView, const TDesC& aErrorCondition); |
|
283 void TestChangeSortOrderL(const TDesC& aSection, CContactUtilitiesCollection* aContactUtility); |
|
284 void RefineFindViewL(const TDesC& aSearchWords, CContactFindView* aView, |
|
285 CContactUtilitiesCollection* aContactUtility); |
|
286 void ValidateErrorCondition(TInt aErr, const TDesC& aErrorCondition); |
|
287 void ValidateResult(TInt aActualResult, TInt aDesiredResult); |
|
288 #ifdef _DEBUG |
|
289 void SetFsErrorConditionL(const TDesC& aErrorCondition, TInt aCount = 0); |
|
290 #endif |
|
291 HBufC* GetAllFieldsLDataFromIniL(const TDesC& aSection, CContactViewBase* aView); |
|
292 HBufC* GetAllFieldsL(TInt aIndex, const TDesC &aSeparator, CContactViewBase* aView); |
|
293 CViewContact* ContactAtL(TInt aIndex, CContactViewBase* aView); |
|
294 TContactItemId AtL(TInt aIndex, CContactViewBase* aView, const TDesC& aErrorCondition); |
|
295 RContactViewSortOrder GetSortOrderL(CContactViewBase* aView, const TDesC& aErrorCondition); |
|
296 TContactViewPreferences ContactViewPreferences(CContactViewBase* aView); |
|
297 RPointerArray<CViewContact> GetContactsMatchingCriteriaL(const TDesC& aSearchWords, CContactViewBase* aView, |
|
298 CContactUtilitiesCollection* aContactUtility, const TDesC& aErrorCondition); |
|
299 RPointerArray<CViewContact> GetContactsMatchingPrefixL(const TDesC& aSearchWords, CContactViewBase* aView, |
|
300 CContactUtilitiesCollection* aContactUtility, const TDesC& aErrorCondition); |
|
301 |
|
302 private: |
|
303 CTestStep* iTestStep; |
|
304 RFs iFsSession; |
|
305 }; |
|
306 |
|
307 |
|
308 // CContactViewValidation |
|
309 class CContactViewValidation : public CBase |
|
310 { |
|
311 public: |
|
312 CContactViewValidation(CTestStep* aTestStep); |
|
313 ~CContactViewValidation(); |
|
314 |
|
315 public: |
|
316 CTestStep& TestStepReference(); |
|
317 void ValidateAtLApi(TContactItemId aContactItemId, const TDesC& aSection); |
|
318 void ValidateContactAtLApi(CViewContact* aViewContact, const TDesC& aSection); |
|
319 void ValidateCountL(const TDesC& aSection, TInt aCount); |
|
320 void ValidateFindL(const TDesC& aSection, TInt aIndex); |
|
321 void ValidateAllFieldsL(const TDesC& aSection, RArray<TPtrC> aRetrievedField, CContactViewBase* aView, |
|
322 CContactViewApiTest* aViewApiTest); |
|
323 void ValidateViewPreferencesL(const TDesC& aSection, TContactViewPreferences& viewPreferences, |
|
324 CContactUtilitiesCollection* aContactUtility); |
|
325 void ValidateSortOrderL(const TUid& aUid, const TUid& aExpectedUid); |
|
326 |
|
327 private: |
|
328 CTestStep* iTestStep; |
|
329 }; |
|
330 |
|
331 #endif |
|
332 |