backupandrestore/backuptest/burtestserver/TestSteps/inc/t_burteststepbase.h
changeset 0 d0791faffa3f
child 19 0aa8cc770c8a
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 /**
       
     2 * Copyright (c) 2004-2009 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 
       
    19 
       
    20 /**
       
    21  @file
       
    22  @released
       
    23 */
       
    24 
       
    25 #ifndef __T_BUR_TEST_STEP_BASE_H__
       
    26 #define __T_BUR_TEST_STEP_BASE_H__
       
    27 
       
    28 #include <test/testexecutestepbase.h>
       
    29 #include <connect/sbeclient.h>
       
    30 #include "t_burcommon.h"
       
    31 #include "t_burtestserver.h"
       
    32 #include "t_storagemanager.h"
       
    33 
       
    34 using namespace conn;
       
    35 
       
    36 namespace bur_ts
       
    37 	{
       
    38 	
       
    39 	const TInt KRetries = 3;
       
    40 	const TInt KDelay = 10000000; //10 sec
       
    41 	
       
    42 	// Forward declaration
       
    43 	class CStorageManager;
       
    44 	
       
    45 	class CBURTestStepBase : public CTestStep
       
    46 		/**
       
    47 		Base class for all test cases to be used by BURTestServer.
       
    48 		It provides common functionality to backup and restore, such as supplying data
       
    49 		from the archive, setting backup/restore mode, getting list of data owners, etc.
       
    50 		
       
    51 		This class may not be directly instantiated. All derived classes must supply 
       
    52 		implementations of all pure virtual functions inherited from CTestStep 
       
    53 		(from TestExecute Framework), namely:
       
    54 		
       
    55 		virtual TVerdict doTestStepPreambleL();\n
       
    56 		virtual TVerdict doTestStepPostambleL();\n
       
    57 		virtual TVerdict doTestStepL();
       
    58 		
       
    59 		The logging methods provide an interface to the text execute logging utility.
       
    60 		
       
    61 		@released
       
    62 		@internalComponent
       
    63 		*/
       
    64 		{
       
    65 	protected:
       
    66 		// No need for 2-phase construction here and this is an abstract class.
       
    67 		CBURTestStepBase(CBURTestServer& aTestServer);
       
    68 		~CBURTestStepBase();
       
    69 		
       
    70 	public:
       
    71 		// Utility function to convert user input into a TDriveList object
       
    72 		static TDriveList StringToDriveListL(TPtrC apText);
       
    73 		
       
    74 		// For logging to the TestExecute logger:
       
    75 		void Log(TUint aIndentationLevel, const TDesC& aLog);
       
    76 		void LogWithText(TUint aIndentationLevel, const TDesC& aLog, const TDesC& aText);
       
    77 		void LogWithText8(TUint aIndentationLevel, const TDesC& aLog, const TDesC8& aText);
       
    78 		void LogWithNum(TUint aIndentationLevel, const TDesC& aLog, TInt aNum);
       
    79 		void LogWithSID(TUint aIndentationLevel, const TDesC& aLog, TSecureId aSecureId);
       
    80 		void LogWithChar(TUint aIndentationLevel, const TDesC& aLog, TChar aChar);
       
    81 		
       
    82 		// Inline methods:
       
    83 		
       
    84 		inline RFs& Fs();
       
    85 		inline CSBEClient* BackupClient() const;
       
    86 		inline CStorageManager* StorageManager() const;
       
    87 		inline const RTransferTypeArray& TransferTypes() const;
       
    88 		inline TInt ExpectStatus() const;
       
    89 		inline TInt ExpectStatus2() const;
       
    90 		
       
    91 	public:
       
    92 		RSIDArray iSidArray;
       
    93 		
       
    94 	private:
       
    95 		HBufC* GetIndentation(TInt aLevel);
       
    96 		
       
    97 	protected:
       
    98 		// Methods required by both CTestStepBackup as well CTestStepRestore:
       
    99 		void ProcessUserOptionsL();
       
   100 		
       
   101 		void PrepareForPartialBURL();
       
   102 		
       
   103 		void PopulateListOfDataOwnersL();
       
   104 		
       
   105 		void SetBURModeL(TBURPartType aBURPartType, TBackupIncType aBackupIncType);
       
   106 		
       
   107 		void CreateStorageManagerL();
       
   108 		
       
   109 		void GenerateSIDTransferTypesL(RTransferTypeArray& aTransferTypes, TTransferDataType aDataType);
       
   110 		
       
   111 		void GeneratePIDTransferTypesL(RTransferTypeArray& aTransferTypes, TPackageDataType aPkgDataType = ESystemData);
       
   112 		
       
   113 		void GenerateJavaTransferTypesL(RTransferTypeArray& aTransferTypes, TJavaTransferType aJavaTransferType);
       
   114 		
       
   115 		void SupplyDataL(RTransferTypeArray& aTransferTypes);
       
   116 		
       
   117 		void SaveDataOwners();
       
   118 		
       
   119 		void CheckSIDStatusL(RTransferTypeArray& aTransferTypes, RTransferTypeArray& aReadyArray);
       
   120 		
       
   121 		TSecureId ExtractIDL(CDataOwnerInfo& aDataOwner);
       
   122 		
       
   123 		void DoSupplyL(TTransferDataType aDataType);
       
   124 		
       
   125 		HBufC* ExtractJavaIDL(CDataOwnerInfo& aDataOwner);
       
   126 		
       
   127 		void CheckValidRegistrationL();
       
   128 		
       
   129 		void SetSIDListForPartialL();
       
   130 		
       
   131 		void GeneratePublicTransferTypesL(RPointerArray<CSBGenericDataType>& aTransferTypes);
       
   132 		
       
   133 		//async methods
       
   134 		void PopulateListOfDataOwnersAsyncL();
       
   135 		
       
   136 		void SetBURModeAsyncL(TBURPartType aBURPartType, TBackupIncType aBackupIncType);
       
   137 		
       
   138 		void ReadListIntoStringArray(const TDesC& aSectionName, const TChar& aDelimiter, RArray<TPtrC>& aResultList);
       
   139 		
       
   140 		void ReadListIntoIntArray(const TDesC& aSectionName, const TChar& aDelimiter, RArray<TInt>& aResultList);
       
   141 		
       
   142 	protected:
       
   143 		/** Test server the test step belongs to: */
       
   144 		CBURTestServer& iParentTestServer;
       
   145 		
       
   146 		/** Data owners */
       
   147 		RDataOwnerArray iDataOwners;
       
   148 		
       
   149 		/** Backup server client */
       
   150 		CSBEClient* iBackupClient;
       
   151 		
       
   152 		/** User defined parameters read in by TestExecute config parser */
       
   153 		TFileName iBackupDirName;
       
   154 		TBackupIncType iBackupIncType;
       
   155 		TBool iIsPartial;
       
   156 		TDriveList iDriveList;
       
   157 		TInt  iExpectStatus;
       
   158 		TInt  iExpectStatus2;
       
   159 		
       
   160 		/** Number of failures */
       
   161 		TInt iFailures;
       
   162 		
       
   163 		/** Storage handler for archiving backup data */
       
   164 		CStorageManager* iStorageManager;
       
   165 		
       
   166 		/** Active scheduler for this test step's thread */
       
   167 		CActiveScheduler* iActiveScheduler;
       
   168 		
       
   169 		/** File server session for use by all derived classes */
       
   170 		RFs iFs;
       
   171 		
       
   172 		/** Array of suite Hashes */
       
   173 		RArray<TPtrC> iJidArray;
       
   174 		
       
   175 		/** Restore or Backup ? */
       
   176 		TBackupMode iMode;
       
   177 		
       
   178 		/** waited for active to become ready? */
       
   179 		TBool iWaitedForActive;
       
   180 		
       
   181 		/** Array of transfer types */
       
   182 		RTransferTypeArray iTransferTypes;
       
   183 		
       
   184 		/** Name array of public files  */
       
   185 		RArray<TPtrC> iPublicFileNames;
       
   186 		
       
   187 		/** Name array of private files */
       
   188 		RArray<TPtrC> iPrivateFileNames;
       
   189 		
       
   190 		/** File size array of private files */
       
   191 		RArray<TInt> iPrivateFileSizes;
       
   192 		};
       
   193 		
       
   194 	// INLINE METHODS:
       
   195 	inline RFs& CBURTestStepBase::Fs()
       
   196 		/**
       
   197 		Provides access to the central file server session.
       
   198 		
       
   199 		@released
       
   200 		@internalComponent
       
   201 		
       
   202 		@return An RFs file server session.
       
   203 		*/
       
   204 		{
       
   205 		return iFs; 
       
   206 		}
       
   207 	
       
   208 	inline CSBEClient* CBURTestStepBase::BackupClient() const
       
   209 		/**
       
   210 		Provides access to the backup client.
       
   211 		
       
   212 		@released
       
   213 		@internalComponent
       
   214 		
       
   215 		@return A pointer to the backup client.
       
   216 		*/
       
   217 		{
       
   218 		return iBackupClient;
       
   219 		}
       
   220 	
       
   221 	inline CStorageManager* CBURTestStepBase::StorageManager() const
       
   222 		/**
       
   223 		Provides access to the stroage manager.
       
   224 		
       
   225 		@released
       
   226 		@internalComponent
       
   227 		
       
   228 		@return A pointer to the storage manager.
       
   229 		*/
       
   230 		{
       
   231 		return iStorageManager;
       
   232 		}
       
   233 		
       
   234 	inline const RTransferTypeArray& CBURTestStepBase::TransferTypes() const
       
   235 		/**
       
   236 		Provides access to the Transfer Types.
       
   237 		
       
   238 		@released
       
   239 		@internalComponent
       
   240 		
       
   241 		@return A reference to the transfer types.
       
   242 		*/
       
   243 		{
       
   244 		return iTransferTypes;
       
   245 		}
       
   246 
       
   247 	inline TInt CBURTestStepBase::ExpectStatus() const
       
   248 		/**
       
   249 		Provides access to the ExpectStatus 'iExpectStatus'.
       
   250 		
       
   251 		@released
       
   252 		@internalComponent
       
   253 		
       
   254 		@return expectstatus value.
       
   255 		*/
       
   256 		{
       
   257 		return iExpectStatus;
       
   258 		}
       
   259 
       
   260 	inline TInt CBURTestStepBase::ExpectStatus2() const
       
   261 		/**
       
   262 		Provides access to the ExpectStatus 'iExpectStatus2'.
       
   263 				
       
   264 		@released
       
   265 		@internalComponent
       
   266 				
       
   267 		@return expectstatus value.
       
   268 		*/
       
   269 		{
       
   270 		return iExpectStatus2;
       
   271 		}
       
   272 
       
   273 	/**
       
   274 	A Simple Active Object class for simulating Asyncrnous calls.
       
   275 	*/	
       
   276 	class CBURActiveObject : public CActive
       
   277 		{
       
   278 	public:
       
   279 		static CBURActiveObject* NewL();
       
   280 		~CBURActiveObject();
       
   281 		
       
   282 		void StartL();
       
   283 		TInt Error();
       
   284 		
       
   285 	protected:
       
   286 		void DoCancel();
       
   287 		void RunL();
       
   288 		TInt RunError(TInt aError);
       
   289 		
       
   290 	private:
       
   291 		CBURActiveObject();
       
   292 		void ConstructL();
       
   293 		
       
   294 	private:
       
   295 		CActiveSchedulerWait* iActiveScheduler;
       
   296 		TInt iError;
       
   297 		};
       
   298 	
       
   299 	} // end of namespace
       
   300 
       
   301 #endif // __T_BUR_TEST_STEP_BASE_H__
       
   302 
       
   303