os/graphics/egl/egltest/endpointtestsuite/automated/tinc/egltest_endpoint_engine.h
Update contrib.
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.
19 @internalComponent - Internal Symbian test code
23 #ifndef __EGLTEST_ENDPOINT_ENGINE_H__
24 #define __EGLTEST_ENDPOINT_ENGINE_H__
26 #include "localtestbase.h"
27 #include "remotetestbase.h"
28 #include "egltest_surface.h"
29 #include "egltest_endpoint_engine_types.h"
30 #include "egltest_endpoint_images.h"
32 #define ENGINE_ASSERT(x) DoEngineAssert((x) != 0, #x, __FILE__, __LINE__)
34 static inline void DoEngineAssert(TInt aX, const char *aXStr,
35 const char *aFile, TInt aLine)
39 RDebug::Printf("EGL_ENDPOINT_TEST_ENGINE ASSERT(%s) failed (value %d) at %s:%d\n",
40 aXStr, aX, aFile, aLine);
41 User::Panic(_L("ENGINE_ASSERT"), aLine);
46 // This could be wrapped in #if/#else to allow us to generate non-unicode text content.
47 #define TESTIDS(x) _S(x)
48 #define CASETITLE(x) _S(x)
52 // We use macros so that we get an automatic comment as to what the fields are,
53 // rather than just listing enums in an array.
54 #define SurfaceTypes1(type1) 1, { type1 }
55 #define SurfaceTypes2(type1, type2) 2, { type1, type2 }
56 #define SurfaceTypes3(type1, type2, type3) 3, { type1, type2, type3 }
57 #define SurfaceTypes4(type1, type2, type3, type4) 4, { type1, type2, type3, type4 }
59 // Macro used for building a TTestCases entry.
60 #define TestCase(x) { x, sizeof(x) / sizeof(x[0]) }
62 // Forward declare this class.
63 class CEgltest_Local_Engine_Exec;
65 // The object passed back from the exec thread to the
72 //Constructor for sending result info.
73 TExecResult(TVerdict aVerdict, TEngineCases aCase);
75 // Constructor for sending result of buffer count paramters.
76 TExecResult(TVerdict aBufferCountVerdict, TVerdict aVerdict, TEngineCases aCase);
81 // Checking buffer count.
82 TVerdict iBufferCountVerdict;
83 // Get Surface parameter reply.
84 TSurfaceParamsRemote iSurfaceParams;
85 // To check that we are in sync - it should match the request.
89 const TInt KMaxLoadThreads = 4;
91 NONSHARABLE_CLASS(CEgltest_Local_Engine): public CLocalTestStepBase
101 CEgltest_Local_Engine(const TTestCases *aTestCases, TInt aNumCases);
102 virtual ~CEgltest_Local_Engine();
103 virtual TVerdict doTestStepL();
104 virtual void DoPreambleL();
105 virtual void DoPostambleL();
106 void SetTestCasesL(const TTestCases * const aTestCases, TInt aNumCases);
109 void RunTestCase(const TTestCases &aTestCase);
110 void RunOneTestCase(const TTestCase& aTestCase, TSurfaceType aSurfType);
111 void SendLocalTestCase(const TRemoteTestParams &aParams);
112 void RunLocalTestCase(TEngineCases aCase);
113 void DoSyncToLocal();
114 void GetLocalResult(TExecResult& aResult, TEngineCases aCase);
115 void DoMonitorThreadEntry();
116 void ForwardPanic(RThread& aThread, RThread& aOtherThread, TRequestStatus &aStatus);
117 static TInt MonitorThreadEntry(TAny *aParam);
118 void RunControllerLocalAndRemoteL(const TEngineTestCase&, const TRemoteTestParams& params);
121 void RunLocalTestCase(const TRemoteTestParams& aMessageIn, TExecResult& aResult);
122 TVerdict RunRemoteTestCase(TInt aTestCase, const TRemoteTestParams& aMessageIn);
123 void RunSingleCaseL(const TTestCase& aTestCase, TSurfaceType aSurfType);
124 void CommonPreambleL();
125 CEgltest_Local_Engine();
126 // The StartThread and EndThread needs to be overridden in the
127 // implementation to provide a good functionality.
128 virtual void StartThreadL(TInt aThreadNumber);
129 virtual void EndThread(TInt aThreadNumber);
132 const TTestCases* iTestCases;
135 RThread iMonitorThread;
136 RThread iControllerThread; // Controller thread
137 RMsgQueue<TExecResult> iExecResultOutQueue;
138 RMsgQueue<TRemoteTestParamsPacket> iExecParamsInQueue;
139 TExecState iExecState;
144 struct TRemoteTestArgs
147 EGLEndpointNOK iEndpoint;
152 struct TAvailableMemory
154 TInt iHeapMemAvailable;
155 TInt iGpuMemAvailable;
158 // Base class that allows "script" style exectution of testcases.
159 NONSHARABLE_CLASS(CEgltest_Remote_Engine): public CRemoteTestStepBase
162 CEgltest_Remote_Engine();
163 virtual ~CEgltest_Remote_Engine();
164 virtual TRemoteTestVerdict DoStartRemoteTestStepL(const TRemoteTestParams& aParams);
165 virtual TRemoteTestVerdict DoEndRemoteTestStepL(const TRemoteTestParams& aParams);
166 virtual TRemoteTestVerdict DoRunRemoteTestCaseL(TInt aTestCase, const TRemoteTestParams& aParams);
168 void LogDump(const TEngineTestCase& aCase);
169 EGLDisplay GetDisplay(TInt aFlags);
170 EGLEndpointNOK GetEndpoint(TInt aIndex, TInt aFlags);
171 EGLImageKHR GetImage(TInt aIndex, TInt aFlags);
172 EGLenum GetEndpointType(TInt aFlags);
173 EGLenum GetSourceType(TInt aFlags);
174 const TSurfaceId GetSurfaceId(TInt aFlags, const TSurfaceId& aSurfaceId);
175 void CheckReturn(TInt aRetval, const TEngineTestCase& aStreamItem, TInt aFailValue,
176 const TText* aFailSymbol, const TText* aFunction);
177 void RunCaseL(TInt aTestCase, const TRemoteTestParams &aParams, const TRemoteTestArgs& aArgs);
178 void CreateEndpointCaseL(const TRemoteTestParams& aParams, const TRemoteTestArgs& aArgs);
179 void ReleaseImageCaseL(const TRemoteTestParams& aParams, const TRemoteTestArgs& aArgs);
180 void ActivateVgContextL();
181 void RequestNotificationL(const TRemoteTestParams& aParams, const TRemoteTestArgs& aArgs);
182 void GetEndpointDirtyAreaL(const TRemoteTestParams& aParams, const TRemoteTestArgs& aArgs);
183 void DoCheckRectsL(EGLint *aActualRects, EGLint aRectCount, EGLint aMaxRects,
184 TInt aRectsIndex, const TRect aSurfacRect);
185 void CheckForMemoryLeaks();
186 void CheckForMemoryLeaksFinish();
188 TInt FillGpuMemory();
189 TInt CalculateAvailableGPUMemory();
190 TInt CalculateAvailableHeapMemory();
192 // Thread entry points for "load" threads.
193 static TInt LoadHeapMemory(TAny *);
194 void LoadHeapMemoryL();
195 static TInt LoadGpuMemory(TAny *);
196 void LoadGpuMemoryL();
198 void StartThreadL(TInt aThreadNumber);
199 void EndThread(TInt aThreadNumber);
200 TThreadFunction GetThreadFunction(TInt aThreadNumber);
203 EGLEndpointNOK iEndpoints[KMaxEndpoints];
204 EGLImageKHR iEglImage[KMaxEndpoints];
205 CTestVgEglImage* iVgImage[KMaxEndpoints];
206 TRequestStatus iRequestStatus[KMaxEndpoints];
207 TRemoteTestVerdict iTestVerdict;
209 CEglWindowSurface *iSurface;
210 // when this flag is set, errors discovered during a test-step is logged.
211 // This is normally true, but for stress tests [etc], it can be turned
212 // off so that when a test is set up to run 1000 times, but only succeeds
213 // X times, we don't get "error, something failed", when we really didn't
217 // Tracking memory available.
218 RArray<TAvailableMemory> iMemoryStats;
220 // Variables to keep track of load-threads.
221 RThread iLoadThread[KMaxLoadThreads];
222 TBool iStopThreadFlag[KMaxLoadThreads];
224 RHeap* iMainThreadHeap;
225 PFNEGLQUERYPROFILINGDATANOKPROC ipfnEglQueryProfilingDataNOK;
229 #define CASE(x) case x: caseName=_S(#x); break
231 static inline const TText* EngineCaseName(TEngineCases aCase)
233 const TText* caseName = _S("Unknown Engine Case");
236 CASE(ECreateEndpointCase);
237 CASE(EBeginStreamingCase);
238 CASE(EAcquireImageCase);
239 CASE(EReleaseImageCase);
240 CASE(EEndStreamingCase);
241 CASE(EContentUpdateCase);
242 CASE(EDestroyEndpointCase);
243 CASE(EInitializeCase);
244 CASE(ETerminateCase);
245 CASE(EGetAttribCase);
246 CASE(ESetAttribCase);
247 CASE(ECreateSurfaceCase);
248 CASE(EDrawContentCase);
249 CASE(ECompareImageCase);
251 CASE(ENotifyWhenCase);
252 CASE(ETestVgImageValidCase);
253 CASE(EDestroyVgImageCase);
254 CASE(EDestroyEglImageCase);
255 CASE(ETimeStampCase);
256 CASE(ERequestNotificationCase);
257 CASE(EWaitForNotificationCase);
258 CASE(ECancelNotificationCase);
259 CASE(EBreakPointCase);
260 CASE(ELogEnableCase);
263 CASE(EGetEndpointDirtyAreaCase);
264 CASE(ESyncLocalCase);
265 CASE(EGetSurfaceParamsCase);
267 CASE(ECreateVgImageCase);
268 CASE(EDestroySurfaceCase);
269 CASE(EStartLoadThreadCase);
270 CASE(EEndLoadThreadCase);
271 CASE(ECheckForMemoryLeaks);
272 CASE(ECheckForMemoryLeaksFinish);
280 inline void LogDump(CTestExecuteLogger &aLogger, const TEngineTestCase& aCase)
282 const TText *caseName = EngineCaseName(aCase.iCase);
283 aLogger.LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo,
284 _L("Performing subcase %d (%s), with flags=%d, err=%04x endpointidx=%d, image=%d, args=(%d, %d)"),
288 aCase.iErrorExpected,
289 aCase.iEndpointIndex,
291 aCase.iArg1, aCase.iArg2);
295 #endif // __EGLTEST_ENDPOINT_ENGINE_H__