testfws/burtestserver/TestSteps/inc/t_burteststepbase.h
changeset 4 b8d1455fddc0
equal deleted inserted replaced
2:73b88125830c 4:b8d1455fddc0
       
     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 		
       
    89 	public:
       
    90 		RSIDArray iSidArray;
       
    91 		
       
    92 	private:
       
    93 		HBufC* GetIndentation(TInt aLevel);
       
    94 		
       
    95 	protected:
       
    96 		// Methods required by both CTestStepBackup as well CTestStepRestore:
       
    97 		void ProcessUserOptionsL();
       
    98 		
       
    99 		void PrepareForPartialBURL();
       
   100 		
       
   101 		void PopulateListOfDataOwnersL();
       
   102 		
       
   103 		void SetBURModeL(TBURPartType aBURPartType, TBackupIncType aBackupIncType);
       
   104 		
       
   105 		void CreateStorageManagerL();
       
   106 		
       
   107 		void GenerateSIDTransferTypesL(RTransferTypeArray& aTransferTypes, TTransferDataType aDataType);
       
   108 		
       
   109 		void GeneratePIDTransferTypesL(RTransferTypeArray& aTransferTypes, TPackageDataType aPkgDataType = ESystemData);
       
   110 		
       
   111 		void GenerateJavaTransferTypesL(RTransferTypeArray& aTransferTypes, TJavaTransferType aJavaTransferType);
       
   112 		
       
   113 		void SupplyDataL(RTransferTypeArray& aTransferTypes);
       
   114 		
       
   115 		void SaveDataOwners();
       
   116 		
       
   117 		void CheckSIDStatusL(RTransferTypeArray& aTransferTypes, RTransferTypeArray& aReadyArray);
       
   118 		
       
   119 		TSecureId ExtractIDL(CDataOwnerInfo& aDataOwner);
       
   120 		
       
   121 		void DoSupplyL(TTransferDataType aDataType);
       
   122 		
       
   123 		HBufC* ExtractJavaIDL(CDataOwnerInfo& aDataOwner);
       
   124 		
       
   125 		void CheckValidRegistrationL();
       
   126 		
       
   127 		void SetSIDListForPartialL();
       
   128 		
       
   129 		void GeneratePublicTransferTypesL(RPointerArray<CSBGenericDataType>& aTransferTypes);
       
   130 		
       
   131 		//async methods
       
   132 		void PopulateListOfDataOwnersAsyncL();
       
   133 		
       
   134 		void SetBURModeAsyncL(TBURPartType aBURPartType, TBackupIncType aBackupIncType);
       
   135 		
       
   136 		
       
   137 	protected:
       
   138 		/** Test server the test step belongs to: */
       
   139 		CBURTestServer& iParentTestServer;
       
   140 		
       
   141 		/** Data owners */
       
   142 		RDataOwnerArray iDataOwners;
       
   143 		
       
   144 		/** Backup server client */
       
   145 		CSBEClient* iBackupClient;
       
   146 		
       
   147 		/** User defined parameters read in by TestExecute config parser */
       
   148 		TFileName iBackupDirName;
       
   149 		TBackupIncType iBackupIncType;
       
   150 		TBool iIsPartial;
       
   151 		TDriveList iDriveList;
       
   152 		
       
   153 		/** Number of failures */
       
   154 		TInt iFailures;
       
   155 		
       
   156 		/** Storage handler for archiving backup data */
       
   157 		CStorageManager* iStorageManager;
       
   158 		
       
   159 		/** Active scheduler for this test step's thread */
       
   160 		CActiveScheduler* iActiveScheduler;
       
   161 		
       
   162 		/** File server session for use by all derived classes */
       
   163 		RFs iFs;
       
   164 		
       
   165 		/** Array of suite Hashes */
       
   166 		RArray<TPtrC> iJidArray;
       
   167 		
       
   168 		/** Restore or Backup ? */
       
   169 		TBackupMode iMode;
       
   170 		
       
   171 		/** waited for active to become ready? */
       
   172 		TBool iWaitedForActive;
       
   173 		
       
   174 		/** Array of transfer types */
       
   175 		RTransferTypeArray iTransferTypes;
       
   176 		};
       
   177 		
       
   178 	// INLINE METHODS:
       
   179 	inline RFs& CBURTestStepBase::Fs()
       
   180 		/**
       
   181 		Provides access to the central file server session.
       
   182 		
       
   183 		@released
       
   184 		@internalComponent
       
   185 		
       
   186 		@return An RFs file server session.
       
   187 		*/
       
   188 		{
       
   189 		return iFs; 
       
   190 		}
       
   191 	
       
   192 	inline CSBEClient* CBURTestStepBase::BackupClient() const
       
   193 		/**
       
   194 		Provides access to the backup client.
       
   195 		
       
   196 		@released
       
   197 		@internalComponent
       
   198 		
       
   199 		@return A pointer to the backup client.
       
   200 		*/
       
   201 		{
       
   202 		return iBackupClient;
       
   203 		}
       
   204 	
       
   205 	inline CStorageManager* CBURTestStepBase::StorageManager() const
       
   206 		/**
       
   207 		Provides access to the stroage manager.
       
   208 		
       
   209 		@released
       
   210 		@internalComponent
       
   211 		
       
   212 		@return A pointer to the storage manager.
       
   213 		*/
       
   214 		{
       
   215 		return iStorageManager;
       
   216 		}
       
   217 		
       
   218 	inline const RTransferTypeArray& CBURTestStepBase::TransferTypes() const
       
   219 		/**
       
   220 		Provides access to the Transfer Types.
       
   221 		
       
   222 		@released
       
   223 		@internalComponent
       
   224 		
       
   225 		@return A reference to the transfer types.
       
   226 		*/
       
   227 		{
       
   228 		return iTransferTypes;
       
   229 		}
       
   230 
       
   231 	/**
       
   232 	A Simple Active Object class for simulating Asyncrnous calls.
       
   233 	*/	
       
   234 	class CBURActiveObject : public CActive
       
   235 		{
       
   236 	public:
       
   237 		static CBURActiveObject* NewL();
       
   238 		~CBURActiveObject();
       
   239 		
       
   240 		void StartL();
       
   241 		TInt Error();
       
   242 		
       
   243 	protected:
       
   244 		void DoCancel();
       
   245 		void RunL();
       
   246 		TInt RunError(TInt aError);
       
   247 		
       
   248 	private:
       
   249 		CBURActiveObject();
       
   250 		void ConstructL();
       
   251 		
       
   252 	private:
       
   253 		CActiveSchedulerWait* iActiveScheduler;
       
   254 		TInt iError;
       
   255 		};
       
   256 	
       
   257 	} // end of namespace
       
   258 
       
   259 #endif // __T_BUR_TEST_STEP_BASE_H__
       
   260 
       
   261