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 "egluUtil.hpp"
31 #include "egluUnique.hpp"
33 #include "eglwLibrary.hpp"
46 template <deUint32 Type>
47 static bool renderable (const eglu::CandidateConfig& c)
49 return (c.renderableType() & Type) == Type;
52 template <deUint32 Type>
53 static bool notRenderable (const eglu::CandidateConfig& c)
55 return (c.renderableType() & Type) == 0;
58 template <deUint32 Bits>
59 static bool surfaceBits (const eglu::CandidateConfig& c)
61 return (c.surfaceType() & Bits) == Bits;
64 template <deUint32 Bits>
65 static bool notSurfaceBits (const eglu::CandidateConfig& c)
67 return (c.surfaceType() & Bits) == 0;
70 NegativeApiTests::NegativeApiTests (EglTestContext& eglTestCtx)
71 : TestCaseGroup(eglTestCtx, "negative_api", "Negative API Tests")
75 NegativeApiTests::~NegativeApiTests (void)
79 void NegativeApiTests::init (void)
81 // \todo [2012-10-02 pyry] Add tests for EGL_NOT_INITIALIZED to all functions taking in EGLDisplay
82 // \todo [2012-10-02 pyry] Implement negative cases for following non-trivial cases:
83 // * eglBindTexImage()
84 // - EGL_BAD_ACCESS is generated if buffer is already bound to a texture
85 // - EGL_BAD_MATCH is generated if the surface attribute EGL_TEXTURE_FORMAT is set to EGL_NO_TEXTURE
86 // - EGL_BAD_MATCH is generated if buffer is not a valid buffer (currently only EGL_BACK_BUFFER may be specified)
87 // - EGL_BAD_SURFACE is generated if surface is not a pbuffer surface supporting texture binding
89 // - EGL_BAD_NATIVE_PIXMAP is generated if the implementation does not support native pixmaps
90 // - EGL_BAD_NATIVE_PIXMAP may be generated if native_pixmap is not a valid native pixmap
91 // - EGL_BAD_MATCH is generated if the format of native_pixmap is not compatible with the color buffer of surface
92 // * eglCreateContext()
93 // - EGL_BAD_MATCH is generated if the current rendering API is EGL_NONE
94 // - 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
95 // - 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
96 // * eglCreatePbufferFromClientBuffer()
97 // - various BAD_MATCH, BAD_ACCESS etc. conditions
98 // * eglCreatePbufferSurface()
99 // - 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
100 // * eglCreatePixmapSurface()
101 // - EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid pixmap attribute
102 // - 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
103 // - EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute
104 // * eglCreateWindowSurface()
105 // - EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid window attribute
106 // - 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
107 // - EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute
108 // * eglMakeCurrent()
109 // - EGL_BAD_MATCH is generated if draw or read are not compatible with context
110 // - EGL_BAD_MATCH is generated if context is set to EGL_NO_CONTEXT and draw or read are not set to EGL_NO_SURFACE
111 // - EGL_BAD_MATCH is generated if draw or read are set to EGL_NO_SURFACE and context is not set to EGL_NO_CONTEXT
112 // - EGL_BAD_ACCESS is generated if context is current to some other thread
113 // - EGL_BAD_NATIVE_PIXMAP may be generated if a native pixmap underlying either draw or read is no longer valid
114 // - EGL_BAD_NATIVE_WINDOW may be generated if a native window underlying either draw or read is no longer valid
115 // * eglReleaseTexImage()
116 // - EGL_BAD_MATCH is generated if buffer is not a valid buffer (currently only EGL_BACK_BUFFER may be specified)
117 // * eglSwapInterval()
118 // - EGL_BAD_SURFACE is generated if there is no surface bound to the current context
120 // - 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
122 using namespace eglw;
123 using namespace eglu;
125 static const EGLint s_emptyAttribList[] = { EGL_NONE };
126 static const EGLint s_es1ContextAttribList[] = { EGL_CONTEXT_CLIENT_VERSION, 1, EGL_NONE };
127 static const EGLint s_es2ContextAttribList[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
129 static const EGLenum s_renderAPIs[] = { EGL_OPENGL_API, EGL_OPENGL_ES_API, EGL_OPENVG_API };
131 TEGL_ADD_API_CASE(bind_api, "eglBindAPI() negative tests",
133 TestLog& log = m_testCtx.getLog();
134 log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if api is not one of the accepted tokens");
136 expectFalse(eglBindAPI(0));
137 expectError(EGL_BAD_PARAMETER);
139 expectFalse(eglBindAPI(0xfdfdfdfd));
140 expectError(EGL_BAD_PARAMETER);
142 expectFalse(eglBindAPI((EGLenum)0xffffffff));
143 expectError(EGL_BAD_PARAMETER);
145 log << TestLog::EndSection;
147 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if the specified client API is not supported by the EGL implementation");
149 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_renderAPIs); ndx++)
151 if (!isAPISupported(s_renderAPIs[ndx]))
153 expectFalse(eglBindAPI(s_renderAPIs[ndx]));
154 expectError(EGL_BAD_PARAMETER);
158 log << TestLog::EndSection;
161 TEGL_ADD_API_CASE(bind_tex_image, "eglBindTexImage() negative tests",
163 TestLog& log = m_testCtx.getLog();
164 EGLDisplay display = getDisplay();
166 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
168 expectFalse(eglBindTexImage(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_BACK_BUFFER));
169 expectError(EGL_BAD_DISPLAY);
171 expectFalse(eglBindTexImage((EGLDisplay)-1, EGL_NO_SURFACE, EGL_BACK_BUFFER));
172 expectError(EGL_BAD_DISPLAY);
174 log << TestLog::EndSection;
176 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
178 expectFalse(eglBindTexImage(display, EGL_NO_SURFACE, EGL_BACK_BUFFER));
179 expectError(EGL_BAD_SURFACE);
181 expectFalse(eglBindTexImage(display, (EGLSurface)-1, EGL_BACK_BUFFER));
182 expectError(EGL_BAD_SURFACE);
184 log << TestLog::EndSection;
187 static const EGLint s_validGenericPbufferAttrib[] = { EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
189 TEGL_ADD_API_CASE(copy_buffers, "eglCopyBuffers() negative tests",
191 TestLog& log = m_testCtx.getLog();
192 const eglw::Library& egl = m_eglTestCtx.getLibrary();
193 EGLDisplay display = getDisplay();
194 const eglu::NativePixmapFactory& factory = eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
195 de::UniquePtr<eglu::NativePixmap> pixmap (factory.createPixmap(&m_eglTestCtx.getNativeDisplay(), 64, 64));
199 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
201 eglu::UniqueSurface surface (egl, display, egl.createPbufferSurface(display, config, s_validGenericPbufferAttrib));
203 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
205 expectFalse(eglCopyBuffers(EGL_NO_DISPLAY, EGL_NO_SURFACE, pixmap->getLegacyNative()));
206 expectError(EGL_BAD_DISPLAY);
208 expectFalse(eglCopyBuffers((EGLDisplay)-1, EGL_NO_SURFACE, pixmap->getLegacyNative()));
209 expectError(EGL_BAD_DISPLAY);
211 log << TestLog::EndSection;
215 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
217 expectFalse(eglCopyBuffers(display, EGL_NO_SURFACE, pixmap->getLegacyNative()));
218 expectError(EGL_BAD_SURFACE);
220 expectFalse(eglCopyBuffers(display, (EGLSurface)-1, pixmap->getLegacyNative()));
221 expectError(EGL_BAD_SURFACE);
223 log << TestLog::EndSection;
226 static const EGLint s_invalidChooseConfigAttribList0[] = { 0, EGL_NONE };
227 static const EGLint s_invalidChooseConfigAttribList1[] = { (EGLint)0xffffffff };
228 static const EGLint s_invalidChooseConfigAttribList2[] = { EGL_BIND_TO_TEXTURE_RGB, 4, EGL_NONE };
229 static const EGLint s_invalidChooseConfigAttribList3[] = { EGL_BIND_TO_TEXTURE_RGBA, 5, EGL_NONE };
230 static const EGLint s_invalidChooseConfigAttribList4[] = { EGL_COLOR_BUFFER_TYPE, 0, EGL_NONE };
231 static const EGLint s_invalidChooseConfigAttribList5[] = { EGL_NATIVE_RENDERABLE, 6, EGL_NONE };
232 static const EGLint s_invalidChooseConfigAttribList6[] = { EGL_TRANSPARENT_TYPE, 6, EGL_NONE };
233 static const EGLint* s_invalidChooseConfigAttribLists[] =
235 &s_invalidChooseConfigAttribList0[0],
236 &s_invalidChooseConfigAttribList1[0],
237 &s_invalidChooseConfigAttribList2[0],
238 &s_invalidChooseConfigAttribList3[0],
239 &s_invalidChooseConfigAttribList4[0],
240 &s_invalidChooseConfigAttribList5[0],
241 &s_invalidChooseConfigAttribList6[0]
244 TEGL_ADD_API_CASE(choose_config, "eglChooseConfig() negative tests",
246 TestLog& log = m_testCtx.getLog();
247 EGLDisplay display = getDisplay();
248 EGLConfig configs[1];
251 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
253 expectFalse(eglChooseConfig(EGL_NO_DISPLAY, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
254 expectError(EGL_BAD_DISPLAY);
256 expectFalse(eglChooseConfig((EGLDisplay)-1, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
257 expectError(EGL_BAD_DISPLAY);
259 log << TestLog::EndSection;
261 log << TestLog::Section("Test2", "EGL_BAD_ATTRIBUTE is generated if attribute_list contains an invalid frame buffer configuration attribute");
263 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidChooseConfigAttribLists); ndx++)
265 expectFalse(eglChooseConfig(display, s_invalidChooseConfigAttribLists[ndx], &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
266 expectError(EGL_BAD_ATTRIBUTE);
269 log << TestLog::EndSection;
271 log << TestLog::Section("Test3", "EGL_BAD_PARAMETER is generated if num_config is NULL");
273 expectFalse(eglChooseConfig(display, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), DE_NULL));
274 expectError(EGL_BAD_PARAMETER);
276 log << TestLog::EndSection;
279 static const EGLint s_invalidCreateContextAttribList0[] = { 0, EGL_NONE };
280 static const EGLint s_invalidCreateContextAttribList1[] = { (EGLint)0xffffffff };
282 TEGL_ADD_API_CASE(create_context, "eglCreateContext() negative tests",
284 TestLog& log = m_testCtx.getLog();
285 EGLDisplay display = getDisplay();
287 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
289 expectNoContext(eglCreateContext(EGL_NO_DISPLAY, DE_NULL, EGL_NO_CONTEXT, s_emptyAttribList));
290 expectError(EGL_BAD_DISPLAY);
292 expectNoContext(eglCreateContext((EGLDisplay)-1, DE_NULL, EGL_NO_CONTEXT, s_emptyAttribList));
293 expectError(EGL_BAD_DISPLAY);
295 log << TestLog::EndSection;
297 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
299 expectNoContext(eglCreateContext(display, (EGLConfig)-1, EGL_NO_CONTEXT, s_emptyAttribList));
300 expectError(EGL_BAD_CONFIG);
302 log << TestLog::EndSection;
304 log << TestLog::Section("Test3", "EGL_BAD_CONFIG is generated if config does not support the current rendering API");
306 if (isAPISupported(EGL_OPENGL_API))
308 EGLConfig es1OnlyConfig;
309 if (getConfig(&es1OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT> << notRenderable<EGL_OPENGL_BIT>))
311 expectTrue(eglBindAPI(EGL_OPENGL_API));
312 expectNoContext(eglCreateContext(display, es1OnlyConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
313 expectError(EGL_BAD_CONFIG);
316 EGLConfig es2OnlyConfig;
317 if (getConfig(&es2OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << notRenderable<EGL_OPENGL_BIT>))
319 expectTrue(eglBindAPI(EGL_OPENGL_API));
320 expectNoContext(eglCreateContext(display, es2OnlyConfig, EGL_NO_CONTEXT, s_es2ContextAttribList));
321 expectError(EGL_BAD_CONFIG);
324 EGLConfig vgOnlyConfig;
325 if (getConfig(&vgOnlyConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notRenderable<EGL_OPENGL_BIT>))
327 expectTrue(eglBindAPI(EGL_OPENGL_API));
328 expectNoContext(eglCreateContext(display, vgOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
329 expectError(EGL_BAD_CONFIG);
333 if (isAPISupported(EGL_OPENGL_ES_API))
335 EGLConfig glOnlyConfig;
336 if (getConfig(&glOnlyConfig, FilterList() << renderable<EGL_OPENGL_BIT> << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>))
338 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
339 expectNoContext(eglCreateContext(display, glOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
340 expectError(EGL_BAD_CONFIG);
343 EGLConfig vgOnlyConfig;
344 if (getConfig(&vgOnlyConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>))
346 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
347 expectNoContext(eglCreateContext(display, vgOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
348 expectError(EGL_BAD_CONFIG);
352 if (isAPISupported(EGL_OPENVG_API))
354 EGLConfig glOnlyConfig;
355 if (getConfig(&glOnlyConfig, FilterList() << renderable<EGL_OPENGL_BIT> << notRenderable<EGL_OPENVG_BIT>))
357 expectTrue(eglBindAPI(EGL_OPENVG_API));
358 expectNoContext(eglCreateContext(display, glOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
359 expectError(EGL_BAD_CONFIG);
362 EGLConfig es1OnlyConfig;
363 if (getConfig(&es1OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT> << notRenderable<EGL_OPENVG_BIT>))
365 expectTrue(eglBindAPI(EGL_OPENVG_API));
366 expectNoContext(eglCreateContext(display, es1OnlyConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
367 expectError(EGL_BAD_CONFIG);
370 EGLConfig es2OnlyConfig;
371 if (getConfig(&es2OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << notRenderable<EGL_OPENVG_BIT>))
373 expectTrue(eglBindAPI(EGL_OPENVG_API));
374 expectNoContext(eglCreateContext(display, es2OnlyConfig, EGL_NO_CONTEXT, s_es2ContextAttribList));
375 expectError(EGL_BAD_CONFIG);
379 log << TestLog::EndSection;
381 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");
383 if (isAPISupported(EGL_OPENGL_ES_API))
385 EGLConfig notES1Config;
386 if (getConfig(¬ES1Config, FilterList() << notRenderable<EGL_OPENGL_ES_BIT>))
388 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
389 expectNoContext(eglCreateContext(display, notES1Config, EGL_NO_CONTEXT, s_es1ContextAttribList));
390 expectError(EGL_BAD_CONFIG);
394 log << TestLog::EndSection;
396 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");
398 if (isAPISupported(EGL_OPENGL_ES_API))
400 EGLConfig notES2Config;
401 if (getConfig(¬ES2Config, FilterList() << notRenderable<EGL_OPENGL_ES2_BIT>))
403 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
404 expectNoContext(eglCreateContext(display, notES2Config, EGL_NO_CONTEXT, s_es2ContextAttribList));
405 expectError(EGL_BAD_CONFIG);
409 log << TestLog::EndSection;
411 log << TestLog::Section("Test6", "EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid context attribute");
413 if (isAPISupported(EGL_OPENGL_API) && !eglu::hasExtension(m_eglTestCtx.getLibrary(), display, "EGL_KHR_create_context"))
416 if (getConfig(&glConfig, FilterList() << renderable<EGL_OPENGL_BIT>))
418 expectTrue(eglBindAPI(EGL_OPENGL_API));
419 expectNoContext(eglCreateContext(display, glConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
420 expectError(EGL_BAD_ATTRIBUTE);
424 if (isAPISupported(EGL_OPENVG_API))
427 if (getConfig(&vgConfig, FilterList() << renderable<EGL_OPENVG_BIT>))
429 expectTrue(eglBindAPI(EGL_OPENVG_API));
430 expectNoContext(eglCreateContext(display, vgConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
431 expectError(EGL_BAD_ATTRIBUTE);
435 if (isAPISupported(EGL_OPENGL_ES_API))
437 bool gotConfig = false;
440 gotConfig = getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT>) ||
441 getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
445 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
446 expectNoContext(eglCreateContext(display, esConfig, EGL_NO_CONTEXT, s_invalidCreateContextAttribList0));
447 expectError(EGL_BAD_ATTRIBUTE);
448 expectNoContext(eglCreateContext(display, esConfig, EGL_NO_CONTEXT, s_invalidCreateContextAttribList1));
449 expectError(EGL_BAD_ATTRIBUTE);
453 log << TestLog::EndSection;
456 TEGL_ADD_API_CASE(create_pbuffer_from_client_buffer, "eglCreatePbufferFromClientBuffer() negative tests",
458 TestLog& log = m_testCtx.getLog();
459 EGLDisplay display = getDisplay();
463 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
465 expectNoSurface(eglCreatePbufferFromClientBuffer(EGL_NO_DISPLAY, EGL_OPENVG_IMAGE, 0, (EGLConfig)0, DE_NULL));
466 expectError(EGL_BAD_DISPLAY);
468 expectNoSurface(eglCreatePbufferFromClientBuffer((EGLDisplay)-1, EGL_OPENVG_IMAGE, 0, (EGLConfig)0, DE_NULL));
469 expectError(EGL_BAD_DISPLAY);
471 log << TestLog::EndSection;
473 if (isAPISupported(EGL_OPENVG_API))
475 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");
477 expectNoSurface(eglCreatePbufferFromClientBuffer(display, EGL_OPENVG_IMAGE, (EGLClientBuffer)-1, (EGLConfig)-1, DE_NULL));
478 expectEitherError(EGL_BAD_CONFIG, EGL_BAD_PARAMETER);
480 log << TestLog::EndSection;
482 log << TestLog::Section("Test3", "EGL_BAD_PARAMETER is generated if buftype is not EGL_OPENVG_IMAGE");
484 expectTrue(eglGetConfigs(display, &anyConfig, 1, &unused));
486 log << TestLog::EndSection;
488 log << TestLog::Section("Test4", "EGL_BAD_PARAMETER is generated if buffer is not valid OpenVG image");
489 expectNoSurface(eglCreatePbufferFromClientBuffer(display, EGL_OPENVG_IMAGE, (EGLClientBuffer)-1, anyConfig, DE_NULL));
490 expectError(EGL_BAD_PARAMETER);
492 log << TestLog::EndSection;
496 static const EGLint s_invalidGenericPbufferAttrib0[] = { 0, EGL_NONE };
497 static const EGLint s_invalidGenericPbufferAttrib1[] = { (EGLint)0xffffffff };
498 static const EGLint s_negativeWidthPbufferAttrib[] = { EGL_WIDTH, -1, EGL_HEIGHT, 64, EGL_NONE };
499 static const EGLint s_negativeHeightPbufferAttrib[] = { EGL_WIDTH, 64, EGL_HEIGHT, -1, EGL_NONE };
500 static const EGLint s_negativeWidthAndHeightPbufferAttrib[] = { EGL_WIDTH, -1, EGL_HEIGHT, -1, EGL_NONE };
501 static const EGLint* s_invalidGenericPbufferAttribs[] =
503 s_invalidGenericPbufferAttrib0,
504 s_invalidGenericPbufferAttrib1,
507 static const EGLint s_invalidNoEsPbufferAttrib0[] = { EGL_MIPMAP_TEXTURE, EGL_TRUE, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
508 static const EGLint s_invalidNoEsPbufferAttrib1[] = { EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
509 static const EGLint s_invalidNoEsPbufferAttrib2[] = { EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
510 static const EGLint* s_invalidNoEsPbufferAttribs[] =
512 s_invalidNoEsPbufferAttrib0,
513 s_invalidNoEsPbufferAttrib1,
514 s_invalidNoEsPbufferAttrib2
517 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 };
518 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 };
519 static const EGLint* s_invalidEsPbufferAttribs[] =
521 s_invalidEsPbufferAttrib0,
522 s_invalidEsPbufferAttrib1
525 static const EGLint s_vgPreMultAlphaPbufferAttrib[] = { EGL_ALPHA_FORMAT, EGL_ALPHA_FORMAT_PRE, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
526 static const EGLint s_vgLinearColorspacePbufferAttrib[] = { EGL_COLORSPACE, EGL_VG_COLORSPACE_LINEAR, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
528 TEGL_ADD_API_CASE(create_pbuffer_surface, "eglCreatePbufferSurface() negative tests",
530 TestLog& log = m_testCtx.getLog();
531 EGLDisplay display = getDisplay();
533 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
535 expectNoSurface(eglCreatePbufferSurface(EGL_NO_DISPLAY, DE_NULL, s_emptyAttribList));
536 expectError(EGL_BAD_DISPLAY);
538 expectNoSurface(eglCreatePbufferSurface((EGLDisplay)-1, DE_NULL, s_emptyAttribList));
539 expectError(EGL_BAD_DISPLAY);
541 log << TestLog::EndSection;
543 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
545 expectNoSurface(eglCreatePbufferSurface(display, (EGLConfig)-1, s_emptyAttribList));
546 expectError(EGL_BAD_CONFIG);
548 log << TestLog::EndSection;
550 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid pixel buffer attribute");
552 // Generic pbuffer-capable config
553 EGLConfig genericConfig;
554 if (getConfig(&genericConfig, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
556 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidGenericPbufferAttribs); ndx++)
558 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_invalidGenericPbufferAttribs[ndx]));
559 expectError(EGL_BAD_ATTRIBUTE);
563 log << TestLog::EndSection;
565 log << TestLog::Section("Test4", "EGL_BAD_MATCH is generated if config does not support rendering to pixel buffers");
567 EGLConfig noPbufferConfig;
568 if (getConfig(&noPbufferConfig, FilterList() << notSurfaceBits<EGL_PBUFFER_BIT>))
570 expectNoSurface(eglCreatePbufferSurface(display, noPbufferConfig, s_validGenericPbufferAttrib));
571 expectError(EGL_BAD_MATCH);
574 log << TestLog::EndSection;
576 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");
578 EGLConfig noEsConfig;
579 if (getConfig(&noEsConfig, FilterList() << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>))
581 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidNoEsPbufferAttribs); ndx++)
583 expectNoSurface(eglCreatePbufferSurface(display, noEsConfig, s_invalidNoEsPbufferAttribs[ndx]));
584 expectError(EGL_BAD_MATCH);
588 log << TestLog::EndSection;
590 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");
592 // ES1 or ES2 config.
594 bool gotEsConfig = getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT>) ||
595 getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
598 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidEsPbufferAttribs); ndx++)
600 expectNoSurface(eglCreatePbufferSurface(display, esConfig, s_invalidEsPbufferAttribs[ndx]));
601 expectError(EGL_BAD_MATCH);
605 log << TestLog::EndSection;
607 log << TestLog::Section("Test7", "EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute");
609 EGLConfig vgNoPreConfig;
610 if (getConfig(&vgNoPreConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notSurfaceBits<EGL_VG_ALPHA_FORMAT_PRE_BIT>))
612 expectNoSurface(eglCreatePbufferSurface(display, vgNoPreConfig, s_vgPreMultAlphaPbufferAttrib));
613 expectError(EGL_BAD_MATCH);
616 EGLConfig vgNoLinearConfig;
617 if (getConfig(&vgNoLinearConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notSurfaceBits<EGL_VG_COLORSPACE_LINEAR_BIT>))
619 expectNoSurface(eglCreatePbufferSurface(display, vgNoLinearConfig, s_vgLinearColorspacePbufferAttrib));
620 expectError(EGL_BAD_MATCH);
623 log << TestLog::EndSection;
625 log << TestLog::Section("Test8", "EGL_BAD_PARAMETER is generated if EGL_WIDTH or EGL_HEIGHT is negative");
627 if (getConfig(&genericConfig, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
629 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeWidthPbufferAttrib));
630 expectError(EGL_BAD_PARAMETER);
632 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeHeightPbufferAttrib));
633 expectError(EGL_BAD_PARAMETER);
635 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeWidthAndHeightPbufferAttrib));
636 expectError(EGL_BAD_PARAMETER);
639 log << TestLog::EndSection;
643 TEGL_ADD_API_CASE(create_pixmap_surface, "eglCreatePixmapSurface() negative tests",
645 TestLog& log = m_testCtx.getLog();
646 EGLDisplay display = getDisplay();
648 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
650 expectNoSurface(eglCreatePixmapSurface(EGL_NO_DISPLAY, DE_NULL, DE_NULL, s_emptyAttribList));
651 expectError(EGL_BAD_DISPLAY);
653 expectNoSurface(eglCreatePixmapSurface((EGLDisplay)-1, DE_NULL, DE_NULL, s_emptyAttribList));
654 expectError(EGL_BAD_DISPLAY);
656 log << TestLog::EndSection;
658 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
660 expectNoSurface(eglCreatePixmapSurface(display, (EGLConfig)-1, DE_NULL, s_emptyAttribList));
661 expectError(EGL_BAD_CONFIG);
663 log << TestLog::EndSection;
666 TEGL_ADD_API_CASE(create_window_surface, "eglCreateWindowSurface() negative tests",
668 EGLConfig config = DE_NULL;
669 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << surfaceBits<EGL_WINDOW_BIT>);
673 TestLog& log = m_testCtx.getLog();
674 EGLDisplay display = getDisplay();
675 const eglu::NativeWindowFactory& factory = eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
676 de::UniquePtr<eglu::NativeWindow> window (factory.createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(256, 256, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
678 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
680 expectNoSurface(eglCreateWindowSurface(EGL_NO_DISPLAY, config, window->getLegacyNative(), s_emptyAttribList));
681 expectError(EGL_BAD_DISPLAY);
683 expectNoSurface(eglCreateWindowSurface((EGLDisplay)-1, config, window->getLegacyNative(), s_emptyAttribList));
684 expectError(EGL_BAD_DISPLAY);
686 log << TestLog::EndSection;
690 TEGL_ADD_API_CASE(destroy_context, "eglDestroyContext() negative tests",
692 TestLog& log = m_testCtx.getLog();
693 EGLDisplay display = getDisplay();
695 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
697 expectFalse(eglDestroyContext(EGL_NO_DISPLAY, DE_NULL));
698 expectError(EGL_BAD_DISPLAY);
700 expectFalse(eglDestroyContext((EGLDisplay)-1, DE_NULL));
701 expectError(EGL_BAD_DISPLAY);
703 log << TestLog::EndSection;
705 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
707 expectFalse(eglDestroyContext(display, DE_NULL));
708 expectError(EGL_BAD_CONTEXT);
710 expectFalse(eglDestroyContext(display, (EGLContext)-1));
711 expectError(EGL_BAD_CONTEXT);
713 log << TestLog::EndSection;
716 TEGL_ADD_API_CASE(destroy_surface, "eglDestroySurface() negative tests",
718 TestLog& log = m_testCtx.getLog();
719 EGLDisplay display = getDisplay();
721 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
723 expectFalse(eglDestroySurface(EGL_NO_DISPLAY, DE_NULL));
724 expectError(EGL_BAD_DISPLAY);
726 expectFalse(eglDestroySurface((EGLDisplay)-1, DE_NULL));
727 expectError(EGL_BAD_DISPLAY);
729 log << TestLog::EndSection;
731 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
733 expectFalse(eglDestroySurface(display, DE_NULL));
734 expectError(EGL_BAD_SURFACE);
736 expectFalse(eglDestroySurface(display, (EGLSurface)-1));
737 expectError(EGL_BAD_SURFACE);
739 log << TestLog::EndSection;
742 TEGL_ADD_API_CASE(get_config_attrib, "eglGetConfigAttrib() negative tests",
744 TestLog& log = m_testCtx.getLog();
745 EGLDisplay display = getDisplay();
748 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
750 expectFalse(eglGetConfigAttrib(EGL_NO_DISPLAY, DE_NULL, EGL_RED_SIZE, &value));
751 expectError(EGL_BAD_DISPLAY);
753 expectFalse(eglGetConfigAttrib((EGLDisplay)-1, DE_NULL, EGL_RED_SIZE, &value));
754 expectError(EGL_BAD_DISPLAY);
756 log << TestLog::EndSection;
758 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
760 expectFalse(eglGetConfigAttrib(display, (EGLConfig)-1, EGL_RED_SIZE, &value));
761 expectError(EGL_BAD_CONFIG);
763 log << TestLog::EndSection;
766 EGLConfig config = DE_NULL;
767 bool hasConfig = getConfig(&config, FilterList());
769 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid frame buffer configuration attribute");
773 expectFalse(eglGetConfigAttrib(display, config, 0, &value));
774 expectError(EGL_BAD_ATTRIBUTE);
776 expectFalse(eglGetConfigAttrib(display, config, -1, &value));
777 expectError(EGL_BAD_ATTRIBUTE);
780 log << TestLog::EndSection;
783 TEGL_ADD_API_CASE(get_configs, "eglGetConfigs() negative tests",
785 TestLog& log = m_testCtx.getLog();
786 EGLDisplay display = getDisplay();
790 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
792 expectFalse(eglGetConfigs(EGL_NO_DISPLAY, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), &numCfgs));
793 expectError(EGL_BAD_DISPLAY);
795 expectFalse(eglGetConfigs((EGLDisplay)-1, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), &numCfgs));
796 expectError(EGL_BAD_DISPLAY);
798 log << TestLog::EndSection;
800 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if num_config is NULL");
802 expectFalse(eglGetConfigs(display, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), DE_NULL));
803 expectError(EGL_BAD_PARAMETER);
805 log << TestLog::EndSection;
808 TEGL_ADD_API_CASE(initialize, "eglInitialize() negative tests",
810 TestLog& log = m_testCtx.getLog();
814 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
816 expectFalse(eglInitialize(EGL_NO_DISPLAY, &major, &minor));
817 expectError(EGL_BAD_DISPLAY);
819 expectFalse(eglInitialize((EGLDisplay)-1, &major, &minor));
820 expectError(EGL_BAD_DISPLAY);
822 log << TestLog::EndSection;
825 TEGL_ADD_API_CASE(make_current, "eglMakeCurrent() negative tests",
827 TestLog& log = m_testCtx.getLog();
828 EGLDisplay display = getDisplay();
830 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
832 expectFalse(eglMakeCurrent(EGL_NO_DISPLAY, DE_NULL, DE_NULL, DE_NULL));
833 expectError(EGL_BAD_DISPLAY);
835 expectFalse(eglMakeCurrent((EGLDisplay)-1, DE_NULL, DE_NULL, DE_NULL));
836 expectError(EGL_BAD_DISPLAY);
838 log << TestLog::EndSection;
840 // Create simple pbuffer surface.
841 EGLSurface surface = EGL_NO_SURFACE;
844 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
846 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
847 expectError(EGL_SUCCESS);
851 // Create simple ES2 context
852 EGLContext context = EGL_NO_CONTEXT;
855 if (getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT>))
857 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
858 expectError(EGL_SUCCESS);
862 if (surface != EGL_NO_SURFACE && context != EGL_NO_CONTEXT)
864 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
866 expectFalse(eglMakeCurrent(display, (EGLSurface)-1, (EGLSurface)-1, context));
867 expectError(EGL_BAD_SURFACE);
869 expectFalse(eglMakeCurrent(display, surface, (EGLSurface)-1, context));
870 expectError(EGL_BAD_SURFACE);
872 expectFalse(eglMakeCurrent(display, (EGLSurface)-1, surface, context));
873 expectError(EGL_BAD_SURFACE);
875 log << TestLog::EndSection;
880 log << TestLog::Section("Test3", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
882 expectFalse(eglMakeCurrent(display, surface, surface, (EGLContext)-1));
883 expectError(EGL_BAD_CONTEXT);
885 log << TestLog::EndSection;
888 if (surface != EGL_NO_SURFACE)
890 log << TestLog::Section("Test4", "EGL_BAD_MATCH is generated if read or draw surface is not EGL_NO_SURFACE and context is EGL_NO_CONTEXT");
892 expectFalse(eglMakeCurrent(display, surface, EGL_NO_SURFACE, EGL_NO_CONTEXT));
893 expectError(EGL_BAD_MATCH);
895 expectFalse(eglMakeCurrent(display, EGL_NO_SURFACE, surface, EGL_NO_CONTEXT));
896 expectError(EGL_BAD_MATCH);
898 expectFalse(eglMakeCurrent(display, surface, surface, EGL_NO_CONTEXT));
899 expectError(EGL_BAD_MATCH);
901 log << TestLog::EndSection;
906 eglDestroyContext(display, context);
907 expectError(EGL_SUCCESS);
912 eglDestroySurface(display, surface);
913 expectError(EGL_SUCCESS);
917 TEGL_ADD_API_CASE(get_current_context, "eglGetCurrentContext() negative tests",
919 expectNoContext(eglGetCurrentContext());
921 if (isAPISupported(EGL_OPENGL_ES_API))
923 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
924 expectError(EGL_SUCCESS);
926 expectNoContext(eglGetCurrentContext());
927 expectError(EGL_SUCCESS);
931 TEGL_ADD_API_CASE(get_current_surface, "eglGetCurrentSurface() negative tests",
933 TestLog& log = m_testCtx.getLog();
934 EGLDisplay display = getDisplay();
935 EGLConfig config = DE_NULL;
936 EGLContext context = EGL_NO_CONTEXT;
937 EGLSurface surface = EGL_NO_SURFACE;
938 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << surfaceBits<EGL_PBUFFER_BIT>);
942 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
943 expectError(EGL_SUCCESS);
945 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
946 expectError(EGL_SUCCESS);
948 // Create simple pbuffer surface.
949 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
950 expectError(EGL_SUCCESS);
952 expectTrue(eglMakeCurrent(display, surface, surface, context));
953 expectError(EGL_SUCCESS);
955 log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if readdraw is neither EGL_READ nor EGL_DRAW");
957 expectNoSurface(eglGetCurrentSurface(EGL_NONE));
958 expectError(EGL_BAD_PARAMETER);
960 log << TestLog::EndSection;
962 expectTrue(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
963 expectError(EGL_SUCCESS);
965 if (surface != EGL_NO_SURFACE)
967 expectTrue(eglDestroySurface(display, surface));
968 expectError(EGL_SUCCESS);
971 if (context != EGL_NO_CONTEXT)
973 expectTrue(eglDestroyContext(display, context));
974 expectError(EGL_SUCCESS);
979 TEGL_ADD_API_CASE(query_context, "eglQueryContext() negative tests",
981 TestLog& log = m_testCtx.getLog();
982 EGLDisplay display = getDisplay();
985 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
987 expectFalse(eglQueryContext(EGL_NO_DISPLAY, DE_NULL, EGL_CONFIG_ID, &value));
988 expectError(EGL_BAD_DISPLAY);
990 expectFalse(eglQueryContext((EGLDisplay)-1, DE_NULL, EGL_CONFIG_ID, &value));
991 expectError(EGL_BAD_DISPLAY);
993 log << TestLog::EndSection;
995 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
997 expectFalse(eglQueryContext(display, DE_NULL, EGL_CONFIG_ID, &value));
998 expectError(EGL_BAD_CONTEXT);
1000 expectFalse(eglQueryContext(display, DE_NULL, EGL_CONFIG_ID, &value));
1001 expectError(EGL_BAD_CONTEXT);
1003 log << TestLog::EndSection;
1005 // Create ES2 context.
1006 EGLConfig config = DE_NULL;
1007 EGLContext context = DE_NULL;
1008 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
1012 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
1013 expectError(EGL_SUCCESS);
1015 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
1016 expectError(EGL_SUCCESS);
1019 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid context attribute");
1023 expectFalse(eglQueryContext(display, context, 0, &value));
1024 expectError(EGL_BAD_ATTRIBUTE);
1025 expectFalse(eglQueryContext(display, context, -1, &value));
1026 expectError(EGL_BAD_ATTRIBUTE);
1027 expectFalse(eglQueryContext(display, context, EGL_RED_SIZE, &value));
1028 expectError(EGL_BAD_ATTRIBUTE);
1031 log << TestLog::EndSection;
1035 expectTrue(eglDestroyContext(display, context));
1036 expectError(EGL_SUCCESS);
1040 TEGL_ADD_API_CASE(query_string, "eglQueryString() negative tests",
1042 TestLog& log = m_testCtx.getLog();
1043 EGLDisplay display = getDisplay();
1045 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1047 expectNull(eglQueryString(EGL_NO_DISPLAY, EGL_VENDOR));
1048 expectError(EGL_BAD_DISPLAY);
1050 expectNull(eglQueryString((EGLDisplay)-1, EGL_VENDOR));
1051 expectError(EGL_BAD_DISPLAY);
1053 log << TestLog::EndSection;
1055 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if name is not an accepted value");
1057 expectNull(eglQueryString(display, 0));
1058 expectError(EGL_BAD_PARAMETER);
1059 expectNull(eglQueryString(display, -1));
1060 expectError(EGL_BAD_PARAMETER);
1062 log << TestLog::EndSection;
1065 TEGL_ADD_API_CASE(query_surface, "eglQuerySurface() negative tests",
1067 TestLog& log = m_testCtx.getLog();
1068 EGLDisplay display = getDisplay();
1071 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1073 expectFalse(eglQuerySurface(EGL_NO_DISPLAY, DE_NULL, EGL_CONFIG_ID, &value));
1074 expectError(EGL_BAD_DISPLAY);
1076 expectFalse(eglQuerySurface((EGLDisplay)-1, DE_NULL, EGL_CONFIG_ID, &value));
1077 expectError(EGL_BAD_DISPLAY);
1079 log << TestLog::EndSection;
1081 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1083 expectFalse(eglQuerySurface(display, DE_NULL, EGL_CONFIG_ID, &value));
1084 expectError(EGL_BAD_SURFACE);
1086 expectFalse(eglQuerySurface(display, (EGLSurface)-1, EGL_CONFIG_ID, &value));
1087 expectError(EGL_BAD_SURFACE);
1089 log << TestLog::EndSection;
1091 // Create pbuffer surface.
1092 EGLSurface surface = EGL_NO_SURFACE;
1095 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
1097 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1098 expectError(EGL_SUCCESS);
1101 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1104 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid surface attribute");
1108 expectFalse(eglQuerySurface(display, surface, 0, &value));
1109 expectError(EGL_BAD_ATTRIBUTE);
1111 expectFalse(eglQuerySurface(display, surface, -1, &value));
1112 expectError(EGL_BAD_ATTRIBUTE);
1115 log << TestLog::EndSection;
1119 eglDestroySurface(display, surface);
1120 expectError(EGL_SUCCESS);
1124 TEGL_ADD_API_CASE(release_tex_image, "eglReleaseTexImage() negative tests",
1126 TestLog& log = m_testCtx.getLog();
1127 EGLDisplay display = getDisplay();
1129 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1131 expectFalse(eglReleaseTexImage(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1132 expectError(EGL_BAD_DISPLAY);
1134 expectFalse(eglReleaseTexImage((EGLDisplay)-1, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1135 expectError(EGL_BAD_DISPLAY);
1137 log << TestLog::EndSection;
1139 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1141 expectFalse(eglReleaseTexImage(display, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1142 expectError(EGL_BAD_SURFACE);
1144 expectFalse(eglReleaseTexImage(display, (EGLSurface)-1, EGL_BACK_BUFFER));
1145 expectError(EGL_BAD_SURFACE);
1147 log << TestLog::EndSection;
1150 TEGL_ADD_API_CASE(surface_attrib, "eglSurfaceAttrib() negative tests",
1152 TestLog& log = m_testCtx.getLog();
1153 EGLDisplay display = getDisplay();
1155 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1157 expectFalse(eglSurfaceAttrib(EGL_NO_DISPLAY, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1158 expectError(EGL_BAD_DISPLAY);
1160 expectFalse(eglSurfaceAttrib((EGLDisplay)-1, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1161 expectError(EGL_BAD_DISPLAY);
1163 log << TestLog::EndSection;
1165 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1167 expectFalse(eglSurfaceAttrib(display, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1168 expectError(EGL_BAD_SURFACE);
1170 expectFalse(eglSurfaceAttrib(display, (EGLSurface)-1, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1171 expectError(EGL_BAD_SURFACE);
1173 log << TestLog::EndSection;
1176 // Create pbuffer surface.
1177 EGLSurface surface = EGL_NO_SURFACE;
1180 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
1182 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1183 expectError(EGL_SUCCESS);
1186 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1189 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid surface attribute");
1193 expectFalse(eglSurfaceAttrib(display, surface, 0, 0));
1194 expectError(EGL_BAD_ATTRIBUTE);
1196 expectFalse(eglSurfaceAttrib(display, surface, -1, 0));
1197 expectError(EGL_BAD_ATTRIBUTE);
1200 log << TestLog::EndSection;
1204 eglDestroySurface(display, surface);
1205 expectError(EGL_SUCCESS);
1210 // Create pbuffer surface without EGL_MULTISAMPLE_RESOLVE_BOX_BIT.
1211 EGLSurface surface = EGL_NO_SURFACE;
1214 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT> << notSurfaceBits<EGL_MULTISAMPLE_RESOLVE_BOX_BIT>))
1216 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1217 expectError(EGL_SUCCESS);
1220 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1223 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");
1227 expectFalse(eglSurfaceAttrib(display, surface, EGL_MULTISAMPLE_RESOLVE, EGL_MULTISAMPLE_RESOLVE_BOX));
1228 expectError(EGL_BAD_MATCH);
1231 log << TestLog::EndSection;
1235 eglDestroySurface(display, surface);
1236 expectError(EGL_SUCCESS);
1241 // Create pbuffer surface without EGL_SWAP_BEHAVIOR_PRESERVED_BIT.
1242 EGLSurface surface = EGL_NO_SURFACE;
1245 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT> << notSurfaceBits<EGL_SWAP_BEHAVIOR_PRESERVED_BIT>))
1247 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1248 expectError(EGL_SUCCESS);
1251 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1254 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");
1258 expectFalse(eglSurfaceAttrib(display, surface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED));
1259 expectError(EGL_BAD_MATCH);
1262 log << TestLog::EndSection;
1266 eglDestroySurface(display, surface);
1267 expectError(EGL_SUCCESS);
1272 TEGL_ADD_API_CASE(swap_buffers, "eglSwapBuffers() negative tests",
1274 TestLog& log = m_testCtx.getLog();
1275 EGLDisplay display = getDisplay();
1277 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1279 expectFalse(eglSwapBuffers(EGL_NO_DISPLAY, DE_NULL));
1280 expectError(EGL_BAD_DISPLAY);
1282 expectFalse(eglSwapBuffers((EGLDisplay)-1, DE_NULL));
1283 expectError(EGL_BAD_DISPLAY);
1285 log << TestLog::EndSection;
1287 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1289 expectFalse(eglSwapBuffers(display, DE_NULL));
1290 expectError(EGL_BAD_SURFACE);
1292 expectFalse(eglSwapBuffers(display, (EGLSurface)-1));
1293 expectError(EGL_BAD_SURFACE);
1295 log << TestLog::EndSection;
1298 TEGL_ADD_API_CASE(swap_interval, "eglSwapInterval() negative tests",
1300 TestLog& log = m_testCtx.getLog();
1301 EGLDisplay display = getDisplay();
1303 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1305 expectFalse(eglSwapInterval(EGL_NO_DISPLAY, 0));
1306 expectError(EGL_BAD_DISPLAY);
1308 expectFalse(eglSwapInterval((EGLDisplay)-1, 0));
1309 expectError(EGL_BAD_DISPLAY);
1311 log << TestLog::EndSection;
1313 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if there is no current context on the calling thread");
1315 expectFalse(eglSwapInterval(display, 0));
1316 expectError(EGL_BAD_CONTEXT);
1318 log << TestLog::EndSection;
1321 TEGL_ADD_API_CASE(terminate, "eglTerminate() negative tests",
1323 TestLog& log = m_testCtx.getLog();
1325 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1327 expectFalse(eglTerminate(EGL_NO_DISPLAY));
1328 expectError(EGL_BAD_DISPLAY);
1330 expectFalse(eglTerminate((EGLDisplay)-1));
1331 expectError(EGL_BAD_DISPLAY);
1333 log << TestLog::EndSection;
1336 TEGL_ADD_API_CASE(wait_native, "eglWaitNative() negative tests",
1338 EGLConfig config = DE_NULL;
1339 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << surfaceBits<EGL_WINDOW_BIT>);
1343 TestLog& log = m_testCtx.getLog();
1344 const Library& egl = m_eglTestCtx.getLibrary();
1345 EGLDisplay display = getDisplay();
1346 const eglu::NativeWindowFactory& factory = eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
1347 de::UniquePtr<eglu::NativeWindow> window (factory.createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(256, 256, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
1348 eglu::UniqueSurface surface (egl, display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, display, config, DE_NULL));
1349 EGLContext context = EGL_NO_CONTEXT;
1351 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
1352 expectError(EGL_SUCCESS);
1354 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
1355 expectError(EGL_SUCCESS);
1357 expectTrue(eglMakeCurrent(display, *surface, *surface, context));
1358 expectError(EGL_SUCCESS);
1360 log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if engine is not a recognized marking engine and native rendering is supported by current surface");
1363 expectEitherError(EGL_BAD_PARAMETER, EGL_SUCCESS);
1365 log << TestLog::EndSection;
1367 expectTrue(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
1368 expectError(EGL_SUCCESS);
1370 if (context != EGL_NO_CONTEXT)
1372 expectTrue(eglDestroyContext(display, context));
1373 expectError(EGL_SUCCESS);