|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "TestContactViewAccessStep.h" |
|
17 |
|
18 /** |
|
19 * Constructor |
|
20 */ |
|
21 CTestContactViewAccessStep::CTestContactViewAccessStep() |
|
22 { |
|
23 // Unique loggind Id for the test step |
|
24 SetTestStepName(KTestContactViewAccessStep); |
|
25 } |
|
26 |
|
27 /** |
|
28 * Destructor |
|
29 */ |
|
30 CTestContactViewAccessStep::~CTestContactViewAccessStep() |
|
31 { |
|
32 |
|
33 if(iViewCollection) |
|
34 { |
|
35 delete iViewCollection; |
|
36 } |
|
37 delete iViewValidation; |
|
38 delete iContactViewTest; |
|
39 delete iContactUtility; |
|
40 delete iBackupHelper; |
|
41 } |
|
42 |
|
43 /** |
|
44 * Base class pure virtual. |
|
45 * @return EPass or EFail indicating the result of the test step. |
|
46 */ |
|
47 TVerdict CTestContactViewAccessStep::doTestStepPreambleL() |
|
48 { |
|
49 iActiveScheduler = new (ELeave) CActiveScheduler; |
|
50 CActiveScheduler::Install(iActiveScheduler); |
|
51 |
|
52 CTestStep* self = static_cast<CTestStep*>(this); |
|
53 iBackupHelper = CBackupRestoreHelper::NewL(*self); |
|
54 |
|
55 // Create utility objects |
|
56 CreateUtilityClassL(); |
|
57 |
|
58 // File from where contacts must be imported |
|
59 TPtrC importFileName; |
|
60 TBool filePresent; |
|
61 filePresent = GetStringFromConfig(ConfigSection(), SharedConstants::KFileToBeImported, importFileName); |
|
62 |
|
63 TBool pbapBased = EFalse; |
|
64 GetBoolFromConfig(ConfigSection(), SharedConstants::KVCardVersionPBAP, pbapBased); |
|
65 if(filePresent) |
|
66 { |
|
67 iContactUtility->ImportVcardContactsL(importFileName, pbapBased); |
|
68 } |
|
69 |
|
70 return CTestStep::doTestStepPreambleL(); |
|
71 } |
|
72 |
|
73 /** |
|
74 * Base class pure virtual. |
|
75 * @return EPass or EFail indicating the result of the test step. |
|
76 */ |
|
77 TVerdict CTestContactViewAccessStep::doTestStepL() |
|
78 { |
|
79 TPtrC listOfViews; |
|
80 GetStringFromConfig(ConfigSection(), SharedConstants::KListOfViews, listOfViews); |
|
81 |
|
82 /* Get the list of views from ini and construct the view like local view/remote view/named remote view/ |
|
83 find view/filtered view/group view/concatenated view or sub view based on the requirement */ |
|
84 RArray<TPtrC> sections; |
|
85 iContactUtility->TokenizeStringL(listOfViews, sections); |
|
86 iContactUtility->ConstructViewsL(sections); //section is destroyed in ConstructViewsL |
|
87 |
|
88 AccessViewsL(); |
|
89 TestViewsUnderBackupRestoreL(); |
|
90 |
|
91 return TestStepResult(); |
|
92 } |
|
93 |
|
94 /** |
|
95 * Test the view API's like AtL(), AllFieldsLC(), ContactAtL(), ContactL(), CountL(), SortOrder(), |
|
96 * ViewPreferences(), RefineFindView(), ContactsMatchingCriteria() and ContactsMatchingPrefixL() |
|
97 * based on the sections given in the ini file. |
|
98 * @param aSection ini sections |
|
99 */ |
|
100 void CTestContactViewAccessStep::TestViewAPIsL(const RArray<TPtrC>& aSection) |
|
101 { |
|
102 // Based on the data specified in the ini file, test the view API's |
|
103 for ( TInt i = 0; i < aSection.Count(); ++i ) |
|
104 { |
|
105 TPtrC viewAccessSection = aSection[i]; |
|
106 |
|
107 // Get the desired view based on the input given from the ini file |
|
108 CContactViewBase* viewBase = iContactUtility->GetDesiredView(viewAccessSection); |
|
109 CleanupStack::PushL(viewBase); |
|
110 |
|
111 TBool testAtLAPI = EFalse; |
|
112 GetBoolFromConfig(viewAccessSection, KTestAtLAPI, testAtLAPI); |
|
113 if ( testAtLAPI ) |
|
114 { |
|
115 // Function to test the AtL() API which returns the contact item id for the specified index |
|
116 TestContactViewAtL(viewAccessSection, viewBase); |
|
117 } |
|
118 |
|
119 TBool testContactAtLAPI = EFalse; |
|
120 GetBoolFromConfig(viewAccessSection, KTestContactAtLAPI, testContactAtLAPI); |
|
121 if ( testContactAtLAPI ) |
|
122 { |
|
123 // Function to test the ContactAtL() API which returns the contact item |
|
124 TestContactAtL(viewAccessSection, viewBase); |
|
125 } |
|
126 |
|
127 TBool testCountLAPI = EFalse; |
|
128 GetBoolFromConfig(viewAccessSection, KTestCountLAPI, testCountLAPI); |
|
129 if ( testCountLAPI ) |
|
130 { |
|
131 // Function to test the CountL() which returns the no. of contact items in the view |
|
132 TestCountL(viewAccessSection, viewBase); |
|
133 } |
|
134 |
|
135 TBool testAllFieldsAPI = EFalse; |
|
136 GetBoolFromConfig(viewAccessSection, KTestAllFieldsAPI, testAllFieldsAPI); |
|
137 if ( testAllFieldsAPI ) |
|
138 { |
|
139 // Function to test the AllFieldsLC() API which returns the fields of the contact item |
|
140 TestContactFieldsL(viewAccessSection, viewBase); |
|
141 } |
|
142 |
|
143 TBool testFindLAPI = EFalse; |
|
144 GetBoolFromConfig(viewAccessSection, KTestFindLAPI, testFindLAPI); |
|
145 if ( testFindLAPI ) |
|
146 { |
|
147 // Function to test the FindL() API which returns the index of the contact item |
|
148 TestFindL(viewAccessSection, viewBase); |
|
149 } |
|
150 |
|
151 TBool testSortOrder = EFalse; |
|
152 GetBoolFromConfig(viewAccessSection, KTestSortOrder, testSortOrder); |
|
153 if ( testSortOrder ) |
|
154 { |
|
155 // Function to test the SortOrder() API which returns the view's sort order |
|
156 TestSortOrderL(viewAccessSection, viewBase); |
|
157 } |
|
158 |
|
159 TBool testViewPreferences = EFalse; |
|
160 GetBoolFromConfig(viewAccessSection, KTestViewPreferences, testViewPreferences); |
|
161 if ( testViewPreferences ) |
|
162 { |
|
163 // Function to test the ViewPreferences() API which returns the view preferences |
|
164 TestContactViewPreferencesL(viewAccessSection, viewBase); |
|
165 } |
|
166 |
|
167 TBool refineFindView = EFalse; |
|
168 GetBoolFromConfig(viewAccessSection, KRefineFindView, refineFindView); |
|
169 if ( refineFindView ) |
|
170 { |
|
171 TInt index; |
|
172 GetIntFromConfig(viewAccessSection, SharedConstants::KIndex, index); |
|
173 // Get the desired view based on the input given from the ini file |
|
174 CContactFindView* view = iViewCollection->GetDesiredFindView(index); |
|
175 TPtrC searchWords; |
|
176 GetStringFromConfig(viewAccessSection, KSearchWords, searchWords); |
|
177 iContactViewTest->RefineFindViewL(searchWords, view, iContactUtility); |
|
178 } |
|
179 |
|
180 TBool testContactsMatchingCriteria = EFalse; |
|
181 GetBoolFromConfig(viewAccessSection, KTestContactsMatchingCriteria, testContactsMatchingCriteria); |
|
182 // if contactMatchingCriteria is set to true, then get the contacts matching the specified words |
|
183 if ( testContactsMatchingCriteria ) |
|
184 { |
|
185 TPtrC findWords; |
|
186 GetStringFromConfig(viewAccessSection, KFindWords, findWords); |
|
187 TPtrC errorCondition; |
|
188 GetStringFromConfig(viewAccessSection, KErrorCondition, errorCondition); |
|
189 RPointerArray <CViewContact> matchContactArray = iContactViewTest->GetContactsMatchingCriteriaL(findWords, viewBase, iContactUtility, errorCondition); |
|
190 CleanupClosePushL(matchContactArray); |
|
191 if(matchContactArray.Count() != 0) |
|
192 { |
|
193 iViewValidation->ValidateCountL(viewAccessSection, matchContactArray.Count()); |
|
194 } |
|
195 CleanupStack::PopAndDestroy(&matchContactArray); |
|
196 } |
|
197 |
|
198 TBool testContactsMatchingPrefix = EFalse; |
|
199 GetBoolFromConfig(viewAccessSection, KTestContactsMatchingPrefix, testContactsMatchingPrefix); |
|
200 |
|
201 // if contactsMatchingPrefix is set to true, then get the contacts where the contacts matches with the prefix |
|
202 if ( testContactsMatchingPrefix ) |
|
203 { |
|
204 TPtrC errorCondition; |
|
205 GetStringFromConfig(viewAccessSection, KErrorCondition, errorCondition); |
|
206 TPtrC searchWords; |
|
207 GetStringFromConfig(viewAccessSection, KSearchWords, searchWords); |
|
208 RPointerArray <CViewContact> matchContactArray = iContactViewTest->GetContactsMatchingPrefixL(searchWords, viewBase, iContactUtility, errorCondition); |
|
209 CleanupClosePushL(matchContactArray); |
|
210 if(matchContactArray.Count() != 0) |
|
211 { |
|
212 iViewValidation->ValidateCountL(viewAccessSection, matchContactArray.Count()); |
|
213 } |
|
214 CleanupStack::PopAndDestroy(&matchContactArray); |
|
215 } |
|
216 TBool testSearchContact = EFalse; |
|
217 GetBoolFromConfig(viewAccessSection, KTestSearchContactId, testSearchContact); |
|
218 |
|
219 // if testSearchContact is set to true, then get the contacts which is having that search word and verify its index |
|
220 if(testSearchContact) |
|
221 { |
|
222 TPtrC errorCondition; |
|
223 GetStringFromConfig(viewAccessSection, KErrorCondition, errorCondition); |
|
224 viewBase = iContactUtility->GetDesiredView(viewAccessSection); |
|
225 TPtrC searchWords; |
|
226 GetStringFromConfig(viewAccessSection, KSearchWords, searchWords); |
|
227 RPointerArray <CViewContact> matchContactArray = iContactViewTest->GetContactsMatchingCriteriaL(searchWords, viewBase, iContactUtility, errorCondition); |
|
228 CleanupClosePushL(matchContactArray); |
|
229 if(matchContactArray.Count()!=0 ) |
|
230 { |
|
231 TInt index = iContactViewTest->FindL(matchContactArray[0]->Id(), viewBase, errorCondition); |
|
232 iViewValidation->ValidateFindL(viewAccessSection, index); |
|
233 } |
|
234 else |
|
235 { |
|
236 ERR_PRINTF2(KContactNotFound, matchContactArray.Count()); |
|
237 SetTestStepResult(EFail); |
|
238 } |
|
239 CleanupStack::PopAndDestroy(&matchContactArray); |
|
240 } |
|
241 |
|
242 TBool testContactssortorderchange = EFalse; |
|
243 GetBoolFromConfig(viewAccessSection, KTestContactssortorderchange, testContactssortorderchange); |
|
244 |
|
245 // if testContactssortorderchange is set to true, then change the sort order of the desired view |
|
246 if ( testContactssortorderchange ) |
|
247 { |
|
248 iContactViewTest->TestChangeSortOrderL(viewAccessSection, iContactUtility); |
|
249 } |
|
250 CleanupStack::Pop(viewBase); |
|
251 } |
|
252 } |
|
253 |
|
254 /** |
|
255 * Verify and validate the Contact item id returned by the AtL() API |
|
256 * @param aSection ini section |
|
257 * @param aView desired view |
|
258 */ |
|
259 void CTestContactViewAccessStep::TestContactViewAtL(const TPtrC& aSection, CContactViewBase* aView) |
|
260 { |
|
261 TPtrC errorCondition; |
|
262 GetStringFromConfig(aSection, KErrorCondition, errorCondition); |
|
263 // Get the required data for AtL() API from the ini file |
|
264 TInt index = iContactViewTest->GetAtLApiDataFromIni(aSection); |
|
265 // Call the AtL() API by passing the index and the desired view |
|
266 TInt desiredContactItemId = iContactViewTest->AtL(index, aView, errorCondition); |
|
267 // validate the returned contact item id with the expected contact item id |
|
268 if(desiredContactItemId != -1) |
|
269 { |
|
270 iViewValidation->ValidateAtLApi(desiredContactItemId, aSection); |
|
271 } |
|
272 } |
|
273 |
|
274 /** |
|
275 * Verify and Validate the contact item returned by the ContactAtL() API |
|
276 * @param aSection ini section |
|
277 * @param aView desired view |
|
278 */ |
|
279 void CTestContactViewAccessStep::TestContactAtL(const TPtrC& aSection, CContactViewBase* aView) |
|
280 { |
|
281 TInt index = iContactViewTest->GetContactAtLApiDataFromIni(aSection); |
|
282 CViewContact* desiredContactItem = iContactViewTest->ContactAtL(index, aView); |
|
283 if(desiredContactItem != NULL) |
|
284 { |
|
285 CleanupStack::PushL(desiredContactItem); |
|
286 iViewValidation->ValidateContactAtLApi(desiredContactItem, aSection); |
|
287 CleanupStack::PopAndDestroy(desiredContactItem); |
|
288 } |
|
289 } |
|
290 |
|
291 /** |
|
292 * Verify and validate the count returned by the CountL() API |
|
293 * @param aSection ini section |
|
294 * @param aView desired view |
|
295 */ |
|
296 void CTestContactViewAccessStep::TestCountL(const TPtrC& aSection, CContactViewBase* aView) |
|
297 { |
|
298 TInt count = 0; |
|
299 TRAPD( err, count = aView->CountL()); |
|
300 if ( err != KErrNone ) |
|
301 { |
|
302 SetTestStepError(err); |
|
303 SetTestStepResult(EFail); |
|
304 } |
|
305 else |
|
306 { |
|
307 iViewValidation->ValidateCountL(aSection, count); |
|
308 } |
|
309 } |
|
310 |
|
311 /** |
|
312 * Verify and validate the index returned by the FindL() API |
|
313 * @param aSection ini section |
|
314 * @param aView desired view |
|
315 */ |
|
316 void CTestContactViewAccessStep::TestFindL(const TPtrC& aSection, CContactViewBase* aView) |
|
317 { |
|
318 TPtrC errorCondition; |
|
319 GetStringFromConfig(aSection, KErrorCondition, errorCondition); |
|
320 TInt id = iContactViewTest->GetFindLApiDataFromIni(aSection); |
|
321 TInt index = iContactViewTest->FindL(id, aView, errorCondition); |
|
322 if(index > -1) |
|
323 { |
|
324 iViewValidation->ValidateFindL(aSection, index); |
|
325 } |
|
326 } |
|
327 |
|
328 /** |
|
329 * Verify and validate the fields returned by the AllFieldsLC() API. |
|
330 * @param aSection ini section |
|
331 * @param aView desired view |
|
332 */ |
|
333 void CTestContactViewAccessStep::TestContactFieldsL(const TPtrC& aSection, CContactViewBase* aView) |
|
334 { |
|
335 HBufC* fields = NULL; |
|
336 TBool invalidData = EFalse; |
|
337 GetBoolFromConfig(aSection, KInvalidData, invalidData); |
|
338 if(invalidData) |
|
339 { |
|
340 //If ivalid data is passed then in udeb mode it is panic but in urel mode it is returning NULL |
|
341 #ifndef _DEBUG |
|
342 TRAPD( err, fields = iContactViewTest->GetAllFieldsLDataFromIniL(aSection, aView)); |
|
343 if ( err != KErrNone ) |
|
344 { |
|
345 SetTestStepError(err); |
|
346 SetTestStepResult(EFail); |
|
347 } |
|
348 else |
|
349 { |
|
350 if(fields != NULL) |
|
351 { |
|
352 // Append fields one by one to the fieldArray |
|
353 RArray<TPtrC> fieldArray; |
|
354 iContactUtility->TokenizeStringL(*fields, fieldArray); |
|
355 iViewValidation->ValidateAllFieldsL(aSection, fieldArray, aView, iContactViewTest); |
|
356 } |
|
357 else |
|
358 { |
|
359 INFO_PRINTF2(KInfoContactFields,&fields); |
|
360 SetTestStepResult(EFail); |
|
361 } |
|
362 } |
|
363 #else |
|
364 SetTestStepResult(EFail); |
|
365 #endif |
|
366 } |
|
367 else |
|
368 { |
|
369 TRAPD( err, fields = iContactViewTest->GetAllFieldsLDataFromIniL(aSection, aView)); |
|
370 if ( err != KErrNone ) |
|
371 { |
|
372 SetTestStepError(err); |
|
373 SetTestStepResult(EFail); |
|
374 } |
|
375 else |
|
376 { |
|
377 if(fields != NULL) |
|
378 { |
|
379 // Append fields one by one to the fieldArray |
|
380 RArray<TPtrC> fieldArray; |
|
381 iContactUtility->TokenizeStringL(*fields, fieldArray); |
|
382 iViewValidation->ValidateAllFieldsL(aSection, fieldArray, aView, iContactViewTest); |
|
383 } |
|
384 else |
|
385 { |
|
386 INFO_PRINTF2(KInfoContactFields,&fields); |
|
387 SetTestStepResult(EFail); |
|
388 } |
|
389 } |
|
390 } |
|
391 } |
|
392 |
|
393 /** |
|
394 * Verify and validate the contact view preferences |
|
395 * @param aSection ini section |
|
396 * @param aView desired view |
|
397 */ |
|
398 void CTestContactViewAccessStep::TestContactViewPreferencesL(const TPtrC& aSection, CContactViewBase* aView) |
|
399 { |
|
400 TContactViewPreferences desiredViewPreferences = iContactViewTest->ContactViewPreferences(aView); |
|
401 iViewValidation->ValidateViewPreferencesL(aSection, desiredViewPreferences, iContactUtility); |
|
402 } |
|
403 |
|
404 /** |
|
405 * Verify and validate the sort order returned by the SortOrderL() API |
|
406 * @param aSection ini section |
|
407 * @param aView desired view |
|
408 */ |
|
409 void CTestContactViewAccessStep::TestSortOrderL(const TPtrC& aSection, CContactViewBase* aView) |
|
410 { |
|
411 TPtrC errorCondition; |
|
412 GetStringFromConfig(aSection, KErrorCondition, errorCondition); |
|
413 // Get the sort order for the desired view |
|
414 RContactViewSortOrder contactViewSortOrder = iContactViewTest->GetSortOrderL(aView, errorCondition); |
|
415 // Get the uid's of the retrieved sort order |
|
416 TPtrC sortOrder; |
|
417 GetStringFromConfig(aSection, KSortOrder, sortOrder); |
|
418 RContactViewSortOrder viewSortOrder = iContactUtility->ConvertStringToSortOrderL(sortOrder); |
|
419 // iterate through the Uid's and validate them |
|
420 for ( TInt i = 0; i < contactViewSortOrder.Count(); ++i ) |
|
421 { |
|
422 TUid expectedUid = viewSortOrder[i]; |
|
423 TUid uid = contactViewSortOrder[i]; |
|
424 iViewValidation->ValidateSortOrderL(uid, expectedUid); |
|
425 } |
|
426 } |
|
427 |
|
428 /** |
|
429 * Create objects of CContactUtilitiesCollection, CContactViewApiTest and CContactViewValidation |
|
430 */ |
|
431 void CTestContactViewAccessStep::CreateUtilityClassL() |
|
432 { |
|
433 TBool createDataBase = ETrue; |
|
434 GetBoolFromConfig(ConfigSection(), SharedConstants::KCreateDataBase, createDataBase); |
|
435 GetStringFromConfig(ConfigSection(), SharedConstants::KDbName, iDbName); |
|
436 |
|
437 iCntDb = CreateAndOpenDataBaseL(iDbName, createDataBase); |
|
438 iViewCollection = CContactViewCollection::NewL(); |
|
439 // Create Utility class object, to export the contact from database |
|
440 CTestStep* self = static_cast<CTestStep*>(this); |
|
441 CleanupStack::PushL(self); |
|
442 iContactUtility = CContactUtilitiesCollection::NewL(*self, DatabaseReference(), ViewCollectionReference()); |
|
443 iContactViewTest = CContactViewApiTest::NewL(self); |
|
444 iViewValidation = new(ELeave) CContactViewValidation(self); |
|
445 CleanupStack::Pop(self); |
|
446 } |
|
447 |
|
448 /** |
|
449 * Return the database reference |
|
450 * @return iCntDb |
|
451 */ |
|
452 CContactDatabase& CTestContactViewAccessStep::DatabaseReference() |
|
453 { |
|
454 return *iCntDb; |
|
455 } |
|
456 |
|
457 /** |
|
458 * Return the viewcollection reference |
|
459 * @return iViewCollection |
|
460 */ |
|
461 CContactViewCollection& CTestContactViewAccessStep::ViewCollectionReference() |
|
462 { |
|
463 return *iViewCollection; |
|
464 } |
|
465 |
|
466 |
|
467 /** |
|
468 * Create and open the contact database |
|
469 * @param aDbName database to be created/ opened |
|
470 * @return CContactDatabase* |
|
471 */ |
|
472 CContactDatabase* CTestContactViewAccessStep::CreateAndOpenDataBaseL(const TPtrC& aDbName, TBool aCreateDataBase) |
|
473 { |
|
474 HBufC* dbName = HBufC::NewLC(aDbName.Length()); |
|
475 dbName->Des().Copy(aDbName); |
|
476 CContactDatabase* cntDb = NULL; |
|
477 if( aCreateDataBase ) |
|
478 { |
|
479 TInt err = 0; |
|
480 // Replace the existing database and opens it |
|
481 if( aDbName != KNullDesC() ) |
|
482 { |
|
483 TRAP(err, cntDb = CContactDatabase::ReplaceL(dbName->Des())); |
|
484 } |
|
485 else //if database name is not given then create and open the default DB |
|
486 { |
|
487 TRAP(err, cntDb = CContactDatabase::ReplaceL()); |
|
488 } |
|
489 |
|
490 if( err != KErrNone ) |
|
491 { |
|
492 ERR_PRINTF2(KErrInCreateDataBase, err); |
|
493 SetTestStepResult(EFail); |
|
494 SetTestStepError(err); |
|
495 } |
|
496 } |
|
497 else |
|
498 { |
|
499 TRAPD(err, cntDb = CContactDatabase::OpenL(dbName->Des())); |
|
500 if( err != KErrNone ) |
|
501 { |
|
502 ERR_PRINTF2(KErrInOpen, err); |
|
503 SetTestStepResult(EFail); |
|
504 SetTestStepError(err); |
|
505 } |
|
506 } |
|
507 CleanupStack::PopAndDestroy(dbName); |
|
508 return cntDb; |
|
509 } |
|
510 |
|
511 /** |
|
512 * Base class pure virtual. |
|
513 * @return EPass or EFail indicating the result of the test step. |
|
514 */ |
|
515 TVerdict CTestContactViewAccessStep::doTestStepPostambleL() |
|
516 { |
|
517 delete iViewCollection; |
|
518 iViewCollection = NULL; |
|
519 // Delete the database if the variable deleteDatabase is set to true |
|
520 TBool deleteDataBase = EFalse; |
|
521 GetBoolFromConfig(ConfigSection(), SharedConstants::KDeleteDataBase, deleteDataBase); |
|
522 delete iCntDb; |
|
523 iContactUtility->DeleteDataBase(deleteDataBase, iDbName); |
|
524 return CTestStep::doTestStepPostambleL(); |
|
525 } |
|
526 |
|
527 /** |
|
528 * Access Contact View Apis and validate their behaviour |
|
529 */ |
|
530 void CTestContactViewAccessStep::AccessViewsL() |
|
531 { |
|
532 TPtrC viewAccessList; |
|
533 GetStringFromConfig(ConfigSection(), KViewAccessList, viewAccessList); |
|
534 |
|
535 /* if the view access list is defined in the ini then test the views api's like CountL(), AtL(), ContactAtL(), |
|
536 FindL(), SortOrder(), ViewPreferences(), AllFieldsLC(), RefineFindView(), GetContactsMatchingCriteria() |
|
537 and GetContactsMatchingPrefix() for the desired view */ |
|
538 if ( viewAccessList != KNullDesC() ) |
|
539 { |
|
540 RArray<TPtrC> accessList; |
|
541 CleanupClosePushL(accessList); |
|
542 iContactUtility->TokenizeStringL(viewAccessList, accessList); |
|
543 TestViewAPIsL(accessList); |
|
544 CleanupStack::PopAndDestroy(&accessList); |
|
545 } |
|
546 } |
|
547 |
|
548 |
|
549 /** |
|
550 * Access Contact View Apis under backup restore conditions |
|
551 */ |
|
552 void CTestContactViewAccessStep::TestViewsUnderBackupRestoreL() |
|
553 { |
|
554 _LIT(KViewAccessUnderBackupRestore, "ViewAccessUnderBackupRestore"); |
|
555 TBool viewAccessUnderBackupRestore = EFalse; |
|
556 GetBoolFromConfig(ConfigSection(), KViewAccessUnderBackupRestore, viewAccessUnderBackupRestore); |
|
557 |
|
558 if(!viewAccessUnderBackupRestore) |
|
559 { |
|
560 return; |
|
561 } |
|
562 |
|
563 InitateBackupL(); |
|
564 AccessViewsL(); |
|
565 |
|
566 StopBackupL(); |
|
567 AccessViewsL(); |
|
568 |
|
569 InitiateRestoreL(); |
|
570 AccessViewsL(); |
|
571 |
|
572 StopRestoreL(); |
|
573 AccessViewsL(); |
|
574 } |
|
575 |
|
576 /** |
|
577 * Initate a system wide backup operation |
|
578 */ |
|
579 void CTestContactViewAccessStep::InitateBackupL() |
|
580 { |
|
581 iBackupHelper->StartBackupL(); |
|
582 } |
|
583 /** |
|
584 * Stop the system wide backup operation |
|
585 */ |
|
586 void CTestContactViewAccessStep::StopBackupL() |
|
587 { |
|
588 iBackupHelper->EndBackupL(); |
|
589 } |
|
590 /** |
|
591 * Initate a system wide restore operation |
|
592 */ |
|
593 void CTestContactViewAccessStep::InitiateRestoreL() |
|
594 { |
|
595 iBackupHelper->StartRestoreL(); |
|
596 } |
|
597 /** |
|
598 * Stop the system wide restore operation |
|
599 */ |
|
600 void CTestContactViewAccessStep::StopRestoreL() |
|
601 { |
|
602 iBackupHelper->EndBackupL(); |
|
603 } |
|
604 |
|
605 /** |
|
606 * Initate a system wide restore operation |
|
607 */ |
|
608 CBackupRestoreHelper* CBackupRestoreHelper::NewL(CTestStep& aTestStep) |
|
609 { |
|
610 CBackupRestoreHelper* self = new(ELeave) CBackupRestoreHelper(aTestStep); |
|
611 CleanupStack::PushL(self); |
|
612 self->ConstructL(); |
|
613 CleanupStack::Pop(self); |
|
614 return self; |
|
615 } |
|
616 |
|
617 |
|
618 /** |
|
619 * Class CBackupRestoreHelper - Constructor |
|
620 * @param aTestStep - Reference to current test step, used to read data from the ini file |
|
621 */ |
|
622 CBackupRestoreHelper::CBackupRestoreHelper(CTestStep& aTestStep) |
|
623 :iBaseTestStep(aTestStep) |
|
624 { |
|
625 } |
|
626 |
|
627 /** |
|
628 * Class CBackupRestoreHelper - second level constructor |
|
629 */ |
|
630 void CBackupRestoreHelper::ConstructL() |
|
631 { |
|
632 /** Initialise the drive list to empty and then get drive list data from |
|
633 File Server. |
|
634 Required before Backup and Restore testing |
|
635 */ |
|
636 iFs.Connect(); |
|
637 iDriveList.FillZ(); |
|
638 User::LeaveIfError(iFs.DriveList(iDriveList)); |
|
639 iBackupClient = conn::CSBEClient::NewL(); |
|
640 } |
|
641 |
|
642 /** |
|
643 * Class CBackupRestoreHelper - destructor |
|
644 */ |
|
645 CBackupRestoreHelper::~CBackupRestoreHelper() |
|
646 { |
|
647 delete iBackupClient; |
|
648 iFs.Close(); |
|
649 } |
|
650 |
|
651 /** |
|
652 * Uses the Secure Backup Engine API and starts a backup. |
|
653 */ |
|
654 void CBackupRestoreHelper::StartBackupL() |
|
655 { |
|
656 iBackupClient->SetBURModeL(iDriveList, conn::EBURBackupFull, conn::EBackupBase); |
|
657 } |
|
658 |
|
659 /** |
|
660 * Uses the Secure Backup Engine API and ends backup. |
|
661 */ |
|
662 void CBackupRestoreHelper::EndBackupL() |
|
663 { |
|
664 iBackupClient->SetBURModeL(iDriveList, conn::EBURNormal, conn::ENoBackup); |
|
665 } |
|
666 |
|
667 /** |
|
668 * Uses the Secure Backup Engine API and starts a restore. |
|
669 */ |
|
670 void CBackupRestoreHelper::StartRestoreL() |
|
671 { |
|
672 iBackupClient->SetBURModeL(iDriveList, conn::EBURRestoreFull, conn::EBackupBase); |
|
673 } |
|
674 |
|
675 /** |
|
676 * Uses the Secure Backup Engine API and ends restore. |
|
677 */ |
|
678 void CBackupRestoreHelper::EndRestoreL() |
|
679 { |
|
680 /** Use the Secure Backup Engine API to "end" a restore. */ |
|
681 iBackupClient->SetBURModeL(iDriveList, conn::EBURNormal, conn::ENoBackup); |
|
682 } |
|
683 |
|
684 |
|
685 /** |
|
686 * Reference to TestStep, used for retreiving ini data, printing operations etc.. |
|
687 */ |
|
688 CTestStep& CBackupRestoreHelper::BaseTestStepReference() |
|
689 { |
|
690 return(iBaseTestStep); |
|
691 } |