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"
36 NegativeApiTests::NegativeApiTests (EglTestContext& eglTestCtx)
37 : TestCaseGroup(eglTestCtx, "negative_api", "Negative API Tests")
41 NegativeApiTests::~NegativeApiTests (void)
45 void NegativeApiTests::init (void)
47 // \todo [2012-10-02 pyry] Add tests for EGL_NOT_INITIALIZED to all functions taking in EGLDisplay
48 // \todo [2012-10-02 pyry] Implement negative cases for following non-trivial cases:
49 // * eglBindTexImage()
50 // - EGL_BAD_ACCESS is generated if buffer is already bound to a texture
51 // - EGL_BAD_MATCH is generated if the surface attribute EGL_TEXTURE_FORMAT is set to EGL_NO_TEXTURE
52 // - EGL_BAD_MATCH is generated if buffer is not a valid buffer (currently only EGL_BACK_BUFFER may be specified)
53 // - EGL_BAD_SURFACE is generated if surface is not a pbuffer surface supporting texture binding
55 // - EGL_BAD_NATIVE_PIXMAP is generated if the implementation does not support native pixmaps
56 // - EGL_BAD_NATIVE_PIXMAP may be generated if native_pixmap is not a valid native pixmap
57 // - EGL_BAD_MATCH is generated if the format of native_pixmap is not compatible with the color buffer of surface
58 // * eglCreateContext()
59 // - EGL_BAD_MATCH is generated if the current rendering API is EGL_NONE
60 // - 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
61 // - 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
62 // * eglCreatePbufferFromClientBuffer()
63 // - various BAD_MATCH, BAD_ACCESS etc. conditions
64 // * eglCreatePbufferSurface()
65 // - 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
66 // * eglCreatePixmapSurface()
67 // - EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid pixmap attribute
68 // - 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
69 // - EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute
70 // * eglCreateWindowSurface()
71 // - EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid window attribute
72 // - 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
73 // - EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute
75 // - EGL_BAD_MATCH is generated if draw or read are not compatible with context
76 // - EGL_BAD_MATCH is generated if context is set to EGL_NO_CONTEXT and draw or read are not set to EGL_NO_SURFACE
77 // - EGL_BAD_MATCH is generated if draw or read are set to EGL_NO_SURFACE and context is not set to EGL_NO_CONTEXT
78 // - EGL_BAD_ACCESS is generated if context is current to some other thread
79 // - EGL_BAD_NATIVE_PIXMAP may be generated if a native pixmap underlying either draw or read is no longer valid
80 // - EGL_BAD_NATIVE_WINDOW may be generated if a native window underlying either draw or read is no longer valid
81 // * eglReleaseTexImage()
82 // - EGL_BAD_MATCH is generated if buffer is not a valid buffer (currently only EGL_BACK_BUFFER may be specified)
83 // * eglSwapInterval()
84 // - EGL_BAD_SURFACE is generated if there is no surface bound to the current context
86 // - 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
88 using namespace tcu::egl;
91 static const EGLint s_emptyAttribList[] = { EGL_NONE };
92 static const EGLint s_es1ContextAttribList[] = { EGL_CONTEXT_CLIENT_VERSION, 1, EGL_NONE };
93 static const EGLint s_es2ContextAttribList[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
95 static const EGLenum s_renderAPIs[] = { EGL_OPENGL_API, EGL_OPENGL_ES_API, EGL_OPENVG_API };
97 TEGL_ADD_API_CASE(bind_api, "eglBindAPI() negative tests",
99 TestLog& log = m_testCtx.getLog();
100 log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if api is not one of the accepted tokens");
102 expectFalse(eglBindAPI(0));
103 expectError(EGL_BAD_PARAMETER);
105 expectFalse(eglBindAPI(0xfdfdfdfd));
106 expectError(EGL_BAD_PARAMETER);
108 expectFalse(eglBindAPI((EGLenum)0xffffffff));
109 expectError(EGL_BAD_PARAMETER);
111 log << TestLog::EndSection;
113 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if the specified client API is not supported by the EGL implementation");
115 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_renderAPIs); ndx++)
117 if (!isAPISupported(s_renderAPIs[ndx]))
119 expectFalse(eglBindAPI(s_renderAPIs[ndx]));
120 expectError(EGL_BAD_PARAMETER);
124 log << TestLog::EndSection;
127 TEGL_ADD_API_CASE(bind_tex_image, "eglBindTexImage() negative tests",
129 TestLog& log = m_testCtx.getLog();
130 EGLDisplay display = getDisplay();
132 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
134 expectFalse(eglBindTexImage(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_BACK_BUFFER));
135 expectError(EGL_BAD_DISPLAY);
137 expectFalse(eglBindTexImage((EGLDisplay)-1, EGL_NO_SURFACE, EGL_BACK_BUFFER));
138 expectError(EGL_BAD_DISPLAY);
140 log << TestLog::EndSection;
142 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
144 expectFalse(eglBindTexImage(display, EGL_NO_SURFACE, EGL_BACK_BUFFER));
145 expectError(EGL_BAD_SURFACE);
147 expectFalse(eglBindTexImage(display, (EGLSurface)-1, EGL_BACK_BUFFER));
148 expectError(EGL_BAD_SURFACE);
150 log << TestLog::EndSection;
153 TEGL_ADD_API_CASE(copy_buffers, "eglCopyBuffers() negative tests",
155 TestLog& log = m_testCtx.getLog();
156 EGLDisplay display = getDisplay();
158 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
160 expectFalse(eglCopyBuffers(EGL_NO_DISPLAY, EGL_NO_SURFACE, (NativePixmapType)0));
161 expectError(EGL_BAD_DISPLAY);
163 expectFalse(eglCopyBuffers((EGLDisplay)-1, EGL_NO_SURFACE, (NativePixmapType)0));
164 expectError(EGL_BAD_DISPLAY);
166 log << TestLog::EndSection;
168 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
170 expectFalse(eglCopyBuffers(display, EGL_NO_SURFACE, (NativePixmapType)0));
171 expectError(EGL_BAD_SURFACE);
173 expectFalse(eglCopyBuffers(display, (EGLSurface)-1, (NativePixmapType)0));
174 expectError(EGL_BAD_SURFACE);
176 log << TestLog::EndSection;
179 static const EGLint s_invalidChooseConfigAttribList0[] = { 0, EGL_NONE };
180 static const EGLint s_invalidChooseConfigAttribList1[] = { (EGLint)0xffffffff };
181 static const EGLint s_invalidChooseConfigAttribList2[] = { EGL_BIND_TO_TEXTURE_RGB, 4, EGL_NONE };
182 static const EGLint s_invalidChooseConfigAttribList3[] = { EGL_BIND_TO_TEXTURE_RGBA, 5, EGL_NONE };
183 static const EGLint s_invalidChooseConfigAttribList4[] = { EGL_COLOR_BUFFER_TYPE, 0, EGL_NONE };
184 static const EGLint s_invalidChooseConfigAttribList5[] = { EGL_MATCH_NATIVE_PIXMAP, -1, EGL_NONE };
185 static const EGLint s_invalidChooseConfigAttribList6[] = { EGL_NATIVE_RENDERABLE, 6, EGL_NONE };
186 static const EGLint s_invalidChooseConfigAttribList7[] = { EGL_TRANSPARENT_TYPE, 6, EGL_NONE };
187 static const EGLint* s_invalidChooseConfigAttribLists[] =
189 &s_invalidChooseConfigAttribList0[0],
190 &s_invalidChooseConfigAttribList1[0],
191 &s_invalidChooseConfigAttribList2[0],
192 &s_invalidChooseConfigAttribList3[0],
193 &s_invalidChooseConfigAttribList4[0],
194 &s_invalidChooseConfigAttribList5[0],
195 &s_invalidChooseConfigAttribList6[0],
196 &s_invalidChooseConfigAttribList7[0]
199 TEGL_ADD_API_CASE(choose_config, "eglChooseConfig() negative tests",
201 TestLog& log = m_testCtx.getLog();
202 EGLDisplay display = getDisplay();
203 EGLConfig configs[1];
206 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
208 expectFalse(eglChooseConfig(EGL_NO_DISPLAY, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
209 expectError(EGL_BAD_DISPLAY);
211 expectFalse(eglChooseConfig((EGLDisplay)-1, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
212 expectError(EGL_BAD_DISPLAY);
214 log << TestLog::EndSection;
216 log << TestLog::Section("Test2", "EGL_BAD_ATTRIBUTE is generated if attribute_list contains an invalid frame buffer configuration attribute");
218 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidChooseConfigAttribLists); ndx++)
220 expectFalse(eglChooseConfig(display, s_invalidChooseConfigAttribLists[ndx], &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
221 expectError(EGL_BAD_ATTRIBUTE);
224 log << TestLog::EndSection;
226 log << TestLog::Section("Test3", "EGL_BAD_PARAMETER is generated if num_config is NULL");
228 expectFalse(eglChooseConfig(display, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), DE_NULL));
229 expectError(EGL_BAD_PARAMETER);
231 log << TestLog::EndSection;
234 static const EGLint s_invalidCreateContextAttribList0[] = { 0, EGL_NONE };
235 static const EGLint s_invalidCreateContextAttribList1[] = { (EGLint)0xffffffff };
237 TEGL_ADD_API_CASE(create_context, "eglCreateContext() negative tests",
239 TestLog& log = m_testCtx.getLog();
240 EGLDisplay display = getDisplay();
242 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
244 expectNoContext(eglCreateContext(EGL_NO_DISPLAY, DE_NULL, EGL_NO_CONTEXT, s_emptyAttribList));
245 expectError(EGL_BAD_DISPLAY);
247 expectNoContext(eglCreateContext((EGLDisplay)-1, DE_NULL, EGL_NO_CONTEXT, s_emptyAttribList));
248 expectError(EGL_BAD_DISPLAY);
250 log << TestLog::EndSection;
252 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
254 expectNoContext(eglCreateContext(display, (EGLConfig)-1, EGL_NO_CONTEXT, s_emptyAttribList));
255 expectError(EGL_BAD_CONFIG);
257 log << TestLog::EndSection;
259 log << TestLog::Section("Test3", "EGL_BAD_CONFIG is generated if config does not support the current rendering API");
261 if (isAPISupported(EGL_OPENGL_API))
263 EGLConfig es1OnlyConfig;
264 if (getConfig(&es1OnlyConfig, FilterList() << (ConfigRenderableType() & EGL_OPENGL_ES_BIT) << (ConfigRenderableType() ^ EGL_OPENGL_BIT)))
266 expectTrue(eglBindAPI(EGL_OPENGL_API));
267 expectNoContext(eglCreateContext(display, es1OnlyConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
268 expectError(EGL_BAD_CONFIG);
271 EGLConfig es2OnlyConfig;
272 if (getConfig(&es2OnlyConfig, FilterList() << (ConfigRenderableType() & EGL_OPENGL_ES2_BIT) << (ConfigRenderableType() ^ EGL_OPENGL_BIT)))
274 expectTrue(eglBindAPI(EGL_OPENGL_API));
275 expectNoContext(eglCreateContext(display, es2OnlyConfig, EGL_NO_CONTEXT, s_es2ContextAttribList));
276 expectError(EGL_BAD_CONFIG);
279 EGLConfig vgOnlyConfig;
280 if (getConfig(&vgOnlyConfig, FilterList() << (ConfigRenderableType() & EGL_OPENVG_BIT) << (ConfigRenderableType() ^ EGL_OPENGL_BIT)))
282 expectTrue(eglBindAPI(EGL_OPENGL_API));
283 expectNoContext(eglCreateContext(display, vgOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
284 expectError(EGL_BAD_CONFIG);
288 if (isAPISupported(EGL_OPENGL_ES_API))
290 EGLConfig glOnlyConfig;
291 if (getConfig(&glOnlyConfig, FilterList() << (ConfigRenderableType() & EGL_OPENGL_BIT) << (ConfigRenderableType() ^ (EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT))))
293 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
294 expectNoContext(eglCreateContext(display, glOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
295 expectError(EGL_BAD_CONFIG);
298 EGLConfig vgOnlyConfig;
299 if (getConfig(&vgOnlyConfig, FilterList() << (ConfigRenderableType() & EGL_OPENVG_BIT) << (ConfigRenderableType() ^ (EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT))))
301 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
302 expectNoContext(eglCreateContext(display, vgOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
303 expectError(EGL_BAD_CONFIG);
307 if (isAPISupported(EGL_OPENVG_API))
309 EGLConfig glOnlyConfig;
310 if (getConfig(&glOnlyConfig, FilterList() << (ConfigRenderableType() & EGL_OPENGL_BIT) << (ConfigRenderableType() ^ EGL_OPENVG_BIT)))
312 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
313 expectNoContext(eglCreateContext(display, glOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
314 expectError(EGL_BAD_CONFIG);
317 EGLConfig es1OnlyConfig;
318 if (getConfig(&es1OnlyConfig, FilterList() << (ConfigRenderableType() & EGL_OPENGL_ES_BIT) << (ConfigRenderableType() ^ EGL_OPENVG_BIT)))
320 expectTrue(eglBindAPI(EGL_OPENGL_API));
321 expectNoContext(eglCreateContext(display, es1OnlyConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
322 expectError(EGL_BAD_CONFIG);
325 EGLConfig es2OnlyConfig;
326 if (getConfig(&es2OnlyConfig, FilterList() << (ConfigRenderableType() & EGL_OPENGL_ES2_BIT) << (ConfigRenderableType() ^ EGL_OPENVG_BIT)))
328 expectTrue(eglBindAPI(EGL_OPENGL_API));
329 expectNoContext(eglCreateContext(display, es2OnlyConfig, EGL_NO_CONTEXT, s_es2ContextAttribList));
330 expectError(EGL_BAD_CONFIG);
334 log << TestLog::EndSection;
336 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");
338 if (isAPISupported(EGL_OPENGL_ES_API))
340 EGLConfig notES1Config;
341 if (getConfig(¬ES1Config, FilterList() << (ConfigRenderableType() ^ EGL_OPENGL_ES_BIT)))
343 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
344 expectNoContext(eglCreateContext(display, notES1Config, EGL_NO_CONTEXT, s_es1ContextAttribList));
345 expectError(EGL_BAD_CONFIG);
349 log << TestLog::EndSection;
351 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");
353 if (isAPISupported(EGL_OPENGL_ES_API))
355 EGLConfig notES2Config;
356 if (getConfig(¬ES2Config, FilterList() << (ConfigRenderableType() ^ EGL_OPENGL_ES2_BIT)))
358 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
359 expectNoContext(eglCreateContext(display, notES2Config, EGL_NO_CONTEXT, s_es2ContextAttribList));
360 expectError(EGL_BAD_CONFIG);
364 log << TestLog::EndSection;
366 log << TestLog::Section("Test6", "EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid context attribute");
368 if (isAPISupported(EGL_OPENGL_API))
371 if (getConfig(&glConfig, FilterList() << (ConfigRenderableType() & EGL_OPENGL_BIT)))
373 expectTrue(eglBindAPI(EGL_OPENGL_API));
374 expectNoContext(eglCreateContext(display, glConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
375 expectError(EGL_BAD_ATTRIBUTE);
379 if (isAPISupported(EGL_OPENVG_API))
382 if (getConfig(&vgConfig, FilterList() << (ConfigRenderableType() & EGL_OPENVG_BIT)))
384 expectTrue(eglBindAPI(EGL_OPENVG_API));
385 expectNoContext(eglCreateContext(display, vgConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
386 expectError(EGL_BAD_ATTRIBUTE);
390 if (isAPISupported(EGL_OPENGL_ES_API))
392 bool gotConfig = false;
395 gotConfig = getConfig(&esConfig, FilterList() << (ConfigRenderableType() & EGL_OPENGL_ES_BIT)) ||
396 getConfig(&esConfig, FilterList() << (ConfigRenderableType() & EGL_OPENGL_ES2_BIT));
400 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
401 expectNoContext(eglCreateContext(display, esConfig, EGL_NO_CONTEXT, s_invalidCreateContextAttribList0));
402 expectError(EGL_BAD_ATTRIBUTE);
403 expectNoContext(eglCreateContext(display, esConfig, EGL_NO_CONTEXT, s_invalidCreateContextAttribList1));
404 expectError(EGL_BAD_ATTRIBUTE);
408 log << TestLog::EndSection;
411 TEGL_ADD_API_CASE(create_pbuffer_from_client_buffer, "eglCreatePbufferFromClientBuffer() negative tests",
413 TestLog& log = m_testCtx.getLog();
414 EGLDisplay display = getDisplay();
418 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
420 expectNoSurface(eglCreatePbufferFromClientBuffer(EGL_NO_DISPLAY, EGL_OPENVG_IMAGE, 0, (EGLConfig)0, DE_NULL));
421 expectError(EGL_BAD_DISPLAY);
423 expectNoSurface(eglCreatePbufferFromClientBuffer((EGLDisplay)-1, EGL_OPENVG_IMAGE, 0, (EGLConfig)0, DE_NULL));
424 expectError(EGL_BAD_DISPLAY);
426 log << TestLog::EndSection;
428 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
430 expectNoSurface(eglCreatePbufferFromClientBuffer(display, EGL_OPENVG_IMAGE, 0, (EGLConfig)-1, DE_NULL));
431 expectError(EGL_BAD_CONFIG);
433 log << TestLog::EndSection;
435 log << TestLog::Section("Test3", "EGL_BAD_PARAMETER is generated if buftype is not EGL_OPENVG_IMAGE");
437 expectTrue(eglGetConfigs(display, &anyConfig, 1, &unused));
439 expectNoSurface(eglCreatePbufferFromClientBuffer(display, EGL_OPENVG_IMAGE, (EGLClientBuffer)-1, anyConfig, DE_NULL));
440 expectError(EGL_BAD_CONFIG);
442 log << TestLog::EndSection;
445 static const EGLint s_validGenericPbufferAttrib[] = { EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
447 static const EGLint s_invalidGenericPbufferAttrib0[] = { 0, EGL_NONE };
448 static const EGLint s_invalidGenericPbufferAttrib1[] = { (EGLint)0xffffffff };
449 static const EGLint s_invalidGenericPbufferAttrib2[] = { EGL_WIDTH, 64, EGL_HEIGHT, -1, EGL_NONE };
450 static const EGLint s_invalidGenericPbufferAttrib3[] = { EGL_WIDTH, -1, EGL_HEIGHT, 64, EGL_NONE };
451 static const EGLint* s_invalidGenericPbufferAttribs[] =
453 s_invalidGenericPbufferAttrib0,
454 s_invalidGenericPbufferAttrib1,
455 s_invalidGenericPbufferAttrib2,
456 s_invalidGenericPbufferAttrib3
459 static const EGLint s_invalidNoEsPbufferAttrib0[] = { EGL_MIPMAP_TEXTURE, EGL_TRUE, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
460 static const EGLint s_invalidNoEsPbufferAttrib1[] = { EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
461 static const EGLint s_invalidNoEsPbufferAttrib2[] = { EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
462 static const EGLint* s_invalidNoEsPbufferAttribs[] =
464 s_invalidNoEsPbufferAttrib0,
465 s_invalidNoEsPbufferAttrib1,
466 s_invalidNoEsPbufferAttrib2
469 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 };
470 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 };
471 static const EGLint* s_invalidEsPbufferAttribs[] =
473 s_invalidEsPbufferAttrib0,
474 s_invalidEsPbufferAttrib1
477 static const EGLint s_vgPreMultAlphaPbufferAttrib[] = { EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
478 static const EGLint s_vgLinearColorspacePbufferAttrib[] = { EGL_VG_COLORSPACE, EGL_VG_COLORSPACE_LINEAR, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
480 TEGL_ADD_API_CASE(create_pbuffer_surface, "eglCreatePbufferSurface() negative tests",
482 TestLog& log = m_testCtx.getLog();
483 EGLDisplay display = getDisplay();
485 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
487 expectNoSurface(eglCreatePbufferSurface(EGL_NO_DISPLAY, DE_NULL, s_emptyAttribList));
488 expectError(EGL_BAD_DISPLAY);
490 expectNoSurface(eglCreatePbufferSurface((EGLDisplay)-1, DE_NULL, s_emptyAttribList));
491 expectError(EGL_BAD_DISPLAY);
493 log << TestLog::EndSection;
495 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
497 expectNoSurface(eglCreatePbufferSurface(display, (EGLConfig)-1, s_emptyAttribList));
498 expectError(EGL_BAD_CONFIG);
500 log << TestLog::EndSection;
502 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid pixel buffer attribute");
504 // Generic pbuffer-capable config
505 EGLConfig genericConfig;
506 if (getConfig(&genericConfig, FilterList() << (ConfigSurfaceType() & EGL_PBUFFER_BIT)))
508 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidGenericPbufferAttribs); ndx++)
510 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_invalidGenericPbufferAttribs[ndx]));
511 expectError(EGL_BAD_ATTRIBUTE);
515 log << TestLog::EndSection;
517 log << TestLog::Section("Test4", "EGL_BAD_MATCH is generated if config does not support rendering to pixel buffers");
519 EGLConfig noPbufferConfig;
520 if (getConfig(&noPbufferConfig, FilterList() << (ConfigSurfaceType() ^ EGL_PBUFFER_BIT)))
522 expectNoSurface(eglCreatePbufferSurface(display, noPbufferConfig, s_validGenericPbufferAttrib));
523 expectError(EGL_BAD_MATCH);
526 log << TestLog::EndSection;
528 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");
530 EGLConfig noEsConfig;
531 if (getConfig(&noEsConfig, FilterList() << (ConfigRenderableType() ^ (EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT))))
533 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidNoEsPbufferAttribs); ndx++)
535 expectNoSurface(eglCreatePbufferSurface(display, noEsConfig, s_invalidNoEsPbufferAttribs[ndx]));
536 expectError(EGL_BAD_MATCH);
540 log << TestLog::EndSection;
542 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");
544 // ES1 or ES2 config.
546 bool gotEsConfig = getConfig(&esConfig, FilterList() << (ConfigRenderableType() & EGL_OPENGL_ES_BIT)) ||
547 getConfig(&esConfig, FilterList() << (ConfigRenderableType() & EGL_OPENGL_ES2_BIT));
550 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidEsPbufferAttribs); ndx++)
552 expectNoSurface(eglCreatePbufferSurface(display, esConfig, s_invalidEsPbufferAttribs[ndx]));
553 expectError(EGL_BAD_MATCH);
557 log << TestLog::EndSection;
559 log << TestLog::Section("Test7", "EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute");
561 EGLConfig vgNoPreConfig;
562 if (getConfig(&vgNoPreConfig, FilterList() << (ConfigRenderableType() & EGL_OPENVG_BIT) << (ConfigSurfaceType() ^ EGL_VG_ALPHA_FORMAT_PRE)))
564 expectNoSurface(eglCreatePbufferSurface(display, vgNoPreConfig, s_vgPreMultAlphaPbufferAttrib));
565 expectError(EGL_BAD_MATCH);
568 EGLConfig vgNoLinearConfig;
569 if (getConfig(&vgNoLinearConfig, FilterList() << (ConfigRenderableType() & EGL_OPENVG_BIT) << (ConfigSurfaceType() ^ EGL_VG_COLORSPACE_LINEAR_BIT)))
571 expectNoSurface(eglCreatePbufferSurface(display, vgNoLinearConfig, s_vgLinearColorspacePbufferAttrib));
572 expectError(EGL_BAD_MATCH);
575 log << TestLog::EndSection;
578 TEGL_ADD_API_CASE(create_pixmap_surface, "eglCreatePixmapSurface() negative tests",
580 TestLog& log = m_testCtx.getLog();
581 EGLDisplay display = getDisplay();
583 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
585 expectNoSurface(eglCreatePixmapSurface(EGL_NO_DISPLAY, DE_NULL, DE_NULL, s_emptyAttribList));
586 expectError(EGL_BAD_DISPLAY);
588 expectNoSurface(eglCreatePixmapSurface((EGLDisplay)-1, DE_NULL, DE_NULL, s_emptyAttribList));
589 expectError(EGL_BAD_DISPLAY);
591 log << TestLog::EndSection;
593 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
595 expectNoSurface(eglCreatePixmapSurface(display, (EGLConfig)-1, DE_NULL, s_emptyAttribList));
596 expectError(EGL_BAD_CONFIG);
598 log << TestLog::EndSection;
600 log << TestLog::Section("Test3", "EGL_BAD_NATIVE_PIXMAP may be generated if native_pixmap is not a valid native pixmap");
602 // Any pixmap-capable config.
603 EGLConfig pixmapConfig;
604 if (getConfig(&pixmapConfig, FilterList() << (ConfigSurfaceType() & EGL_PIXMAP_BIT)))
606 expectNoSurface(eglCreatePixmapSurface(display, pixmapConfig, DE_NULL, s_emptyAttribList));
607 expectError(EGL_BAD_NATIVE_PIXMAP);
609 expectNoSurface(eglCreatePixmapSurface(display, pixmapConfig, (EGLNativePixmapType)-1, s_emptyAttribList));
610 expectError(EGL_BAD_NATIVE_PIXMAP);
613 log << TestLog::EndSection;
616 TEGL_ADD_API_CASE(create_window_surface, "eglCreateWindowSurface() negative tests",
618 TestLog& log = m_testCtx.getLog();
619 EGLDisplay display = getDisplay();
621 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
623 expectNoSurface(eglCreateWindowSurface(EGL_NO_DISPLAY, DE_NULL, DE_NULL, s_emptyAttribList));
624 expectError(EGL_BAD_DISPLAY);
626 expectNoSurface(eglCreateWindowSurface((EGLDisplay)-1, DE_NULL, DE_NULL, s_emptyAttribList));
627 expectError(EGL_BAD_DISPLAY);
629 log << TestLog::EndSection;
631 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
633 expectNoSurface(eglCreateWindowSurface(display, (EGLConfig)-1, DE_NULL, s_emptyAttribList));
634 expectError(EGL_BAD_CONFIG);
636 log << TestLog::EndSection;
638 log << TestLog::Section("Test3", "EGL_BAD_NATIVE_WINDOW may be generated if native_window is not a valid native window");
640 // Any window-capable config.
641 EGLConfig windowConfig;
642 if (getConfig(&windowConfig, FilterList() << (ConfigSurfaceType() & EGL_WINDOW_BIT)))
644 expectNoSurface(eglCreateWindowSurface(display, windowConfig, DE_NULL, s_emptyAttribList));
645 expectError(EGL_BAD_NATIVE_PIXMAP);
647 expectNoSurface(eglCreateWindowSurface(display, windowConfig, (EGLNativeWindowType)-1, s_emptyAttribList));
648 expectError(EGL_BAD_NATIVE_PIXMAP);
651 log << TestLog::EndSection;
654 TEGL_ADD_API_CASE(destroy_context, "eglDestroyContext() negative tests",
656 TestLog& log = m_testCtx.getLog();
657 EGLDisplay display = getDisplay();
659 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
661 expectFalse(eglDestroyContext(EGL_NO_DISPLAY, DE_NULL));
662 expectError(EGL_BAD_DISPLAY);
664 expectFalse(eglDestroyContext((EGLDisplay)-1, DE_NULL));
665 expectError(EGL_BAD_DISPLAY);
667 log << TestLog::EndSection;
669 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
671 expectFalse(eglDestroyContext(display, DE_NULL));
672 expectError(EGL_BAD_CONTEXT);
674 expectFalse(eglDestroyContext(display, (EGLContext)-1));
675 expectError(EGL_BAD_CONTEXT);
677 log << TestLog::EndSection;
680 TEGL_ADD_API_CASE(destroy_surface, "eglDestroySurface() negative tests",
682 TestLog& log = m_testCtx.getLog();
683 EGLDisplay display = getDisplay();
685 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
687 expectFalse(eglDestroySurface(EGL_NO_DISPLAY, DE_NULL));
688 expectError(EGL_BAD_DISPLAY);
690 expectFalse(eglDestroySurface((EGLDisplay)-1, DE_NULL));
691 expectError(EGL_BAD_DISPLAY);
693 log << TestLog::EndSection;
695 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
697 expectFalse(eglDestroySurface(display, DE_NULL));
698 expectError(EGL_BAD_SURFACE);
700 expectFalse(eglDestroySurface(display, (EGLSurface)-1));
701 expectError(EGL_BAD_SURFACE);
703 log << TestLog::EndSection;
706 TEGL_ADD_API_CASE(get_config_attrib, "eglGetConfigAttrib() negative tests",
708 TestLog& log = m_testCtx.getLog();
709 EGLDisplay display = getDisplay();
712 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
714 expectFalse(eglGetConfigAttrib(EGL_NO_DISPLAY, DE_NULL, EGL_RED_SIZE, &value));
715 expectError(EGL_BAD_DISPLAY);
717 expectFalse(eglGetConfigAttrib((EGLDisplay)-1, DE_NULL, EGL_RED_SIZE, &value));
718 expectError(EGL_BAD_DISPLAY);
720 log << TestLog::EndSection;
722 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
724 expectFalse(eglGetConfigAttrib(display, (EGLConfig)-1, EGL_RED_SIZE, &value));
725 expectError(EGL_BAD_CONFIG);
727 log << TestLog::EndSection;
730 EGLConfig config = DE_NULL;
731 bool hasConfig = getConfig(&config, FilterList());
733 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid frame buffer configuration attribute");
737 expectFalse(eglGetConfigAttrib(display, config, 0, &value));
738 expectError(EGL_BAD_ATTRIBUTE);
740 expectFalse(eglGetConfigAttrib(display, config, -1, &value));
741 expectError(EGL_BAD_ATTRIBUTE);
744 log << TestLog::EndSection;
747 TEGL_ADD_API_CASE(get_configs, "eglGetConfigs() negative tests",
749 TestLog& log = m_testCtx.getLog();
750 EGLDisplay display = getDisplay();
754 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
756 expectFalse(eglGetConfigs(EGL_NO_DISPLAY, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), &numCfgs));
757 expectError(EGL_BAD_DISPLAY);
759 expectFalse(eglGetConfigs((EGLDisplay)-1, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), &numCfgs));
760 expectError(EGL_BAD_DISPLAY);
762 log << TestLog::EndSection;
764 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if num_config is NULL");
766 expectFalse(eglGetConfigs(display, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), DE_NULL));
767 expectError(EGL_BAD_PARAMETER);
769 log << TestLog::EndSection;
772 TEGL_ADD_API_CASE(get_display, "eglGetDisplay() negative tests",
774 expectNoDisplay(eglGetDisplay((EGLNativeDisplayType)-1));
775 expectError(EGL_SUCCESS);
778 TEGL_ADD_API_CASE(initialize, "eglInitialize() negative tests",
780 TestLog& log = m_testCtx.getLog();
784 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
786 expectFalse(eglInitialize(EGL_NO_DISPLAY, &major, &minor));
787 expectError(EGL_BAD_DISPLAY);
789 expectFalse(eglInitialize((EGLDisplay)-1, &major, &minor));
790 expectError(EGL_BAD_DISPLAY);
792 log << TestLog::EndSection;
795 TEGL_ADD_API_CASE(make_current, "eglMakeCurrent() negative tests",
797 TestLog& log = m_testCtx.getLog();
798 EGLDisplay display = getDisplay();
800 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
802 expectFalse(eglMakeCurrent(EGL_NO_DISPLAY, DE_NULL, DE_NULL, DE_NULL));
803 expectError(EGL_BAD_DISPLAY);
805 expectFalse(eglMakeCurrent((EGLDisplay)-1, DE_NULL, DE_NULL, DE_NULL));
806 expectError(EGL_BAD_DISPLAY);
808 log << TestLog::EndSection;
810 // Create simple pbuffer surface.
811 EGLSurface surface = EGL_NO_SURFACE;
814 if (getConfig(&config, FilterList() << (ConfigSurfaceType() & EGL_PBUFFER_BIT)))
816 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
817 expectError(EGL_SUCCESS);
821 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
823 expectFalse(eglMakeCurrent(display, (EGLSurface)-1, (EGLSurface)-1, DE_NULL));
824 expectError(EGL_BAD_SURFACE);
828 expectFalse(eglMakeCurrent(display, surface, (EGLSurface)-1, DE_NULL));
829 expectError(EGL_BAD_SURFACE);
831 expectFalse(eglMakeCurrent(display, (EGLSurface)-1, surface, DE_NULL));
832 expectError(EGL_BAD_SURFACE);
835 log << TestLog::EndSection;
837 log << TestLog::Section("Test3", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
841 expectFalse(eglMakeCurrent(display, surface, surface, DE_NULL));
842 expectError(EGL_BAD_CONTEXT);
844 expectFalse(eglMakeCurrent(display, surface, surface, (EGLContext)-1));
845 expectError(EGL_BAD_CONTEXT);
848 log << TestLog::EndSection;
852 eglDestroySurface(display, surface);
853 expectError(EGL_SUCCESS);
857 TEGL_ADD_API_CASE(get_current_context, "eglGetCurrentContext() negative tests",
859 expectNoContext(eglGetCurrentContext());
861 if (isAPISupported(EGL_OPENGL_ES_API))
863 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
864 expectError(EGL_SUCCESS);
866 expectNoContext(eglGetCurrentContext());
867 expectError(EGL_SUCCESS);
871 TEGL_ADD_API_CASE(get_current_surface, "eglGetCurrentSurface() negative tests",
873 TestLog& log = m_testCtx.getLog();
875 log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if readdraw is neither EGL_READ nor EGL_DRAW");
877 expectNoSurface(eglGetCurrentSurface(EGL_NONE));
878 expectError(EGL_BAD_PARAMETER);
880 log << TestLog::EndSection;
882 expectNoSurface(eglGetCurrentSurface(EGL_READ));
883 expectError(EGL_SUCCESS);
885 expectNoSurface(eglGetCurrentSurface(EGL_DRAW));
886 expectError(EGL_SUCCESS);
889 TEGL_ADD_API_CASE(query_context, "eglQueryContext() negative tests",
891 TestLog& log = m_testCtx.getLog();
892 EGLDisplay display = getDisplay();
895 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
897 expectFalse(eglQueryContext(EGL_NO_DISPLAY, DE_NULL, EGL_CONFIG_ID, &value));
898 expectError(EGL_BAD_DISPLAY);
900 expectFalse(eglQueryContext((EGLDisplay)-1, DE_NULL, EGL_CONFIG_ID, &value));
901 expectError(EGL_BAD_DISPLAY);
903 log << TestLog::EndSection;
905 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
907 expectFalse(eglQueryContext(display, DE_NULL, EGL_CONFIG_ID, &value));
908 expectError(EGL_BAD_CONTEXT);
910 expectFalse(eglQueryContext(display, DE_NULL, EGL_CONFIG_ID, &value));
911 expectError(EGL_BAD_CONTEXT);
913 log << TestLog::EndSection;
915 // Create ES2 context.
916 EGLConfig config = DE_NULL;
917 EGLContext context = DE_NULL;
918 bool gotConfig = getConfig(&config, FilterList() << (ConfigRenderableType() & EGL_OPENGL_ES2_BIT));
922 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
923 expectError(EGL_SUCCESS);
925 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
926 expectError(EGL_SUCCESS);
929 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid context attribute");
933 expectFalse(eglQueryContext(display, context, 0, &value));
934 expectError(EGL_BAD_ATTRIBUTE);
935 expectFalse(eglQueryContext(display, context, -1, &value));
936 expectError(EGL_BAD_ATTRIBUTE);
937 expectFalse(eglQueryContext(display, context, EGL_RED_SIZE, &value));
938 expectError(EGL_BAD_ATTRIBUTE);
941 log << TestLog::EndSection;
945 expectTrue(eglDestroyContext(display, context));
946 expectError(EGL_SUCCESS);
950 TEGL_ADD_API_CASE(query_string, "eglQueryString() negative tests",
952 TestLog& log = m_testCtx.getLog();
953 EGLDisplay display = getDisplay();
955 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
957 expectNull(eglQueryString(EGL_NO_DISPLAY, EGL_VENDOR));
958 expectError(EGL_BAD_DISPLAY);
960 expectNull(eglQueryString((EGLDisplay)-1, EGL_VENDOR));
961 expectError(EGL_BAD_DISPLAY);
963 log << TestLog::EndSection;
965 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if name is not an accepted value");
967 expectNull(eglQueryString(display, 0));
968 expectError(EGL_BAD_PARAMETER);
969 expectNull(eglQueryString(display, -1));
970 expectError(EGL_BAD_PARAMETER);
972 log << TestLog::EndSection;
975 TEGL_ADD_API_CASE(query_surface, "eglQuerySurface() negative tests",
977 TestLog& log = m_testCtx.getLog();
978 EGLDisplay display = getDisplay();
981 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
983 expectFalse(eglQuerySurface(EGL_NO_DISPLAY, DE_NULL, EGL_CONFIG_ID, &value));
984 expectError(EGL_BAD_DISPLAY);
986 expectFalse(eglQuerySurface((EGLDisplay)-1, DE_NULL, EGL_CONFIG_ID, &value));
987 expectError(EGL_BAD_DISPLAY);
989 log << TestLog::EndSection;
991 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
993 expectFalse(eglQuerySurface(display, DE_NULL, EGL_CONFIG_ID, &value));
994 expectError(EGL_BAD_SURFACE);
996 expectFalse(eglQuerySurface(display, (EGLSurface)-1, EGL_CONFIG_ID, &value));
997 expectError(EGL_BAD_SURFACE);
999 log << TestLog::EndSection;
1001 // Create pbuffer surface.
1002 EGLSurface surface = EGL_NO_SURFACE;
1005 if (getConfig(&config, FilterList() << (ConfigSurfaceType() & EGL_PBUFFER_BIT)))
1007 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1008 expectError(EGL_SUCCESS);
1011 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1014 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid surface attribute");
1018 expectFalse(eglQuerySurface(display, surface, 0, &value));
1019 expectError(EGL_BAD_ATTRIBUTE);
1021 expectFalse(eglQuerySurface(display, surface, -1, &value));
1022 expectError(EGL_BAD_ATTRIBUTE);
1025 log << TestLog::EndSection;
1029 eglDestroySurface(display, surface);
1030 expectError(EGL_SUCCESS);
1034 TEGL_ADD_API_CASE(release_tex_image, "eglReleaseTexImage() negative tests",
1036 TestLog& log = m_testCtx.getLog();
1037 EGLDisplay display = getDisplay();
1039 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1041 expectFalse(eglReleaseTexImage(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1042 expectError(EGL_BAD_DISPLAY);
1044 expectFalse(eglReleaseTexImage((EGLDisplay)-1, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1045 expectError(EGL_BAD_DISPLAY);
1047 log << TestLog::EndSection;
1049 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1051 expectFalse(eglReleaseTexImage(display, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1052 expectError(EGL_BAD_SURFACE);
1054 expectFalse(eglReleaseTexImage(display, (EGLSurface)-1, EGL_BACK_BUFFER));
1055 expectError(EGL_BAD_SURFACE);
1057 log << TestLog::EndSection;
1060 TEGL_ADD_API_CASE(surface_attrib, "eglSurfaceAttrib() negative tests",
1062 TestLog& log = m_testCtx.getLog();
1063 EGLDisplay display = getDisplay();
1065 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1067 expectFalse(eglSurfaceAttrib(EGL_NO_DISPLAY, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1068 expectError(EGL_BAD_DISPLAY);
1070 expectFalse(eglSurfaceAttrib((EGLDisplay)-1, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1071 expectError(EGL_BAD_DISPLAY);
1073 log << TestLog::EndSection;
1075 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1077 expectFalse(eglSurfaceAttrib(display, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1078 expectError(EGL_BAD_SURFACE);
1080 expectFalse(eglSurfaceAttrib(display, (EGLSurface)-1, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1081 expectError(EGL_BAD_SURFACE);
1083 log << TestLog::EndSection;
1086 // Create pbuffer surface.
1087 EGLSurface surface = EGL_NO_SURFACE;
1090 if (getConfig(&config, FilterList() << (ConfigSurfaceType() & EGL_PBUFFER_BIT)))
1092 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1093 expectError(EGL_SUCCESS);
1096 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1099 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid surface attribute");
1103 expectFalse(eglSurfaceAttrib(display, surface, 0, 0));
1104 expectError(EGL_BAD_ATTRIBUTE);
1106 expectFalse(eglSurfaceAttrib(display, surface, -1, 0));
1107 expectError(EGL_BAD_ATTRIBUTE);
1110 log << TestLog::EndSection;
1114 eglDestroySurface(display, surface);
1115 expectError(EGL_SUCCESS);
1120 // Create pbuffer surface without EGL_MULTISAMPLE_RESOLVE_BOX_BIT.
1121 EGLSurface surface = EGL_NO_SURFACE;
1124 if (getConfig(&config, FilterList() << (ConfigSurfaceType() & EGL_PBUFFER_BIT) << (ConfigSurfaceType() ^ EGL_MULTISAMPLE_RESOLVE_BOX_BIT)))
1126 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1127 expectError(EGL_SUCCESS);
1130 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1133 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");
1137 expectFalse(eglSurfaceAttrib(display, surface, EGL_MULTISAMPLE_RESOLVE, EGL_MULTISAMPLE_RESOLVE_BOX));
1138 expectError(EGL_BAD_MATCH);
1141 log << TestLog::EndSection;
1145 eglDestroySurface(display, surface);
1146 expectError(EGL_SUCCESS);
1151 // Create pbuffer surface without EGL_SWAP_BEHAVIOR_PRESERVED_BIT.
1152 EGLSurface surface = EGL_NO_SURFACE;
1155 if (getConfig(&config, FilterList() << (ConfigSurfaceType() & EGL_PBUFFER_BIT) << (ConfigSurfaceType() ^ EGL_SWAP_BEHAVIOR_PRESERVED_BIT)))
1157 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1158 expectError(EGL_SUCCESS);
1161 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1164 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");
1168 expectFalse(eglSurfaceAttrib(display, surface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED));
1169 expectError(EGL_BAD_MATCH);
1172 log << TestLog::EndSection;
1176 eglDestroySurface(display, surface);
1177 expectError(EGL_SUCCESS);
1182 TEGL_ADD_API_CASE(swap_buffers, "eglSwapBuffers() negative tests",
1184 TestLog& log = m_testCtx.getLog();
1185 EGLDisplay display = getDisplay();
1187 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1189 expectFalse(eglSwapBuffers(EGL_NO_DISPLAY, DE_NULL));
1190 expectError(EGL_BAD_DISPLAY);
1192 expectFalse(eglSwapBuffers((EGLDisplay)-1, DE_NULL));
1193 expectError(EGL_BAD_DISPLAY);
1195 log << TestLog::EndSection;
1197 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1199 expectFalse(eglSwapBuffers(display, DE_NULL));
1200 expectError(EGL_BAD_SURFACE);
1202 expectFalse(eglSwapBuffers(display, (EGLSurface)-1));
1203 expectError(EGL_BAD_SURFACE);
1205 log << TestLog::EndSection;
1208 TEGL_ADD_API_CASE(swap_interval, "eglSwapInterval() negative tests",
1210 TestLog& log = m_testCtx.getLog();
1211 EGLDisplay display = getDisplay();
1213 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1215 expectFalse(eglSwapInterval(EGL_NO_DISPLAY, 0));
1216 expectError(EGL_BAD_DISPLAY);
1218 expectFalse(eglSwapInterval((EGLDisplay)-1, 0));
1219 expectError(EGL_BAD_DISPLAY);
1221 log << TestLog::EndSection;
1223 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if there is no current context on the calling thread");
1225 expectFalse(eglSwapInterval(display, 0));
1226 expectError(EGL_BAD_CONTEXT);
1228 log << TestLog::EndSection;
1231 TEGL_ADD_API_CASE(terminate, "eglTerminate() negative tests",
1233 TestLog& log = m_testCtx.getLog();
1235 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1237 expectFalse(eglTerminate(EGL_NO_DISPLAY));
1238 expectError(EGL_BAD_DISPLAY);
1240 expectFalse(eglTerminate((EGLDisplay)-1));
1241 expectError(EGL_BAD_DISPLAY);
1243 log << TestLog::EndSection;
1246 TEGL_ADD_API_CASE(wait_native, "eglWaitNative() negative tests",
1248 TestLog& log = m_testCtx.getLog();
1250 log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if engine is not a recognized marking engine");
1252 expectFalse(eglWaitNative(-1));
1253 expectError(EGL_BAD_PARAMETER);
1255 log << TestLog::EndSection;