|
1 // Copyright (c) 2009 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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 |
|
13 |
|
14 /** |
|
15 @file |
|
16 @test |
|
17 @internalComponent - Internal Symbian test code |
|
18 */ |
|
19 |
|
20 |
|
21 /* |
|
22 * To add a new message that can be passed over the message queue: |
|
23 * 1. Add the test name to the TTestUid enum. |
|
24 * 2. Create a T class to hold the params. |
|
25 * 3. Add the T class to the TRemoteTestParams union. |
|
26 * |
|
27 * These steps are described in more detail below, where the |
|
28 * individual bits should be added. |
|
29 */ |
|
30 |
|
31 |
|
32 #ifndef __EGLTEST_COMMSCOMMON_H__ |
|
33 #define __EGLTEST_COMMSCOMMON_H__ |
|
34 |
|
35 |
|
36 #include <e32base.h> |
|
37 #include <graphics/surface.h> |
|
38 #include <EGL/egl.h> |
|
39 #include "log.h" |
|
40 #include "egltest_endpoint_engine_types.h" |
|
41 |
|
42 #define ENDPOINT_ASSERT_DEBUG(x, y) do { if (!x) { RDebug::Printf("Assertion (%s) failed: %s:%d ", #x, __FILE__, __LINE__); y; } } while(0) |
|
43 |
|
44 //The maximum size of a message in an async message queue is 256 bytes. |
|
45 //If these valuses are increased, the maximum size will be exceeded. |
|
46 const TInt KRSLogMessageLength = 172; |
|
47 const TInt KRSLogFileLength = 32; |
|
48 |
|
49 |
|
50 //Names for the Async message queues that are used for |
|
51 //communication between the TEF driver app and the test |
|
52 //thread within window server. |
|
53 _LIT(KResultQueueName, "RemoteTestEnvResultQueue"); |
|
54 _LIT(KParamsQueueName, "RemoteTestEnvParamsQueue"); |
|
55 |
|
56 const TInt KStartTestStepCaseNumber = -1; |
|
57 const TInt KEndTestStepCaseNumber = -2; |
|
58 |
|
59 //Uids for all of the tests that the test thread knows about. |
|
60 enum TTestUid |
|
61 { |
|
62 //Endpoint Api Exposure Test. |
|
63 ETestUidEndpointApiExposure, |
|
64 |
|
65 // Common UID for engine code. |
|
66 ETestUidEndpointEngine, |
|
67 |
|
68 // Endpoint Lifetime test. |
|
69 ETestUidEndpointLifetime, |
|
70 |
|
71 //Image Tearing Test. |
|
72 ETestUidEndpointTearing, |
|
73 |
|
74 //Multithreaded stress tests. |
|
75 ETestUidEndpointThreadStress, |
|
76 |
|
77 //Release Image with Gles context tests. |
|
78 ETestUidEndpointReleaseImageGles, |
|
79 |
|
80 // vgThreading test. |
|
81 ETestUidVgThreading, |
|
82 }; |
|
83 |
|
84 |
|
85 //Each test should have a struct with data members to hold |
|
86 //the test's parameters. The name name should begin |
|
87 //"TTest..." and should contain no member functions. |
|
88 //(c-style struct). |
|
89 |
|
90 //If it is found that many tests use the same params, we should |
|
91 //create a TTestGeneric class to hold the params and derive |
|
92 //classes from it. |
|
93 |
|
94 struct TTestEndpointApiExposure |
|
95 { |
|
96 }; |
|
97 |
|
98 struct TTestEndpointTearing |
|
99 { |
|
100 TSurfaceId iSurfaceId; |
|
101 }; |
|
102 |
|
103 struct TTestEndpointThreadStress |
|
104 { |
|
105 TInt iNumThreads; |
|
106 }; |
|
107 |
|
108 struct TTestEndpointReleaseImageGles |
|
109 { |
|
110 TBool iUseValidGlesContext; |
|
111 }; |
|
112 |
|
113 |
|
114 //Union for all of the structs that tests use to pass |
|
115 //params between the local side and the remote side. |
|
116 union TRemoteTestParams |
|
117 { |
|
118 //Endpoint Api Exposure Test. |
|
119 TTestEndpointApiExposure iTestEndpointApiExposure; |
|
120 |
|
121 //Endpoint engine data. |
|
122 TTestEndpointEngine iEndpointEngine; |
|
123 |
|
124 // Endpoint Engine configuration data. |
|
125 TTestEndpointEngineConfig iEndpointEngineConfig; |
|
126 |
|
127 //Image Tearing Test. |
|
128 TTestEndpointTearing iEndpointTearing; |
|
129 |
|
130 //Multithreaded stress tests. |
|
131 TTestEndpointThreadStress iEndpointThreadStress; |
|
132 |
|
133 //Release Image with Gles context tests. |
|
134 TTestEndpointReleaseImageGles iEndpointReleaseImageGles; |
|
135 }; |
|
136 |
|
137 |
|
138 //Structure that is passed from local side to remote side |
|
139 //in the async message queue. It contains the test Uid, |
|
140 //test case and the params. |
|
141 class TRemoteTestParamsPacket |
|
142 { |
|
143 public: |
|
144 TRemoteTestParamsPacket(); |
|
145 TRemoteTestParamsPacket(TTestUid aTestUid, TInt aTestCase, const TRemoteTestParams& aParams); |
|
146 const TTestUid iUid; |
|
147 const TInt iTestCase; |
|
148 const TRemoteTestParams iParams; |
|
149 }; |
|
150 |
|
151 |
|
152 //The object passed back to the TEF driver app from the test |
|
153 //thread. It can be used for sending the resuult of a test and |
|
154 //for logging. |
|
155 class TRemoteTestResult |
|
156 { |
|
157 public: |
|
158 TRemoteTestResult(); |
|
159 |
|
160 //Constructor for sending logging info. |
|
161 TRemoteTestResult(TTestUid aUid, TInt aTestCase, const TDesC8& aFile, TInt aLine, TInt aSeverity, const TDesC& aMessage); |
|
162 |
|
163 //Constructor for sending result info. |
|
164 TRemoteTestResult(TTestUid aUid, TInt aTestCase, TRemoteTestVerdict aVerdict); |
|
165 |
|
166 public: |
|
167 //If EFalse this is a logging message, else a result message. |
|
168 TBool iFinished; |
|
169 TTestUid iUid; |
|
170 TInt iTestCase; |
|
171 |
|
172 //Result message. |
|
173 TRemoteTestVerdict iVerdict; |
|
174 |
|
175 //Logging message. |
|
176 TBuf8<KRSLogFileLength> iFile; |
|
177 TInt iLine; |
|
178 TInt iSeverity; |
|
179 TBuf8<KRSLogMessageLength> iMessage; |
|
180 }; |
|
181 |
|
182 |
|
183 //Inline functions -------------------------------------------------------- |
|
184 |
|
185 inline TRemoteTestParamsPacket::TRemoteTestParamsPacket() : |
|
186 iUid((TTestUid)0), |
|
187 iTestCase(0), |
|
188 iParams(TRemoteTestParams()) |
|
189 { |
|
190 } |
|
191 |
|
192 |
|
193 inline TRemoteTestParamsPacket::TRemoteTestParamsPacket(TTestUid aTestUid, TInt aTestCase, const TRemoteTestParams& aParams) : |
|
194 iUid(aTestUid), |
|
195 iTestCase(aTestCase), |
|
196 iParams(aParams) |
|
197 { |
|
198 } |
|
199 |
|
200 |
|
201 inline TRemoteTestResult::TRemoteTestResult() |
|
202 { |
|
203 } |
|
204 |
|
205 |
|
206 inline TRemoteTestResult::TRemoteTestResult(TTestUid aUid, TInt aTestCase, const TDesC8& aFile, TInt aLine, TInt aSeverity, const TDesC& aMessage) : |
|
207 iFinished(EFalse), |
|
208 iVerdict(ERtvInconclusive), |
|
209 iUid(aUid), |
|
210 iTestCase(aTestCase), |
|
211 iLine(aLine), |
|
212 iSeverity(aSeverity) |
|
213 { |
|
214 //Copy the filename to the log object. If the string is too long, |
|
215 //truncate the string and append an elipsis to the log. |
|
216 //The "-1"s ensure that a free char is left for appending a NULL (in the TEF app). |
|
217 TBool truncate = iFile.MaxLength()-1 < aFile.Length(); |
|
218 TInt numChars = truncate ? iFile.MaxLength()-3-1 : aFile.Length(); |
|
219 iFile = aFile.Left(numChars); |
|
220 if(truncate) |
|
221 { |
|
222 iFile.Append(_L("...")); |
|
223 } |
|
224 |
|
225 //Copy the message to the log object. If the string is too long, |
|
226 //truncate the string and append an elipsis to the log. |
|
227 //Note we convert message from unicode to ascii to conserve space in the message queue. |
|
228 truncate = iMessage.MaxLength() < aMessage.Length(); |
|
229 numChars = truncate ? iMessage.MaxLength()-3 : aMessage.Length(); |
|
230 iMessage.Copy(aMessage.Left(numChars)); |
|
231 if(truncate) |
|
232 { |
|
233 iMessage.Append(_L8("...")); |
|
234 } |
|
235 } |
|
236 |
|
237 |
|
238 inline TRemoteTestResult::TRemoteTestResult(TTestUid aUid, TInt aTestCase, TRemoteTestVerdict aVerdict) : |
|
239 iFinished(ETrue), |
|
240 iUid(aUid), |
|
241 iTestCase(aTestCase), |
|
242 iVerdict(aVerdict) |
|
243 { |
|
244 } |
|
245 |
|
246 //------------------------------------------------------------------------------------ |
|
247 |
|
248 |
|
249 #endif |