|
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 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @test |
|
19 */ |
|
20 |
|
21 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE |
|
22 #include <sgresource/sgimage.h> |
|
23 #else |
|
24 #include <graphics/sgimage.h> |
|
25 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE |
|
26 #include <test/tefunit.h> // for ASSERT macros |
|
27 #include <GLES/gl.h> |
|
28 |
|
29 #include "egltest_general.h" |
|
30 |
|
31 #include <test/egltestcommonconversion.h> |
|
32 #include <test/egltestcommoninisettings.h> |
|
33 #include <test/egltestcommonsgimageinfo.h> |
|
34 |
|
35 |
|
36 /** |
|
37 @SYMTestCaseID GRAPHICS-EGL-0005 |
|
38 |
|
39 @SYMTestPriority 1 |
|
40 |
|
41 @SYMPREQ 39 |
|
42 |
|
43 @SYMREQ See SGL.GT0386.401 document |
|
44 |
|
45 @SYMTestCaseDesc |
|
46 Dump diagnostic information that may help in debugging any issues found in the other tests. |
|
47 This is not really a test in itself, but can be listed in the test script as a specific test step. |
|
48 It is expected always to pass. |
|
49 |
|
50 @SYMTestActions |
|
51 Repeatedly call eglQueryString() with each of the following parameters: |
|
52 * EGL_CLIENT_APIS |
|
53 * EGL_EXTENSIONS |
|
54 * EGL_VENDOR |
|
55 * EGL_VERSION |
|
56 For each call, dump the resulting string to the test log file. |
|
57 If the result of EGL_CLIENT_APIS includes "OpenVG" then bind to the OpenVG API and repeatedly call vgGetString() with each of the following parameters |
|
58 * VG_VENDOR |
|
59 * VG_RENDERER |
|
60 * VG_VERSION |
|
61 * VG_EXTENSIONS |
|
62 If the result of EGL_CLIENT_APIS includes "OpenGLES" then bind to the OpenGLES API and repeatedly call GetString() with each of the following parameters |
|
63 * VENDOR |
|
64 * RENDERER |
|
65 * VERSION |
|
66 * EXTENSIONS. |
|
67 |
|
68 @SYMTestExpectedResults |
|
69 All data will be dumped to the test log file. |
|
70 There are no specific pass criteria for this test case. |
|
71 */ |
|
72 TVerdict CEglTest_DumpStrings::doTestStepL() |
|
73 { |
|
74 SetTestStepID(_L("GRAPHICS-EGL-0005")); |
|
75 INFO_PRINTF1(_L("CEglTest_DumpStrings::doTestStepL")); |
|
76 |
|
77 // Create display object |
|
78 GetDisplayL(); |
|
79 |
|
80 CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, 0); |
|
81 |
|
82 // Initialise the display object |
|
83 eglSess->InitializeL(); |
|
84 |
|
85 // EGL Strings |
|
86 INFO_PRINTF1(_L("Dumping EGL strings")); |
|
87 |
|
88 // Note that eglQueryString() MUST be called AFTER eglInitialize() for iDisplay |
|
89 TPtrC8 ptrEglClientApis((const TText8 *)eglQueryString(iDisplay, EGL_CLIENT_APIS)); |
|
90 DumpString(_L("EGL_CLIENT_APIS"),ptrEglClientApis); |
|
91 |
|
92 const char* strEglExtensions = eglQueryString(iDisplay, EGL_EXTENSIONS); |
|
93 ASSERT_EGL_TRUE(strEglExtensions!=NULL); |
|
94 DumpString(_L("EGL_EXTENSIONS"), TPtrC8((const TText8 *)strEglExtensions)); |
|
95 |
|
96 const char* strEglVendor = eglQueryString(iDisplay, EGL_VENDOR); |
|
97 ASSERT_EGL_TRUE(strEglVendor!=NULL); |
|
98 DumpString(_L("EGL_VENDOR"), TPtrC8((const TText8 *)strEglVendor)); |
|
99 |
|
100 const char* strEglVersion = eglQueryString(iDisplay, EGL_VERSION); |
|
101 ASSERT_EGL_TRUE(strEglVersion!=NULL); |
|
102 DumpString(_L("EGL_VERSION"), TPtrC8((const TText8 *)strEglVersion)); |
|
103 |
|
104 // OpenVG Strings |
|
105 if (ptrEglClientApis.Find(_L8("OpenVG")) >= 0) |
|
106 { |
|
107 INFO_PRINTF1(_L("Dumping OpenVG strings")); |
|
108 |
|
109 // OpenVG needs a current VG context before it will allow the call to vgGetString |
|
110 TUidPixelFormat pixelFormat = EglTestConversion::VgFormatToSgPixelFormat(KDefaultSurfaceFormat); |
|
111 TSgImageInfoOpenVgTarget imageInfo = TSgImageInfoOpenVgTarget(pixelFormat, KPixmapSize); |
|
112 eglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo,CTestEglSession::EResourceCloseSgImageEarly, EGL_OPENVG_API); |
|
113 |
|
114 TPtrC8 ptrVgVendor((const TText8 *)vgGetString(VG_VENDOR)); |
|
115 DumpString(_L("VG_VENDOR"), ptrVgVendor); |
|
116 |
|
117 TPtrC8 ptrVgRenderer((const TText8 *)vgGetString(VG_RENDERER)); |
|
118 DumpString(_L("VG_RENDERER"), ptrVgRenderer); |
|
119 |
|
120 TPtrC8 ptrVgVersion((const TText8 *)vgGetString(VG_VERSION)); |
|
121 DumpString(_L("VERSION"), ptrVgVersion); |
|
122 |
|
123 TPtrC8 ptrVgExtensions((const TText8 *)vgGetString(VG_EXTENSIONS)); |
|
124 DumpString(_L("VG_EXTENSIONS"), ptrVgExtensions); |
|
125 |
|
126 //cleanup the context & surface |
|
127 eglSess->CleanupSurfaceSgImageL(); |
|
128 } |
|
129 |
|
130 // OpenGLES Strings |
|
131 if (ptrEglClientApis.Find(_L8("OpenGL_ES")) >= 0) |
|
132 { |
|
133 INFO_PRINTF1(_L("Dumping OpenGLES strings")); |
|
134 |
|
135 // OpenGLES needs a current GLES context before it will allow the call to glGetString |
|
136 TUidPixelFormat pixelFormat = EglTestConversion::VgFormatToSgPixelFormat(KDefaultSurfaceFormat); |
|
137 TSgImageInfoOpenVgTarget imageInfo = TSgImageInfoOpenVgTarget(pixelFormat, KPixmapSize); |
|
138 eglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo,CTestEglSession::EResourceCloseSgImageEarly, EGL_OPENGL_ES_API); |
|
139 |
|
140 TPtrC8 ptrGlesVendor((const TText8 *)glGetString(GL_VENDOR)); |
|
141 DumpString(_L("GL_VENDOR"), ptrGlesVendor); |
|
142 |
|
143 TPtrC8 ptrGlesRenderer((const TText8 *)glGetString(GL_RENDERER)); |
|
144 DumpString(_L("GL_RENDERER"), ptrGlesRenderer); |
|
145 |
|
146 TPtrC8 ptrGlesVersion((const TText8 *)glGetString(GL_VERSION)); |
|
147 DumpString(_L("GL_VERSION"), ptrGlesVersion); |
|
148 |
|
149 TPtrC8 ptrGlesExtensions((const TText8 *)glGetString(GL_EXTENSIONS)); |
|
150 DumpString(_L("GL_EXTENSIONS"), ptrGlesExtensions); |
|
151 |
|
152 //cleanup the context & surface |
|
153 eglSess->CleanupSurfaceSgImageL(); |
|
154 } |
|
155 |
|
156 CleanupStack::PopAndDestroy(eglSess); |
|
157 TerminateDisplayL(); |
|
158 RecordTestResultL(); |
|
159 CloseTMSGraphicsStep(); |
|
160 return TestStepResult(); |
|
161 } |
|
162 |
|
163 void CEglTest_DumpStrings::DumpString(const TDesC& aField, const TDesC8& aValue) |
|
164 { |
|
165 const TInt KMaxValueLength = 256; |
|
166 TBuf16<KMaxValueLength> bufValue; |
|
167 bufValue.Copy(aValue.Left(KMaxValueLength)); |
|
168 INFO_PRINTF3(_L("%S: \"%S\""), &aField, &bufValue); |
|
169 } |
|
170 |
|
171 /** |
|
172 @SYMTestCaseID GRAPHICS-EGL-0010 |
|
173 |
|
174 @SYMTestPriority 1 |
|
175 |
|
176 @SYMPREQ 39 |
|
177 |
|
178 @SYMREQ See SGL.GT0386.401 document |
|
179 |
|
180 @SYMTestCaseDesc |
|
181 To ensure that eglQueryString() returns the correct information. |
|
182 |
|
183 @SYMTestActions |
|
184 Call eglQueryString() with the EGL_EXTENSIONS parameter |
|
185 |
|
186 @SYMTestExpectedResults |
|
187 The returned space separated list is expected to include the items as defined in the .ini file. |
|
188 This list is implementation specific, so the .ini file can be configured depending on each implementation. |
|
189 As an example, the following ones are expected in most EGL implementations: |
|
190 * EGL_NOK_pixmap_type_rsgimage |
|
191 * EGL_SYMBIAN_COMPOSITION |
|
192 * EGL_KHR_image_base |
|
193 * EGL_KHR_image_pixmap |
|
194 * EGL_KHR_reusable_sync |
|
195 The above list will be configurable on a per-platform basis, via an INI file. If a platform does not support |
|
196 any of the above extensions then it may opt not to test for it via the INI file. |
|
197 */ |
|
198 TVerdict CEglTest_QueryString_Extensions::doTestStepL() |
|
199 { |
|
200 SetTestStepID(_L("GRAPHICS-EGL-0010")); |
|
201 INFO_PRINTF1(_L("CEglTest_QueryString_Extensions::doTestStepL")); |
|
202 |
|
203 TInt numExtensions=0; |
|
204 if (!GetIntFromConfig(KSectionQueryExtensions, KKeyCountExtensionsEGL, numExtensions)) |
|
205 { |
|
206 ERR_PRINTF2(_L("Cannot find key '%S' in INI file"), &KKeyCountExtensionsEGL); |
|
207 User::Leave(KErrArgument); |
|
208 } |
|
209 INFO_PRINTF2(_L("Looking for %d EGL extensions"), numExtensions); |
|
210 TBuf<32> bufExtensionNameKey; |
|
211 TBuf16<128> bufExtensionNameValue16; |
|
212 TPtrC16 ptrExtensionNameValue16(bufExtensionNameValue16); |
|
213 for(TInt i=0; i<numExtensions; i++) |
|
214 { |
|
215 bufExtensionNameKey.Format(KKeyExtensionEGLX, i); |
|
216 if (!GetStringFromConfig(KSectionQueryExtensions, bufExtensionNameKey, ptrExtensionNameValue16)) |
|
217 { |
|
218 ERR_PRINTF2(_L("Cannot find key '%S' in INI file"), &bufExtensionNameKey); |
|
219 User::Leave(KErrArgument); |
|
220 } |
|
221 INFO_PRINTF2(_L("Checking for extension \"%S\""), &ptrExtensionNameValue16); |
|
222 TEST(CheckForExtensionL(0, ptrExtensionNameValue16)); |
|
223 } |
|
224 |
|
225 numExtensions=0; |
|
226 if (!GetIntFromConfig(KSectionQueryExtensions, KKeyCountExtensionsVG, numExtensions)) |
|
227 { |
|
228 ERR_PRINTF2(_L("Cannot find key '%S' in INI file"), &KKeyCountExtensionsVG); |
|
229 User::Leave(KErrArgument); |
|
230 } |
|
231 INFO_PRINTF2(_L("Looking for %d VG extensions"), numExtensions); |
|
232 for(TUint i=0; i<numExtensions; i++) |
|
233 { |
|
234 bufExtensionNameKey.Format(KKeyExtensionVGX, i); |
|
235 if (!GetStringFromConfig(ConfigSection(), bufExtensionNameKey, ptrExtensionNameValue16)) |
|
236 { |
|
237 ERR_PRINTF2(_L("Cannot find key '%S' in INI file"), &bufExtensionNameKey); |
|
238 User::Leave(KErrArgument); |
|
239 } |
|
240 INFO_PRINTF2(_L("Checking for extension \"%S\""), &ptrExtensionNameValue16); |
|
241 TEST(CheckForExtensionL(0, ptrExtensionNameValue16)); |
|
242 } |
|
243 |
|
244 RecordTestResultL(); |
|
245 CloseTMSGraphicsStep(); |
|
246 return TestStepResult(); |
|
247 } |
|
248 |
|
249 /** |
|
250 @SYMTestCaseID GRAPHICS-EGL-0012 |
|
251 |
|
252 @SYMTestPriority 3 |
|
253 |
|
254 @SYMPREQ 39 |
|
255 |
|
256 @SYMREQ ReqNum |
|
257 |
|
258 @SYMTestCaseDesc |
|
259 Ensure that eglGetProcAddress() returns NULL when given invalid data. |
|
260 |
|
261 @SYMTestActions |
|
262 Call eglGetProcAddress() with a <procname> that is known not to be supported - e.g. "qwerty" |
|
263 Call eglGetProcAddress() with an empty <procname> - i.e. "" |
|
264 Call eglGetProcAddress() with a null <procname> - i.e. NULL |
|
265 |
|
266 @SYMTestExpectedResults |
|
267 For each case, eglGetProcAddress() should return NULL, without raising an EGL error. |
|
268 */ |
|
269 TVerdict CEglTest_General_Negative_ProcAddress::doTestStepL() |
|
270 { |
|
271 SetTestStepID(_L("GRAPHICS-EGL-0012")); |
|
272 INFO_PRINTF1(_L("CEglTest_General_Negative_ProcAddress::doTestStepL")); |
|
273 |
|
274 // Create display object |
|
275 GetDisplayL(); |
|
276 |
|
277 // Initialize display object |
|
278 INFO_PRINTF1(_L("Calling eglInitialize")); |
|
279 TEST_EGL_ERROR(eglInitialize(iDisplay, NULL, NULL), EGL_SUCCESS); |
|
280 |
|
281 INFO_PRINTF1(_L("Calling eglGetProcAddress() with a 'procname' that is known not to be supported")); |
|
282 TEST_EGL_ERROR(eglGetProcAddress("qwerty") == NULL, EGL_SUCCESS); |
|
283 |
|
284 INFO_PRINTF1(_L("Calling eglGetProcAddress() with an empty 'procname'")); |
|
285 TEST_EGL_ERROR(eglGetProcAddress("") == NULL, EGL_SUCCESS); |
|
286 |
|
287 INFO_PRINTF1(_L("Calling eglGetProcAddress() with a null 'procname'")); |
|
288 TEST_EGL_ERROR(eglGetProcAddress(NULL) == NULL, EGL_SUCCESS); |
|
289 |
|
290 TerminateDisplayL(); |
|
291 RecordTestResultL(); |
|
292 CloseTMSGraphicsStep(); |
|
293 return TestStepResult(); |
|
294 } |
|
295 |
|
296 |
|
297 /** |
|
298 @SYMTestCaseID GRAPHICS-EGL-0309 |
|
299 |
|
300 @SYMPREQ PREQ2650 |
|
301 |
|
302 @SYMTestCaseDesc |
|
303 1. EglTerminate() with an invalid/non-existant display |
|
304 2. Double eglTerminate() with an uninitialised display |
|
305 3. Double eglTerminate() with an initialised display |
|
306 |
|
307 @SYMTestPriority High |
|
308 |
|
309 @SYMTestStatus Implemented |
|
310 |
|
311 @SYMTestActions |
|
312 1. Call eglTerminate with an invalid display handle argument. Call eglTerminate with EGL_NO_DISPLAY argument |
|
313 2. Create an uninitialised display and call eglTerminate() twice. Re-create and terminate the display to check for memory leaks. |
|
314 3. Create an initialised display and call eglTerminate() twice. Re-create and terminate the display to check for memory leaks. |
|
315 |
|
316 @SYMTestExpectedResults |
|
317 1. eglTerminate should return EGL_FALSE on both calls with error EGL_BAD_DISPLAY |
|
318 2. eglTerminate should return EGL_TRUE on all calls and the display should not be set to EGL_NO_DISPLAY. |
|
319 3. eglTerminate should return EGL_TRUE on all calls and the display should not be set to EGL_NO_DISPLAY. |
|
320 The UHEAP markers should indicate no memory leaks after this test case has run. |
|
321 */ |
|
322 TVerdict CEglTest_EglTerminate_Negative::doTestStepL() |
|
323 { |
|
324 INFO_PRINTF1(_L("CEglTest_EglTerminate_Negative::doTestStepL")); |
|
325 SetTestStepID(_L("GRAPHICS-EGL-0309")); |
|
326 |
|
327 //Test 1 - Arbitrary invalid display handle |
|
328 const EGLDisplay invalidDisplay = 77; |
|
329 |
|
330 //Call eglTerminate with the invalid display handle |
|
331 TEST(eglTerminate(invalidDisplay) == EGL_FALSE); |
|
332 ASSERT_EGL_ERROR(EGL_BAD_DISPLAY); |
|
333 |
|
334 //Call eglTerminate with argument EGL_NO_DISPLAY |
|
335 TEST(eglTerminate(EGL_NO_DISPLAY) == EGL_FALSE); |
|
336 ASSERT_EGL_ERROR(EGL_BAD_DISPLAY); |
|
337 |
|
338 //Test 2 - Create display object |
|
339 iDisplay = EGL_NO_DISPLAY; |
|
340 GetDisplayL(); |
|
341 |
|
342 //Call eglTerminate twice |
|
343 ASSERT_EGL_TRUE(eglTerminate(iDisplay)); |
|
344 TEST(eglGetError() == EGL_SUCCESS); |
|
345 |
|
346 ASSERT_EGL_TRUE(eglTerminate(iDisplay)); |
|
347 TEST(eglGetError() == EGL_SUCCESS); |
|
348 |
|
349 //Recreate display object and call eglTerminate() |
|
350 iDisplay = EGL_NO_DISPLAY; |
|
351 GetDisplayL(); |
|
352 ASSERT_EGL_TRUE(eglTerminate(iDisplay)); |
|
353 TEST(eglGetError() == EGL_SUCCESS); |
|
354 |
|
355 //Test 3 |
|
356 iDisplay = EGL_NO_DISPLAY; |
|
357 GetDisplayL(); |
|
358 CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, 0); |
|
359 |
|
360 // Initialise the display object |
|
361 eglSess->InitializeL(); |
|
362 |
|
363 //Call eglTerminate twice |
|
364 ASSERT_EGL_TRUE(eglTerminate(iDisplay)); |
|
365 TEST(eglGetError() == EGL_SUCCESS); |
|
366 |
|
367 ASSERT_EGL_TRUE(eglTerminate(iDisplay)); |
|
368 TEST(eglGetError() == EGL_SUCCESS); |
|
369 |
|
370 //Recreate display object |
|
371 iDisplay = EGL_NO_DISPLAY; |
|
372 GetDisplayL(); |
|
373 |
|
374 //Call eglTerminate |
|
375 ASSERT_EGL_TRUE(eglTerminate(iDisplay)); |
|
376 TEST(eglGetError() == EGL_SUCCESS); |
|
377 |
|
378 //cleanup and stuff... |
|
379 CleanupStack::PopAndDestroy(1, eglSess); |
|
380 ASSERT_EGL_TRUE(eglReleaseThread()); |
|
381 |
|
382 RecordTestResultL(); |
|
383 CloseTMSGraphicsStep(); |
|
384 return TestStepResult(); |
|
385 } |