backupandrestore/backuptest/burtestserver/TestSteps/src/t_teststepbackup2.cpp
changeset 0 d0791faffa3f
child 11 f5809cfbf6d5
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 2004-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 /**
       
    17  @file
       
    18  @released
       
    19 */
       
    20 
       
    21 #include <connect/sbtypes.h>
       
    22 #include "t_teststepbackup2.h"
       
    23 #include <apgcli.h>
       
    24 
       
    25 namespace bur_ts
       
    26 	{	
       
    27 		
       
    28 	CBURTestStepBackup2* CBURTestStepBackup2::NewL(CBURTestServer& aTestServer)
       
    29 		/**
       
    30 		Symbian OS Constructor
       
    31 		
       
    32 		@internalComponent
       
    33 		@released
       
    34 		
       
    35 		@param aParent - The parent CBURTestServer of this child test step.
       
    36 		@return Pointer to a newly created CBURTestStepBackup2 object.
       
    37 		*/
       
    38 		{
       
    39 		CBURTestStepBackup2* self = new (ELeave) CBURTestStepBackup2(aTestServer);
       
    40 		CleanupStack::PushL(self);
       
    41 		self->ConstructL();
       
    42 		CleanupStack::Pop();
       
    43 		return self;
       
    44 		}
       
    45 
       
    46 	CBURTestStepBackup2::CBURTestStepBackup2(CBURTestServer& aTestServer)
       
    47 		/**
       
    48 		C++ Constructor
       
    49 		
       
    50 		@internalComponent
       
    51 		@released
       
    52 		
       
    53 		@param aParent - The parent CBURTestServer of this child test step.
       
    54 		*/
       
    55 		: CBURTestStepBase(aTestServer), iDataTransferHandler(NULL)
       
    56 		{}
       
    57 	
       
    58 	void CBURTestStepBackup2::ConstructL()
       
    59 		/**
       
    60 		Symbian OS 2nd-phase Constructor
       
    61 		
       
    62 		@internalComponent
       
    63 		@released
       
    64 		*/
       
    65 		{
       
    66 		TInt error;
       
    67 		
       
    68 		// Initialise the drive list to empty
       
    69 		iDriveList.FillZ();
       
    70 		
       
    71 		User::LeaveIfError(iFs.Connect());
       
    72 		
       
    73 		// Install an active scheduler for this test step
       
    74 		iActiveScheduler = new(ELeave) CActiveScheduler;
       
    75 		CActiveScheduler::Install(iActiveScheduler);
       
    76 		
       
    77 		TRAP(error, iBackupClient = CSBEClient::NewL());
       
    78 		if (error != KErrNone)
       
    79 			{
       
    80 			_LIT(KClientConnection, "SBEClientConnection");
       
    81 			User::Panic(KClientConnection,error);
       
    82 			}
       
    83 			
       
    84 		_LIT(KBURTBackup, "BURTestServerBackup");
       
    85 		User::RenameThread(KBURTBackup);
       
    86 		//User::SetCritical(User::ESystemCritical);
       
    87 		
       
    88 		SetTestStepName(KBURTestBackup2);
       
    89 		}
       
    90 	
       
    91 	CBURTestStepBackup2::~CBURTestStepBackup2()
       
    92 		/**
       
    93 		C++ Destructor
       
    94 		
       
    95 		@internalComponent
       
    96 		@released
       
    97 		*/
       
    98 		{
       
    99 		delete iDataTransferHandler;
       
   100 		}
       
   101 
       
   102 	TVerdict CBURTestStepBackup2::doTestStepPreambleL()
       
   103 		/**
       
   104 		Override of base class virtual function
       
   105 		
       
   106 		@internalComponent
       
   107 		@released
       
   108 		
       
   109 		@return TVerdict code
       
   110 		*/
       
   111 		{
       
   112 		SetTestStepResult(EPass);
       
   113 		return TestStepResult();
       
   114 		}
       
   115 
       
   116 	TVerdict CBURTestStepBackup2::doTestStepL()
       
   117 		/**
       
   118 		Override of base class pure virtual
       
   119 		
       
   120 		@internalComponent
       
   121 		@released
       
   122 		
       
   123 		@return TVerdict code
       
   124 		*/
       
   125 		{
       
   126 		_LIT(KLog1, "Processing user options...");
       
   127 		Log(LOG_LEVEL2, KLog1);
       
   128 		ProcessUserOptionsL();
       
   129 		
       
   130 		// Get a list of data owners:
       
   131 		PopulateListOfDataOwnersL();
       
   132 		
       
   133 		TBURPartType type = EBURBackupFull;
       
   134 		
       
   135 		if (iIsPartial)
       
   136 			{
       
   137 			_LIT(KLog2, "Preparing for PARTIAL backup...");
       
   138 			Log(LOG_LEVEL2, KLog2);
       
   139 			type = EBURBackupPartial;
       
   140 			PrepareForPartialBURL();
       
   141 			SetSIDListForPartialL();
       
   142 			}
       
   143 		else
       
   144 			{
       
   145 			_LIT(KLog3, "Preparing for FULL backup...");
       
   146 			Log(LOG_LEVEL2, KLog3);
       
   147 			}
       
   148 		
       
   149 		CheckValidRegistrationL();
       
   150 		
       
   151 		_LIT(KLog4, "Saving Data Owners...");
       
   152 		Log(LOG_LEVEL2, KLog4);
       
   153 		SaveDataOwners();
       
   154 		
       
   155 		Log(LOG_LEVEL2, _L("Setting backup mode..."));
       
   156 		TRAPD(err,SetBURModeL(type, iBackupIncType));
       
   157 		if (err != KErrNone)
       
   158 			{
       
   159 			_LIT(KBURError, "Error setting Backup mode ");
       
   160 			Log(LOG_LEVEL3, KBURError);
       
   161 			}
       
   162 		
       
   163 		iDataTransferHandler = CAsyncBackupTransferHandler::NewL(this);
       
   164 		Log(LOG_LEVEL2, _L("Starting backup..."));
       
   165 		
       
   166 		//BackupRegistrationDataL();
       
   167 		
       
   168 		BackupPublicDataL();
       
   169 		
       
   170 		BackupJavaMidletsL();
       
   171 		BackupJavaMidletsDataL();
       
   172 		
       
   173 		// Backup data according to user preferences
       
   174 		if (iBackupIncType == EBackupIncrement)
       
   175 			{
       
   176 			IncrementalBackupL();
       
   177 			}
       
   178 		else
       
   179 			{
       
   180 			BaseBackupL();
       
   181 			}
       
   182 		GetLargePublicFileListL();
       
   183 		Log(LOG_LEVEL2, _L("Setting backup mode to Normal ..."));
       
   184 		TRAPD(err2,SetBURModeL(EBURNormal, ENoBackup));
       
   185 		if (err2 != KErrNone)
       
   186 			{
       
   187 			_LIT(KBURError, "Error setting Backup mode ");
       
   188 			Log(LOG_LEVEL3, KBURError);
       
   189 			}
       
   190 		
       
   191 		TestSetBURMode();
       
   192 		
       
   193 		return TestStepResult();
       
   194 		}
       
   195 	
       
   196 	void CBURTestStepBackup2::BaseBackupL()
       
   197 		/**
       
   198 		@internalComponent
       
   199 		@released
       
   200 		*/
       
   201 		{
       
   202 		// system data
       
   203 		BackupSystemBaseDataL();
       
   204 		BackupSystemSnapshotDataL();
       
   205 		
       
   206 		//active
       
   207 		BackupActiveBaseDataL();
       
   208 		BackupActiveSnapshotDataL();
       
   209 		
       
   210 		//passive
       
   211 		BackupPassiveBaseDataL();
       
   212 		BackupPassiveSnapshotDataL();
       
   213 		}
       
   214 	
       
   215 	void CBURTestStepBackup2::IncrementalBackupL()
       
   216 		/**
       
   217 		@internalComponent
       
   218 		@released
       
   219 		*/
       
   220 		{
       
   221 		_LIT(KInc, "Backup mode: INCREMENTAL");
       
   222 		Log(LOG_LEVEL2, KInc);
       
   223 		//active
       
   224 		SupplySystemSnapshotDataL();
       
   225 		SupplyActiveSnapshotDataL();
       
   226 		SupplyPassiveSnapshotDataL();
       
   227 		TRAPD(err,iBackupClient->AllSnapshotsSuppliedL());
       
   228 		if (err != KErrNone)
       
   229 			{
       
   230 			_LIT(KSnapErr, "Error Supplying Snapshot Data ");
       
   231 			LogWithNum(LOG_LEVEL3, KSnapErr, err);
       
   232 			}
       
   233 		else
       
   234 			{
       
   235 			_LIT(KSnap, "All Snapshots Supplied");
       
   236 			Log(LOG_LEVEL3, KSnap);
       
   237 			}
       
   238 			
       
   239 		// system data
       
   240 		BackupSystemBaseDataL();
       
   241 		BackupSystemSnapshotDataL();
       
   242 		
       
   243 		// active
       
   244 		BackupActiveIncDataL();
       
   245 		BackupActiveSnapshotDataL();
       
   246 		
       
   247 		//passive
       
   248 		BackupPassiveIncDataL();
       
   249 		BackupPassiveSnapshotDataL();
       
   250 		}
       
   251 		
       
   252 	void CBURTestStepBackup2::BackupSystemBaseDataL()
       
   253 		/**
       
   254 		@internalComponent
       
   255 		@released
       
   256 		*/
       
   257 		{
       
   258 		_LIT(KLog, "Backup System Data ...");
       
   259 		Log(LOG_LEVEL2, KLog);
       
   260 		GeneratePIDTransferTypesL(iTransferTypes, ESystemData);
       
   261 		DoBackupL();
       
   262 		}
       
   263 
       
   264 	void CBURTestStepBackup2::SupplyDataL(RTransferTypeArray& aTransferTypes, TRequestStatus& aStatus)
       
   265 		{//added for coverage test
       
   266 		TInt transferTypesCount = aTransferTypes.Count();
       
   267 		for(TInt currentIndex = 0; currentIndex < transferTypesCount; ++currentIndex)
       
   268 			{
       
   269 			TInt error;		
       
   270 			TInt increments = 0;
       
   271 			TInt incrIndex = 1;
       
   272 			
       
   273 			TSBDerivedType dataType = aTransferTypes[currentIndex]->DerivedTypeL();
       
   274 			
       
   275 			// check for incremental data
       
   276 			switch(dataType)
       
   277 				{
       
   278 				case ESIDTransferDerivedType:
       
   279 					{
       
   280 					CSBSIDTransferType* type = CSBSIDTransferType::NewL(aTransferTypes[currentIndex]);
       
   281 					CleanupStack::PushL(type);
       
   282 					
       
   283 					_LIT(KSid, "Supplying data for ID: ");
       
   284 					LogWithSID(LOG_LEVEL3, KSid, type->SecureIdL());
       
   285 					
       
   286 					if (type->DataTypeL() == EActiveIncrementalData || type->DataTypeL() == EPassiveIncrementalData)
       
   287 						{
       
   288 						increments = iStorageManager->TotalIncFiles(type);
       
   289 						if (!increments)
       
   290 							{
       
   291 							_LIT(KErrorText2, "No increments found");
       
   292 							Log(LOG_LEVEL4, KErrorText2);
       
   293 							// cleanup
       
   294 							CleanupStack::PopAndDestroy(type);
       
   295 							continue;
       
   296 							}
       
   297 						else 
       
   298 							{
       
   299 							_LIT(KIncFound, "Number of increments found: ");
       
   300 							LogWithNum(LOG_LEVEL4, KIncFound, increments);
       
   301 							} // else if
       
   302 						} // if
       
   303 					CleanupStack::PopAndDestroy(type);
       
   304 					}
       
   305 					break;
       
   306 				case EPackageTransferDerivedType:
       
   307 					{
       
   308 					// package stuff
       
   309 					CSBPackageTransferType* pType = CSBPackageTransferType::NewL(aTransferTypes[currentIndex]);
       
   310 					CleanupStack::PushL(pType);
       
   311 					_LIT(KPid, "Supplying data for Package ID: ");
       
   312 					LogWithSID(LOG_LEVEL3, KPid, pType->PackageIdL());
       
   313 					CleanupStack::PopAndDestroy(pType);
       
   314 					}
       
   315 					break;
       
   316 				case EJavaTransferDerivedType:
       
   317 					{
       
   318 					// java stuff
       
   319 					CSBJavaTransferType* jType = CSBJavaTransferType::NewL(aTransferTypes[currentIndex]);
       
   320 					CleanupStack::PushL(jType);
       
   321 					_LIT(KJid, "Supplying data for Java SuiteHash: ");
       
   322 					LogWithText(LOG_LEVEL3, KJid, jType->SuiteHashL());
       
   323 					CleanupStack::PopAndDestroy(jType);
       
   324 					}
       
   325 					break;
       
   326 				
       
   327 				} // switch
       
   328 			TBool runAgain = ETrue;		
       
   329 			do 
       
   330 				{
       
   331 				TBool finished;				
       
   332 				TPtr8* bufferPtr = NULL;
       
   333 				TRAP(error, bufferPtr = &iBackupClient->TransferDataAddressL());
       
   334 				if (error != KErrNone)
       
   335 					{
       
   336 					_LIT(KErrTDA, "Error getting TransferDataAddress: ");
       
   337 					LogWithNum(LOG_LEVEL4, KErrTDA, error);
       
   338 					break;
       
   339 					}
       
   340 				TRAP(error, iStorageManager->RetrieveDataL(aTransferTypes[currentIndex], *bufferPtr, finished, incrIndex));
       
   341 				if (error != KErrNone)
       
   342 					{
       
   343 					iStorageManager->Reset();
       
   344 					if (error == KErrPathNotFound || error == KErrNotFound)
       
   345 						{
       
   346 						_LIT(KErrorText2, "Data doesn't exists");
       
   347 						Log(LOG_LEVEL4, KErrorText2);
       
   348 						}
       
   349 					else
       
   350 						{
       
   351 						_LIT(KErrorText1, "Error reading from archive: ");
       
   352 						LogWithNum(LOG_LEVEL4, KErrorText1, error);
       
   353 						iFailures++;
       
   354 						}
       
   355 					break;
       
   356 					} 
       
   357 				else
       
   358 					{
       
   359 					_LIT(KLogBytes, "Number of bytes to send: ");
       
   360 					LogWithNum(LOG_LEVEL4, KLogBytes, bufferPtr->Length());	
       
   361 			
       
   362 					TRAP(error, iBackupClient->SupplyDataL(*aTransferTypes[currentIndex], finished, aStatus));
       
   363 					if (error != KErrNone)
       
   364 						{
       
   365 						_LIT(KErrorText2, "Error supplying data to backup server: ");
       
   366 						LogWithNum(LOG_LEVEL4, KErrorText2, error);
       
   367 						if (iExpectStatus != error)
       
   368 							iFailures++;
       
   369 						break;
       
   370 						}
       
   371 					else
       
   372 						{
       
   373 						_LIT(KSuccess, "Operation finished successfully");
       
   374 						Log(LOG_LEVEL4, KSuccess);
       
   375 						}
       
   376 					
       
   377 					} // else
       
   378 					
       
   379 				if ((finished && !increments) || (incrIndex == increments && finished)) // if finished 
       
   380 					{
       
   381 					runAgain = EFalse;
       
   382 					}
       
   383 				else if (finished && incrIndex < increments) // is incremental data move to next increment
       
   384 					{
       
   385 					incrIndex++;
       
   386 					runAgain = ETrue;
       
   387 					}
       
   388 				else 
       
   389 					{
       
   390 					runAgain = ETrue;
       
   391 					}
       
   392 				} // do
       
   393 				while (runAgain);
       
   394 			} // for
       
   395 			
       
   396 			if (!iFailures)
       
   397 				{
       
   398 				_LIT(KComp, "No errors found");
       
   399 				Log(LOG_LEVEL3, KComp);
       
   400 				}
       
   401 		// Do not delete bufferPtr, as it gets deleted by the iBackupClient
       
   402 		}
       
   403 	
       
   404 	void CBURTestStepBackup2::SupplySystemSnapshotDataL()
       
   405 		/**
       
   406 		@internalComponent
       
   407 		@released
       
   408 		*/
       
   409 		{
       
   410 		GeneratePIDTransferTypesL(iTransferTypes, ESystemSnapshotData);
       
   411 		// go through each of them and check if we have snapshot to supply
       
   412 		if (iTransferTypes.Count())
       
   413 			{
       
   414 			_LIT(KLog, "Supply System Snapshot Data ...");
       
   415 			Log(LOG_LEVEL2, KLog);
       
   416 			
       
   417 			TRequestStatus status;
       
   418 			SupplyDataL(iTransferTypes, status);
       
   419 			}
       
   420 		}
       
   421 		
       
   422 	void CBURTestStepBackup2::BackupSystemSnapshotDataL()
       
   423 		/**
       
   424 		@internalComponent
       
   425 		@released
       
   426 		*/
       
   427 		{
       
   428 		_LIT(KLog, "Backup System Snapshot Data ...");
       
   429 		Log(LOG_LEVEL2, KLog);
       
   430 		GeneratePIDTransferTypesL(iTransferTypes, ESystemSnapshotData);
       
   431 		DoBackupL();
       
   432 		}
       
   433 	
       
   434 	
       
   435 	void CBURTestStepBackup2::BackupRegistrationDataL()
       
   436 		/**
       
   437 		@internalComponent
       
   438 		@released
       
   439 		*/
       
   440 		{
       
   441 		_LIT(KReg, "Backup registration data...");
       
   442 		Log(LOG_LEVEL2, KReg);
       
   443 		GenerateSIDTransferTypesL(iTransferTypes, ERegistrationData);
       
   444 		DoBackupL();
       
   445 		}
       
   446 	
       
   447 	void CBURTestStepBackup2::BackupPassiveSnapshotDataL()
       
   448 		/**
       
   449 		@internalComponent
       
   450 		@released
       
   451 		*/
       
   452 		{
       
   453 		_LIT(KPassSnap, "Backup passive snapshot data...");
       
   454 		Log(LOG_LEVEL2, KPassSnap);
       
   455 		GenerateSIDTransferTypesL(iTransferTypes, EPassiveSnapshotData);
       
   456 		DoBackupL();
       
   457 		}
       
   458 	
       
   459 	void CBURTestStepBackup2::SupplyPassiveSnapshotDataL()
       
   460 		/**
       
   461 		@internalComponent
       
   462 		@released
       
   463 		*/
       
   464 		{
       
   465 		_LIT(KSupp, "Supplying passive snapshot data...");
       
   466 		Log(LOG_LEVEL2, KSupp);
       
   467 		DoSupplyL(EPassiveSnapshotData);
       
   468 		}
       
   469 
       
   470 	void CBURTestStepBackup2::BackupPassiveBaseDataL()
       
   471 		/**
       
   472 		@internalComponent
       
   473 		@released
       
   474 		*/
       
   475 		{
       
   476 		_LIT(KPassBase, "Backup passive base data...");
       
   477 		Log(LOG_LEVEL2, KPassBase);
       
   478 		GenerateSIDTransferTypesL(iTransferTypes, EPassiveBaseData);
       
   479 		DoBackupL();
       
   480 		}
       
   481 	
       
   482 	void CBURTestStepBackup2::BackupPassiveIncDataL()
       
   483 		/**
       
   484 		@internalComponent
       
   485 		@released
       
   486 		*/
       
   487 		{
       
   488 		_LIT(KPassInc, "Backup passive incremental data...");
       
   489 		Log(LOG_LEVEL2, KPassInc);
       
   490 		GenerateSIDTransferTypesL(iTransferTypes, EPassiveIncrementalData);
       
   491 		DoBackupL();
       
   492 		}
       
   493 	
       
   494 	void CBURTestStepBackup2::BackupActiveSnapshotDataL()
       
   495 		/**
       
   496 		@internalComponent
       
   497 		@released
       
   498 		*/
       
   499 		{
       
   500 		_LIT(KActSnap, "Backup active snapshot data...");
       
   501 		Log(LOG_LEVEL2, KActSnap);
       
   502 		DoActiveBackupL(EActiveSnapshotData);
       
   503 		}
       
   504 	
       
   505 	void CBURTestStepBackup2::SupplyActiveSnapshotDataL()
       
   506 		/**
       
   507 		@internalComponent
       
   508 		@released
       
   509 		*/
       
   510 		{
       
   511 		_LIT(KSuppActSnap,"Supplying active snapshot data...");
       
   512 		Log(LOG_LEVEL2, KSuppActSnap);
       
   513 		DoSupplyL(EActiveSnapshotData);
       
   514 		}
       
   515 	
       
   516 	void CBURTestStepBackup2::BackupActiveBaseDataL()
       
   517 		/**
       
   518 		@internalComponent
       
   519 		@released
       
   520 		*/
       
   521 		{
       
   522 		_LIT(KActBase, "Backup active base data...");
       
   523 		Log(LOG_LEVEL2, KActBase);
       
   524 		DoActiveBackupL(EActiveBaseData);
       
   525 		}
       
   526 
       
   527 	void CBURTestStepBackup2::BackupActiveIncDataL()
       
   528 		/**
       
   529 		@internalComponent
       
   530 		@released
       
   531 		*/
       
   532 		{
       
   533 		_LIT(KActInc, "Backup active incremental data...");
       
   534 		Log(LOG_LEVEL2, KActInc);
       
   535 		DoActiveBackupL(EActiveIncrementalData);
       
   536 		}
       
   537 		
       
   538 	void CBURTestStepBackup2::BackupPublicDataL()
       
   539 		/**
       
   540 		@internalComponent
       
   541 		@released
       
   542 		*/
       
   543 		{
       
   544 		_LIT(KPublic, "Backup Public Data...");
       
   545 		Log(LOG_LEVEL2, KPublic);
       
   546 		RPointerArray<CSBGenericDataType> array;
       
   547 		TRAP_IGNORE(GeneratePublicTransferTypesL(array));
       
   548 		TRAP_IGNORE(DoPublicBackupL(array));
       
   549 		array.ResetAndDestroy();
       
   550 		array.Close();
       
   551 		}
       
   552 		
       
   553 	void CBURTestStepBackup2::DoPublicBackupL(RPointerArray<CSBGenericDataType>& aTransferTypes)
       
   554 		/**
       
   555 		@internalComponent
       
   556 		@released
       
   557 		*/
       
   558 		{
       
   559 		_LIT(KNote, "Public data is Not saved it just for Testing purposes to show the list of files got from the device!");
       
   560 		Log(LOG_LEVEL2, KNote);
       
   561 		RFileArray array;
       
   562 		CleanupClosePushL(array);	
       
   563 		
       
   564 		TInt length = iDriveList.Length();
       
   565 		TInt count = aTransferTypes.Count();
       
   566 		for (TInt driveCount = 0; driveCount < length && count; driveCount++)
       
   567 			{
       
   568 			if (iDriveList[driveCount])
       
   569 				{
       
   570 				for (TInt i =0; i < count; i++)
       
   571 					{
       
   572 					iBackupClient->PublicFileListL(TDriveNumber(driveCount), *aTransferTypes[i], array);
       
   573 					
       
   574 					TInt fileCount = array.Count();
       
   575 					_LIT(KFoundCount, "Found number of files: ");
       
   576 					LogWithNum(LOG_LEVEL3, KFoundCount, fileCount);
       
   577 					
       
   578 					for (TInt j = 0; j < fileCount; j++)
       
   579 						{
       
   580 						_LIT(KFile, "Public File: ");
       
   581 						LogWithText(LOG_LEVEL4, KFile, array[j].iName);
       
   582 						}
       
   583 					
       
   584 					/** Only for one partial backup */
       
   585 					if (iPublicFileNames.Count() > 0)
       
   586 						{
       
   587 						if (fileCount != iPublicFileNames.Count())
       
   588 							{
       
   589 							iFailures++;
       
   590 							_LIT(KLogCount, "Backup count of public files don't match ");
       
   591 							Log(LOG_LEVEL3, KLogCount);
       
   592 							SetTestStepResult(TVerdict(EFail));				
       
   593 							}
       
   594 						
       
   595 						for (TInt k=0; k<fileCount; ++k)
       
   596 							{
       
   597 							if (iPublicFileNames.Find(array[k].iName) == KErrNotFound) 
       
   598 								{
       
   599 								iFailures++;
       
   600 								_LIT(KLogName, "Backup name of public files don't match ");
       
   601 								Log(LOG_LEVEL3, KLogName);
       
   602 								SetTestStepResult(TVerdict(EFail));										
       
   603 								}
       
   604 							}						
       
   605 						}
       
   606 					array.Reset();
       
   607 					}
       
   608 				}
       
   609 			}
       
   610 		CleanupStack::PopAndDestroy(&array);
       
   611 		}
       
   612 	
       
   613 	void CBURTestStepBackup2::DoBackupL()
       
   614 		/**
       
   615 		Core backup method to carry out the transfer as well as the storage of 
       
   616 		data to the archive.
       
   617 		
       
   618 		@internalComponent
       
   619 		@released
       
   620 		
       
   621 		@param aDataType - Type of data to be backed up.
       
   622 		*/
       
   623 		{
       
   624 		if (iTransferTypes.Count())
       
   625 			{
       
   626 			// STEP 2 - Start the data request handler to backup data:
       
   627 			_LIT(KLog2, "Requesting backup data for IDs per drive...");
       
   628 			Log(LOG_LEVEL3, KLog2);
       
   629 			iDataTransferHandler->StartL();
       
   630 			// Log success:
       
   631 			if (iDataTransferHandler->Success())
       
   632 				{
       
   633 				_LIT(KLog3, "Operation finished with no errors");
       
   634 				Log(LOG_LEVEL3, KLog3);
       
   635 				} //if
       
   636 			else
       
   637 				{
       
   638 				iFailures++;
       
   639 				_LIT(KLog4, "Operation failed with errors ");
       
   640 				Log(LOG_LEVEL3, KLog4);
       
   641 				SetTestStepResult(TVerdict(EFail));
       
   642 				} //else
       
   643 			} //if 
       
   644 		else 
       
   645 			{
       
   646 			_LIT(KLogNoTrans, "Nothing to do ");
       
   647 			Log(LOG_LEVEL3, KLogNoTrans);
       
   648 			} //else
       
   649 		}
       
   650 		
       
   651 		
       
   652 	void CBURTestStepBackup2::DoActiveBackupL(TTransferDataType aTransferDataType)
       
   653 		/**
       
   654 		@internalComponent
       
   655 		@released
       
   656 		*/
       
   657 		{
       
   658 		RTransferTypeArray transferTypes;
       
   659 		GenerateSIDTransferTypesL(transferTypes, aTransferDataType);
       
   660 		if (transferTypes.Count())
       
   661 			{
       
   662 			TRAPD(error,
       
   663 			for (TInt i=0; i < KRetries;)
       
   664 				{
       
   665 				CheckSIDStatusL(transferTypes, iTransferTypes);													
       
   666 				if (iTransferTypes.Count()) // dataowners ready
       
   667 					{
       
   668 					DoBackupL();
       
   669 					} 
       
   670 				else if (transferTypes.Count()) // data owners not ready
       
   671 					{
       
   672 					User::After(KDelay);
       
   673 					i++;
       
   674 					}
       
   675 				else // finished with all sids
       
   676 					{
       
   677 					break;
       
   678 					}
       
   679 				} // for
       
   680 				); //TRAPD
       
   681 			if (transferTypes.Count())
       
   682 				{
       
   683 				iFailures++;
       
   684 				_LIT(KLogNoTrans, "***Error: Some Data Owners were Not Ready or Failed to Connect");
       
   685 				Log(LOG_LEVEL3, KLogNoTrans);
       
   686 				} //if
       
   687 			transferTypes.ResetAndDestroy();
       
   688 			
       
   689 			User::LeaveIfError(error);
       
   690 			}
       
   691 		else 
       
   692 			{
       
   693 			_LIT(KLogNoTrans, "Nothing to do ");
       
   694 			Log(LOG_LEVEL3, KLogNoTrans);
       
   695 			}
       
   696 
       
   697 		}
       
   698 		
       
   699 	void CBURTestStepBackup2::BackupJavaMidletsL()
       
   700 		/**
       
   701 		@internalComponent
       
   702 		@released
       
   703 		*/
       
   704 		{
       
   705 		_LIT(KMidlet, "Backup midlets...");
       
   706 		Log(LOG_LEVEL2, KMidlet);
       
   707 		GenerateJavaTransferTypesL(iTransferTypes, EJavaMIDlet);
       
   708 		DoBackupL();
       
   709 		}
       
   710 		
       
   711 	void CBURTestStepBackup2::BackupJavaMidletsDataL()
       
   712 		/**
       
   713 		@internalComponent
       
   714 		@released
       
   715 		*/
       
   716 		{
       
   717 		_LIT(KMidletData, "Backup midlets data...");
       
   718 		Log(LOG_LEVEL2, KMidletData);
       
   719 		GenerateJavaTransferTypesL(iTransferTypes, EJavaMIDletData);
       
   720 		DoBackupL();
       
   721 		}
       
   722 	
       
   723 	TVerdict CBURTestStepBackup2::doTestStepPostambleL()
       
   724 		/**
       
   725 		@return - TVerdict code
       
   726 		 Override of base class pure virtual
       
   727 		*/
       
   728 		{
       
   729 		_LIT(KLog, "Number of failures:");
       
   730 		LogWithNum(LOG_LEVEL3, KLog, iFailures);
       
   731 		if (iFailures)
       
   732 			{
       
   733 			SetTestStepResult(TVerdict(EFail));
       
   734 			}
       
   735 		return TestStepResult();
       
   736 		}
       
   737 	void CBURTestStepBackup2::GetLargePublicFileListL()
       
   738 		{
       
   739 		//Coverage test get large public file list
       
   740 		RPointerArray<CSBGenericDataType> transferTypes;
       
   741 		CleanupClosePushL(transferTypes);
       
   742 		TRAP_IGNORE(GeneratePublicTransferTypesL(transferTypes));
       
   743 		RFileArray array;
       
   744 		CleanupClosePushL(array);
       
   745 		TInt length = iDriveList.Length();
       
   746 		TInt count = transferTypes.Count();
       
   747 		for (TInt driveCount = 0; driveCount < length && count; driveCount++)
       
   748 			{
       
   749 			if (iDriveList[driveCount])
       
   750 				{
       
   751 				for (TInt i =0; i < count; i++)
       
   752 					{
       
   753 					CBURActiveObject* active = CBURActiveObject::NewL();
       
   754 					CleanupStack::PushL(active);					
       
   755 					RPointerArray<CSBEFileEntry> fileEntry;
       
   756 					TBool bFinish;
       
   757 					CleanupClosePushL(fileEntry);
       
   758 					iBackupClient->PublicFileListL(TDriveNumber(driveCount), *transferTypes[i], 
       
   759 							fileEntry,
       
   760 							bFinish,
       
   761 							0,
       
   762 							1024,
       
   763 							active->iStatus);
       
   764 					active->StartL();
       
   765 					User::LeaveIfError(active->Error());
       
   766 					TInt fileCount = fileEntry.Count();
       
   767 					for (TInt j = 0; j < fileCount; j++)
       
   768 						{
       
   769 						_LIT(KFile, "File: ");
       
   770 						LogWithText(LOG_LEVEL4, KFile, fileEntry[j]->Filename());
       
   771 						}
       
   772 					CleanupStack::PopAndDestroy(&fileEntry);
       
   773 					CleanupStack::PopAndDestroy(active);
       
   774 
       
   775 					_LIT(KFoundCount, "Get large file list and found number of files: ");
       
   776 					LogWithNum(LOG_LEVEL3, KFoundCount, fileCount);
       
   777 					array.Reset();
       
   778 					}
       
   779 				}
       
   780 			}		
       
   781 		CleanupStack::PopAndDestroy(&array);
       
   782 		CleanupStack::PopAndDestroy(&transferTypes);
       
   783 		
       
   784 		//added for coverage test: test sbtypes
       
   785 		if(iDataOwners.Count() > 0)
       
   786 			{
       
   787 			TDriveList& ref1 = iDataOwners[0]->DriveList();			
       
   788 			HBufC8* hbuf = iDataOwners[0]->ExternaliseL();
       
   789 			CSBGenericDataType& genDataType = iDataOwners[0]->Identifier();
       
   790 			
       
   791 			const CDataOwnerInfo& refDataOwner = *iDataOwners[0];
       
   792 			const CSBGenericDataType& genDataType2 =refDataOwner.Identifier();
       
   793 			const TDriveList& ref2 = refDataOwner.DriveList();
       
   794 			
       
   795 			_LIT(fname, "test.txt");
       
   796 			TEntry entry;
       
   797 			entry.iName = fname;
       
   798 			
       
   799 			RApaLsSession apaSession;
       
   800 			User::LeaveIfError(apaSession.Connect());
       
   801 			CleanupClosePushL(apaSession);
       
   802 			CSBEFileEntry* sbeFile = CSBEFileEntry::NewLC(entry, apaSession);
       
   803 			HBufC8* tmpBuf =sbeFile->ExternaliseLC();
       
   804 			
       
   805 			sbeFile->FileAttributes();
       
   806 			sbeFile->Filename();
       
   807 			sbeFile->FileSize();
       
   808 			sbeFile->LastModified();
       
   809 			sbeFile->MIMEType();
       
   810 			sbeFile->MIMEUid();			
       
   811 			
       
   812 			TInt count;
       
   813 			CSBEFileEntry* sbeFile2= CSBEFileEntry::NewLC(*tmpBuf, count);
       
   814 						
       
   815 			CleanupStack::PopAndDestroy(sbeFile2);
       
   816 			CleanupStack::PopAndDestroy(tmpBuf);
       
   817 			CleanupStack::PopAndDestroy(sbeFile);
       
   818 			CleanupStack::PopAndDestroy(&apaSession);
       
   819 			}		
       
   820 		}
       
   821 	
       
   822 	void CBURTestStepBackup2::TestSetBURMode()
       
   823 		{
       
   824 		TRAPD(err, SetBURModeL(EBURUnset, EBackupBase));
       
   825 		TRAP(err, SetBURModeL(EBURUnset, EBackupBase));
       
   826 		TRAP(err, SetBURModeL(EBURNormal, EBackupBase));
       
   827 		TRAP(err, SetBURModeL(EBURNormal, EBackupBase));
       
   828 		TRAP(err, SetBURModeL(EBURUnset, EBackupBase));
       
   829 		TRAP(err, SetBURModeL(EBURUnset, EBackupBase));
       
   830 		
       
   831 		TSecureId sid(0x10202BE9);
       
   832 		HBufC* hbuf = NULL;
       
   833 		
       
   834 		//this method is not implemented at server side
       
   835 		TRAP(err, iBackupClient->PublicFileListXMLL(EDriveC, sid, hbuf));
       
   836 		
       
   837 		TRAP(err, SetBURModeL(EBURBackupFull, EBackupBase));
       
   838 		
       
   839 		//this method is not implemented at server side
       
   840 		TRAP(err, iBackupClient->PublicFileListXMLL(EDriveC, sid, hbuf));
       
   841 		
       
   842 		TRAP(err, SetBURModeL(EBURBackupFull, EBackupBase));
       
   843 		TRAP(err, SetBURModeL(EBURBackupPartial, EBackupBase));
       
   844 				
       
   845 		TRAP(err, SetBURModeL(EBURBackupPartial, EBackupIncrement));
       
   846 		TRAP(err, SetBURModeL(EBURBackupFull, EBackupIncrement));		
       
   847 		
       
   848 		{//this operation is expected to fail
       
   849 			TRAP(err, PopulateListOfDataOwnersL());
       
   850 			iFailures--;
       
   851 		}
       
   852 		
       
   853 		TRAP(err, SetBURModeL(EBURBackupPartial, ENoBackup));
       
   854 		TRAP(err, SetBURModeL(EBURBackupFull, ENoBackup));		
       
   855 		
       
   856 		TRAP(err, SetBURModeL(EBURRestoreFull, EBackupBase));
       
   857 		TRAP(err, SetBURModeL(EBURRestorePartial, EBackupBase));
       
   858 				
       
   859 		TRAP(err, SetBURModeL(EBURRestoreFull, EBackupIncrement));
       
   860 		TRAP(err, SetBURModeL(EBURRestorePartial, EBackupIncrement));
       
   861 		
       
   862 		TRAP(err, SetBURModeL(EBURRestoreFull, ENoBackup));
       
   863 		TRAP(err, SetBURModeL(EBURRestorePartial, ENoBackup));
       
   864 		TRAP(err, SetBURModeL(EBURNormal, EBackupBase));
       
   865 		
       
   866 		//this method is not implemented at server side
       
   867 		TRAP(err, iBackupClient->PublicFileListXMLL(EDriveC, sid, hbuf));
       
   868 		}
       
   869 	}	// end namespace