author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:15:33 +0300 | |
branch | RCL_3 |
changeset 85 | 38bb213f60ba |
parent 74 | 6b5524b4f673 |
permissions | -rw-r--r-- |
63 | 1 |
/* |
2 |
* Copyright (c) 2007 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 |
// INCLUDE FILES |
|
19 |
#include <StifParser.h> |
|
20 |
#include <CPsQueryItem.h> |
|
21 |
#include "TestSuiteInputData.h" |
|
22 |
#include "pstestcontactshandler.h" |
|
23 |
#include "psclienttestsuitedefs.h" |
|
24 |
#include <vpbkeng.rsg> |
|
25 |
||
26 |
// ============================== MEMBER FUNCTIONS ============================ |
|
27 |
||
28 |
// ---------------------------------------------------------------------------- |
|
29 |
// Two Phase constructor |
|
30 |
// ---------------------------------------------------------------------------- |
|
31 |
CTestSuiteInputData* CTestSuiteInputData::NewL(CStifItemParser& aItem, CPSRequestHandler& aPsClientHandler) |
|
32 |
{ |
|
33 |
CTestSuiteInputData* self = new (ELeave) CTestSuiteInputData(); |
|
34 |
CleanupStack::PushL(self); |
|
35 |
self->ConstructL(aItem, aPsClientHandler); |
|
36 |
CleanupStack::Pop(); |
|
37 |
return self; |
|
38 |
} |
|
39 |
||
40 |
// ---------------------------------------------------------------------------- |
|
41 |
// Second phase construction |
|
42 |
// ---------------------------------------------------------------------------- |
|
43 |
void CTestSuiteInputData::ConstructL(CStifItemParser& /*aItem*/,CPSRequestHandler& aPsClientHandler) |
|
44 |
{ |
|
45 |
iContactHandler = CPcsTestContactsHandler::NewL(); |
|
46 |
iPsClientHandler = &aPsClientHandler; |
|
47 |
iMaxNumberOfResults = 100; |
|
48 |
iSortType = EAlphabetical; |
|
49 |
} |
|
50 |
||
51 |
// ---------------------------------------------------------------------------- |
|
52 |
// Default constructor |
|
53 |
// ---------------------------------------------------------------------------- |
|
54 |
CTestSuiteInputData::CTestSuiteInputData() |
|
55 |
{ |
|
56 |
} |
|
57 |
||
58 |
// ---------------------------------------------------------------------------- |
|
59 |
// Destructor |
|
60 |
// ---------------------------------------------------------------------------- |
|
61 |
CTestSuiteInputData::~CTestSuiteInputData() |
|
62 |
{ |
|
63 |
delete iQueryBuf; |
|
64 |
delete iKeyboardModeBuf; |
|
65 |
delete iContactHandler; |
|
66 |
delete iInputSearchString; |
|
67 |
delete iExpectedResultString; |
|
68 |
delete iGroupToBeSearched; |
|
69 |
||
70 |
iCacheUris.ResetAndDestroy(); |
|
71 |
iResultData.ResetAndDestroy(); |
|
72 |
iInputCacheData.ResetAndDestroy(); |
|
73 |
iDisplayFields.Close(); |
|
74 |
iSortOrder.Close(); |
|
75 |
iExpectedLocations.Close(); |
|
76 |
} |
|
77 |
||
78 |
// ---------------------------------------------------------------------------- |
|
79 |
// Destructor |
|
80 |
// ---------------------------------------------------------------------------- |
|
81 |
TDesC& CTestSuiteInputData::KeyboardMode() const |
|
82 |
{ |
|
83 |
return *iKeyboardModeBuf; |
|
84 |
} |
|
85 |
||
86 |
// ---------------------------------------------------------------------------- |
|
87 |
// Sets the keyboard mode |
|
88 |
// ---------------------------------------------------------------------------- |
|
89 |
void CTestSuiteInputData::SetKeyboardModeL(const TDesC& aKeyboardMode) |
|
90 |
{ |
|
91 |
iKeyboardModeBuf = aKeyboardMode.AllocL(); |
|
92 |
} |
|
93 |
||
94 |
// ---------------------------------------------------------------------------- |
|
95 |
// Returns the search query (as specified in the config file) |
|
96 |
// ---------------------------------------------------------------------------- |
|
97 |
TDesC& CTestSuiteInputData::Query() const |
|
98 |
{ |
|
99 |
return *iQueryBuf; |
|
100 |
} |
|
101 |
||
102 |
// ---------------------------------------------------------------------------- |
|
103 |
// Returns the Input string (as specified in the config file) |
|
104 |
// ---------------------------------------------------------------------------- |
|
105 |
TDesC& CTestSuiteInputData::InputSearchString() const |
|
106 |
{ |
|
107 |
return *iInputSearchString; |
|
108 |
} |
|
109 |
||
110 |
// ---------------------------------------------------------------------------- |
|
111 |
// Returns the Input string (as specified in the config file) |
|
112 |
// ---------------------------------------------------------------------------- |
|
113 |
const TDesC& CTestSuiteInputData::ExpectedResultString() const |
|
114 |
{ |
|
115 |
return *iExpectedResultString; |
|
116 |
} |
|
117 |
||
118 |
// ---------------------------------------------------------------------------- |
|
119 |
// Returns the Input boolean (as specified in the config file) |
|
120 |
// ---------------------------------------------------------------------------- |
|
121 |
TBool CTestSuiteInputData::InputBoolean() const |
|
122 |
{ |
|
123 |
return iInputBoolean; |
|
124 |
} |
|
125 |
||
126 |
// ---------------------------------------------------------------------------- |
|
127 |
// Sets the search query |
|
128 |
// |
|
129 |
// ---------------------------------------------------------------------------- |
|
130 |
void CTestSuiteInputData::SetQueryL(const TDesC& aQuery) |
|
131 |
{ |
|
132 |
iQueryBuf = aQuery.AllocL(); |
|
133 |
} |
|
134 |
||
135 |
// ---------------------------------------------------------------------------- |
|
136 |
// Returns the input cache data |
|
137 |
// ---------------------------------------------------------------------------- |
|
138 |
void CTestSuiteInputData::InputCacheData(TInt aIndex, cacheData& aInputCacheData) const |
|
139 |
{ |
|
140 |
if(aIndex >= iInputCacheData.Count()) |
|
141 |
{ |
|
142 |
return; |
|
143 |
} |
|
144 |
||
145 |
aInputCacheData = *(iInputCacheData[aIndex]); |
|
146 |
} |
|
147 |
||
148 |
// ---------------------------------------------------------------------------- |
|
149 |
// Appends the cachedata to results data |
|
150 |
// ---------------------------------------------------------------------------- |
|
151 |
void CTestSuiteInputData::AppendResultDataL(const cacheData& aResultData) |
|
152 |
{ |
|
153 |
iResultData.Append(&aResultData); |
|
154 |
} |
|
155 |
||
156 |
// ---------------------------------------------------------------------------- |
|
157 |
// Returns the count for inputcachedata |
|
158 |
// ---------------------------------------------------------------------------- |
|
159 |
TInt CTestSuiteInputData::InputCacheDataCount() const |
|
160 |
{ |
|
161 |
return( iInputCacheData.Count() ); |
|
162 |
} |
|
163 |
||
164 |
// ---------------------------------------------------------------------------- |
|
165 |
// Returns the expected results array |
|
166 |
// ---------------------------------------------------------------------------- |
|
167 |
void CTestSuiteInputData::ResultData(RPointerArray<cacheData>& aResultData) const |
|
168 |
{ |
|
169 |
for(TInt i=0; i<iResultData.Count(); i++ ) |
|
170 |
{ |
|
171 |
aResultData.Append(iResultData[i]); |
|
172 |
} |
|
173 |
} |
|
174 |
||
175 |
// ---------------------------------------------------------------------------- |
|
176 |
// Returns the sort Type |
|
177 |
// ---------------------------------------------------------------------------- |
|
178 |
TSortType CTestSuiteInputData::GetSortType() |
|
179 |
{ |
|
180 |
return iSortType; |
|
181 |
} |
|
182 |
||
183 |
// ---------------------------------------------------------------------------- |
|
184 |
// Appends the cachedata to cache data |
|
185 |
// ---------------------------------------------------------------------------- |
|
186 |
void CTestSuiteInputData::AppendInputCacheDataL(const cacheData& aInputCacheData) |
|
187 |
{ |
|
188 |
iInputCacheData.Append(&aInputCacheData); |
|
189 |
} |
|
190 |
||
191 |
// ---------------------------------------------------------------------------- |
|
192 |
// Returns the count of the expected result data |
|
193 |
// |
|
194 |
// ---------------------------------------------------------------------------- |
|
195 |
TInt CTestSuiteInputData::ResultDataCount() const |
|
196 |
{ |
|
197 |
return( iResultData.Count() ); |
|
198 |
} |
|
199 |
||
200 |
// ---------------------------------------------------------------------------- |
|
201 |
// Return the cache uri at given index |
|
202 |
// ---------------------------------------------------------------------------- |
|
203 |
TDesC& CTestSuiteInputData::CacheUris(TInt aIndex) const |
|
204 |
{ |
|
205 |
if ( aIndex >= iCacheUris.Count() ) |
|
206 |
{ |
|
207 |
//return NULL; |
|
208 |
} |
|
209 |
||
210 |
return *(iCacheUris[aIndex]); |
|
211 |
} |
|
212 |
||
213 |
// ---------------------------------------------------------------------------- |
|
214 |
// Sets the cache uris |
|
215 |
// ---------------------------------------------------------------------------- |
|
216 |
void CTestSuiteInputData::ApendCacheUrisL(RPointerArray<TDesC>& aCacheUriArray) |
|
217 |
{ |
|
218 |
iCacheUris.ResetAndDestroy(); |
|
219 |
for(TInt i =0; i <aCacheUriArray.Count(); i++ ) |
|
220 |
iCacheUris.Append(aCacheUriArray[i]); |
|
221 |
} |
|
222 |
||
223 |
// ---------------------------------------------------------------------------- |
|
224 |
// Returns the count of the cacheuris |
|
225 |
// |
|
226 |
// ---------------------------------------------------------------------------- |
|
227 |
TInt CTestSuiteInputData::CacheUrisCount() const |
|
228 |
{ |
|
229 |
return( iCacheUris.Count() ); |
|
230 |
} |
|
231 |
||
232 |
// ----------------------------------------------------------------------------- |
|
233 |
// This function parses the input parameters |
|
234 |
// ----------------------------------------------------------------------------- |
|
235 |
void CTestSuiteInputData::ParseInputL(CStifItemParser& aItem) |
|
236 |
{ |
|
237 |
TPtrC string; |
|
238 |
||
239 |
// parsing type to be set before parsing a string |
|
240 |
// EQuoteStyleParsing: information between quotes is handled as a one string. |
|
241 |
aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); |
|
242 |
||
243 |
// loop till there is a token in i/p string |
|
244 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
245 |
{ |
|
246 |
HBufC *item = string.AllocL(); |
|
247 |
TChar sqBracketOpen = '['; |
|
248 |
TChar sqBracketClose = ']'; |
|
249 |
||
250 |
TInt sqBracketStartPos = string.Locate(sqBracketOpen); |
|
251 |
TInt sqBracketEndPos = string.Locate(sqBracketClose); |
|
252 |
||
253 |
if ( (sqBracketStartPos!=KErrNotFound) && (sqBracketEndPos!=KErrNotFound) ) |
|
254 |
{ |
|
255 |
TPtrC16 optionPtr = string.Left(sqBracketStartPos); |
|
256 |
||
257 |
TPtrC16 dataPtr = string.Mid(sqBracketStartPos+1, sqBracketEndPos-sqBracketStartPos-1); |
|
258 |
||
259 |
// Check the type of tag, then do the corresponding parsing |
|
260 |
if(optionPtr.Compare(KCreateContacts) == 0) |
|
261 |
{ |
|
262 |
// Contacts to be created |
|
263 |
ParseInputForContactsDataL(dataPtr,0); |
|
264 |
} |
|
265 |
else if(optionPtr.Compare(KSearchQueryTag) == 0) |
|
266 |
{ |
|
267 |
// Search query |
|
268 |
ParseInputForSearchQueryL(dataPtr); |
|
269 |
} |
|
270 |
else if(optionPtr.Compare(KUriTag) == 0) |
|
271 |
{ |
|
272 |
// Data store uris |
|
273 |
ParseInputForDataStoresUriL(dataPtr); |
|
274 |
} |
|
275 |
else if(optionPtr.Compare(KSearchExpectedResult) == 0) |
|
276 |
{ |
|
277 |
// Expected results |
|
278 |
ParseInputForContactsDataL(dataPtr,1); |
|
279 |
} |
|
280 |
else if(optionPtr.Compare(KSearchExpectedMatchLocations) == 0) |
|
281 |
{ |
|
282 |
// Expected match locations result |
|
283 |
ParseInputForMatchLocationsL(dataPtr); |
|
284 |
} |
|
285 |
||
286 |
else if(optionPtr.Compare(KSetDisplayFields) == 0) |
|
287 |
{ |
|
288 |
// Display fields |
|
289 |
ParseInputForDisplayFieldsL(dataPtr); |
|
290 |
} |
|
291 |
else if(optionPtr.Compare(KSearchOnInputString) == 0) |
|
292 |
{ |
|
293 |
// Input search string |
|
294 |
ParseInputInputSearchStringL(dataPtr); |
|
295 |
} |
|
296 |
else if(optionPtr.Compare(KExpectedResultString) == 0) |
|
297 |
{ |
|
298 |
// Expected result string |
|
299 |
ParseInputExpectedResultStringL(dataPtr); |
|
300 |
} |
|
301 |
else if(optionPtr.Compare(KInputBoolean) == 0) |
|
302 |
{ |
|
303 |
// Input boolean |
|
304 |
ParseInputInputBoolean(dataPtr); |
|
305 |
} |
|
306 |
else if(optionPtr.Compare(KSearchExpectedResultForInput) == 0) |
|
307 |
{ |
|
308 |
// Expected results for input string search |
|
309 |
ParseInputForContactsDataL(dataPtr,1); |
|
310 |
} |
|
311 |
else if(optionPtr.Compare(KSupprotedLanguage) == 0) |
|
312 |
{ |
|
313 |
// Languages supported |
|
314 |
ParseInputForLanguageSupportL(dataPtr); |
|
315 |
} |
|
316 |
else if(optionPtr.Compare(KAddGroup) == 0) |
|
317 |
{ |
|
318 |
// Add groups to phonebook |
|
319 |
ParseInputForAddingGroupsL(dataPtr); |
|
320 |
} |
|
321 |
else if(optionPtr.Compare(KSearchInGroup) == 0) |
|
322 |
{ |
|
323 |
// Search within a particular group |
|
324 |
ParseInputForSearchWithinGroupL(dataPtr); |
|
325 |
} |
|
326 |
else if(optionPtr.Compare(KSortOrderTag) == 0) |
|
327 |
{ |
|
328 |
// Search within a particular group |
|
329 |
ParseInputForSortOrderL(dataPtr); |
|
330 |
} |
|
331 |
} |
|
332 |
else |
|
333 |
{ |
|
334 |
// Wrong Input.. |
|
335 |
User::Leave(KErrGeneral); |
|
336 |
} |
|
337 |
} |
|
338 |
} |
|
339 |
||
340 |
// ----------------------------------------------------------------------------- |
|
341 |
// Returned parsed expected result locations |
|
342 |
// ----------------------------------------------------------------------------- |
|
343 |
const RArray<TPsMatchLocation>& CTestSuiteInputData::ExpectedLocations() |
|
344 |
{ |
|
345 |
return iExpectedLocations; |
|
346 |
} |
|
347 |
||
348 |
// ----------------------------------------------------------------------------- |
|
349 |
// Parses the input parameters for contacts data for creating contacts in |
|
350 |
// the phonebook |
|
351 |
// ----------------------------------------------------------------------------- |
|
352 |
||
353 |
void CTestSuiteInputData::ParseInputForContactsDataL(TDesC& aInput,TInt aType) |
|
354 |
{ |
|
355 |
TChar comma = ','; |
|
356 |
TChar bracketOpen = '('; |
|
357 |
TChar bracketClose = ')'; |
|
358 |
TInt commaPos = aInput.Locate(comma); |
|
359 |
TInt numOfContacts = 0; |
|
360 |
||
361 |
if(commaPos !=KErrNotFound ) |
|
362 |
{ |
|
363 |
TPtrC temp = aInput.Left(commaPos); |
|
364 |
TLex num(temp); |
|
365 |
TInt err = num.Val(numOfContacts); // parse the string to extract integer value |
|
366 |
||
367 |
TInt startofBracket = aInput.Locate(bracketOpen); |
|
368 |
for(TInt i =0; i<numOfContacts; i++ ) |
|
369 |
{ |
|
370 |
TInt j = startofBracket; |
|
371 |
||
372 |
// Get the data for each contact |
|
373 |
while(aInput[j] != bracketClose ) |
|
374 |
j++; |
|
375 |
||
376 |
TPtrC16 dataPtr = aInput.Mid(startofBracket + 1,j - 1 - startofBracket ); |
|
377 |
||
378 |
AddSingleContactDataL(dataPtr,aType); |
|
379 |
if(i<numOfContacts - 1 ) |
|
380 |
{ |
|
381 |
while(aInput[j] != bracketOpen ) |
|
382 |
j++; |
|
383 |
||
384 |
startofBracket = j; |
|
385 |
} |
|
386 |
} |
|
387 |
} |
|
388 |
} |
|
389 |
||
390 |
// ----------------------------------------------------------------------------- |
|
391 |
// This function adds single contacts data |
|
392 |
// if (aType), |
|
393 |
// then it is added to the iResultData |
|
394 |
// else |
|
395 |
// it is added to the iInputCacheData |
|
396 |
// ----------------------------------------------------------------------------- |
|
397 |
||
398 |
void CTestSuiteInputData::AddSingleContactDataL(TDesC& aInput, TInt aType) |
|
399 |
{ |
|
400 |
TChar comma = ','; |
|
401 |
TChar colon = ':'; |
|
402 |
TInt commaPos = -1 ; |
|
403 |
cacheData* tempcacheData = new (ELeave) cacheData(); |
|
404 |
||
405 |
TInt arrCount = iInputCacheData.Count(); |
|
406 |
for (TInt j = 0 ; j< aInput.Length();) |
|
407 |
{ |
|
408 |
TInt Startpos = commaPos + 1; |
|
409 |
||
410 |
while(aInput[j] != colon) |
|
411 |
j++; |
|
412 |
TPtrC16 vpbkfielddataPtr = aInput.Mid(Startpos ,j - Startpos); |
|
413 |
||
414 |
// Get the corresponding integer value |
|
415 |
TInt fieldId = GetFieldIdFromVpbkIdentifierL(vpbkfielddataPtr); |
|
416 |
||
417 |
tempcacheData->vpbkId.Append(fieldId); |
|
418 |
||
419 |
Startpos = j + 1; |
|
420 |
||
421 |
while ( (j < aInput.Length()) && (aInput[j] != comma) ) |
|
422 |
j++; |
|
423 |
||
424 |
TPtrC16 dataPtr = aInput.Mid(Startpos ,j - Startpos); |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
425 |
|
63 | 426 |
// Add data to the class |
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
427 |
tempcacheData->data.Append(dataPtr.AllocL()); |
63 | 428 |
|
429 |
commaPos = j ; |
|
430 |
j++; |
|
431 |
} |
|
432 |
||
433 |
// Check and add to appropriate data structure |
|
434 |
if(aType) |
|
435 |
{ |
|
436 |
iResultData.Append(tempcacheData); |
|
437 |
} |
|
438 |
else |
|
439 |
{ |
|
440 |
iInputCacheData.Append(tempcacheData); |
|
441 |
} |
|
442 |
} |
|
443 |
||
444 |
// ----------------------------------------------------------------------------- |
|
445 |
// Parses the input parameters for result match locations |
|
446 |
// ----------------------------------------------------------------------------- |
|
447 |
void CTestSuiteInputData::ParseInputForMatchLocationsL(TDesC& aInput) |
|
448 |
{ |
|
449 |
const TChar KComma(','); |
|
450 |
const TChar KColon(':'); |
|
451 |
||
452 |
if ( 0 == aInput.Length() ) |
|
453 |
{ |
|
454 |
return; |
|
455 |
} |
|
456 |
TLex lex(aInput); |
|
457 |
do |
|
458 |
{ |
|
459 |
TInt index; |
|
460 |
TInt length; |
|
461 |
User::LeaveIfError( lex.Val( index ) ); |
|
462 |
if ( KColon != lex.Get() ) |
|
463 |
{ |
|
464 |
User::Leave( KErrArgument ); |
|
465 |
} |
|
466 |
User::LeaveIfError( lex.Val( length ) ); |
|
467 |
TPsMatchLocation newLocation = {index, length, TBidiText::ELeftToRight }; |
|
468 |
iExpectedLocations.AppendL( newLocation ); |
|
469 |
} while ( KComma == lex.Get() ); |
|
470 |
} |
|
471 |
||
472 |
// ----------------------------------------------------------------------------- |
|
473 |
// This function returns the vpbk id corresponding to config file strings |
|
474 |
// ----------------------------------------------------------------------------- |
|
475 |
||
476 |
TInt CTestSuiteInputData::GetFieldIdFromVpbkIdentifierL(TDesC& aIdentifierAsString) |
|
477 |
{ |
|
478 |
if(aIdentifierAsString.Compare(KFirstName) == 0) |
|
479 |
{ |
|
480 |
return R_VPBK_FIELD_TYPE_FIRSTNAME; |
|
481 |
} |
|
482 |
else if(aIdentifierAsString.Compare(KLastName) == 0) |
|
483 |
{ |
|
484 |
return R_VPBK_FIELD_TYPE_LASTNAME; |
|
485 |
} |
|
486 |
else if(aIdentifierAsString.Compare(KCompanyName) == 0) |
|
487 |
{ |
|
488 |
return R_VPBK_FIELD_TYPE_COMPANYNAME; |
|
489 |
} |
|
490 |
||
491 |
return -1; |
|
492 |
} |
|
493 |
||
494 |
// ----------------------------------------------------------------------------- |
|
495 |
// This function parses input for cache uris |
|
496 |
// ----------------------------------------------------------------------------- |
|
497 |
void CTestSuiteInputData::ParseInputForDataStoresUriL(TDesC& aInput) |
|
498 |
{ |
|
499 |
RPointerArray<TDesC> Uris; |
|
500 |
TChar separator = ','; |
|
501 |
||
502 |
// Get the uris which are separated by commas |
|
503 |
GetCharacterSeparatedDataL( aInput,separator, Uris); |
|
504 |
for(TInt i = 0; i< Uris.Count(); i++) |
|
505 |
{ |
|
506 |
HBufC *temp = Uris[i]->AllocL(); |
|
507 |
iCacheUris.Append(Uris[i]); |
|
508 |
} |
|
509 |
} |
|
510 |
||
511 |
// ----------------------------------------------------------------------------- |
|
512 |
// This function parses the input for display fields |
|
513 |
// ----------------------------------------------------------------------------- |
|
514 |
void CTestSuiteInputData::ParseInputForDisplayFieldsL(TDesC& aInput) |
|
515 |
{ |
|
516 |
RPointerArray<TDesC> dispFieldsBuf; |
|
517 |
||
518 |
TChar separator = ','; |
|
519 |
GetCharacterSeparatedDataL(aInput, separator, dispFieldsBuf); |
|
520 |
for (TInt i = 0; i< dispFieldsBuf.Count(); i++) |
|
521 |
{ |
|
522 |
TInt fieldId = 0; |
|
523 |
TLex num(*(dispFieldsBuf[i])); |
|
524 |
||
525 |
TInt err = num.Val(fieldId); // parse the string to extract integer value |
|
526 |
if (err != KErrNone) |
|
527 |
{ |
|
528 |
User::Leave(KErrGeneral); |
|
529 |
} |
|
530 |
else |
|
531 |
{ |
|
532 |
iDisplayFields.Append(fieldId); |
|
533 |
} |
|
534 |
} |
|
535 |
} |
|
536 |
||
537 |
// ----------------------------------------------------------------------------- |
|
538 |
// This function splits the the input separated by particular character |
|
539 |
// ----------------------------------------------------------------------------- |
|
540 |
void CTestSuiteInputData::GetCharacterSeparatedDataL(TDesC& aInput, TChar aSeparator, RPointerArray<TDesC> &aSeparatedData) |
|
541 |
{ |
|
542 |
TInt SeparatorPos = -1 ; |
|
543 |
for (TInt j = 0 ; j< aInput.Length();) |
|
544 |
{ |
|
545 |
TInt Startpos = SeparatorPos + 1; |
|
546 |
// Get the data for each contact |
|
547 |
while ( (j < aInput.Length()) && (aInput[j] != aSeparator) ) |
|
548 |
j++; |
|
549 |
||
550 |
TPtrC16 dataPtr = aInput.Mid(Startpos ,j - Startpos); |
|
551 |
||
552 |
// Add data to the output |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
553 |
HBufC* tempData = dataPtr.AllocL(); |
63 | 554 |
aSeparatedData.Append(tempData); |
555 |
SeparatorPos = j; |
|
556 |
j++; |
|
557 |
} |
|
558 |
} |
|
559 |
||
560 |
// ----------------------------------------------------------------------------- |
|
561 |
// This function parses the input for search query |
|
562 |
// ----------------------------------------------------------------------------- |
|
563 |
void CTestSuiteInputData::ParseInputForSearchQueryL(TDesC& aInput) |
|
564 |
{ |
|
565 |
RPointerArray<TDesC> queryData; |
|
566 |
TChar separator = ','; |
|
567 |
GetCharacterSeparatedDataL( aInput,separator, queryData); |
|
568 |
||
569 |
// If number of fields != 4 , then it is an error |
|
570 |
if(queryData.Count() != 4) |
|
571 |
{ |
|
572 |
queryData.ResetAndDestroy(); |
|
573 |
User::Leave(KErrArgument); |
|
574 |
} |
|
575 |
else |
|
576 |
{ |
|
577 |
iQueryBuf = queryData[0]->AllocL(); |
|
578 |
iKeyboardModeBuf = queryData[1]->AllocL(); |
|
579 |
||
580 |
if(queryData[2]->Compare(KPatternSort) == 0) |
|
581 |
{ |
|
582 |
iSortType = EPatternBased; |
|
583 |
} |
|
584 |
else if(queryData[2]->Compare(KAlphaSort) == 0) |
|
585 |
{ |
|
586 |
iSortType = EAlphabetical; |
|
587 |
} |
|
588 |
else |
|
589 |
{ |
|
590 |
queryData.ResetAndDestroy(); |
|
591 |
User::Leave(KErrArgument); |
|
592 |
} |
|
593 |
||
594 |
// Number of results |
|
595 |
iMaxNumberOfResults = 0; |
|
596 |
TLex num(*(queryData[3])); |
|
597 |
TInt err = num.Val(iMaxNumberOfResults); |
|
598 |
||
599 |
if( KErrNone != err) |
|
600 |
{ |
|
601 |
queryData.ResetAndDestroy(); |
|
602 |
User::Leave(KErrArgument); |
|
603 |
} |
|
604 |
queryData.ResetAndDestroy(); |
|
605 |
} |
|
606 |
} |
|
607 |
||
608 |
// ----------------------------------------------------------------------------- |
|
609 |
// This function creates contacts (contacts data is taken from iInputCacheData |
|
610 |
// ----------------------------------------------------------------------------- |
|
611 |
void CTestSuiteInputData::CreateContactsL() |
|
612 |
{ |
|
613 |
for(TInt i =0 ; i <iInputCacheData.Count(); i++ ) |
|
614 |
{ |
|
615 |
// create the specified contact |
|
616 |
iContactHandler->CreateOneContactL(*(iInputCacheData[i])); |
|
617 |
CActiveScheduler::Start(); |
|
618 |
} |
|
619 |
} |
|
620 |
||
621 |
// ----------------------------------------------------------------------------- |
|
622 |
// This function creates the search query from the input buffer |
|
623 |
// ----------------------------------------------------------------------------- |
|
624 |
void CTestSuiteInputData::CreateSearchQueryL(CPsQuery& aPsQuery, TDesC& aQueryBuf) |
|
625 |
{ |
|
626 |
TKeyboardModes keyboardMode = EModeUndefined; |
|
627 |
||
628 |
// Check the keyboard mode |
|
629 |
if(iKeyboardModeBuf->Compare(KItut) == 0) |
|
630 |
{ |
|
631 |
keyboardMode = EItut; |
|
632 |
} |
|
633 |
else if (iKeyboardModeBuf->Compare(KQwerty) == 0) |
|
634 |
{ |
|
635 |
keyboardMode = EQwerty; |
|
636 |
} |
|
637 |
else if (iKeyboardModeBuf->Compare(KPredictiveItuT) == 0) |
|
638 |
{ |
|
639 |
keyboardMode = EPredictiveItuT; |
|
640 |
} |
|
641 |
else if (iKeyboardModeBuf->Compare(KPredictiveQwerty) == 0) |
|
642 |
{ |
|
643 |
keyboardMode = EPredictiveQwerty; |
|
644 |
} |
|
645 |
else if (iKeyboardModeBuf->Compare(KPredictiveDefaultKeyboard) == 0) |
|
646 |
{ |
|
647 |
keyboardMode = EPredictiveDefaultKeyboard; |
|
648 |
} |
|
649 |
else if (iKeyboardModeBuf->Compare(KNonPredictive) == 0) |
|
650 |
{ |
|
651 |
keyboardMode = ENonPredictive; |
|
652 |
} |
|
653 |
||
654 |
else // mixed mode |
|
655 |
{ |
|
656 |
// convert the search query to the required format |
|
657 |
for(TInt i = 0; i < aQueryBuf.Length(); i++) |
|
658 |
{ |
|
659 |
CPsQueryItem* item = CPsQueryItem::NewL(); |
|
660 |
item->SetCharacter(aQueryBuf[i]); // set search character |
|
661 |
||
662 |
// set the keyboard mode |
|
663 |
if( (iKeyboardModeBuf->Des().Mid(i,1)).Compare(KPredictiveItuTCode) == 0) |
|
664 |
{ |
|
665 |
item->SetMode(EPredictiveItuT); |
|
666 |
} |
|
667 |
else if( (iKeyboardModeBuf->Des().Mid(i,1)).Compare(KPredictiveQwertyCode) == 0) |
|
668 |
{ |
|
669 |
item->SetMode(EPredictiveQwerty); |
|
670 |
} |
|
671 |
else if( (iKeyboardModeBuf->Des().Mid(i,1)).Compare(KPredictiveDefaultCode) == 0) |
|
672 |
{ |
|
673 |
item->SetMode(EPredictiveDefaultKeyboard); |
|
674 |
} |
|
675 |
else if( (iKeyboardModeBuf->Des().Mid(i,1)).Compare(KNonPredictiveCode) == 0) |
|
676 |
{ |
|
677 |
item->SetMode(ENonPredictive); |
|
678 |
} |
|
679 |
else |
|
680 |
{ |
|
681 |
item->SetMode(EModeUndefined); |
|
682 |
} |
|
683 |
||
684 |
aPsQuery.AppendL(*item); |
|
685 |
} |
|
686 |
||
687 |
return; |
|
688 |
} |
|
689 |
||
690 |
// create the query as CPsQuery object |
|
691 |
// for EItut and EQwerty mode |
|
692 |
for(TInt j = 0; j < aQueryBuf.Length(); j++) |
|
693 |
{ |
|
694 |
CPsQueryItem* item1 = CPsQueryItem::NewL(); |
|
695 |
item1->SetCharacter(aQueryBuf[j]); |
|
696 |
item1->SetMode(keyboardMode); |
|
697 |
aPsQuery.AppendL(*item1); |
|
698 |
} |
|
699 |
} |
|
700 |
||
701 |
// ----------------------------------------------------------------------------- |
|
702 |
// Perform the search settings |
|
703 |
// ----------------------------------------------------------------------------- |
|
704 |
void CTestSuiteInputData::PerformSearchSettingsL(CPsSettings& aSettings) |
|
705 |
{ |
|
706 |
RPointerArray<TDesC> databases; // list of databases |
|
707 |
RArray<TInt> displayFields; // list of display fields |
|
708 |
||
709 |
// add the display fields |
|
710 |
if(iDisplayFields.Count()) |
|
711 |
{ |
|
712 |
for (TInt i=0; i<iDisplayFields.Count(); i++) |
|
713 |
displayFields.Append(iDisplayFields[i]); |
|
714 |
} |
|
715 |
else |
|
716 |
{ |
|
717 |
displayFields.Append(R_VPBK_FIELD_TYPE_FIRSTNAME); // Firstname |
|
718 |
displayFields.Append(R_VPBK_FIELD_TYPE_LASTNAME); // Lastname |
|
719 |
displayFields.Append(R_VPBK_FIELD_TYPE_COMPANYNAME); // Company name |
|
720 |
} |
|
721 |
||
722 |
// Set the databases to be searched |
|
723 |
for(TInt i =0; i <iCacheUris.Count(); i++ ) |
|
724 |
{ |
|
725 |
databases.Append(iCacheUris[i]->AllocL()); |
|
726 |
} |
|
727 |
||
728 |
// Perform the settings |
|
729 |
aSettings.SetSearchUrisL(databases); |
|
730 |
aSettings.SetDisplayFieldsL(displayFields); |
|
731 |
aSettings.SetMaxResults(iMaxNumberOfResults); |
|
732 |
||
733 |
// Set sort type |
|
734 |
aSettings.SetSortType(iSortType); |
|
735 |
||
736 |
// cleanup |
|
737 |
displayFields.Close(); |
|
738 |
databases.Reset(); |
|
739 |
databases.Close(); |
|
740 |
} |
|
741 |
||
742 |
// ----------------------------------------------------------------------------- |
|
743 |
// This function compares the searchResults with expected results |
|
744 |
// The expected results are stored in iResultData |
|
745 |
// ----------------------------------------------------------------------------- |
|
746 |
TInt CTestSuiteInputData::CompareResWithExpResL(RPointerArray<CPsClientData>& searchResults) |
|
747 |
{ |
|
748 |
TInt returnStatus = KErrNone; |
|
749 |
||
750 |
if(iResultData.Count() != searchResults.Count() ) |
|
751 |
{ |
|
752 |
returnStatus = KErrGeneral; |
|
753 |
} |
|
754 |
else |
|
755 |
{ |
|
756 |
TInt totalMatches = 0; |
|
757 |
for(TInt expResCnt=0; expResCnt < iResultData.Count(); expResCnt++ ) |
|
758 |
{ |
|
759 |
for(TInt resCnt=0; resCnt < searchResults.Count(); resCnt++ ) |
|
760 |
{ |
|
761 |
CPsClientData* tempPsData = searchResults[resCnt]; |
|
762 |
TBool comapreRes = CompareInputDataWithResultDataL(*tempPsData,*(iResultData[expResCnt])); |
|
763 |
if( comapreRes ) |
|
764 |
{ |
|
765 |
totalMatches++; |
|
766 |
} |
|
767 |
} |
|
768 |
} |
|
769 |
||
770 |
// If totalMatches === searchResults.Count(), then the match exists |
|
771 |
if(totalMatches != searchResults.Count() ) |
|
772 |
{ |
|
773 |
returnStatus = KErrGeneral; |
|
774 |
} |
|
775 |
else |
|
776 |
{ |
|
777 |
returnStatus = KErrNone; |
|
778 |
} |
|
779 |
} |
|
780 |
||
781 |
return returnStatus; |
|
782 |
} |
|
783 |
||
784 |
TInt CTestSuiteInputData::ExactMatchCompareInputDataWithResultDataL(RPointerArray<CPsClientData>& searchResults) |
|
785 |
{ |
|
786 |
TBool returnStatus = KErrNone; |
|
787 |
||
788 |
if (iResultData.Count() != searchResults.Count()) |
|
789 |
{ |
|
790 |
returnStatus = KErrGeneral; |
|
791 |
} |
|
792 |
else |
|
793 |
{ |
|
794 |
for (TInt resCnt=0; resCnt < searchResults.Count(); resCnt++) |
|
795 |
{ |
|
796 |
CPsClientData* tempPsData = searchResults[resCnt]; |
|
797 |
TBool comapreRes = CompareInputDataWithResultDataL(*tempPsData,*(iResultData[resCnt])); |
|
798 |
if (comapreRes == EFalse) |
|
799 |
{ |
|
800 |
returnStatus = KErrGeneral; |
|
801 |
break; |
|
802 |
} |
|
803 |
} |
|
804 |
} |
|
805 |
||
806 |
return returnStatus; |
|
807 |
} |
|
808 |
||
809 |
// ----------------------------------------------------------------------------- |
|
810 |
// This function compares the cachedata with the CPsClientData |
|
811 |
// ----------------------------------------------------------------------------- |
|
812 |
TBool CTestSuiteInputData::CompareInputDataWithResultDataL(CPsClientData& aResData,cacheData aInputData) |
|
813 |
{ |
|
814 |
TBool result = ETrue; |
|
815 |
RArray<TInt> dataOrder; |
|
816 |
||
817 |
iPsClientHandler->GetDataOrderL(*(iCacheUris[0]), dataOrder); |
|
818 |
||
819 |
HBufC* res1 = HBufC::NewL(100); |
|
820 |
HBufC* res2 = HBufC::NewL(100); |
|
821 |
for(TInt i =0; i< dataOrder.Count(); i++) |
|
822 |
{ |
|
823 |
res1->Des().Append( *(aResData.Data(i))); |
|
824 |
||
825 |
TInt loc = aInputData.vpbkId.Find(dataOrder[i]); |
|
826 |
if( loc != KErrNotFound) |
|
827 |
{ |
|
828 |
res2->Des().Append(*(aInputData.data[loc])); |
|
829 |
} |
|
830 |
else |
|
831 |
{ |
|
832 |
result = EFalse; |
|
833 |
break; |
|
834 |
} |
|
835 |
||
836 |
} |
|
837 |
if((res1->Des().Compare(*res2)) ==0) |
|
838 |
result = ETrue; |
|
839 |
else |
|
840 |
result = EFalse; |
|
841 |
return result; |
|
842 |
} |
|
843 |
||
844 |
// ----------------------------------------------------------------------------- |
|
845 |
// This function parses the input search string |
|
846 |
// ----------------------------------------------------------------------------- |
|
847 |
void CTestSuiteInputData::ParseInputInputSearchStringL(TDesC& aInput) |
|
848 |
{ |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
849 |
iInputSearchString = aInput.AllocL(); |
63 | 850 |
} |
851 |
||
852 |
// ----------------------------------------------------------------------------- |
|
853 |
// This function parses the input expected result string |
|
854 |
// ----------------------------------------------------------------------------- |
|
855 |
void CTestSuiteInputData::ParseInputExpectedResultStringL(TDesC& aInput) |
|
856 |
{ |
|
857 |
iExpectedResultString = aInput.AllocL(); |
|
858 |
} |
|
859 |
||
860 |
// ----------------------------------------------------------------------------- |
|
861 |
// This function parses the input expected result string |
|
862 |
// ----------------------------------------------------------------------------- |
|
863 |
void CTestSuiteInputData::ParseInputInputBoolean(TDesC& aInput) |
|
864 |
{ |
|
865 |
if(aInput.Compare(KTrue) == 0) |
|
866 |
{ |
|
867 |
iInputBoolean = ETrue; |
|
868 |
} |
|
869 |
else if(aInput.Compare(KFalse) == 0) |
|
870 |
{ |
|
871 |
iInputBoolean = EFalse; |
|
872 |
} |
|
873 |
else |
|
874 |
{ |
|
875 |
User::Leave(KErrArgument); |
|
876 |
} |
|
877 |
} |
|
878 |
||
879 |
// ----------------------------------------------------------------------------- |
|
880 |
// Deletes all the created contacts |
|
881 |
// ----------------------------------------------------------------------------- |
|
882 |
void CTestSuiteInputData::DeleteAllCreatedContactsL() |
|
883 |
{ |
|
884 |
iContactHandler->DeleteAllCreatedContactsL(); |
|
885 |
CActiveScheduler::Start(); |
|
886 |
} |
|
887 |
||
888 |
// ----------------------------------------------------------------------------- |
|
889 |
// Deletes contacts with specific contact ids |
|
890 |
// ----------------------------------------------------------------------------- |
|
891 |
void CTestSuiteInputData::DeleteContactsWithIdsL(RArray<TInt>& aContactIdArray) |
|
892 |
{ |
|
893 |
iContactHandler->DeleteContactsWithIdsL(aContactIdArray); |
|
894 |
// CActiveScheduler::Start(); |
|
895 |
} |
|
896 |
||
897 |
// ----------------------------------------------------------------------------- |
|
898 |
// This function parses the input for the languge supported tag |
|
899 |
// ----------------------------------------------------------------------------- |
|
900 |
void CTestSuiteInputData::ParseInputForLanguageSupportL(TDesC& aInput) |
|
901 |
{ |
|
902 |
RPointerArray<TDesC> langData; |
|
903 |
TChar separator = ','; |
|
904 |
GetCharacterSeparatedDataL( aInput,separator, langData); |
|
905 |
||
906 |
//If there are more than 2 elements, then it is an error |
|
907 |
if(langData.Count() != 2) |
|
908 |
{ |
|
909 |
User::Leave(KErrArgument); |
|
910 |
} |
|
911 |
||
912 |
// get Language Id |
|
913 |
TInt lang = -1; |
|
914 |
TLex num(*(langData[0])); |
|
915 |
TInt err = num.Val(lang); |
|
916 |
// for 57 this value will be ELangHindi |
|
917 |
if( KErrNone == err) |
|
918 |
{ |
|
919 |
iLangId = (TLanguage)lang; |
|
920 |
} |
|
921 |
else |
|
922 |
{ |
|
923 |
User::Leave(KErrArgument); |
|
924 |
} |
|
925 |
||
926 |
if(langData[1]->Compare(KTrue) == 0) |
|
927 |
{ |
|
928 |
iIsLangSupported = ETrue; |
|
929 |
} |
|
930 |
else if(langData[1]->Compare(KFalse) == 0) |
|
931 |
{ |
|
932 |
iIsLangSupported = EFalse; |
|
933 |
} |
|
934 |
else |
|
935 |
{ |
|
936 |
User::Leave(KErrArgument); |
|
937 |
} |
|
938 |
} |
|
939 |
||
940 |
// ----------------------------------------------------------------------------- |
|
941 |
// This function parses the input for addition of group to phonebook |
|
942 |
// ----------------------------------------------------------------------------- |
|
943 |
void CTestSuiteInputData::ParseInputForAddingGroupsL(TDesC& aInput) |
|
944 |
{ |
|
945 |
TChar comma = ','; |
|
946 |
TInt commaPos = aInput.Locate(comma); |
|
947 |
HBufC* gropName = HBufC::NewL(commaPos); |
|
948 |
gropName->Des().Copy(aInput.Left(commaPos)); |
|
949 |
TInt len = aInput.Length() - commaPos; |
|
950 |
HBufC* temp2 = aInput.Right(len - 1).AllocL(); |
|
951 |
ParseInputForContactsDataL(*temp2,0); |
|
952 |
||
953 |
//Add the group |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
954 |
iContactHandler->AddGroupL(*gropName); |
63 | 955 |
CActiveScheduler :: Start(); |
956 |
||
957 |
//Create Contacts |
|
958 |
CreateContactsL(); |
|
959 |
iContactHandler->AddCreatedContactsToGroup(); |
|
960 |
} |
|
961 |
||
962 |
// ----------------------------------------------------------------------------- |
|
963 |
// This function parse the input for the group to seach in that particular group |
|
964 |
// ----------------------------------------------------------------------------- |
|
965 |
void CTestSuiteInputData::ParseInputForSearchWithinGroupL(TDesC& aInput) |
|
966 |
{ |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
967 |
iGroupToBeSearched = aInput.AllocL(); |
63 | 968 |
} |
969 |
||
970 |
// ----------------------------------------------------------------------------- |
|
971 |
// Return the input language |
|
972 |
// ----------------------------------------------------------------------------- |
|
973 |
TLanguage CTestSuiteInputData::LanguageInput() |
|
974 |
{ |
|
975 |
return iLangId; |
|
976 |
} |
|
977 |
||
978 |
// ----------------------------------------------------------------------------- |
|
979 |
// Return the input language expected result |
|
980 |
// ----------------------------------------------------------------------------- |
|
981 |
TBool CTestSuiteInputData::LanguageInputExpectedResult() |
|
982 |
{ |
|
983 |
return iIsLangSupported; |
|
984 |
} |
|
985 |
||
986 |
// ----------------------------------------------------------------------------- |
|
987 |
// Return the group to be searched |
|
988 |
// ----------------------------------------------------------------------------- |
|
989 |
TDesC& CTestSuiteInputData::GroupToBeSearched() const |
|
990 |
{ |
|
991 |
return *iGroupToBeSearched; |
|
992 |
} |
|
993 |
||
994 |
// ----------------------------------------------------------------------------- |
|
995 |
// Tests if Id returns correct vpbklink |
|
996 |
// ----------------------------------------------------------------------------- |
|
997 |
TBool CTestSuiteInputData::TestVpbkLinkForIdL(CPSRequestHandler& aPsClientHandler,const CPsClientData& aSearchResult) |
|
998 |
{ |
|
999 |
return iContactHandler->TestVpbkLinkForIdL(aPsClientHandler,aSearchResult); |
|
1000 |
} |
|
1001 |
||
1002 |
// ----------------------------------------------------------------------------- |
|
1003 |
// Parses the input for sort order |
|
1004 |
// ----------------------------------------------------------------------------- |
|
1005 |
void CTestSuiteInputData::ParseInputForSortOrderL(TDesC& aInput) |
|
1006 |
{ |
|
1007 |
TChar aSeparator = ','; |
|
1008 |
RPointerArray<TDesC> aSeparatedData; |
|
1009 |
GetCharacterSeparatedDataL(aInput,aSeparator,aSeparatedData); |
|
1010 |
||
1011 |
for (TInt i=0; i < aSeparatedData.Count(); i++) |
|
1012 |
{ |
|
1013 |
TInt fieldId = 0; |
|
1014 |
TLex numlex(*(aSeparatedData[i])); |
|
1015 |
TInt err = numlex.Val(fieldId); // parse the string to extract integer value |
|
1016 |
if(err != KErrNone) |
|
1017 |
{ |
|
1018 |
User::Leave(KErrGeneral); |
|
1019 |
} |
|
1020 |
iSortOrder.Append(fieldId); |
|
1021 |
||
1022 |
} |
|
1023 |
} |
|
1024 |
||
1025 |
// ----------------------------------------------------------------------------- |
|
1026 |
// Returns the sort order |
|
1027 |
// ----------------------------------------------------------------------------- |
|
1028 |
void CTestSuiteInputData::SortOrder(RArray<TInt>& aSortOrder) |
|
1029 |
{ |
|
1030 |
for (TInt i=0; i < iSortOrder.Count(); i++) |
|
1031 |
{ |
|
1032 |
aSortOrder.Append(iSortOrder[i]); |
|
1033 |
} |
|
1034 |
} |
|
1035 |
||
1036 |
// End of file |