summaryrefslogtreecommitdiffstats
path: root/plugins/contacts/symbian/contactsmodel/tsrc/integration/cntperftest/src/testcontactviewaccessstep.cpp
blob: c5181d21f399c6dd508c9c34b5b92d1087718974 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
/*
* Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
* Contact: http://www.qt-project.org/legal
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*
*/


#include "testcontactviewaccessstep.h"

/**
 * Constructor
 */
CTestContactViewAccessStep::CTestContactViewAccessStep()
	{
	// Unique loggind Id for the test step
	SetTestStepName(KTestContactViewAccessStep);
	}

/**
 * Destructor
 */
CTestContactViewAccessStep::~CTestContactViewAccessStep()
	{

	if(iViewCollection)
		{
		delete iViewCollection;
		}
	delete iViewValidation;
	delete iContactViewTest;
	delete iContactUtility;
	delete iBackupHelper;
	}

/**
 * Base class pure virtual.
 * @return	EPass or EFail indicating the result of the test step.
 */
TVerdict CTestContactViewAccessStep::doTestStepPreambleL()
	{
	iActiveScheduler = new (ELeave) CActiveScheduler;
	CActiveScheduler::Install(iActiveScheduler);

	CTestStep* self = static_cast<CTestStep*>(this);
 	iBackupHelper = CBackupRestoreHelper::NewL(*self);

	// Create utility objects
	CreateUtilityClassL();

	// File from where contacts must be imported
	TPtrC	importFileName;
	TBool	filePresent;
	filePresent = GetStringFromConfig(ConfigSection(), SharedConstants::KFileToBeImported, importFileName);

	TBool	pbapBased = EFalse;
	GetBoolFromConfig(ConfigSection(), SharedConstants::KVCardVersionPBAP, pbapBased);
	if(filePresent)
		{
		iContactUtility->ImportVcardContactsL(importFileName, pbapBased);
		}

	return CTestStep::doTestStepPreambleL();
	}

/**
 * Base class pure virtual.
 * @return EPass or EFail indicating the result of the test step.
 */
TVerdict CTestContactViewAccessStep::doTestStepL()
	{
	TPtrC	listOfViews;
	GetStringFromConfig(ConfigSection(), SharedConstants::KListOfViews, listOfViews);

	/* Get the list of views from ini and construct the view like local view/remote view/named remote view/
	   find view/filtered view/group view/concatenated view or sub view based on the requirement */
	RArray<TPtrC>	sections;
	iContactUtility->TokenizeStringL(listOfViews, sections);
	iContactUtility->ConstructViewsL(sections); //section is destroyed in ConstructViewsL

	AccessViewsL();
	TestViewsUnderBackupRestoreL();

	return TestStepResult();
	}

/**
 * Test the view API's like AtL(), AllFieldsLC(), ContactAtL(), ContactL(), CountL(), SortOrder(),
 * ViewPreferences(), RefineFindView(), ContactsMatchingCriteria() and ContactsMatchingPrefixL()
 * based on the sections given in the ini file.
 * @param aSection ini sections
 */
void CTestContactViewAccessStep::TestViewAPIsL(const RArray<TPtrC>& aSection)
	{
	// Based on the data specified in the ini file, test the view API's
	for ( TInt i = 0; i < aSection.Count(); ++i )
		{		
		TPtrC	viewAccessSection = aSection[i];
		
		// Get the desired view based on the input given from the ini file	
		CContactViewBase*	viewBase = iContactUtility->GetDesiredView(viewAccessSection);	
		CleanupStack::PushL(viewBase);
			
		TBool	testAtLAPI = EFalse;
		GetBoolFromConfig(viewAccessSection, KTestAtLAPI, testAtLAPI);	
		if ( testAtLAPI )
			{			
			// Function to test the AtL() API which returns the contact item id for the specified index
			TestContactViewAtL(viewAccessSection, viewBase);
			}

		TBool	testContactAtLAPI = EFalse;
		GetBoolFromConfig(viewAccessSection, KTestContactAtLAPI, testContactAtLAPI);
		if ( testContactAtLAPI )
			{			
			// Function to test the ContactAtL() API which returns the contact item
			TestContactAtL(viewAccessSection, viewBase);
			}

		TBool	testCountLAPI = EFalse;
		GetBoolFromConfig(viewAccessSection, KTestCountLAPI, testCountLAPI);
		if ( testCountLAPI )
			{
			// Function to test the CountL() which returns the no. of contact items in the view
			TestCountL(viewAccessSection, viewBase);
			}

		TBool	testAllFieldsAPI = EFalse;
		GetBoolFromConfig(viewAccessSection, KTestAllFieldsAPI, testAllFieldsAPI);
		if ( testAllFieldsAPI )
			{
			// Function to test the AllFieldsLC() API which returns the fields of the contact item
			TestContactFieldsL(viewAccessSection, viewBase);
			}

		TBool	testFindLAPI = EFalse;
		GetBoolFromConfig(viewAccessSection, KTestFindLAPI, testFindLAPI);
		if ( testFindLAPI )
			{
			// Function to test the FindL() API which returns the index of the contact item
			TestFindL(viewAccessSection, viewBase);
			}

		TBool	testSortOrder = EFalse;
		GetBoolFromConfig(viewAccessSection, KTestSortOrder, testSortOrder);
		if ( testSortOrder )
			{
			// Function to test the SortOrder() API which returns the view's sort order
			TestSortOrderL(viewAccessSection, viewBase);
			}

		TBool	testViewPreferences = EFalse;
		GetBoolFromConfig(viewAccessSection, KTestViewPreferences, testViewPreferences);
		if ( testViewPreferences )
			{
			// Function to test the ViewPreferences() API which returns the view preferences
			TestContactViewPreferencesL(viewAccessSection, viewBase);
			}

		TBool	refineFindView = EFalse;
		GetBoolFromConfig(viewAccessSection, KRefineFindView, refineFindView);
		if ( refineFindView )
			{
			TInt	index;
			GetIntFromConfig(viewAccessSection, SharedConstants::KIndex, index);
			// Get the desired view based on the input given from the ini file
			CContactFindView* view = iViewCollection->GetDesiredFindView(index);
			TPtrC	searchWords;
			GetStringFromConfig(viewAccessSection, KSearchWords, searchWords);
			iContactViewTest->RefineFindViewL(searchWords, view, iContactUtility);
			}
			
		TBool	testContactsMatchingCriteria = EFalse;
		GetBoolFromConfig(viewAccessSection, KTestContactsMatchingCriteria, testContactsMatchingCriteria);
		// if contactMatchingCriteria is set to true, then get the contacts matching the specified words
		if ( testContactsMatchingCriteria )
			{			
			TPtrC	findWords;
			GetStringFromConfig(viewAccessSection, KFindWords, findWords);
			TPtrC	errorCondition;
			GetStringFromConfig(viewAccessSection, KErrorCondition, errorCondition);
			RPointerArray <CViewContact> matchContactArray = iContactViewTest->GetContactsMatchingCriteriaL(findWords, viewBase, iContactUtility, errorCondition);
			CleanupClosePushL(matchContactArray);
			if(matchContactArray.Count() != 0)
				{
				iViewValidation->ValidateCountL(viewAccessSection, matchContactArray.Count());
				}			
			CleanupStack::PopAndDestroy(&matchContactArray);
			}

		TBool	testContactsMatchingPrefix = EFalse;
		GetBoolFromConfig(viewAccessSection, KTestContactsMatchingPrefix, testContactsMatchingPrefix);

		// if contactsMatchingPrefix is set to true, then get the contacts where the contacts matches with the prefix
		if ( testContactsMatchingPrefix )
			{			
			TPtrC	errorCondition;
			GetStringFromConfig(viewAccessSection, KErrorCondition, errorCondition);
			TPtrC	searchWords;
			GetStringFromConfig(viewAccessSection, KSearchWords, searchWords);
			RPointerArray <CViewContact> matchContactArray = iContactViewTest->GetContactsMatchingPrefixL(searchWords, viewBase, iContactUtility, errorCondition);
			CleanupClosePushL(matchContactArray);
			if(matchContactArray.Count() != 0)
				{
				iViewValidation->ValidateCountL(viewAccessSection, matchContactArray.Count());	
				}			
			CleanupStack::PopAndDestroy(&matchContactArray);
			}
		TBool	testSearchContact = EFalse;
		GetBoolFromConfig(viewAccessSection, KTestSearchContactId, testSearchContact);
		
		// if testSearchContact is set to true, then get the contacts which is having that search word and verify its index
		if(testSearchContact)
			{
			TPtrC	errorCondition;			
			GetStringFromConfig(viewAccessSection, KErrorCondition, errorCondition);
			viewBase = iContactUtility->GetDesiredView(viewAccessSection);
			TPtrC	searchWords;
			GetStringFromConfig(viewAccessSection, KSearchWords, searchWords);
			RPointerArray <CViewContact> matchContactArray = iContactViewTest->GetContactsMatchingCriteriaL(searchWords, viewBase, iContactUtility, errorCondition);
			CleanupClosePushL(matchContactArray);			
			if(matchContactArray.Count()!=0 )
				{
				TInt	index = iContactViewTest->FindL(matchContactArray[0]->Id(), viewBase, errorCondition);
				iViewValidation->ValidateFindL(viewAccessSection, index);
				}
			else
				{
				ERR_PRINTF2(KContactNotFound, matchContactArray.Count());
				SetTestStepResult(EFail);
				}			
			CleanupStack::PopAndDestroy(&matchContactArray);
			}
		
		TBool	testContactssortorderchange = EFalse;
		GetBoolFromConfig(viewAccessSection, KTestContactssortorderchange, testContactssortorderchange);	
		
		// if testContactssortorderchange is set to true, then change the sort order of the desired view
		if ( testContactssortorderchange )
			{				
			iContactViewTest->TestChangeSortOrderL(viewAccessSection, iContactUtility);			
			}
		CleanupStack::Pop(viewBase);
		}
	}

/**
 * Verify and validate the Contact item id returned by the AtL() API
 * @param aSection ini section
 * @param aView desired view
 */
void CTestContactViewAccessStep::TestContactViewAtL(const TPtrC& aSection, CContactViewBase* aView)
	{
	TPtrC	errorCondition;
	GetStringFromConfig(aSection, KErrorCondition, errorCondition);
	// Get the required data for AtL() API from the ini file
	TInt	index = iContactViewTest->GetAtLApiDataFromIni(aSection);
	// Call the AtL() API by passing the index and the desired view
	TInt	desiredContactItemId = iContactViewTest->AtL(index, aView, errorCondition);
	// validate the returned contact item id with the expected contact item id
	if(desiredContactItemId != -1)
		{
		iViewValidation->ValidateAtLApi(desiredContactItemId, aSection);
		}
	}

/**
 * Verify and Validate the contact item returned by the ContactAtL() API
 * @param aSection ini section
 * @param aView desired view
 */
void CTestContactViewAccessStep::TestContactAtL(const TPtrC& aSection, CContactViewBase* aView)
	{
	TInt	index = iContactViewTest->GetContactAtLApiDataFromIni(aSection);
	CViewContact*	desiredContactItem = iContactViewTest->ContactAtL(index, aView);
	if(desiredContactItem != NULL)
		{
		CleanupStack::PushL(desiredContactItem);
		iViewValidation->ValidateContactAtLApi(desiredContactItem, aSection);
		CleanupStack::PopAndDestroy(desiredContactItem);
		}
	}

/**
 * Verify and validate the count returned by the CountL() API
 * @param aSection ini section
 * @param aView desired view
 */
void CTestContactViewAccessStep::TestCountL(const TPtrC& aSection, CContactViewBase* aView)
	{
	TInt count = 0;
	TRAPD( err, count = aView->CountL());
	if ( err != KErrNone )
		{
		SetTestStepError(err);
		SetTestStepResult(EFail);
		}
	else
		{
		iViewValidation->ValidateCountL(aSection, count);
		}	
	}

/**
 * Verify and validate the index returned by the FindL() API
 * @param aSection ini section
 * @param aView desired view
 */
void CTestContactViewAccessStep::TestFindL(const TPtrC& aSection, CContactViewBase* aView)
	{
	TPtrC	errorCondition;
	GetStringFromConfig(aSection, KErrorCondition, errorCondition);
	TInt	id = iContactViewTest->GetFindLApiDataFromIni(aSection);
	TInt	index = iContactViewTest->FindL(id, aView, errorCondition);
	if(index > -1)
		{
		iViewValidation->ValidateFindL(aSection, index);
		}	
	}

/**
 * Verify and validate the fields returned by the AllFieldsLC() API.
 * @param aSection ini section
 * @param aView desired view
 */
void CTestContactViewAccessStep::TestContactFieldsL(const TPtrC& aSection, CContactViewBase* aView)
	{
	HBufC* fields = NULL;
	TBool invalidData = EFalse;	
	GetBoolFromConfig(aSection, KInvalidData, invalidData);	
	if(invalidData)
		{
		//If ivalid data is passed then in udeb mode it is panic but in urel mode it is returning NULL
		#ifndef _DEBUG						
		TRAPD( err, fields = iContactViewTest->GetAllFieldsLDataFromIniL(aSection, aView));
		if ( err != KErrNone )
			{
			SetTestStepError(err);
			SetTestStepResult(EFail);
			}
		else
			{
			if(fields != NULL)
				{
				// Append fields one by one to the fieldArray
				RArray<TPtrC>	fieldArray;
				iContactUtility->TokenizeStringL(*fields, fieldArray);
				iViewValidation->ValidateAllFieldsL(aSection, fieldArray, aView, iContactViewTest);
				}
			else
				{
				INFO_PRINTF2(KInfoContactFields,&fields);
				SetTestStepResult(EFail);
				}
			}			
		#else
			SetTestStepResult(EFail);
		#endif
		}
	else
		{
		TRAPD( err, fields = iContactViewTest->GetAllFieldsLDataFromIniL(aSection, aView));
			if ( err != KErrNone )
				{
				SetTestStepError(err);
				SetTestStepResult(EFail);
				}
			else
				{
				if(fields != NULL)
					{
					// Append fields one by one to the fieldArray
					RArray<TPtrC>	fieldArray;
					iContactUtility->TokenizeStringL(*fields, fieldArray);
					iViewValidation->ValidateAllFieldsL(aSection, fieldArray, aView, iContactViewTest);
					}
				else
					{
					INFO_PRINTF2(KInfoContactFields,&fields);
					SetTestStepResult(EFail);
					}
				}
			}
	}

/**
 * Verify and validate the contact view preferences
 * @param aSection ini section
 * @param aView desired view
 */
void CTestContactViewAccessStep::TestContactViewPreferencesL(const TPtrC& aSection, CContactViewBase* aView)
	{
	TContactViewPreferences	desiredViewPreferences = iContactViewTest->ContactViewPreferences(aView);
	iViewValidation->ValidateViewPreferencesL(aSection, desiredViewPreferences, iContactUtility);
	}

/**
 * Verify and validate the sort order returned by the SortOrderL() API
 * @param aSection ini section
 * @param aView desired view
 */
void CTestContactViewAccessStep::TestSortOrderL(const TPtrC& aSection, CContactViewBase* aView)
	{
	TPtrC	errorCondition;
	GetStringFromConfig(aSection, KErrorCondition, errorCondition);
	// Get the sort order for the desired view
	RContactViewSortOrder	contactViewSortOrder = iContactViewTest->GetSortOrderL(aView, errorCondition);
	// Get the uid's of the retrieved sort order
	TPtrC	sortOrder;
	GetStringFromConfig(aSection, KSortOrder, sortOrder);
	RContactViewSortOrder	viewSortOrder =	iContactUtility->ConvertStringToSortOrderL(sortOrder);	
	// iterate through the Uid's and validate them
	for ( TInt i = 0; i < contactViewSortOrder.Count(); ++i )	
		{
		TUid	expectedUid = viewSortOrder[i];
		TUid	uid = contactViewSortOrder[i];		
		iViewValidation->ValidateSortOrderL(uid, expectedUid);
		}
	}

/**
 * Create objects of CContactUtilitiesCollection, CContactViewApiTest and CContactViewValidation
 */
void CTestContactViewAccessStep::CreateUtilityClassL()
	{
	TBool	createDataBase = ETrue;
	GetBoolFromConfig(ConfigSection(), SharedConstants::KCreateDataBase, createDataBase);
	GetStringFromConfig(ConfigSection(), SharedConstants::KDbName, iDbName);

	iCntDb = CreateAndOpenDataBaseL(iDbName, createDataBase);
	iViewCollection = CContactViewCollection::NewL();
	// Create Utility class object, to export the contact from database
	CTestStep* self = static_cast<CTestStep*>(this);
	CleanupStack::PushL(self);
	iContactUtility = CContactUtilitiesCollection::NewL(*self, DatabaseReference(), ViewCollectionReference());
	iContactViewTest = CContactViewApiTest::NewL(self);
	iViewValidation = new(ELeave) CContactViewValidation(self);
	CleanupStack::Pop(self);
	}

/**
 * Return the database reference
 * @return iCntDb 
 */
CContactDatabase& CTestContactViewAccessStep::DatabaseReference()
	{
	return *iCntDb;
	}

/**
 * Return the viewcollection reference
 * @return  iViewCollection 
 */
CContactViewCollection& CTestContactViewAccessStep::ViewCollectionReference()
	{
	return *iViewCollection;
	}


/**
 * Create and open the contact database
 * @param aDbName database to be created/ opened
 * @return CContactDatabase*
 */
CContactDatabase* CTestContactViewAccessStep::CreateAndOpenDataBaseL(const TPtrC& aDbName, TBool aCreateDataBase)
	{
	HBufC*	dbName = HBufC::NewLC(aDbName.Length());
	dbName->Des().Copy(aDbName);
	CContactDatabase*	cntDb = NULL;
	if( aCreateDataBase )
		{
		TInt	err = 0;
		// Replace the existing database and opens it
		if( aDbName != KNullDesC() )
			{
			TRAP(err, cntDb = CContactDatabase::ReplaceL(dbName->Des()));
			}
		else //if database name is not given then create and open the default DB
			{
			TRAP(err, cntDb = CContactDatabase::ReplaceL());
			}

		if( err != KErrNone )
			{
			ERR_PRINTF2(KErrInCreateDataBase, err);
			SetTestStepResult(EFail);
			SetTestStepError(err);
			}
		}
	else
		{
		TRAPD(err, cntDb = CContactDatabase::OpenL(dbName->Des()));
		if( err != KErrNone )
			{
			ERR_PRINTF2(KErrInOpen, err);
			SetTestStepResult(EFail);
			SetTestStepError(err);
			}
		}
	CleanupStack::PopAndDestroy(dbName);
	return	cntDb;
	}

/**
 * Base class pure virtual.
 * @return		EPass or EFail indicating the result of the test step.
 */
TVerdict CTestContactViewAccessStep::doTestStepPostambleL()
	{
	delete iViewCollection;
	iViewCollection = NULL;
	// Delete the database if the variable deleteDatabase is set to true
	TBool	deleteDataBase = EFalse;
	GetBoolFromConfig(ConfigSection(), SharedConstants::KDeleteDataBase, deleteDataBase);
	delete iCntDb;
	iContactUtility->DeleteDataBase(deleteDataBase, iDbName);
	return CTestStep::doTestStepPostambleL();
	}

/**
 * Access Contact View Apis and validate their behaviour
 */
void CTestContactViewAccessStep::AccessViewsL()
	{
	TPtrC	viewAccessList;
	GetStringFromConfig(ConfigSection(), KViewAccessList, viewAccessList);

	/* if the view access list is defined in the ini then test the views api's like CountL(), AtL(), ContactAtL(),
	   FindL(), SortOrder(), ViewPreferences(), AllFieldsLC(), RefineFindView(), GetContactsMatchingCriteria()
	   and GetContactsMatchingPrefix() for the desired view */
	if ( viewAccessList != KNullDesC() )
		{
		RArray<TPtrC>	accessList;
		CleanupClosePushL(accessList);
		iContactUtility->TokenizeStringL(viewAccessList, accessList);
		TestViewAPIsL(accessList);
		CleanupStack::PopAndDestroy(&accessList);
		}
	}


/**
 * Access Contact View Apis under backup restore conditions
 */
void CTestContactViewAccessStep::TestViewsUnderBackupRestoreL()
	{
	_LIT(KViewAccessUnderBackupRestore, "ViewAccessUnderBackupRestore");
	TBool	viewAccessUnderBackupRestore = EFalse;
	GetBoolFromConfig(ConfigSection(), KViewAccessUnderBackupRestore, viewAccessUnderBackupRestore);
	
	if(!viewAccessUnderBackupRestore)
		{
		return;	
		}

	InitateBackupL();
	AccessViewsL();

	StopBackupL();
	AccessViewsL();

	InitiateRestoreL();
	AccessViewsL();

	StopRestoreL();
	AccessViewsL();
	}

/**
 * Initate a system wide backup operation
 */
void CTestContactViewAccessStep::InitateBackupL()
	{
	iBackupHelper->StartBackupL();
	}
/**
 * Stop the system wide backup operation
 */
void CTestContactViewAccessStep::StopBackupL()
	{
	iBackupHelper->EndBackupL();
	}
/**
 * Initate a system wide restore operation
 */
void CTestContactViewAccessStep::InitiateRestoreL()
	{
	iBackupHelper->StartRestoreL();
	}
/**
 * Stop the system wide restore operation
 */
void CTestContactViewAccessStep::StopRestoreL()
	{
	iBackupHelper->EndBackupL();
	}

/**
 * Initate a system wide restore operation
 */
CBackupRestoreHelper* CBackupRestoreHelper::NewL(CTestStep& aTestStep)
	{
	CBackupRestoreHelper* self = new(ELeave) CBackupRestoreHelper(aTestStep);
	CleanupStack::PushL(self);
	self->ConstructL();
	CleanupStack::Pop(self);
	return self;
	}


/**
 * Class CBackupRestoreHelper - Constructor
 * @param aTestStep - Reference to current test step, used to read data from the ini file
 */
CBackupRestoreHelper::CBackupRestoreHelper(CTestStep& aTestStep)
:iBaseTestStep(aTestStep)
	{
	}

/**
 * Class CBackupRestoreHelper - second level constructor
 */
void CBackupRestoreHelper::ConstructL()
	{
	/** Initialise the drive list to empty and then get drive list data from
	 File Server.
	 Required before Backup and Restore testing
	 */
	iFs.Connect();
	iDriveList.FillZ();
	User::LeaveIfError(iFs.DriveList(iDriveList));
	iBackupClient = conn::CSBEClient::NewL();
	}

/**
 * Class CBackupRestoreHelper - destructor
 */
CBackupRestoreHelper::~CBackupRestoreHelper()
	{
	delete iBackupClient;
	iFs.Close();
	}

/**
 * Uses the Secure Backup Engine API  and starts a backup.
 */
void CBackupRestoreHelper::StartBackupL()
	{
	iBackupClient->SetBURModeL(iDriveList, conn::EBURBackupFull, conn::EBackupBase);
	}

/**
 * Uses the Secure Backup Engine API  and ends backup.
 */
void CBackupRestoreHelper::EndBackupL()
	{
	iBackupClient->SetBURModeL(iDriveList, conn::EBURNormal, conn::ENoBackup);
	}

/**
 * Uses the Secure Backup Engine API  and starts a restore.
 */
void CBackupRestoreHelper::StartRestoreL()
	{
	iBackupClient->SetBURModeL(iDriveList, conn::EBURRestoreFull, conn::EBackupBase);
	}

/**
 * Uses the Secure Backup Engine API  and ends restore.
 */
void CBackupRestoreHelper::EndRestoreL()
	{
	/** Use the Secure Backup Engine API to "end" a restore. */
	iBackupClient->SetBURModeL(iDriveList, conn::EBURNormal, conn::ENoBackup);
	}


/**
 * Reference to TestStep, used for retreiving ini data, printing operations etc.. 
 */
CTestStep& CBackupRestoreHelper::BaseTestStepReference()
	{
	return(iBaseTestStep);
	}