1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program EGL Module
3 * ---------------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief Negative API Tests.
22 *//*--------------------------------------------------------------------*/
24 #include "teglNegativeApiTests.hpp"
25 #include "teglApiCase.hpp"
27 #include "egluNativeDisplay.hpp"
28 #include "egluNativeWindow.hpp"
29 #include "egluUtil.hpp"
30 #include "egluUnique.hpp"
43 template <deUint32 Type>
44 static bool renderable (const eglu::CandidateConfig& c)
46 return (c.renderableType() & Type) == Type;
49 template <deUint32 Type>
50 static bool notRenderable (const eglu::CandidateConfig& c)
52 return (c.renderableType() & Type) == 0;
55 template <deUint32 Bits>
56 static bool surfaceBits (const eglu::CandidateConfig& c)
58 return (c.surfaceType() & Bits) == Bits;
61 template <deUint32 Bits>
62 static bool notSurfaceBits (const eglu::CandidateConfig& c)
64 return (c.surfaceType() & Bits) == 0;
67 NegativeApiTests::NegativeApiTests (EglTestContext& eglTestCtx)
68 : TestCaseGroup(eglTestCtx, "negative_api", "Negative API Tests")
72 NegativeApiTests::~NegativeApiTests (void)
76 void NegativeApiTests::init (void)
78 // \todo [2012-10-02 pyry] Add tests for EGL_NOT_INITIALIZED to all functions taking in EGLDisplay
79 // \todo [2012-10-02 pyry] Implement negative cases for following non-trivial cases:
80 // * eglBindTexImage()
81 // - EGL_BAD_ACCESS is generated if buffer is already bound to a texture
82 // - EGL_BAD_MATCH is generated if the surface attribute EGL_TEXTURE_FORMAT is set to EGL_NO_TEXTURE
83 // - EGL_BAD_MATCH is generated if buffer is not a valid buffer (currently only EGL_BACK_BUFFER may be specified)
84 // - EGL_BAD_SURFACE is generated if surface is not a pbuffer surface supporting texture binding
86 // - EGL_BAD_NATIVE_PIXMAP is generated if the implementation does not support native pixmaps
87 // - EGL_BAD_NATIVE_PIXMAP may be generated if native_pixmap is not a valid native pixmap
88 // - EGL_BAD_MATCH is generated if the format of native_pixmap is not compatible with the color buffer of surface
89 // * eglCreateContext()
90 // - EGL_BAD_MATCH is generated if the current rendering API is EGL_NONE
91 // - EGL_BAD_MATCH is generated if the server context state for share_context exists in an address space which cannot be shared with the newly created context
92 // - EGL_BAD_CONTEXT is generated if share_context is not an EGL rendering context of the same client API type as the newly created context and is not EGL_NO_CONTEXT
93 // * eglCreatePbufferFromClientBuffer()
94 // - various BAD_MATCH, BAD_ACCESS etc. conditions
95 // * eglCreatePbufferSurface()
96 // - EGL_BAD_MATCH is generated if the EGL_TEXTURE_FORMAT attribute is not EGL_NO_TEXTURE, and EGL_WIDTH and/or EGL_HEIGHT specify an invalid size
97 // * eglCreatePixmapSurface()
98 // - EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid pixmap attribute
99 // - EGL_BAD_MATCH is generated if the attributes of native_pixmap do not correspond to config or if config does not support rendering to pixmaps
100 // - EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute
101 // * eglCreateWindowSurface()
102 // - EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid window attribute
103 // - EGL_BAD_MATCH is generated if the attributes of native_window do not correspond to config or if config does not support rendering to windows
104 // - EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute
105 // * eglMakeCurrent()
106 // - EGL_BAD_MATCH is generated if draw or read are not compatible with context
107 // - EGL_BAD_MATCH is generated if context is set to EGL_NO_CONTEXT and draw or read are not set to EGL_NO_SURFACE
108 // - EGL_BAD_MATCH is generated if draw or read are set to EGL_NO_SURFACE and context is not set to EGL_NO_CONTEXT
109 // - EGL_BAD_ACCESS is generated if context is current to some other thread
110 // - EGL_BAD_NATIVE_PIXMAP may be generated if a native pixmap underlying either draw or read is no longer valid
111 // - EGL_BAD_NATIVE_WINDOW may be generated if a native window underlying either draw or read is no longer valid
112 // * eglReleaseTexImage()
113 // - EGL_BAD_MATCH is generated if buffer is not a valid buffer (currently only EGL_BACK_BUFFER may be specified)
114 // * eglSwapInterval()
115 // - EGL_BAD_SURFACE is generated if there is no surface bound to the current context
117 // - EGL_BAD_CURRENT_SURFACE is generated if the surface associated with the current context has a native window or pixmap, and that window or pixmap is no longer valid
119 using namespace eglw;
120 using namespace eglu;
122 static const EGLint s_emptyAttribList[] = { EGL_NONE };
123 static const EGLint s_es1ContextAttribList[] = { EGL_CONTEXT_CLIENT_VERSION, 1, EGL_NONE };
124 static const EGLint s_es2ContextAttribList[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
126 static const EGLenum s_renderAPIs[] = { EGL_OPENGL_API, EGL_OPENGL_ES_API, EGL_OPENVG_API };
128 TEGL_ADD_API_CASE(bind_api, "eglBindAPI() negative tests",
130 TestLog& log = m_testCtx.getLog();
131 log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if api is not one of the accepted tokens");
133 expectFalse(eglBindAPI(0));
134 expectError(EGL_BAD_PARAMETER);
136 expectFalse(eglBindAPI(0xfdfdfdfd));
137 expectError(EGL_BAD_PARAMETER);
139 expectFalse(eglBindAPI((EGLenum)0xffffffff));
140 expectError(EGL_BAD_PARAMETER);
142 log << TestLog::EndSection;
144 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if the specified client API is not supported by the EGL implementation");
146 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_renderAPIs); ndx++)
148 if (!isAPISupported(s_renderAPIs[ndx]))
150 expectFalse(eglBindAPI(s_renderAPIs[ndx]));
151 expectError(EGL_BAD_PARAMETER);
155 log << TestLog::EndSection;
158 TEGL_ADD_API_CASE(bind_tex_image, "eglBindTexImage() negative tests",
160 TestLog& log = m_testCtx.getLog();
161 EGLDisplay display = getDisplay();
163 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
165 expectFalse(eglBindTexImage(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_BACK_BUFFER));
166 expectError(EGL_BAD_DISPLAY);
168 expectFalse(eglBindTexImage((EGLDisplay)-1, EGL_NO_SURFACE, EGL_BACK_BUFFER));
169 expectError(EGL_BAD_DISPLAY);
171 log << TestLog::EndSection;
173 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
175 expectFalse(eglBindTexImage(display, EGL_NO_SURFACE, EGL_BACK_BUFFER));
176 expectError(EGL_BAD_SURFACE);
178 expectFalse(eglBindTexImage(display, (EGLSurface)-1, EGL_BACK_BUFFER));
179 expectError(EGL_BAD_SURFACE);
181 log << TestLog::EndSection;
184 TEGL_ADD_API_CASE(copy_buffers, "eglCopyBuffers() negative tests",
186 TestLog& log = m_testCtx.getLog();
187 EGLDisplay display = getDisplay();
189 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
191 expectFalse(eglCopyBuffers(EGL_NO_DISPLAY, EGL_NO_SURFACE, (EGLNativePixmapType)0));
192 expectError(EGL_BAD_DISPLAY);
194 expectFalse(eglCopyBuffers((EGLDisplay)-1, EGL_NO_SURFACE, (EGLNativePixmapType)0));
195 expectError(EGL_BAD_DISPLAY);
197 log << TestLog::EndSection;
199 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
201 expectFalse(eglCopyBuffers(display, EGL_NO_SURFACE, (EGLNativePixmapType)0));
202 expectError(EGL_BAD_SURFACE);
204 expectFalse(eglCopyBuffers(display, (EGLSurface)-1, (EGLNativePixmapType)0));
205 expectError(EGL_BAD_SURFACE);
207 log << TestLog::EndSection;
210 static const EGLint s_invalidChooseConfigAttribList0[] = { 0, EGL_NONE };
211 static const EGLint s_invalidChooseConfigAttribList1[] = { (EGLint)0xffffffff };
212 static const EGLint s_invalidChooseConfigAttribList2[] = { EGL_BIND_TO_TEXTURE_RGB, 4, EGL_NONE };
213 static const EGLint s_invalidChooseConfigAttribList3[] = { EGL_BIND_TO_TEXTURE_RGBA, 5, EGL_NONE };
214 static const EGLint s_invalidChooseConfigAttribList4[] = { EGL_COLOR_BUFFER_TYPE, 0, EGL_NONE };
215 static const EGLint s_invalidChooseConfigAttribList5[] = { EGL_MATCH_NATIVE_PIXMAP, -1, EGL_NONE };
216 static const EGLint s_invalidChooseConfigAttribList6[] = { EGL_NATIVE_RENDERABLE, 6, EGL_NONE };
217 static const EGLint s_invalidChooseConfigAttribList7[] = { EGL_TRANSPARENT_TYPE, 6, EGL_NONE };
218 static const EGLint* s_invalidChooseConfigAttribLists[] =
220 &s_invalidChooseConfigAttribList0[0],
221 &s_invalidChooseConfigAttribList1[0],
222 &s_invalidChooseConfigAttribList2[0],
223 &s_invalidChooseConfigAttribList3[0],
224 &s_invalidChooseConfigAttribList4[0],
225 &s_invalidChooseConfigAttribList5[0],
226 &s_invalidChooseConfigAttribList6[0],
227 &s_invalidChooseConfigAttribList7[0]
230 TEGL_ADD_API_CASE(choose_config, "eglChooseConfig() negative tests",
232 TestLog& log = m_testCtx.getLog();
233 EGLDisplay display = getDisplay();
234 EGLConfig configs[1];
237 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
239 expectFalse(eglChooseConfig(EGL_NO_DISPLAY, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
240 expectError(EGL_BAD_DISPLAY);
242 expectFalse(eglChooseConfig((EGLDisplay)-1, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
243 expectError(EGL_BAD_DISPLAY);
245 log << TestLog::EndSection;
247 log << TestLog::Section("Test2", "EGL_BAD_ATTRIBUTE is generated if attribute_list contains an invalid frame buffer configuration attribute");
249 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidChooseConfigAttribLists); ndx++)
251 expectFalse(eglChooseConfig(display, s_invalidChooseConfigAttribLists[ndx], &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
252 expectError(EGL_BAD_ATTRIBUTE);
255 log << TestLog::EndSection;
257 log << TestLog::Section("Test3", "EGL_BAD_PARAMETER is generated if num_config is NULL");
259 expectFalse(eglChooseConfig(display, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), DE_NULL));
260 expectError(EGL_BAD_PARAMETER);
262 log << TestLog::EndSection;
265 static const EGLint s_invalidCreateContextAttribList0[] = { 0, EGL_NONE };
266 static const EGLint s_invalidCreateContextAttribList1[] = { (EGLint)0xffffffff };
268 TEGL_ADD_API_CASE(create_context, "eglCreateContext() negative tests",
270 TestLog& log = m_testCtx.getLog();
271 EGLDisplay display = getDisplay();
273 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
275 expectNoContext(eglCreateContext(EGL_NO_DISPLAY, DE_NULL, EGL_NO_CONTEXT, s_emptyAttribList));
276 expectError(EGL_BAD_DISPLAY);
278 expectNoContext(eglCreateContext((EGLDisplay)-1, DE_NULL, EGL_NO_CONTEXT, s_emptyAttribList));
279 expectError(EGL_BAD_DISPLAY);
281 log << TestLog::EndSection;
283 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
285 expectNoContext(eglCreateContext(display, (EGLConfig)-1, EGL_NO_CONTEXT, s_emptyAttribList));
286 expectError(EGL_BAD_CONFIG);
288 log << TestLog::EndSection;
290 log << TestLog::Section("Test3", "EGL_BAD_CONFIG is generated if config does not support the current rendering API");
292 if (isAPISupported(EGL_OPENGL_API))
294 EGLConfig es1OnlyConfig;
295 if (getConfig(&es1OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT> << notRenderable<EGL_OPENGL_BIT>))
297 expectTrue(eglBindAPI(EGL_OPENGL_API));
298 expectNoContext(eglCreateContext(display, es1OnlyConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
299 expectError(EGL_BAD_CONFIG);
302 EGLConfig es2OnlyConfig;
303 if (getConfig(&es2OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << notRenderable<EGL_OPENGL_BIT>))
305 expectTrue(eglBindAPI(EGL_OPENGL_API));
306 expectNoContext(eglCreateContext(display, es2OnlyConfig, EGL_NO_CONTEXT, s_es2ContextAttribList));
307 expectError(EGL_BAD_CONFIG);
310 EGLConfig vgOnlyConfig;
311 if (getConfig(&vgOnlyConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notRenderable<EGL_OPENGL_BIT>))
313 expectTrue(eglBindAPI(EGL_OPENGL_API));
314 expectNoContext(eglCreateContext(display, vgOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
315 expectError(EGL_BAD_CONFIG);
319 if (isAPISupported(EGL_OPENGL_ES_API))
321 EGLConfig glOnlyConfig;
322 if (getConfig(&glOnlyConfig, FilterList() << renderable<EGL_OPENGL_BIT> << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>))
324 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
325 expectNoContext(eglCreateContext(display, glOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
326 expectError(EGL_BAD_CONFIG);
329 EGLConfig vgOnlyConfig;
330 if (getConfig(&vgOnlyConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>))
332 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
333 expectNoContext(eglCreateContext(display, vgOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
334 expectError(EGL_BAD_CONFIG);
338 if (isAPISupported(EGL_OPENVG_API))
340 EGLConfig glOnlyConfig;
341 if (getConfig(&glOnlyConfig, FilterList() << renderable<EGL_OPENGL_BIT> << notRenderable<EGL_OPENVG_BIT>))
343 expectTrue(eglBindAPI(EGL_OPENVG_API));
344 expectNoContext(eglCreateContext(display, glOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
345 expectError(EGL_BAD_CONFIG);
348 EGLConfig es1OnlyConfig;
349 if (getConfig(&es1OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT> << notRenderable<EGL_OPENVG_BIT>))
351 expectTrue(eglBindAPI(EGL_OPENVG_API));
352 expectNoContext(eglCreateContext(display, es1OnlyConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
353 expectError(EGL_BAD_CONFIG);
356 EGLConfig es2OnlyConfig;
357 if (getConfig(&es2OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << notRenderable<EGL_OPENVG_BIT>))
359 expectTrue(eglBindAPI(EGL_OPENVG_API));
360 expectNoContext(eglCreateContext(display, es2OnlyConfig, EGL_NO_CONTEXT, s_es2ContextAttribList));
361 expectError(EGL_BAD_CONFIG);
365 log << TestLog::EndSection;
367 log << TestLog::Section("Test4", "EGL_BAD_CONFIG is generated if OpenGL ES 1.x context is requested and EGL_RENDERABLE_TYPE attribute of config does not contain EGL_OPENGL_ES_BIT");
369 if (isAPISupported(EGL_OPENGL_ES_API))
371 EGLConfig notES1Config;
372 if (getConfig(¬ES1Config, FilterList() << notRenderable<EGL_OPENGL_ES_BIT>))
374 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
375 expectNoContext(eglCreateContext(display, notES1Config, EGL_NO_CONTEXT, s_es1ContextAttribList));
376 expectError(EGL_BAD_CONFIG);
380 log << TestLog::EndSection;
382 log << TestLog::Section("Test5", "EGL_BAD_CONFIG is generated if OpenGL ES 2.x context is requested and EGL_RENDERABLE_TYPE attribute of config does not contain EGL_OPENGL_ES2_BIT");
384 if (isAPISupported(EGL_OPENGL_ES_API))
386 EGLConfig notES2Config;
387 if (getConfig(¬ES2Config, FilterList() << notRenderable<EGL_OPENGL_ES2_BIT>))
389 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
390 expectNoContext(eglCreateContext(display, notES2Config, EGL_NO_CONTEXT, s_es2ContextAttribList));
391 expectError(EGL_BAD_CONFIG);
395 log << TestLog::EndSection;
397 log << TestLog::Section("Test6", "EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid context attribute");
399 if (isAPISupported(EGL_OPENGL_API))
402 if (getConfig(&glConfig, FilterList() << renderable<EGL_OPENGL_BIT>))
404 expectTrue(eglBindAPI(EGL_OPENGL_API));
405 expectNoContext(eglCreateContext(display, glConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
406 expectError(EGL_BAD_ATTRIBUTE);
410 if (isAPISupported(EGL_OPENVG_API))
413 if (getConfig(&vgConfig, FilterList() << renderable<EGL_OPENVG_BIT>))
415 expectTrue(eglBindAPI(EGL_OPENVG_API));
416 expectNoContext(eglCreateContext(display, vgConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
417 expectError(EGL_BAD_ATTRIBUTE);
421 if (isAPISupported(EGL_OPENGL_ES_API))
423 bool gotConfig = false;
426 gotConfig = getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT>) ||
427 getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
431 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
432 expectNoContext(eglCreateContext(display, esConfig, EGL_NO_CONTEXT, s_invalidCreateContextAttribList0));
433 expectError(EGL_BAD_ATTRIBUTE);
434 expectNoContext(eglCreateContext(display, esConfig, EGL_NO_CONTEXT, s_invalidCreateContextAttribList1));
435 expectError(EGL_BAD_ATTRIBUTE);
439 log << TestLog::EndSection;
442 TEGL_ADD_API_CASE(create_pbuffer_from_client_buffer, "eglCreatePbufferFromClientBuffer() negative tests",
444 TestLog& log = m_testCtx.getLog();
445 EGLDisplay display = getDisplay();
449 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
451 expectNoSurface(eglCreatePbufferFromClientBuffer(EGL_NO_DISPLAY, EGL_OPENVG_IMAGE, 0, (EGLConfig)0, DE_NULL));
452 expectError(EGL_BAD_DISPLAY);
454 expectNoSurface(eglCreatePbufferFromClientBuffer((EGLDisplay)-1, EGL_OPENVG_IMAGE, 0, (EGLConfig)0, DE_NULL));
455 expectError(EGL_BAD_DISPLAY);
457 log << TestLog::EndSection;
459 log << TestLog::Section("Test2", "EGL_BAD_CONFIG or EGL_BAD_PARAMETER is generated if config is not an EGL frame buffer configuration and if buffer is not valid OpenVG image");
461 expectNoSurface(eglCreatePbufferFromClientBuffer(display, EGL_OPENVG_IMAGE, (EGLClientBuffer)-1, (EGLConfig)-1, DE_NULL));
462 expectEitherError(EGL_BAD_CONFIG, EGL_BAD_PARAMETER);
464 log << TestLog::EndSection;
466 log << TestLog::Section("Test3", "EGL_BAD_PARAMETER is generated if buftype is not EGL_OPENVG_IMAGE");
468 log << TestLog::EndSection;
470 expectTrue(eglGetConfigs(display, &anyConfig, 1, &unused));
472 log << TestLog::Section("Test4", "EGL_BAD_PARAMETER is generated if buffer is not valid OpenVG image");
473 expectNoSurface(eglCreatePbufferFromClientBuffer(display, EGL_OPENVG_IMAGE, (EGLClientBuffer)-1, anyConfig, DE_NULL));
474 expectError(EGL_BAD_PARAMETER);
476 log << TestLog::EndSection;
479 static const EGLint s_validGenericPbufferAttrib[] = { EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
481 static const EGLint s_invalidGenericPbufferAttrib0[] = { 0, EGL_NONE };
482 static const EGLint s_invalidGenericPbufferAttrib1[] = { (EGLint)0xffffffff };
483 static const EGLint s_negativeWidthPbufferAttrib[] = { EGL_WIDTH, -1, EGL_HEIGHT, 64, EGL_NONE };
484 static const EGLint s_negativeHeightPbufferAttrib[] = { EGL_WIDTH, 64, EGL_HEIGHT, -1, EGL_NONE };
485 static const EGLint s_negativeWidthAndHeightPbufferAttrib[] = { EGL_WIDTH, -1, EGL_HEIGHT, -1, EGL_NONE };
486 static const EGLint* s_invalidGenericPbufferAttribs[] =
488 s_invalidGenericPbufferAttrib0,
489 s_invalidGenericPbufferAttrib1,
492 static const EGLint s_invalidNoEsPbufferAttrib0[] = { EGL_MIPMAP_TEXTURE, EGL_TRUE, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
493 static const EGLint s_invalidNoEsPbufferAttrib1[] = { EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
494 static const EGLint s_invalidNoEsPbufferAttrib2[] = { EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
495 static const EGLint* s_invalidNoEsPbufferAttribs[] =
497 s_invalidNoEsPbufferAttrib0,
498 s_invalidNoEsPbufferAttrib1,
499 s_invalidNoEsPbufferAttrib2
502 static const EGLint s_invalidEsPbufferAttrib0[] = { EGL_TEXTURE_FORMAT, EGL_NO_TEXTURE, EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
503 static const EGLint s_invalidEsPbufferAttrib1[] = { EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA, EGL_TEXTURE_TARGET, EGL_NO_TEXTURE, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
504 static const EGLint* s_invalidEsPbufferAttribs[] =
506 s_invalidEsPbufferAttrib0,
507 s_invalidEsPbufferAttrib1
510 static const EGLint s_vgPreMultAlphaPbufferAttrib[] = { EGL_ALPHA_FORMAT, EGL_ALPHA_FORMAT_PRE, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
511 static const EGLint s_vgLinearColorspacePbufferAttrib[] = { EGL_COLORSPACE, EGL_VG_COLORSPACE_LINEAR, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
513 TEGL_ADD_API_CASE(create_pbuffer_surface, "eglCreatePbufferSurface() negative tests",
515 TestLog& log = m_testCtx.getLog();
516 EGLDisplay display = getDisplay();
518 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
520 expectNoSurface(eglCreatePbufferSurface(EGL_NO_DISPLAY, DE_NULL, s_emptyAttribList));
521 expectError(EGL_BAD_DISPLAY);
523 expectNoSurface(eglCreatePbufferSurface((EGLDisplay)-1, DE_NULL, s_emptyAttribList));
524 expectError(EGL_BAD_DISPLAY);
526 log << TestLog::EndSection;
528 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
530 expectNoSurface(eglCreatePbufferSurface(display, (EGLConfig)-1, s_emptyAttribList));
531 expectError(EGL_BAD_CONFIG);
533 log << TestLog::EndSection;
535 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid pixel buffer attribute");
537 // Generic pbuffer-capable config
538 EGLConfig genericConfig;
539 if (getConfig(&genericConfig, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
541 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidGenericPbufferAttribs); ndx++)
543 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_invalidGenericPbufferAttribs[ndx]));
544 expectError(EGL_BAD_ATTRIBUTE);
548 log << TestLog::EndSection;
550 log << TestLog::Section("Test4", "EGL_BAD_MATCH is generated if config does not support rendering to pixel buffers");
552 EGLConfig noPbufferConfig;
553 if (getConfig(&noPbufferConfig, FilterList() << notSurfaceBits<EGL_PBUFFER_BIT>))
555 expectNoSurface(eglCreatePbufferSurface(display, noPbufferConfig, s_validGenericPbufferAttrib));
556 expectError(EGL_BAD_MATCH);
559 log << TestLog::EndSection;
561 log << TestLog::Section("Test5", "EGL_BAD_ATTRIBUTE is generated if attrib_list contains any of the attributes EGL_MIPMAP_TEXTURE, EGL_TEXTURE_FORMAT, or EGL_TEXTURE_TARGET, and config does not support OpenGL ES rendering");
563 EGLConfig noEsConfig;
564 if (getConfig(&noEsConfig, FilterList() << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>))
566 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidNoEsPbufferAttribs); ndx++)
568 expectNoSurface(eglCreatePbufferSurface(display, noEsConfig, s_invalidNoEsPbufferAttribs[ndx]));
569 expectError(EGL_BAD_MATCH);
573 log << TestLog::EndSection;
575 log << TestLog::Section("Test6", "EGL_BAD_MATCH is generated if the EGL_TEXTURE_FORMAT attribute is EGL_NO_TEXTURE, and EGL_TEXTURE_TARGET is something other than EGL_NO_TEXTURE; or, EGL_TEXTURE_FORMAT is something other than EGL_NO_TEXTURE, and EGL_TEXTURE_TARGET is EGL_NO_TEXTURE");
577 // ES1 or ES2 config.
579 bool gotEsConfig = getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT>) ||
580 getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
583 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidEsPbufferAttribs); ndx++)
585 expectNoSurface(eglCreatePbufferSurface(display, esConfig, s_invalidEsPbufferAttribs[ndx]));
586 expectError(EGL_BAD_MATCH);
590 log << TestLog::EndSection;
592 log << TestLog::Section("Test7", "EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute");
594 EGLConfig vgNoPreConfig;
595 if (getConfig(&vgNoPreConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notSurfaceBits<EGL_VG_ALPHA_FORMAT_PRE_BIT>))
597 expectNoSurface(eglCreatePbufferSurface(display, vgNoPreConfig, s_vgPreMultAlphaPbufferAttrib));
598 expectError(EGL_BAD_MATCH);
601 EGLConfig vgNoLinearConfig;
602 if (getConfig(&vgNoLinearConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notSurfaceBits<EGL_VG_COLORSPACE_LINEAR_BIT>))
604 expectNoSurface(eglCreatePbufferSurface(display, vgNoLinearConfig, s_vgLinearColorspacePbufferAttrib));
605 expectError(EGL_BAD_MATCH);
608 log << TestLog::EndSection;
610 log << TestLog::Section("Test8", "EGL_BAD_PARAMETER is generated if EGL_WIDTH or EGL_HEIGHT is negative");
612 if (getConfig(&genericConfig, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
614 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeWidthPbufferAttrib));
615 expectError(EGL_BAD_PARAMETER);
617 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeHeightPbufferAttrib));
618 expectError(EGL_BAD_PARAMETER);
620 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeWidthAndHeightPbufferAttrib));
621 expectError(EGL_BAD_PARAMETER);
624 log << TestLog::EndSection;
628 TEGL_ADD_API_CASE(create_pixmap_surface, "eglCreatePixmapSurface() negative tests",
630 TestLog& log = m_testCtx.getLog();
631 EGLDisplay display = getDisplay();
633 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
635 expectNoSurface(eglCreatePixmapSurface(EGL_NO_DISPLAY, DE_NULL, DE_NULL, s_emptyAttribList));
636 expectError(EGL_BAD_DISPLAY);
638 expectNoSurface(eglCreatePixmapSurface((EGLDisplay)-1, DE_NULL, DE_NULL, s_emptyAttribList));
639 expectError(EGL_BAD_DISPLAY);
641 log << TestLog::EndSection;
643 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
645 expectNoSurface(eglCreatePixmapSurface(display, (EGLConfig)-1, DE_NULL, s_emptyAttribList));
646 expectError(EGL_BAD_CONFIG);
648 log << TestLog::EndSection;
650 log << TestLog::Section("Test3", "EGL_BAD_NATIVE_PIXMAP may be generated if native_pixmap is not a valid native pixmap");
652 // Any pixmap-capable config.
653 EGLConfig pixmapConfig;
654 if (getConfig(&pixmapConfig, FilterList() << surfaceBits<EGL_PIXMAP_BIT>))
656 expectNoSurface(eglCreatePixmapSurface(display, pixmapConfig, DE_NULL, s_emptyAttribList));
657 expectError(EGL_BAD_NATIVE_PIXMAP);
660 log << TestLog::EndSection;
663 TEGL_ADD_API_CASE(create_window_surface, "eglCreateWindowSurface() negative tests",
665 TestLog& log = m_testCtx.getLog();
666 EGLDisplay display = getDisplay();
668 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
670 expectNoSurface(eglCreateWindowSurface(EGL_NO_DISPLAY, DE_NULL, DE_NULL, s_emptyAttribList));
671 expectError(EGL_BAD_DISPLAY);
673 expectNoSurface(eglCreateWindowSurface((EGLDisplay)-1, DE_NULL, DE_NULL, s_emptyAttribList));
674 expectError(EGL_BAD_DISPLAY);
676 log << TestLog::EndSection;
678 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
680 expectNoSurface(eglCreateWindowSurface(display, (EGLConfig)-1, DE_NULL, s_emptyAttribList));
681 expectError(EGL_BAD_CONFIG);
683 log << TestLog::EndSection;
685 log << TestLog::Section("Test3", "EGL_BAD_NATIVE_WINDOW may be generated if native_window is not a valid native window");
687 // Any window-capable config.
688 EGLConfig windowConfig;
689 if (getConfig(&windowConfig, FilterList() << surfaceBits<EGL_WINDOW_BIT>))
691 expectNoSurface(eglCreateWindowSurface(display, windowConfig, DE_NULL, s_emptyAttribList));
692 expectError(EGL_BAD_NATIVE_WINDOW);
695 log << TestLog::EndSection;
698 TEGL_ADD_API_CASE(destroy_context, "eglDestroyContext() negative tests",
700 TestLog& log = m_testCtx.getLog();
701 EGLDisplay display = getDisplay();
703 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
705 expectFalse(eglDestroyContext(EGL_NO_DISPLAY, DE_NULL));
706 expectError(EGL_BAD_DISPLAY);
708 expectFalse(eglDestroyContext((EGLDisplay)-1, DE_NULL));
709 expectError(EGL_BAD_DISPLAY);
711 log << TestLog::EndSection;
713 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
715 expectFalse(eglDestroyContext(display, DE_NULL));
716 expectError(EGL_BAD_CONTEXT);
718 expectFalse(eglDestroyContext(display, (EGLContext)-1));
719 expectError(EGL_BAD_CONTEXT);
721 log << TestLog::EndSection;
724 TEGL_ADD_API_CASE(destroy_surface, "eglDestroySurface() negative tests",
726 TestLog& log = m_testCtx.getLog();
727 EGLDisplay display = getDisplay();
729 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
731 expectFalse(eglDestroySurface(EGL_NO_DISPLAY, DE_NULL));
732 expectError(EGL_BAD_DISPLAY);
734 expectFalse(eglDestroySurface((EGLDisplay)-1, DE_NULL));
735 expectError(EGL_BAD_DISPLAY);
737 log << TestLog::EndSection;
739 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
741 expectFalse(eglDestroySurface(display, DE_NULL));
742 expectError(EGL_BAD_SURFACE);
744 expectFalse(eglDestroySurface(display, (EGLSurface)-1));
745 expectError(EGL_BAD_SURFACE);
747 log << TestLog::EndSection;
750 TEGL_ADD_API_CASE(get_config_attrib, "eglGetConfigAttrib() negative tests",
752 TestLog& log = m_testCtx.getLog();
753 EGLDisplay display = getDisplay();
756 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
758 expectFalse(eglGetConfigAttrib(EGL_NO_DISPLAY, DE_NULL, EGL_RED_SIZE, &value));
759 expectError(EGL_BAD_DISPLAY);
761 expectFalse(eglGetConfigAttrib((EGLDisplay)-1, DE_NULL, EGL_RED_SIZE, &value));
762 expectError(EGL_BAD_DISPLAY);
764 log << TestLog::EndSection;
766 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
768 expectFalse(eglGetConfigAttrib(display, (EGLConfig)-1, EGL_RED_SIZE, &value));
769 expectError(EGL_BAD_CONFIG);
771 log << TestLog::EndSection;
774 EGLConfig config = DE_NULL;
775 bool hasConfig = getConfig(&config, FilterList());
777 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid frame buffer configuration attribute");
781 expectFalse(eglGetConfigAttrib(display, config, 0, &value));
782 expectError(EGL_BAD_ATTRIBUTE);
784 expectFalse(eglGetConfigAttrib(display, config, -1, &value));
785 expectError(EGL_BAD_ATTRIBUTE);
788 log << TestLog::EndSection;
791 TEGL_ADD_API_CASE(get_configs, "eglGetConfigs() negative tests",
793 TestLog& log = m_testCtx.getLog();
794 EGLDisplay display = getDisplay();
798 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
800 expectFalse(eglGetConfigs(EGL_NO_DISPLAY, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), &numCfgs));
801 expectError(EGL_BAD_DISPLAY);
803 expectFalse(eglGetConfigs((EGLDisplay)-1, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), &numCfgs));
804 expectError(EGL_BAD_DISPLAY);
806 log << TestLog::EndSection;
808 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if num_config is NULL");
810 expectFalse(eglGetConfigs(display, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), DE_NULL));
811 expectError(EGL_BAD_PARAMETER);
813 log << TestLog::EndSection;
816 TEGL_ADD_API_CASE(get_display, "eglGetDisplay() negative tests",
818 expectNoDisplay(eglGetDisplay((EGLNativeDisplayType)-1));
819 expectError(EGL_SUCCESS);
822 TEGL_ADD_API_CASE(initialize, "eglInitialize() negative tests",
824 TestLog& log = m_testCtx.getLog();
828 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
830 expectFalse(eglInitialize(EGL_NO_DISPLAY, &major, &minor));
831 expectError(EGL_BAD_DISPLAY);
833 expectFalse(eglInitialize((EGLDisplay)-1, &major, &minor));
834 expectError(EGL_BAD_DISPLAY);
836 log << TestLog::EndSection;
839 TEGL_ADD_API_CASE(make_current, "eglMakeCurrent() negative tests",
841 TestLog& log = m_testCtx.getLog();
842 EGLDisplay display = getDisplay();
844 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
846 expectFalse(eglMakeCurrent(EGL_NO_DISPLAY, DE_NULL, DE_NULL, DE_NULL));
847 expectError(EGL_BAD_DISPLAY);
849 expectFalse(eglMakeCurrent((EGLDisplay)-1, DE_NULL, DE_NULL, DE_NULL));
850 expectError(EGL_BAD_DISPLAY);
852 log << TestLog::EndSection;
854 // Create simple pbuffer surface.
855 EGLSurface surface = EGL_NO_SURFACE;
858 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
860 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
861 expectError(EGL_SUCCESS);
865 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
867 expectFalse(eglMakeCurrent(display, (EGLSurface)-1, (EGLSurface)-1, DE_NULL));
868 expectError(EGL_BAD_SURFACE);
872 expectFalse(eglMakeCurrent(display, surface, (EGLSurface)-1, DE_NULL));
873 expectError(EGL_BAD_SURFACE);
875 expectFalse(eglMakeCurrent(display, (EGLSurface)-1, surface, DE_NULL));
876 expectError(EGL_BAD_SURFACE);
879 log << TestLog::EndSection;
881 log << TestLog::Section("Test3", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
885 expectFalse(eglMakeCurrent(display, surface, surface, (EGLContext)-1));
886 expectError(EGL_BAD_CONTEXT);
889 log << TestLog::EndSection;
893 eglDestroySurface(display, surface);
894 expectError(EGL_SUCCESS);
898 TEGL_ADD_API_CASE(get_current_context, "eglGetCurrentContext() negative tests",
900 expectNoContext(eglGetCurrentContext());
902 if (isAPISupported(EGL_OPENGL_ES_API))
904 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
905 expectError(EGL_SUCCESS);
907 expectNoContext(eglGetCurrentContext());
908 expectError(EGL_SUCCESS);
912 TEGL_ADD_API_CASE(get_current_surface, "eglGetCurrentSurface() negative tests",
914 TestLog& log = m_testCtx.getLog();
915 EGLDisplay display = getDisplay();
916 EGLConfig config = DE_NULL;
917 EGLContext context = EGL_NO_CONTEXT;
918 EGLSurface surface = EGL_NO_SURFACE;
919 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << surfaceBits<EGL_PBUFFER_BIT>);
923 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
924 expectError(EGL_SUCCESS);
926 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
927 expectError(EGL_SUCCESS);
929 // Create simple pbuffer surface.
930 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
931 expectError(EGL_SUCCESS);
933 expectTrue(eglMakeCurrent(display, surface, surface, context));
934 expectError(EGL_SUCCESS);
936 log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if readdraw is neither EGL_READ nor EGL_DRAW");
938 expectNoSurface(eglGetCurrentSurface(EGL_NONE));
939 expectError(EGL_BAD_PARAMETER);
941 log << TestLog::EndSection;
943 expectTrue(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
944 expectError(EGL_SUCCESS);
946 if (surface != EGL_NO_SURFACE)
948 expectTrue(eglDestroySurface(display, surface));
949 expectError(EGL_SUCCESS);
952 if (context != EGL_NO_CONTEXT)
954 expectTrue(eglDestroyContext(display, context));
955 expectError(EGL_SUCCESS);
960 TEGL_ADD_API_CASE(query_context, "eglQueryContext() negative tests",
962 TestLog& log = m_testCtx.getLog();
963 EGLDisplay display = getDisplay();
966 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
968 expectFalse(eglQueryContext(EGL_NO_DISPLAY, DE_NULL, EGL_CONFIG_ID, &value));
969 expectError(EGL_BAD_DISPLAY);
971 expectFalse(eglQueryContext((EGLDisplay)-1, DE_NULL, EGL_CONFIG_ID, &value));
972 expectError(EGL_BAD_DISPLAY);
974 log << TestLog::EndSection;
976 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
978 expectFalse(eglQueryContext(display, DE_NULL, EGL_CONFIG_ID, &value));
979 expectError(EGL_BAD_CONTEXT);
981 expectFalse(eglQueryContext(display, DE_NULL, EGL_CONFIG_ID, &value));
982 expectError(EGL_BAD_CONTEXT);
984 log << TestLog::EndSection;
986 // Create ES2 context.
987 EGLConfig config = DE_NULL;
988 EGLContext context = DE_NULL;
989 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
993 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
994 expectError(EGL_SUCCESS);
996 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
997 expectError(EGL_SUCCESS);
1000 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid context attribute");
1004 expectFalse(eglQueryContext(display, context, 0, &value));
1005 expectError(EGL_BAD_ATTRIBUTE);
1006 expectFalse(eglQueryContext(display, context, -1, &value));
1007 expectError(EGL_BAD_ATTRIBUTE);
1008 expectFalse(eglQueryContext(display, context, EGL_RED_SIZE, &value));
1009 expectError(EGL_BAD_ATTRIBUTE);
1012 log << TestLog::EndSection;
1016 expectTrue(eglDestroyContext(display, context));
1017 expectError(EGL_SUCCESS);
1021 TEGL_ADD_API_CASE(query_string, "eglQueryString() negative tests",
1023 TestLog& log = m_testCtx.getLog();
1024 EGLDisplay display = getDisplay();
1026 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1028 expectNull(eglQueryString(EGL_NO_DISPLAY, EGL_VENDOR));
1029 expectError(EGL_BAD_DISPLAY);
1031 expectNull(eglQueryString((EGLDisplay)-1, EGL_VENDOR));
1032 expectError(EGL_BAD_DISPLAY);
1034 log << TestLog::EndSection;
1036 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if name is not an accepted value");
1038 expectNull(eglQueryString(display, 0));
1039 expectError(EGL_BAD_PARAMETER);
1040 expectNull(eglQueryString(display, -1));
1041 expectError(EGL_BAD_PARAMETER);
1043 log << TestLog::EndSection;
1046 TEGL_ADD_API_CASE(query_surface, "eglQuerySurface() negative tests",
1048 TestLog& log = m_testCtx.getLog();
1049 EGLDisplay display = getDisplay();
1052 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1054 expectFalse(eglQuerySurface(EGL_NO_DISPLAY, DE_NULL, EGL_CONFIG_ID, &value));
1055 expectError(EGL_BAD_DISPLAY);
1057 expectFalse(eglQuerySurface((EGLDisplay)-1, DE_NULL, EGL_CONFIG_ID, &value));
1058 expectError(EGL_BAD_DISPLAY);
1060 log << TestLog::EndSection;
1062 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1064 expectFalse(eglQuerySurface(display, DE_NULL, EGL_CONFIG_ID, &value));
1065 expectError(EGL_BAD_SURFACE);
1067 expectFalse(eglQuerySurface(display, (EGLSurface)-1, EGL_CONFIG_ID, &value));
1068 expectError(EGL_BAD_SURFACE);
1070 log << TestLog::EndSection;
1072 // Create pbuffer surface.
1073 EGLSurface surface = EGL_NO_SURFACE;
1076 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
1078 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1079 expectError(EGL_SUCCESS);
1082 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1085 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid surface attribute");
1089 expectFalse(eglQuerySurface(display, surface, 0, &value));
1090 expectError(EGL_BAD_ATTRIBUTE);
1092 expectFalse(eglQuerySurface(display, surface, -1, &value));
1093 expectError(EGL_BAD_ATTRIBUTE);
1096 log << TestLog::EndSection;
1100 eglDestroySurface(display, surface);
1101 expectError(EGL_SUCCESS);
1105 TEGL_ADD_API_CASE(release_tex_image, "eglReleaseTexImage() negative tests",
1107 TestLog& log = m_testCtx.getLog();
1108 EGLDisplay display = getDisplay();
1110 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1112 expectFalse(eglReleaseTexImage(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1113 expectError(EGL_BAD_DISPLAY);
1115 expectFalse(eglReleaseTexImage((EGLDisplay)-1, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1116 expectError(EGL_BAD_DISPLAY);
1118 log << TestLog::EndSection;
1120 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1122 expectFalse(eglReleaseTexImage(display, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1123 expectError(EGL_BAD_SURFACE);
1125 expectFalse(eglReleaseTexImage(display, (EGLSurface)-1, EGL_BACK_BUFFER));
1126 expectError(EGL_BAD_SURFACE);
1128 log << TestLog::EndSection;
1131 TEGL_ADD_API_CASE(surface_attrib, "eglSurfaceAttrib() negative tests",
1133 TestLog& log = m_testCtx.getLog();
1134 EGLDisplay display = getDisplay();
1136 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1138 expectFalse(eglSurfaceAttrib(EGL_NO_DISPLAY, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1139 expectError(EGL_BAD_DISPLAY);
1141 expectFalse(eglSurfaceAttrib((EGLDisplay)-1, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1142 expectError(EGL_BAD_DISPLAY);
1144 log << TestLog::EndSection;
1146 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1148 expectFalse(eglSurfaceAttrib(display, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1149 expectError(EGL_BAD_SURFACE);
1151 expectFalse(eglSurfaceAttrib(display, (EGLSurface)-1, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1152 expectError(EGL_BAD_SURFACE);
1154 log << TestLog::EndSection;
1157 // Create pbuffer surface.
1158 EGLSurface surface = EGL_NO_SURFACE;
1161 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
1163 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1164 expectError(EGL_SUCCESS);
1167 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1170 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid surface attribute");
1174 expectFalse(eglSurfaceAttrib(display, surface, 0, 0));
1175 expectError(EGL_BAD_ATTRIBUTE);
1177 expectFalse(eglSurfaceAttrib(display, surface, -1, 0));
1178 expectError(EGL_BAD_ATTRIBUTE);
1181 log << TestLog::EndSection;
1185 eglDestroySurface(display, surface);
1186 expectError(EGL_SUCCESS);
1191 // Create pbuffer surface without EGL_MULTISAMPLE_RESOLVE_BOX_BIT.
1192 EGLSurface surface = EGL_NO_SURFACE;
1195 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT> << notSurfaceBits<EGL_MULTISAMPLE_RESOLVE_BOX_BIT>))
1197 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1198 expectError(EGL_SUCCESS);
1201 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1204 log << TestLog::Section("Test4", "EGL_BAD_MATCH is generated if attribute is EGL_MULTISAMPLE_RESOLVE, value is EGL_MULTISAMPLE_RESOLVE_BOX, and the EGL_SURFACE_TYPE attribute of the EGLConfig used to create surface does not contain EGL_MULTISAMPLE_RESOLVE_BOX_BIT");
1208 expectFalse(eglSurfaceAttrib(display, surface, EGL_MULTISAMPLE_RESOLVE, EGL_MULTISAMPLE_RESOLVE_BOX));
1209 expectError(EGL_BAD_MATCH);
1212 log << TestLog::EndSection;
1216 eglDestroySurface(display, surface);
1217 expectError(EGL_SUCCESS);
1222 // Create pbuffer surface without EGL_SWAP_BEHAVIOR_PRESERVED_BIT.
1223 EGLSurface surface = EGL_NO_SURFACE;
1226 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT> << notSurfaceBits<EGL_SWAP_BEHAVIOR_PRESERVED_BIT>))
1228 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1229 expectError(EGL_SUCCESS);
1232 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1235 log << TestLog::Section("Test5", "EGL_BAD_MATCH is generated if attribute is EGL_SWAP_BEHAVIOR, value is EGL_BUFFER_PRESERVED, and the EGL_SURFACE_TYPE attribute of the EGLConfig used to create surface does not contain EGL_SWAP_BEHAVIOR_PRESERVED_BIT");
1239 expectFalse(eglSurfaceAttrib(display, surface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED));
1240 expectError(EGL_BAD_MATCH);
1243 log << TestLog::EndSection;
1247 eglDestroySurface(display, surface);
1248 expectError(EGL_SUCCESS);
1253 TEGL_ADD_API_CASE(swap_buffers, "eglSwapBuffers() negative tests",
1255 TestLog& log = m_testCtx.getLog();
1256 EGLDisplay display = getDisplay();
1258 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1260 expectFalse(eglSwapBuffers(EGL_NO_DISPLAY, DE_NULL));
1261 expectError(EGL_BAD_DISPLAY);
1263 expectFalse(eglSwapBuffers((EGLDisplay)-1, DE_NULL));
1264 expectError(EGL_BAD_DISPLAY);
1266 log << TestLog::EndSection;
1268 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1270 expectFalse(eglSwapBuffers(display, DE_NULL));
1271 expectError(EGL_BAD_SURFACE);
1273 expectFalse(eglSwapBuffers(display, (EGLSurface)-1));
1274 expectError(EGL_BAD_SURFACE);
1276 log << TestLog::EndSection;
1279 TEGL_ADD_API_CASE(swap_interval, "eglSwapInterval() negative tests",
1281 TestLog& log = m_testCtx.getLog();
1282 EGLDisplay display = getDisplay();
1284 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1286 expectFalse(eglSwapInterval(EGL_NO_DISPLAY, 0));
1287 expectError(EGL_BAD_DISPLAY);
1289 expectFalse(eglSwapInterval((EGLDisplay)-1, 0));
1290 expectError(EGL_BAD_DISPLAY);
1292 log << TestLog::EndSection;
1294 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if there is no current context on the calling thread");
1296 expectFalse(eglSwapInterval(display, 0));
1297 expectError(EGL_BAD_CONTEXT);
1299 log << TestLog::EndSection;
1302 TEGL_ADD_API_CASE(terminate, "eglTerminate() negative tests",
1304 TestLog& log = m_testCtx.getLog();
1306 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1308 expectFalse(eglTerminate(EGL_NO_DISPLAY));
1309 expectError(EGL_BAD_DISPLAY);
1311 expectFalse(eglTerminate((EGLDisplay)-1));
1312 expectError(EGL_BAD_DISPLAY);
1314 log << TestLog::EndSection;
1317 TEGL_ADD_API_CASE(wait_native, "eglWaitNative() negative tests",
1319 EGLConfig config = DE_NULL;
1320 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << surfaceBits<EGL_WINDOW_BIT>);
1324 TestLog& log = m_testCtx.getLog();
1325 const Library& egl = m_eglTestCtx.getLibrary();
1326 EGLDisplay display = getDisplay();
1327 const eglu::NativeWindowFactory& factory = eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
1328 de::UniquePtr<eglu::NativeWindow> window (factory.createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(256, 256, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
1329 eglu::UniqueSurface surface (egl, display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, display, config, DE_NULL));
1330 EGLContext context = EGL_NO_CONTEXT;
1332 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
1333 expectError(EGL_SUCCESS);
1335 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
1336 expectError(EGL_SUCCESS);
1338 expectTrue(eglMakeCurrent(display, *surface, *surface, context));
1339 expectError(EGL_SUCCESS);
1341 log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if engine is not a recognized marking engine");
1343 expectFalse(eglWaitNative(-1));
1344 expectError(EGL_BAD_PARAMETER);
1346 log << TestLog::EndSection;
1348 expectTrue(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
1349 expectError(EGL_SUCCESS);
1351 if (context != EGL_NO_CONTEXT)
1353 expectTrue(eglDestroyContext(display, context));
1354 expectError(EGL_SUCCESS);