First public contribution.
1 // Copyright (c) 2009-2010 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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 @internalComponent - Internal Symbian test code
21 #ifndef __REMOTETESTBASE_H__
22 #define __REMOTETESTBASE_H__
26 #include <e32msgqueue.h>
27 #include <test/tefexportconst.h>
28 #include "eglendpointwrap.h"
29 #include "egltest_commscommon.h"
32 class CRemoteTestStepBase;
36 //Active object used to generate a timeout if worker thread takes too long.
37 class CTimeoutTimer : public CTimer
40 static CTimeoutTimer* NewL(CRemoteTestEnv& aEnv, TInt aPriority);
44 CTimeoutTimer(CRemoteTestEnv& aEnv, TInt aPriority);
53 //Active object used to listen to the worker thread to see if it panics.
54 class CWorkerListener : public CActive
57 static CWorkerListener* NewL(CRemoteTestEnv& aEnv, TInt aPriority);
59 void Listen(RThread& aThread);
62 CWorkerListener(CRemoteTestEnv& aEnv, TInt aPriority);
73 //Active object used to listen for test case completion from the worker thread.
74 class CTestCaseListener : public CActive
77 static CTestCaseListener* NewL(CRemoteTestEnv& aEnv, TInt aPriority);
82 CTestCaseListener(CRemoteTestEnv& aEnv, TInt aPriority);
92 //This class provides the remote test environment. CreateRemoteTestStepL()
93 //Should be edited to return an instance of a derived CRemoteTestStepBase
94 //class that corresponds with the passed in aTestUid.
95 class CRemoteTestEnv : public CActive
98 static CRemoteTestEnv* NewL();
99 virtual ~CRemoteTestEnv();
101 void StartReceivingCmds();
102 CRemoteTestStepBase* CreateRemoteTestStepL(TTestUid aTestUid);
104 void SendResult(TRemoteTestVerdict aVerdict);
105 void SendLog(const TDesC8& aFile, TInt aLine, TInt aSeverity, const TDesC& aMessage);
107 void TestCaseCompleted();
108 void TestCaseTimedOut();
109 void WorkerExitted();
120 TBool SetupTestStep();
122 //These functions run in the context of the worker thread.
123 void RunCurrentTestStepL();
124 static TInt TestThreadEntryPoint(TAny* aSelf);
126 void DoEglHeapMark();
127 void DoEglHeapCheck();
130 RMsgQueue<TRemoteTestResult> iResultOutQueue;
131 RMsgQueue<TRemoteTestParamsPacket> iParamsInQueue;
133 CRemoteTestStepBase* iCurTestStep;
134 TRemoteTestParamsPacket iCurTestCaseParamsPacket;
135 TRemoteTestVerdict iCurTestCaseVerdict;
138 TThreadId iSupervisorId;
139 TRequestStatus iNotifyRunTestCase;
141 CTimeoutTimer* iTimeoutTimer;
142 CWorkerListener* iWorkerListener;
143 CTestCaseListener* iTestCaseListener;
147 //This is the base class for all remote test steps. Derived classes should implement
148 //DoRemoteTestStepL(), and return the result of the test as a TVerdict.
149 class CRemoteTestStepBase : public CBase, public MLog
152 virtual ~CRemoteTestStepBase();
154 virtual TRemoteTestVerdict DoStartRemoteTestStepL(const TRemoteTestParams& aMessageIn);
155 virtual TRemoteTestVerdict DoRunRemoteTestCaseL(TInt aTestCase, const TRemoteTestParams& aMessageIn) = 0;
156 virtual TRemoteTestVerdict DoEndRemoteTestStepL(const TRemoteTestParams& aMessageIn);
158 virtual TInt Timeout() const;
160 void Log(const TText8* aFile, TInt aLine, TInt aSeverity, TRefByValue<const TDesC> aFmt, ...);
161 const TEglEndpointWrap& EglEndpoint() const;
167 CRemoteTestStepBase(TTestUid aUid);
170 friend class CRemoteTestEnv;
171 //Function called by CRemoteTestEnv.
172 //It should NOT be called by a derived class during construction.
173 void ConstructL(CRemoteTestEnv& aTestEnv);
177 TInt iCurrentTestCase;
178 CRemoteTestEnv* iTestEnv;
179 TEglEndpointWrap iEndpoint;
183 // Logger Macros - based on TEF but for use with CRemoteTestStepBase.
184 //The severity enumeration is from TEF.
185 #define REMOTE_INFO_PRINTF1(p1) Log(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1))
186 #define REMOTE_INFO_PRINTF2(p1, p2) Log(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2))
187 #define REMOTE_INFO_PRINTF3(p1, p2, p3) Log(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3))
188 #define REMOTE_INFO_PRINTF4(p1, p2, p3, p4) Log(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4))
189 #define REMOTE_INFO_PRINTF5(p1, p2, p3, p4, p5) Log(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5))
190 #define REMOTE_INFO_PRINTF6(p1, p2, p3, p4, p5, p6) Log(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5), (p6))
191 #define REMOTE_INFO_PRINTF7(p1, p2, p3, p4, p5, p6, p7) Log(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5), (p6), (p7))
193 #define REMOTE_WARN_PRINTF1(p1) Log(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1))
194 #define REMOTE_WARN_PRINTF2(p1, p2) Log(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2))
195 #define REMOTE_WARN_PRINTF3(p1, p2, p3) Log(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3))
196 #define REMOTE_WARN_PRINTF4(p1, p2, p3, p4) Log(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4))
197 #define REMOTE_WARN_PRINTF5(p1, p2, p3, p4, p5) Log(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4), (p5))
198 #define REMOTE_WARN_PRINTF6(p1, p2, p3, p4, p5, p6) Log(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4), (p5), (p6))
199 #define REMOTE_WARN_PRINTF7(p1, p2, p3, p4, p5, p6, p7) Log(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4), (p5), (p6), (p7))
201 #define REMOTE_ERR_PRINTF1(p1) Log(((TText8*)__FILE__), __LINE__, ESevrErr, (p1))
202 #define REMOTE_ERR_PRINTF2(p1, p2) Log(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2))
203 #define REMOTE_ERR_PRINTF3(p1, p2, p3) Log(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3))
204 #define REMOTE_ERR_PRINTF4(p1, p2, p3, p4) Log(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4))
205 #define REMOTE_ERR_PRINTF5(p1, p2, p3, p4, p5) Log(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5))
206 #define REMOTE_ERR_PRINTF6(p1, p2, p3, p4, p5, p6) Log(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5), (p6))
207 #define REMOTE_ERR_PRINTF7(p1, p2, p3, p4, p5, p6, p7) Log(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5), (p6), (p7))