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