sl@0
|
1 |
// Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
|
sl@0
|
13 |
|
sl@0
|
14 |
/**
|
sl@0
|
15 |
@file
|
sl@0
|
16 |
@test
|
sl@0
|
17 |
@internalComponent - Internal Symbian test code
|
sl@0
|
18 |
*/
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
#ifndef __REMOTETESTBASE_H__
|
sl@0
|
22 |
#define __REMOTETESTBASE_H__
|
sl@0
|
23 |
|
sl@0
|
24 |
|
sl@0
|
25 |
#include <e32base.h>
|
sl@0
|
26 |
#include <e32msgqueue.h>
|
sl@0
|
27 |
#include <test/tefexportconst.h>
|
sl@0
|
28 |
#include "eglendpointwrap.h"
|
sl@0
|
29 |
#include "egltest_commscommon.h"
|
sl@0
|
30 |
|
sl@0
|
31 |
|
sl@0
|
32 |
class CRemoteTestStepBase;
|
sl@0
|
33 |
class CRemoteTestEnv;
|
sl@0
|
34 |
|
sl@0
|
35 |
|
sl@0
|
36 |
//Active object used to generate a timeout if worker thread takes too long.
|
sl@0
|
37 |
class CTimeoutTimer : public CTimer
|
sl@0
|
38 |
{
|
sl@0
|
39 |
public:
|
sl@0
|
40 |
static CTimeoutTimer* NewL(CRemoteTestEnv& aEnv, TInt aPriority);
|
sl@0
|
41 |
~CTimeoutTimer();
|
sl@0
|
42 |
|
sl@0
|
43 |
private:
|
sl@0
|
44 |
CTimeoutTimer(CRemoteTestEnv& aEnv, TInt aPriority);
|
sl@0
|
45 |
void ConstructL();
|
sl@0
|
46 |
void RunL();
|
sl@0
|
47 |
|
sl@0
|
48 |
private:
|
sl@0
|
49 |
CRemoteTestEnv& iEnv;
|
sl@0
|
50 |
};
|
sl@0
|
51 |
|
sl@0
|
52 |
|
sl@0
|
53 |
//Active object used to listen to the worker thread to see if it panics.
|
sl@0
|
54 |
class CWorkerListener : public CActive
|
sl@0
|
55 |
{
|
sl@0
|
56 |
public:
|
sl@0
|
57 |
static CWorkerListener* NewL(CRemoteTestEnv& aEnv, TInt aPriority);
|
sl@0
|
58 |
~CWorkerListener();
|
sl@0
|
59 |
void Listen(RThread& aThread);
|
sl@0
|
60 |
|
sl@0
|
61 |
private:
|
sl@0
|
62 |
CWorkerListener(CRemoteTestEnv& aEnv, TInt aPriority);
|
sl@0
|
63 |
void ConstructL();
|
sl@0
|
64 |
void RunL();
|
sl@0
|
65 |
void DoCancel();
|
sl@0
|
66 |
|
sl@0
|
67 |
private:
|
sl@0
|
68 |
CRemoteTestEnv& iEnv;
|
sl@0
|
69 |
RThread* iThread;
|
sl@0
|
70 |
};
|
sl@0
|
71 |
|
sl@0
|
72 |
|
sl@0
|
73 |
//Active object used to listen for test case completion from the worker thread.
|
sl@0
|
74 |
class CTestCaseListener : public CActive
|
sl@0
|
75 |
{
|
sl@0
|
76 |
public:
|
sl@0
|
77 |
static CTestCaseListener* NewL(CRemoteTestEnv& aEnv, TInt aPriority);
|
sl@0
|
78 |
~CTestCaseListener();
|
sl@0
|
79 |
void Listen();
|
sl@0
|
80 |
|
sl@0
|
81 |
private:
|
sl@0
|
82 |
CTestCaseListener(CRemoteTestEnv& aEnv, TInt aPriority);
|
sl@0
|
83 |
void ConstructL();
|
sl@0
|
84 |
void RunL();
|
sl@0
|
85 |
void DoCancel();
|
sl@0
|
86 |
|
sl@0
|
87 |
private:
|
sl@0
|
88 |
CRemoteTestEnv& iEnv;
|
sl@0
|
89 |
};
|
sl@0
|
90 |
|
sl@0
|
91 |
|
sl@0
|
92 |
//This class provides the remote test environment. CreateRemoteTestStepL()
|
sl@0
|
93 |
//Should be edited to return an instance of a derived CRemoteTestStepBase
|
sl@0
|
94 |
//class that corresponds with the passed in aTestUid.
|
sl@0
|
95 |
class CRemoteTestEnv : public CActive
|
sl@0
|
96 |
{
|
sl@0
|
97 |
public:
|
sl@0
|
98 |
static CRemoteTestEnv* NewL();
|
sl@0
|
99 |
virtual ~CRemoteTestEnv();
|
sl@0
|
100 |
|
sl@0
|
101 |
void StartReceivingCmds();
|
sl@0
|
102 |
CRemoteTestStepBase* CreateRemoteTestStepL(TTestUid aTestUid);
|
sl@0
|
103 |
|
sl@0
|
104 |
void SendResult(TRemoteTestVerdict aVerdict);
|
sl@0
|
105 |
void SendLog(const TDesC8& aFile, TInt aLine, TInt aSeverity, const TDesC& aMessage);
|
sl@0
|
106 |
|
sl@0
|
107 |
void TestCaseCompleted();
|
sl@0
|
108 |
void TestCaseTimedOut();
|
sl@0
|
109 |
void WorkerExitted();
|
sl@0
|
110 |
|
sl@0
|
111 |
protected:
|
sl@0
|
112 |
CRemoteTestEnv();
|
sl@0
|
113 |
void ConstructL();
|
sl@0
|
114 |
|
sl@0
|
115 |
private:
|
sl@0
|
116 |
void RunL();
|
sl@0
|
117 |
void DoCancel();
|
sl@0
|
118 |
|
sl@0
|
119 |
void ReceiveCmd();
|
sl@0
|
120 |
TBool SetupTestStep();
|
sl@0
|
121 |
|
sl@0
|
122 |
//These functions run in the context of the worker thread.
|
sl@0
|
123 |
void RunCurrentTestStepL();
|
sl@0
|
124 |
static TInt TestThreadEntryPoint(TAny* aSelf);
|
sl@0
|
125 |
|
sl@0
|
126 |
void DoEglHeapMark();
|
sl@0
|
127 |
void DoEglHeapCheck();
|
sl@0
|
128 |
|
sl@0
|
129 |
private:
|
sl@0
|
130 |
RMsgQueue<TRemoteTestResult> iResultOutQueue;
|
sl@0
|
131 |
RMsgQueue<TRemoteTestParamsPacket> iParamsInQueue;
|
sl@0
|
132 |
|
sl@0
|
133 |
CRemoteTestStepBase* iCurTestStep;
|
sl@0
|
134 |
TRemoteTestParamsPacket iCurTestCaseParamsPacket;
|
sl@0
|
135 |
TRemoteTestVerdict iCurTestCaseVerdict;
|
sl@0
|
136 |
RThread iCurWorker;
|
sl@0
|
137 |
|
sl@0
|
138 |
TThreadId iSupervisorId;
|
sl@0
|
139 |
TRequestStatus iNotifyRunTestCase;
|
sl@0
|
140 |
|
sl@0
|
141 |
CTimeoutTimer* iTimeoutTimer;
|
sl@0
|
142 |
CWorkerListener* iWorkerListener;
|
sl@0
|
143 |
CTestCaseListener* iTestCaseListener;
|
sl@0
|
144 |
};
|
sl@0
|
145 |
|
sl@0
|
146 |
|
sl@0
|
147 |
//This is the base class for all remote test steps. Derived classes should implement
|
sl@0
|
148 |
//DoRemoteTestStepL(), and return the result of the test as a TVerdict.
|
sl@0
|
149 |
class CRemoteTestStepBase : public CBase, public MLog
|
sl@0
|
150 |
{
|
sl@0
|
151 |
public:
|
sl@0
|
152 |
virtual ~CRemoteTestStepBase();
|
sl@0
|
153 |
|
sl@0
|
154 |
virtual TRemoteTestVerdict DoStartRemoteTestStepL(const TRemoteTestParams& aMessageIn);
|
sl@0
|
155 |
virtual TRemoteTestVerdict DoRunRemoteTestCaseL(TInt aTestCase, const TRemoteTestParams& aMessageIn) = 0;
|
sl@0
|
156 |
virtual TRemoteTestVerdict DoEndRemoteTestStepL(const TRemoteTestParams& aMessageIn);
|
sl@0
|
157 |
|
sl@0
|
158 |
virtual TInt Timeout() const;
|
sl@0
|
159 |
|
sl@0
|
160 |
void Log(const TText8* aFile, TInt aLine, TInt aSeverity, TRefByValue<const TDesC> aFmt, ...);
|
sl@0
|
161 |
const TEglEndpointWrap& EglEndpoint() const;
|
sl@0
|
162 |
|
sl@0
|
163 |
void EglStartL();
|
sl@0
|
164 |
void EglEndL();
|
sl@0
|
165 |
|
sl@0
|
166 |
protected:
|
sl@0
|
167 |
CRemoteTestStepBase(TTestUid aUid);
|
sl@0
|
168 |
|
sl@0
|
169 |
private:
|
sl@0
|
170 |
friend class CRemoteTestEnv;
|
sl@0
|
171 |
//Function called by CRemoteTestEnv.
|
sl@0
|
172 |
//It should NOT be called by a derived class during construction.
|
sl@0
|
173 |
void ConstructL(CRemoteTestEnv& aTestEnv);
|
sl@0
|
174 |
|
sl@0
|
175 |
private:
|
sl@0
|
176 |
const TTestUid iUid;
|
sl@0
|
177 |
TInt iCurrentTestCase;
|
sl@0
|
178 |
CRemoteTestEnv* iTestEnv;
|
sl@0
|
179 |
TEglEndpointWrap iEndpoint;
|
sl@0
|
180 |
};
|
sl@0
|
181 |
|
sl@0
|
182 |
|
sl@0
|
183 |
// Logger Macros - based on TEF but for use with CRemoteTestStepBase.
|
sl@0
|
184 |
//The severity enumeration is from TEF.
|
sl@0
|
185 |
#define REMOTE_INFO_PRINTF1(p1) Log(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1))
|
sl@0
|
186 |
#define REMOTE_INFO_PRINTF2(p1, p2) Log(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2))
|
sl@0
|
187 |
#define REMOTE_INFO_PRINTF3(p1, p2, p3) Log(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3))
|
sl@0
|
188 |
#define REMOTE_INFO_PRINTF4(p1, p2, p3, p4) Log(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4))
|
sl@0
|
189 |
#define REMOTE_INFO_PRINTF5(p1, p2, p3, p4, p5) Log(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5))
|
sl@0
|
190 |
#define REMOTE_INFO_PRINTF6(p1, p2, p3, p4, p5, p6) Log(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5), (p6))
|
sl@0
|
191 |
#define REMOTE_INFO_PRINTF7(p1, p2, p3, p4, p5, p6, p7) Log(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5), (p6), (p7))
|
sl@0
|
192 |
|
sl@0
|
193 |
#define REMOTE_WARN_PRINTF1(p1) Log(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1))
|
sl@0
|
194 |
#define REMOTE_WARN_PRINTF2(p1, p2) Log(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2))
|
sl@0
|
195 |
#define REMOTE_WARN_PRINTF3(p1, p2, p3) Log(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3))
|
sl@0
|
196 |
#define REMOTE_WARN_PRINTF4(p1, p2, p3, p4) Log(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4))
|
sl@0
|
197 |
#define REMOTE_WARN_PRINTF5(p1, p2, p3, p4, p5) Log(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4), (p5))
|
sl@0
|
198 |
#define REMOTE_WARN_PRINTF6(p1, p2, p3, p4, p5, p6) Log(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4), (p5), (p6))
|
sl@0
|
199 |
#define REMOTE_WARN_PRINTF7(p1, p2, p3, p4, p5, p6, p7) Log(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4), (p5), (p6), (p7))
|
sl@0
|
200 |
|
sl@0
|
201 |
#define REMOTE_ERR_PRINTF1(p1) Log(((TText8*)__FILE__), __LINE__, ESevrErr, (p1))
|
sl@0
|
202 |
#define REMOTE_ERR_PRINTF2(p1, p2) Log(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2))
|
sl@0
|
203 |
#define REMOTE_ERR_PRINTF3(p1, p2, p3) Log(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3))
|
sl@0
|
204 |
#define REMOTE_ERR_PRINTF4(p1, p2, p3, p4) Log(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4))
|
sl@0
|
205 |
#define REMOTE_ERR_PRINTF5(p1, p2, p3, p4, p5) Log(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5))
|
sl@0
|
206 |
#define REMOTE_ERR_PRINTF6(p1, p2, p3, p4, p5, p6) Log(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5), (p6))
|
sl@0
|
207 |
#define REMOTE_ERR_PRINTF7(p1, p2, p3, p4, p5, p6, p7) Log(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5), (p6), (p7))
|
sl@0
|
208 |
|
sl@0
|
209 |
|
sl@0
|
210 |
#endif
|