testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/utils/inc/testexecuteserverutils.h
changeset 2 8bb370ba6d1d
equal deleted inserted replaced
1:bbd31066657e 2:8bb370ba6d1d
       
     1 /*
       
     2 * Copyright (c) 2005-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 * Definitions of classes local to TestExecuteUtils
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  @file TestExecuteServerUtils.h
       
    23 */
       
    24 
       
    25 #if (!defined __SERVER_UTILS_H__)
       
    26 #define __SERVER_UTILS_H__
       
    27 #include <test/testexecuteserverbase.h>
       
    28 #include <test/testexecutestepbase.h>
       
    29 
       
    30 class CActiveBase : public CActive
       
    31 /**
       
    32 @internalTechnology
       
    33 @test
       
    34 */
       
    35 	{
       
    36 public:
       
    37 	inline 	TRequestStatus& Status();
       
    38 	inline 	void SetActive();
       
    39 	inline	void Kick();
       
    40 	inline	void Prime();
       
    41 	inline	void Complete(TInt aCode);
       
    42 	inline	virtual ~CActiveBase();
       
    43 	inline  TDes& Error();
       
    44 	inline TBool& TimedOut();
       
    45 protected:
       
    46 	inline	CActiveBase();
       
    47 	TBuf<KMaxTestExecuteNameLength> iError;
       
    48 	TBool iTimeOut;
       
    49 	};
       
    50 
       
    51 class CControlBase : public CActiveBase
       
    52 /**
       
    53 @internalTechnology
       
    54 @test
       
    55 */
       
    56 	{
       
    57 public:
       
    58 	inline CControlBase(CTestServer& aServer);
       
    59 	inline void DoCancel();
       
    60 	virtual void Stop() =0;
       
    61 	inline CTestServer& Server();
       
    62 	inline TDes& Args();
       
    63 	inline RMessage2& Message();
       
    64 	inline RThread& WorkerThread();
       
    65 private:
       
    66 	CTestServer&						iServer;
       
    67 	RMessage2							iMessage;
       
    68 	RThread								iWorkerThread;
       
    69 	TBuf<KMaxTestExecuteCommandLength>	iArgs;
       
    70 	};
       
    71 	
       
    72 	
       
    73 class CStepControlBase : public CControlBase
       
    74 /**
       
    75 @internalTechnology
       
    76 @test
       
    77 */
       
    78 	{
       
    79 public:
       
    80 	inline CStepControlBase(CTestServer& aServer);
       
    81 	virtual void StartL(const RMessage2& aMessage,const TDesC& aStepArgs) = 0;
       
    82 	inline TDes& StepName();
       
    83 private:
       
    84 	RMessage2 iMessage;
       
    85 	RThread iWorkerThread;
       
    86 	TBuf<KMaxTestStepNameLength> iStepName;
       
    87 	};
       
    88 
       
    89 class CBlockControlBase : public CControlBase
       
    90 /**
       
    91 @internalTechnology
       
    92 @test
       
    93 */
       
    94 	{
       
    95 public:
       
    96 	inline CBlockControlBase(CTestServer& aServer);
       
    97 	~CBlockControlBase();
       
    98 	virtual void StartL(const RMessage2& aMessage,const TDesC& aArgs, const TDesC8& aBlockArrayPtr) = 0;
       
    99 	virtual TTEFItemArray*	BlockArray() const;
       
   100 
       
   101 protected:
       
   102 	virtual void			CreateBlockArrayL( const TDesC8& aBlockArrayPtr );
       
   103 	virtual HBufC8*			CreateBlockArrayPckgLC();
       
   104 	
       
   105 private:
       
   106 	TTEFItemArray*						iBlockArray;
       
   107 	RMessage2							iMessage;
       
   108 	RThread								iWorkerThread;
       
   109 	TBuf<KMaxTestExecuteCommandLength>	iBlockArgs;
       
   110 	};
       
   111 
       
   112 class CStepControl : public CStepControlBase
       
   113 /**
       
   114 @internalTechnology
       
   115 @test
       
   116 */
       
   117 	{
       
   118 public:
       
   119 	CStepControl(CTestServer& aServer, const TDesC& aStepName);
       
   120 	void RunL();
       
   121 	void StartL(const RMessage2& aMessage,const TDesC& aStepArgs);
       
   122 	void Stop();
       
   123 	~CStepControl();
       
   124 private:
       
   125 	};
       
   126 
       
   127 class CBlockControl : public CBlockControlBase
       
   128 /**
       
   129 @internalTechnology
       
   130 @test
       
   131 */
       
   132 	{
       
   133 public:
       
   134 	CBlockControl(CTestServer& aServer);
       
   135 	void RunL();
       
   136 	void StartL(const RMessage2& aMessage,const TDesC& aArgs, const TDesC8& aBlockArrayPtr);
       
   137 	void Stop();
       
   138 	~CBlockControl();
       
   139 	};
       
   140 
       
   141 class CWorkerMonitor;
       
   142 class CWorkerControl;
       
   143 class CPersistentStepControl : public CStepControlBase
       
   144 /**
       
   145 @internalTechnology
       
   146 @test
       
   147 */
       
   148 	{
       
   149 public:
       
   150 	CPersistentStepControl(CTestServer& aServer);
       
   151 	virtual ~CPersistentStepControl();
       
   152 	void StartL(const RMessage2& aMessage,const TDesC& aStepArgs);
       
   153 	void RunL();
       
   154 	void Stop();
       
   155 	inline void ChildCompletion();
       
   156 private:
       
   157 	CWorkerControl* iWorkerControl;
       
   158 	CWorkerMonitor* iWorkerMonitor;
       
   159 	TBool iInitialised;
       
   160 	};
       
   161 
       
   162 class CBlockWorkerControl;
       
   163 class CPersistentBlockControl : public CBlockControlBase
       
   164 /**
       
   165 @internalTechnology
       
   166 @test
       
   167 */
       
   168 	{
       
   169 public:
       
   170 	CPersistentBlockControl(CTestServer& aServer);
       
   171 	virtual ~CPersistentBlockControl();
       
   172 	void StartL(const RMessage2& aMessage,const TDesC& aArgs, const TDesC8& aBlockArrayPtr);
       
   173 	void RunL();
       
   174 	void Stop();
       
   175 	inline void ChildCompletion();
       
   176 
       
   177 private:
       
   178 	CBlockWorkerControl* 	iWorkerControl;
       
   179 	CWorkerMonitor* 		iWorkerMonitor;
       
   180 	TBool					iInitialised;
       
   181 	};
       
   182 
       
   183 class CWorkerMonitor : public CActiveBase
       
   184 /**
       
   185 @internalTechnology
       
   186 @test
       
   187 */
       
   188 	{
       
   189 public:
       
   190 	inline CWorkerMonitor(TRequestStatus& aParentStatus);
       
   191 	inline virtual ~CWorkerMonitor();
       
   192 	inline void RunL();
       
   193 	inline void DoCancel();
       
   194 private:
       
   195 	TRequestStatus& iParentStatus;
       
   196 	};
       
   197 
       
   198 class CWorkerControl : public CActiveBase
       
   199 /**
       
   200 @internalTechnology
       
   201 @test
       
   202 */
       
   203 	{
       
   204 public:
       
   205 	inline CWorkerControl(CTestServer& aServer,TRequestStatus& aParentStatus);
       
   206 	inline ~CWorkerControl();
       
   207 	inline void RunL();
       
   208 	inline void DoCancel();
       
   209 	inline TRequestStatus& WorkerStatus();
       
   210 	inline RThread& ControllerThread();
       
   211 	inline RSemaphore& Semaphore();
       
   212 	inline CTestServer& Server();
       
   213 	inline TInt& Result();
       
   214 	inline TPtrC& Args();
       
   215 	inline TPtrC& StepName();
       
   216 	inline TDes& PersistentError();
       
   217 	//defect 116046
       
   218 	inline void SetCleanupPtr(CTrapCleanup* aCleanup);
       
   219 	inline void Cleanup();
       
   220 	//END defect 116046
       
   221 private:
       
   222 	CTestServer& iServer;
       
   223 	TRequestStatus& iParentStatus;
       
   224 	RSemaphore iSemaphore;
       
   225 	TRequestStatus iWorkerStatus;
       
   226 	RThread iControllerThread;
       
   227 	TPtrC iArgs;
       
   228 	TPtrC iStepName;
       
   229 	TInt iResult;
       
   230 	TBuf<KMaxTestExecuteNameLength> iPersistentError;
       
   231 	//defect 116046
       
   232 	CTrapCleanup* iCleanup;
       
   233 	//END defect 116046
       
   234 	};
       
   235 
       
   236 class CBlockWorkerControl : public CWorkerControl
       
   237 /**
       
   238 @internalTechnology
       
   239 @test
       
   240 */
       
   241 	{
       
   242 public:
       
   243 	inline CBlockWorkerControl(CTestServer& aServer,TRequestStatus& iParentStatus );
       
   244 	inline ~CBlockWorkerControl();
       
   245 	inline void				SetBlockArray( TTEFItemArray* aBlockArray );
       
   246 	inline TTEFItemArray*	BlockArray() const;
       
   247 
       
   248 private:
       
   249 	TTEFItemArray*			iBlockArray;
       
   250 	};
       
   251 	
       
   252 class CTestSession : public CSession2
       
   253 /**
       
   254 @publishedPartner
       
   255 @test
       
   256 */
       
   257 	{
       
   258 public:
       
   259 	IMPORT_C CTestSession();
       
   260 	IMPORT_C virtual ~CTestSession();
       
   261 	IMPORT_C virtual void ServiceL(const RMessage2& aMessage);
       
   262 private:
       
   263 	CPersistentStepControl*		iPersistentStepControl;
       
   264 	CPersistentBlockControl*	iPersistentBlockControl;
       
   265 	TTEFItemArray*				iBlockArray;
       
   266 	};
       
   267 
       
   268 #include <test/testexecuteserverutils.inl>
       
   269 #endif
       
   270