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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
|
/*
* Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
* Contact: http://www.qt-project.org/legal
* 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:
* Utility Class which construct different type of views like local view, remote view,
* named remote view, find view, filtered view, group view, concatenated view and sub view.
* It is a collection of different classes like CContactViewCollection, CContactViewApiTest and
* CContactViewValidation
* CContactViewCollection - It is the collection of the arrays which contains pointers to the
* constructed views. Depending upon the requirement, the views can be retrieved.
* CContactViewApiTest - It is set of test functions which calls the View API's and return
* the value.
* CContactViewValidation - It is set of validation functions which validates the result
* returned by the functions in the CContactViewApiTest and the expected results from ini.
*
*/
#ifndef CONTACT_UTILITIES_COLLECTION_H
#define CONTACT_UTILITIES_COLLECTION_H
// User Includes
#include "cntperfserver.h"
#include "ccontactvieweventqueue.h"
#include "clientserver.h"
// System Includes
#include <e32base.h>
#include <e32cmn.h>
#include <cntview.h>
#include <cntdb.h>
#include <cntitem.h>
#include <cntviewbase.h>
#include <test/testexecutestepbase.h>
// Constant Literals
// CContactUtilitiesCollection
_LIT(KLocalView, "localview");
_LIT(KRemoteView, "remoteview");
_LIT(KNamedRemoteView, "namedremoteview");
_LIT(KFindView, "findview");
_LIT(KFilteredView, "filteredview");
_LIT(KGroupView, "groupview");
_LIT(KConcatenatedView, "concatenatedview");
_LIT(KSubView, "subview");
_LIT(KViewSortOrder, "viewsortorder");
_LIT(KViewPreferences, "viewpreferences");
_LIT(KLocalViewSortPlugin, "localviewsortplugin");
_LIT(KViewNotReady, "viewnotready");
_LIT(KAllocTestForLocalView, "alloctestforlocalview");
_LIT(KRemoteViewSortPlugin, "remoteviewsortplugin");
_LIT(KAllocTestForRemoteView, "alloctestforremoteview");
_LIT(KNamedRemoteViewName, "name");
_LIT(KNamedViewSortPlugin, "namedviewsortplugin");
_LIT(KAllocTestForNamedRemoteView, "alloctestfornamedremoteview");
_LIT(KSearchWords, "searchwords");
_LIT(KFindViewSortPlugin, "findviewsortplugin");
_LIT(KSearchType, "searchtype");
_LIT(KAllocTestForFindView, "alloctestfornamedremoteview");
_LIT(KGroupType, "grouptype");
_LIT(KGroupName, "groupname");
_LIT(KGroupId, "groupid");
_LIT(KGroupVersion, "groupviewversion");
_LIT(KAllocTestForGroupView, "alloctestforgroupview");
_LIT(KViewFilter, "viewfilter");
_LIT(KAllocTestForFilteredView, "alloctestforfilteredview");
_LIT(KLowerBoundary, "lowerboundary");
_LIT(KHigherBoundary, "higherboundary");
_LIT(KBoundary, "boundary");
_LIT(KAllocTestForSubView, "alloctestforsubview");
_LIT(KViewBase, "viewbase");
_LIT(KIndexOfViews, "indexofview");
_LIT(KComponentViews, "componentviews");
_LIT(KViewType, "viewtype");
_LIT(KAllocTest, "alloctest");
_LIT(KIndexOfView, "indexofview");
_LIT(KErrInCreateDataBase, "Error in creating database");
_LIT(KErrInOpen, "Error in opening database");
_LIT(KErrInDeleteDataBase, "Error in deleting database");
_LIT(KErrSortPlugin, "Error No Sort Plugin available");
_LIT(KContactNotFound, "No of contact found : %d");
_LIT(KErrorNone, "ErrNone");
// CContactViewCollection
_LIT(KAtLIndex, "atlindex");
_LIT(KContactAtLIndex, "contactatlindex");
_LIT(KContactItemId, "contactitemid");
_LIT(KAllFieldsIndex, "allfieldsindex");
_LIT(KFieldSeparator, "fieldseparator");
_LIT(KErrInRefineFindView, "Error while refining the find view");
// CContactViewApiTest
_LIT(KError, "The actual result is %d while the desired result is %d ");
_LIT(KDiskFull, "diskfull");
_LIT(KDiskNotReady, "disknotready");
_LIT(KNoError, "errornone");
// CContactViewValidation
_LIT(KDesiredContactItemId, "desiredcontactitemid");
_LIT(KDesiredContactId, "desiredcontactid");
_LIT(KDesiredContactType, "desiredcontacttype");
_LIT(KDesiredContactFilter, "desiredcontactfilter");
_LIT(KDesiredCount, "desiredcount");
_LIT(KDesiredIndex, "desiredindex");
_LIT(KIndex, "index");
_LIT(KErrInContactId, "Error in Contact Item id");
_LIT(KErrInContactType, "Error in Contact type");
_LIT(KErrExpectedAndRetrievedFields,"Expected and retrieved fields is %S, %S");
_LIT(KErrExpectedAndRetrievedViewPreferences,"Expected and retrieved viewpreferences is %d, %d");
_LIT(KErrExpectedAndRetrievedUid, "Expected and retrieved uid is %d, %d");
_LIT(KErrExpectedAndRetrievedCount, "Expected and retrieved count is %d, %d");
_LIT(KErrExpectedAndRetrievedIndex, "Expected and retrieved index is %d, %d");
_LIT(KErrExpectedAndRetrivedContactItemId,"Expected and retrieved Contact Item Id is %d, %d");
const TUint KFsAccessCount = 1;
const TUint KEventWaitTime = 30;
const TInt KMaxLengthString = 100;
class CContactViewCollection;
class CContactUtilitiesCollection : public CBase
{
public:
static CContactUtilitiesCollection* NewL(CTestStep& aTestStep, CContactDatabase& aDb, CContactViewCollection& aViewCollection);
~CContactUtilitiesCollection();
private:
CContactUtilitiesCollection(CTestStep& aTestStep, CContactDatabase& aDb, CContactViewCollection& aViewCollection);
public:
CTestStep& BaseTestStepReference();
CContactDatabase& DatabaseReference();
CContactViewCollection& ViewCollectionReference();
void GetDataAndConstructLocalViewL(const TDesC& aSection);
void GetDataAndConstructRemoteViewL(const TDesC& aSection);
void GetDataAndConstructNamedRemoteViewL(const TDesC& aSection);
void GetDataAndConstructFindViewL(const TDesC& aSection);
void GetDataAndConstructGroupViewL(const TDesC& aSection);
void GetDataAndConstructFilteredViewL(const TDesC& aSection);
void GetDataAndConstructSubViewL(const TDesC& aSection);
void ConstructLocalViewL(const TDesC& aSortOrder, const TDesC& aViewPreferences, const TDesC& aSortPlugin,
TBool aViewNotReady);
void ConstructRemoteViewL(const TDesC& aSortOrder, const TDesC& aViewPreferences, const TDesC& aSortPlugin,
TBool aViewNotReady);
void ConstructNamedRemoteViewL(const TDesC& aName, const TDesC& aSortOrder, const TDesC& aViewPreferences,
const TDesC& aSortPlugin, TBool aViewNotReady);
void ConstructFindViewL(const TDesC& aSearchWords, const TDesC& aSearchType,
CContactViewBase* aViewBase, TBool aViewNotReady);
void ConstructGroupViewL(const TDesC& aGroupType, const TDesC& aGroupName, const TInt& aGroupId,
CContactViewBase* aViewBase, TBool aViewNotReady, TInt& aGroupVersion);
void ConstructFilteredViewL(const TDesC& aViewFilter, CContactViewBase* aViewBase, TBool aViewNotReady);
void ConstructConcatenatedViewL(const TDesC& aSection);
void ConstructSubViewL(const TDesC& aLowerBoundary, const TDesC& aHigherBoundary, const TDesC& aBoundary,
CContactViewBase* aViewBase, TBool aViewNotReady);
void ConstructViewsL(RArray<TPtrC> aSections);
void TokenizeStringL(const TDesC& aString, RArray<TPtrC>& aList, TChar aSeparator = ',');
void DeleteDataBase(TBool aDeleteDataBase, const TDesC& aDbName);
void CreateViewUnderOOMConditionL(const TDesC& aSection, const TDesC& aViewType, const TDesC& aAllocTest );
void OOMTestForViewsL(const TDesC& aSection, const TDesC& aViewType, const TDesC& aAllocTest);
void ImportVcardContactsL(const TPtrC& aImportFileName, TBool aPbapBased);
RPointerArray<CContactViewBase>& GetComponentViewsL(const TDesC& aSection);
CContactViewBase* GetDesiredView(const TDesC& aSection);
RContactViewSortOrder ConvertStringToSortOrderL(const TDesC& aSortOrder);
TContactViewPreferences ConvertStringToContactViewPreferencesL(const TDesC& aViewPreferences);
CContactViewBase::TSearchType GetSearchType(const TDesC& aSearchType);
CContactGroupView::TGroupType GetGroupType(const TDesC& aGroupType);
CContactDatabase::TContactViewFilter GetContactViewFilterL(const TDesC& aFilter);
void ConstructViewsL();
TUid CContactUtilitiesCollection::GetContactFieldType(const TDesC& aContactFieldString);
void WaitForViewReady(CContactViewEventQueue*& aViewEventQueue);
void ImportContactsL();
private:
CTestStep& iBaseTestStep;
CContactDatabase& iDb;
CContactViewCollection& iViewCollection;
};
// CContactViewCollection
class CContactViewCollection : public CBase
{
public:
static CContactViewCollection* NewL();
~CContactViewCollection();
private:
CContactViewCollection();
public:
RPointerArray<CContactLocalView>& GetLocalViewArray();
RPointerArray<CContactRemoteView>& GetRemoteViewArray();
RPointerArray<CContactNamedRemoteView>& GetNamedRemoteViewArray();
RPointerArray<CContactFindView>& GetFindViewArray();
RPointerArray<CContactFilteredView>& GetFilteredViewArray();
RPointerArray<CContactGroupView>& GetGroupViewArray();
RPointerArray<CContactConcatenatedView>& GetConcatenatedViewArray();
RPointerArray<CContactSubView>& GetSubViewArray();
RPointerArray<CContactViewBase>& GetComponentViews();
RPointerArray<CContactViewEventQueue>& GetContactViewEventsQueueL(const TDesC& aTypeOfView);
CContactLocalView* GetDesiredLocalView(TInt indexOfView);
CContactRemoteView* GetDesiredRemoteView(TInt indexOfView);
CContactNamedRemoteView* GetDesiredNamedRemoteView(TInt indexOfView);
CContactFindView* GetDesiredFindView(TInt indexOfView);
CContactFilteredView* GetDesiredFilteredView(TInt indexOfView);
CContactGroupView* GetDesiredGroupView(TInt indexOfView);
CContactConcatenatedView* GetDesiredConcatenatedView(TInt indexOfView);
CContactSubView* GetDesiredSubView(TInt indexOfView);
CContactViewEventQueue* GetDesiredViewEventL(TInt indexOfView, const TDesC& aTypeOfView);
void CloseLocalViewAndEventQueue();
void CloseRemoteViewAndEventQueue();
void CloseNamedRemoteViewAndEventQueue();
void CloseFindViewAndEventQueue();
void CloseFilteredViewAndEventQueue();
void CloseGroupViewAndEventQueue();
void CloseConcatenatedViewAndEventQueue();
void CloseSubViewAndEventQueue();
CContactViewEventQueue& GetDesiredViewObserver(const TDesC& aTypeOfView, const TInt aViewIndex);
CContactViewBase* GetDesiredView(const TDesC& aTypeOfView, const TInt aViewIndex);
CContactViewEventQueue& RetrieveDesiredViewObserverL(CTestStep& aTestStepReference);
public:
RPointerArray<CContactLocalView> iArrayOfLocalViews;
RPointerArray<CContactRemoteView> iArrayOfRemoteViews;
RPointerArray<CContactNamedRemoteView> iArrayOfNamedRemoteViews;
RPointerArray<CContactFindView> iArrayOfFindViews;
RPointerArray<CContactFilteredView> iArrayOfFilteredViews;
RPointerArray<CContactGroupView> iArrayOfGroupViews;
RPointerArray<CContactConcatenatedView> iArrayOfConcatenatedViews;
RPointerArray<CContactSubView> iArrayOfSubViews;
RPointerArray<CContactViewBase> iArrayOfViewBase;
RPointerArray<CContactViewEventQueue> iArrayOfLocalViewEvents;
RPointerArray<CContactViewEventQueue> iArrayOfRemoteViewEvents;
RPointerArray<CContactViewEventQueue> iArrayOfNamedRemoteViewEvents;
RPointerArray<CContactViewEventQueue> iArrayOfGroupViewEvents;
RPointerArray<CContactViewEventQueue> iArrayOfFindViewEvents;
RPointerArray<CContactViewEventQueue> iArrayOfFilteredViewEvents;
RPointerArray<CContactViewEventQueue> iArrayOfConcatenatedViewEvents;
RPointerArray<CContactViewEventQueue> iArrayOfSubViewEvents;
RPointerArray<CContactViewEventQueue> iArrayViewEvents;
};
// CContactViewApiTest
class CContactViewApiTest : public CBase
{
public:
static CContactViewApiTest* CContactViewApiTest::NewL(CTestStep* aTestStep);
~CContactViewApiTest();
private:
CContactViewApiTest(CTestStep* aTestStep);
public:
CTestStep& TestStepReference();
RFs& GetFsSessionL();
TInt GetAtLApiDataFromIni(const TDesC& aSection);
TInt GetContactAtLApiDataFromIni(const TDesC& aSection);
TInt GetFindLApiDataFromIni(const TPtrC& aSection);
TInt FindL(TContactItemId aId, CContactViewBase* aView, const TDesC& aErrorCondition);
void TestChangeSortOrderL(const TDesC& aSection, CContactUtilitiesCollection* aContactUtility);
void RefineFindViewL(const TDesC& aSearchWords, CContactFindView* aView,
CContactUtilitiesCollection* aContactUtility);
void ValidateErrorCondition(TInt aErr, const TDesC& aErrorCondition);
void ValidateResult(TInt aActualResult, TInt aDesiredResult);
#ifdef _DEBUG
void SetFsErrorConditionL(const TDesC& aErrorCondition, TInt aCount = 0);
#endif
HBufC* GetAllFieldsLDataFromIniL(const TDesC& aSection, CContactViewBase* aView);
HBufC* GetAllFieldsL(TInt aIndex, const TDesC &aSeparator, CContactViewBase* aView);
CViewContact* ContactAtL(TInt aIndex, CContactViewBase* aView);
TContactItemId AtL(TInt aIndex, CContactViewBase* aView, const TDesC& aErrorCondition);
RContactViewSortOrder GetSortOrderL(CContactViewBase* aView, const TDesC& aErrorCondition);
TContactViewPreferences ContactViewPreferences(CContactViewBase* aView);
RPointerArray<CViewContact> GetContactsMatchingCriteriaL(const TDesC& aSearchWords, CContactViewBase* aView,
CContactUtilitiesCollection* aContactUtility, const TDesC& aErrorCondition);
RPointerArray<CViewContact> GetContactsMatchingPrefixL(const TDesC& aSearchWords, CContactViewBase* aView,
CContactUtilitiesCollection* aContactUtility, const TDesC& aErrorCondition);
private:
CTestStep* iTestStep;
RFs iFsSession;
};
// CContactViewValidation
class CContactViewValidation : public CBase
{
public:
CContactViewValidation(CTestStep* aTestStep);
~CContactViewValidation();
public:
CTestStep& TestStepReference();
void ValidateAtLApi(TContactItemId aContactItemId, const TDesC& aSection);
void ValidateContactAtLApi(CViewContact* aViewContact, const TDesC& aSection);
void ValidateCountL(const TDesC& aSection, TInt aCount);
void ValidateFindL(const TDesC& aSection, TInt aIndex);
void ValidateAllFieldsL(const TDesC& aSection, RArray<TPtrC> aRetrievedField, CContactViewBase* aView,
CContactViewApiTest* aViewApiTest);
void ValidateViewPreferencesL(const TDesC& aSection, TContactViewPreferences& viewPreferences,
CContactUtilitiesCollection* aContactUtility);
void ValidateSortOrderL(const TUid& aUid, const TUid& aExpectedUid);
private:
CTestStep* iTestStep;
};
#endif
|