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 };
130 static const eglu::ConfigFilter s_renderAPIFilters[] = { renderable<EGL_OPENGL_BIT>, renderable<EGL_OPENGL_ES_BIT>, renderable<EGL_OPENVG_BIT> };
132 TEGL_ADD_API_CASE(bind_api, "eglBindAPI() negative tests",
134 TestLog& log = m_testCtx.getLog();
135 log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if api is not one of the accepted tokens");
137 expectFalse(eglBindAPI(0));
138 expectError(EGL_BAD_PARAMETER);
140 expectFalse(eglBindAPI(0xfdfdfdfd));
141 expectError(EGL_BAD_PARAMETER);
143 expectFalse(eglBindAPI((EGLenum)0xffffffff));
144 expectError(EGL_BAD_PARAMETER);
146 log << TestLog::EndSection;
148 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if the specified client API is not supported by the EGL display, or no configuration is provided for the specified API.");
150 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_renderAPIs); ndx++)
152 if (!isAPISupported(s_renderAPIs[ndx]))
154 if (!eglBindAPI(s_renderAPIs[ndx]))
155 expectError(EGL_BAD_PARAMETER);
159 expectFalse(getConfig(&eglConfig, FilterList() << s_renderAPIFilters[ndx]));
164 log << TestLog::EndSection;
167 TEGL_ADD_API_CASE(bind_tex_image, "eglBindTexImage() negative tests",
169 TestLog& log = m_testCtx.getLog();
170 EGLDisplay display = getDisplay();
172 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
174 expectFalse(eglBindTexImage(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_BACK_BUFFER));
175 expectError(EGL_BAD_DISPLAY);
177 expectFalse(eglBindTexImage((EGLDisplay)-1, EGL_NO_SURFACE, EGL_BACK_BUFFER));
178 expectError(EGL_BAD_DISPLAY);
180 log << TestLog::EndSection;
182 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
184 expectFalse(eglBindTexImage(display, EGL_NO_SURFACE, EGL_BACK_BUFFER));
185 expectError(EGL_BAD_SURFACE);
187 expectFalse(eglBindTexImage(display, (EGLSurface)-1, EGL_BACK_BUFFER));
188 expectError(EGL_BAD_SURFACE);
190 log << TestLog::EndSection;
193 static const EGLint s_validGenericPbufferAttrib[] = { EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
195 TEGL_ADD_API_CASE(copy_buffers, "eglCopyBuffers() negative tests",
197 TestLog& log = m_testCtx.getLog();
198 const eglw::Library& egl = m_eglTestCtx.getLibrary();
199 EGLDisplay display = getDisplay();
200 const eglu::NativePixmapFactory& factory = eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
201 de::UniquePtr<eglu::NativePixmap> pixmap (factory.createPixmap(&m_eglTestCtx.getNativeDisplay(), 64, 64));
205 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
207 eglu::UniqueSurface surface (egl, display, egl.createPbufferSurface(display, config, s_validGenericPbufferAttrib));
209 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
211 expectFalse(eglCopyBuffers(EGL_NO_DISPLAY, EGL_NO_SURFACE, pixmap->getLegacyNative()));
212 expectError(EGL_BAD_DISPLAY);
214 expectFalse(eglCopyBuffers((EGLDisplay)-1, EGL_NO_SURFACE, pixmap->getLegacyNative()));
215 expectError(EGL_BAD_DISPLAY);
217 log << TestLog::EndSection;
221 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
223 expectFalse(eglCopyBuffers(display, EGL_NO_SURFACE, pixmap->getLegacyNative()));
224 expectError(EGL_BAD_SURFACE);
226 expectFalse(eglCopyBuffers(display, (EGLSurface)-1, pixmap->getLegacyNative()));
227 expectError(EGL_BAD_SURFACE);
229 log << TestLog::EndSection;
232 static const EGLint s_invalidChooseConfigAttribList0[] = { 0, EGL_NONE };
233 static const EGLint s_invalidChooseConfigAttribList1[] = { (EGLint)0xffffffff };
234 static const EGLint s_invalidChooseConfigAttribList2[] = { EGL_BIND_TO_TEXTURE_RGB, 4, EGL_NONE };
235 static const EGLint s_invalidChooseConfigAttribList3[] = { EGL_BIND_TO_TEXTURE_RGBA, 5, EGL_NONE };
236 static const EGLint s_invalidChooseConfigAttribList4[] = { EGL_COLOR_BUFFER_TYPE, 0, EGL_NONE };
237 static const EGLint s_invalidChooseConfigAttribList5[] = { EGL_NATIVE_RENDERABLE, 6, EGL_NONE };
238 static const EGLint s_invalidChooseConfigAttribList6[] = { EGL_TRANSPARENT_TYPE, 6, EGL_NONE };
239 static const EGLint* s_invalidChooseConfigAttribLists[] =
241 &s_invalidChooseConfigAttribList0[0],
242 &s_invalidChooseConfigAttribList1[0],
243 &s_invalidChooseConfigAttribList2[0],
244 &s_invalidChooseConfigAttribList3[0],
245 &s_invalidChooseConfigAttribList4[0],
246 &s_invalidChooseConfigAttribList5[0],
247 &s_invalidChooseConfigAttribList6[0]
250 TEGL_ADD_API_CASE(choose_config, "eglChooseConfig() negative tests",
252 TestLog& log = m_testCtx.getLog();
253 EGLDisplay display = getDisplay();
254 EGLConfig configs[1];
257 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
259 expectFalse(eglChooseConfig(EGL_NO_DISPLAY, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
260 expectError(EGL_BAD_DISPLAY);
262 expectFalse(eglChooseConfig((EGLDisplay)-1, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
263 expectError(EGL_BAD_DISPLAY);
265 log << TestLog::EndSection;
267 log << TestLog::Section("Test2", "EGL_BAD_ATTRIBUTE is generated if attribute_list contains an invalid frame buffer configuration attribute");
269 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidChooseConfigAttribLists); ndx++)
271 expectFalse(eglChooseConfig(display, s_invalidChooseConfigAttribLists[ndx], &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
272 expectError(EGL_BAD_ATTRIBUTE);
275 log << TestLog::EndSection;
277 log << TestLog::Section("Test3", "EGL_BAD_PARAMETER is generated if num_config is NULL");
279 expectFalse(eglChooseConfig(display, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), DE_NULL));
280 expectError(EGL_BAD_PARAMETER);
282 log << TestLog::EndSection;
285 static const EGLint s_invalidCreateContextAttribList0[] = { 0, EGL_NONE };
286 static const EGLint s_invalidCreateContextAttribList1[] = { (EGLint)0xffffffff };
288 TEGL_ADD_API_CASE(create_context, "eglCreateContext() negative tests",
290 TestLog& log = m_testCtx.getLog();
291 EGLDisplay display = getDisplay();
293 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
295 expectNoContext(eglCreateContext(EGL_NO_DISPLAY, DE_NULL, EGL_NO_CONTEXT, s_emptyAttribList));
296 expectError(EGL_BAD_DISPLAY);
298 expectNoContext(eglCreateContext((EGLDisplay)-1, DE_NULL, EGL_NO_CONTEXT, s_emptyAttribList));
299 expectError(EGL_BAD_DISPLAY);
301 log << TestLog::EndSection;
303 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
305 expectNoContext(eglCreateContext(display, (EGLConfig)-1, EGL_NO_CONTEXT, s_emptyAttribList));
306 expectError(EGL_BAD_CONFIG);
308 log << TestLog::EndSection;
310 log << TestLog::Section("Test3", "EGL_BAD_CONFIG is generated if config does not support the current rendering API");
312 if (isAPISupported(EGL_OPENGL_API))
314 EGLConfig es1OnlyConfig;
315 if (getConfig(&es1OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT> << notRenderable<EGL_OPENGL_BIT>))
317 expectTrue(eglBindAPI(EGL_OPENGL_API));
318 expectNoContext(eglCreateContext(display, es1OnlyConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
319 expectError(EGL_BAD_CONFIG);
322 EGLConfig es2OnlyConfig;
323 if (getConfig(&es2OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << notRenderable<EGL_OPENGL_BIT>))
325 expectTrue(eglBindAPI(EGL_OPENGL_API));
326 expectNoContext(eglCreateContext(display, es2OnlyConfig, EGL_NO_CONTEXT, s_es2ContextAttribList));
327 expectError(EGL_BAD_CONFIG);
330 EGLConfig vgOnlyConfig;
331 if (getConfig(&vgOnlyConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notRenderable<EGL_OPENGL_BIT>))
333 expectTrue(eglBindAPI(EGL_OPENGL_API));
334 expectNoContext(eglCreateContext(display, vgOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
335 expectError(EGL_BAD_CONFIG);
339 if (isAPISupported(EGL_OPENGL_ES_API))
341 EGLConfig glOnlyConfig;
342 if (getConfig(&glOnlyConfig, FilterList() << renderable<EGL_OPENGL_BIT> << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>))
344 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
345 expectNoContext(eglCreateContext(display, glOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
346 expectError(EGL_BAD_CONFIG);
349 EGLConfig vgOnlyConfig;
350 if (getConfig(&vgOnlyConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>))
352 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
353 expectNoContext(eglCreateContext(display, vgOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
354 expectError(EGL_BAD_CONFIG);
358 if (isAPISupported(EGL_OPENVG_API))
360 EGLConfig glOnlyConfig;
361 if (getConfig(&glOnlyConfig, FilterList() << renderable<EGL_OPENGL_BIT> << notRenderable<EGL_OPENVG_BIT>))
363 expectTrue(eglBindAPI(EGL_OPENVG_API));
364 expectNoContext(eglCreateContext(display, glOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
365 expectError(EGL_BAD_CONFIG);
368 EGLConfig es1OnlyConfig;
369 if (getConfig(&es1OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT> << notRenderable<EGL_OPENVG_BIT>))
371 expectTrue(eglBindAPI(EGL_OPENVG_API));
372 expectNoContext(eglCreateContext(display, es1OnlyConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
373 expectError(EGL_BAD_CONFIG);
376 EGLConfig es2OnlyConfig;
377 if (getConfig(&es2OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << notRenderable<EGL_OPENVG_BIT>))
379 expectTrue(eglBindAPI(EGL_OPENVG_API));
380 expectNoContext(eglCreateContext(display, es2OnlyConfig, EGL_NO_CONTEXT, s_es2ContextAttribList));
381 expectError(EGL_BAD_CONFIG);
385 log << TestLog::EndSection;
387 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");
389 if (isAPISupported(EGL_OPENGL_ES_API))
391 EGLConfig notES1Config;
392 if (getConfig(¬ES1Config, FilterList() << notRenderable<EGL_OPENGL_ES_BIT>))
394 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
395 expectNoContext(eglCreateContext(display, notES1Config, EGL_NO_CONTEXT, s_es1ContextAttribList));
396 expectError(EGL_BAD_CONFIG);
400 log << TestLog::EndSection;
402 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");
404 if (isAPISupported(EGL_OPENGL_ES_API))
406 EGLConfig notES2Config;
407 if (getConfig(¬ES2Config, FilterList() << notRenderable<EGL_OPENGL_ES2_BIT>))
409 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
410 expectNoContext(eglCreateContext(display, notES2Config, EGL_NO_CONTEXT, s_es2ContextAttribList));
411 expectError(EGL_BAD_CONFIG);
415 log << TestLog::EndSection;
417 log << TestLog::Section("Test6", "EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid context attribute");
419 if (isAPISupported(EGL_OPENGL_API) && !eglu::hasExtension(m_eglTestCtx.getLibrary(), display, "EGL_KHR_create_context"))
422 if (getConfig(&glConfig, FilterList() << renderable<EGL_OPENGL_BIT>))
424 expectTrue(eglBindAPI(EGL_OPENGL_API));
425 expectNoContext(eglCreateContext(display, glConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
426 expectError(EGL_BAD_ATTRIBUTE);
430 if (isAPISupported(EGL_OPENVG_API))
433 if (getConfig(&vgConfig, FilterList() << renderable<EGL_OPENVG_BIT>))
435 expectTrue(eglBindAPI(EGL_OPENVG_API));
436 expectNoContext(eglCreateContext(display, vgConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
437 expectError(EGL_BAD_ATTRIBUTE);
441 if (isAPISupported(EGL_OPENGL_ES_API))
443 bool gotConfig = false;
446 gotConfig = getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT>) ||
447 getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
451 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
452 expectNoContext(eglCreateContext(display, esConfig, EGL_NO_CONTEXT, s_invalidCreateContextAttribList0));
453 expectError(EGL_BAD_ATTRIBUTE);
454 expectNoContext(eglCreateContext(display, esConfig, EGL_NO_CONTEXT, s_invalidCreateContextAttribList1));
455 expectError(EGL_BAD_ATTRIBUTE);
459 log << TestLog::EndSection;
462 TEGL_ADD_API_CASE(create_pbuffer_from_client_buffer, "eglCreatePbufferFromClientBuffer() negative tests",
464 TestLog& log = m_testCtx.getLog();
465 EGLDisplay display = getDisplay();
469 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
471 expectNoSurface(eglCreatePbufferFromClientBuffer(EGL_NO_DISPLAY, EGL_OPENVG_IMAGE, 0, (EGLConfig)0, DE_NULL));
472 expectError(EGL_BAD_DISPLAY);
474 expectNoSurface(eglCreatePbufferFromClientBuffer((EGLDisplay)-1, EGL_OPENVG_IMAGE, 0, (EGLConfig)0, DE_NULL));
475 expectError(EGL_BAD_DISPLAY);
477 log << TestLog::EndSection;
479 if (isAPISupported(EGL_OPENVG_API))
481 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");
483 expectNoSurface(eglCreatePbufferFromClientBuffer(display, EGL_OPENVG_IMAGE, (EGLClientBuffer)-1, (EGLConfig)-1, DE_NULL));
484 expectEitherError(EGL_BAD_CONFIG, EGL_BAD_PARAMETER);
486 log << TestLog::EndSection;
488 log << TestLog::Section("Test3", "EGL_BAD_PARAMETER is generated if buftype is not EGL_OPENVG_IMAGE");
490 expectTrue(eglGetConfigs(display, &anyConfig, 1, &unused));
492 log << TestLog::EndSection;
494 log << TestLog::Section("Test4", "EGL_BAD_PARAMETER is generated if buffer is not valid OpenVG image");
495 expectNoSurface(eglCreatePbufferFromClientBuffer(display, EGL_OPENVG_IMAGE, (EGLClientBuffer)-1, anyConfig, DE_NULL));
496 expectError(EGL_BAD_PARAMETER);
498 log << TestLog::EndSection;
502 static const EGLint s_invalidGenericPbufferAttrib0[] = { 0, EGL_NONE };
503 static const EGLint s_invalidGenericPbufferAttrib1[] = { (EGLint)0xffffffff };
504 static const EGLint s_negativeWidthPbufferAttrib[] = { EGL_WIDTH, -1, EGL_HEIGHT, 64, EGL_NONE };
505 static const EGLint s_negativeHeightPbufferAttrib[] = { EGL_WIDTH, 64, EGL_HEIGHT, -1, EGL_NONE };
506 static const EGLint s_negativeWidthAndHeightPbufferAttrib[] = { EGL_WIDTH, -1, EGL_HEIGHT, -1, EGL_NONE };
507 static const EGLint* s_invalidGenericPbufferAttribs[] =
509 s_invalidGenericPbufferAttrib0,
510 s_invalidGenericPbufferAttrib1,
513 static const EGLint s_invalidNoEsPbufferAttrib0[] = { EGL_MIPMAP_TEXTURE, EGL_TRUE, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
514 static const EGLint s_invalidNoEsPbufferAttrib1[] = { EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
515 static const EGLint s_invalidNoEsPbufferAttrib2[] = { EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
516 static const EGLint* s_invalidNoEsPbufferAttribs[] =
518 s_invalidNoEsPbufferAttrib0,
519 s_invalidNoEsPbufferAttrib1,
520 s_invalidNoEsPbufferAttrib2
523 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 };
524 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 };
525 static const EGLint* s_invalidEsPbufferAttribs[] =
527 s_invalidEsPbufferAttrib0,
528 s_invalidEsPbufferAttrib1
531 static const EGLint s_vgPreMultAlphaPbufferAttrib[] = { EGL_ALPHA_FORMAT, EGL_ALPHA_FORMAT_PRE, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
532 static const EGLint s_vgLinearColorspacePbufferAttrib[] = { EGL_COLORSPACE, EGL_VG_COLORSPACE_LINEAR, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
534 TEGL_ADD_API_CASE(create_pbuffer_surface, "eglCreatePbufferSurface() negative tests",
536 TestLog& log = m_testCtx.getLog();
537 EGLDisplay display = getDisplay();
539 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
541 expectNoSurface(eglCreatePbufferSurface(EGL_NO_DISPLAY, DE_NULL, s_emptyAttribList));
542 expectError(EGL_BAD_DISPLAY);
544 expectNoSurface(eglCreatePbufferSurface((EGLDisplay)-1, DE_NULL, s_emptyAttribList));
545 expectError(EGL_BAD_DISPLAY);
547 log << TestLog::EndSection;
549 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
551 expectNoSurface(eglCreatePbufferSurface(display, (EGLConfig)-1, s_emptyAttribList));
552 expectError(EGL_BAD_CONFIG);
554 log << TestLog::EndSection;
556 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid pixel buffer attribute");
558 // Generic pbuffer-capable config
559 EGLConfig genericConfig;
560 if (getConfig(&genericConfig, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
562 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidGenericPbufferAttribs); ndx++)
564 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_invalidGenericPbufferAttribs[ndx]));
565 expectError(EGL_BAD_ATTRIBUTE);
569 log << TestLog::EndSection;
571 log << TestLog::Section("Test4", "EGL_BAD_MATCH is generated if config does not support rendering to pixel buffers");
573 EGLConfig noPbufferConfig;
574 if (getConfig(&noPbufferConfig, FilterList() << notSurfaceBits<EGL_PBUFFER_BIT>))
576 expectNoSurface(eglCreatePbufferSurface(display, noPbufferConfig, s_validGenericPbufferAttrib));
577 expectError(EGL_BAD_MATCH);
580 log << TestLog::EndSection;
582 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");
584 EGLConfig noEsConfig;
585 if (getConfig(&noEsConfig, FilterList() << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>))
587 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidNoEsPbufferAttribs); ndx++)
589 expectNoSurface(eglCreatePbufferSurface(display, noEsConfig, s_invalidNoEsPbufferAttribs[ndx]));
590 expectError(EGL_BAD_MATCH);
594 log << TestLog::EndSection;
596 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");
598 // ES1 or ES2 config.
600 bool gotEsConfig = getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT>) ||
601 getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
604 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidEsPbufferAttribs); ndx++)
606 expectNoSurface(eglCreatePbufferSurface(display, esConfig, s_invalidEsPbufferAttribs[ndx]));
607 expectError(EGL_BAD_MATCH);
611 log << TestLog::EndSection;
613 log << TestLog::Section("Test7", "EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute");
615 EGLConfig vgNoPreConfig;
616 if (getConfig(&vgNoPreConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notSurfaceBits<EGL_VG_ALPHA_FORMAT_PRE_BIT>))
618 expectNoSurface(eglCreatePbufferSurface(display, vgNoPreConfig, s_vgPreMultAlphaPbufferAttrib));
619 expectError(EGL_BAD_MATCH);
622 EGLConfig vgNoLinearConfig;
623 if (getConfig(&vgNoLinearConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notSurfaceBits<EGL_VG_COLORSPACE_LINEAR_BIT>))
625 expectNoSurface(eglCreatePbufferSurface(display, vgNoLinearConfig, s_vgLinearColorspacePbufferAttrib));
626 expectError(EGL_BAD_MATCH);
629 log << TestLog::EndSection;
631 log << TestLog::Section("Test8", "EGL_BAD_PARAMETER is generated if EGL_WIDTH or EGL_HEIGHT is negative");
633 if (getConfig(&genericConfig, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
635 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeWidthPbufferAttrib));
636 expectError(EGL_BAD_PARAMETER);
638 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeHeightPbufferAttrib));
639 expectError(EGL_BAD_PARAMETER);
641 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeWidthAndHeightPbufferAttrib));
642 expectError(EGL_BAD_PARAMETER);
645 log << TestLog::EndSection;
649 TEGL_ADD_API_CASE(create_pixmap_surface, "eglCreatePixmapSurface() negative tests",
651 TestLog& log = m_testCtx.getLog();
652 EGLDisplay display = getDisplay();
654 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
656 expectNoSurface(eglCreatePixmapSurface(EGL_NO_DISPLAY, DE_NULL, DE_NULL, s_emptyAttribList));
657 expectError(EGL_BAD_DISPLAY);
659 expectNoSurface(eglCreatePixmapSurface((EGLDisplay)-1, DE_NULL, DE_NULL, s_emptyAttribList));
660 expectError(EGL_BAD_DISPLAY);
662 log << TestLog::EndSection;
664 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
666 expectNoSurface(eglCreatePixmapSurface(display, (EGLConfig)-1, DE_NULL, s_emptyAttribList));
667 expectError(EGL_BAD_CONFIG);
669 log << TestLog::EndSection;
672 TEGL_ADD_API_CASE(create_window_surface, "eglCreateWindowSurface() negative tests",
674 EGLConfig config = DE_NULL;
675 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << surfaceBits<EGL_WINDOW_BIT>);
679 TestLog& log = m_testCtx.getLog();
680 EGLDisplay display = getDisplay();
681 const eglu::NativeWindowFactory& factory = eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
682 de::UniquePtr<eglu::NativeWindow> window (factory.createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(256, 256, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
684 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
686 expectNoSurface(eglCreateWindowSurface(EGL_NO_DISPLAY, config, window->getLegacyNative(), s_emptyAttribList));
687 expectError(EGL_BAD_DISPLAY);
689 expectNoSurface(eglCreateWindowSurface((EGLDisplay)-1, config, window->getLegacyNative(), s_emptyAttribList));
690 expectError(EGL_BAD_DISPLAY);
692 log << TestLog::EndSection;
696 TEGL_ADD_API_CASE(destroy_context, "eglDestroyContext() negative tests",
698 TestLog& log = m_testCtx.getLog();
699 EGLDisplay display = getDisplay();
701 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
703 expectFalse(eglDestroyContext(EGL_NO_DISPLAY, DE_NULL));
704 expectError(EGL_BAD_DISPLAY);
706 expectFalse(eglDestroyContext((EGLDisplay)-1, DE_NULL));
707 expectError(EGL_BAD_DISPLAY);
709 log << TestLog::EndSection;
711 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
713 expectFalse(eglDestroyContext(display, DE_NULL));
714 expectError(EGL_BAD_CONTEXT);
716 expectFalse(eglDestroyContext(display, (EGLContext)-1));
717 expectError(EGL_BAD_CONTEXT);
719 log << TestLog::EndSection;
722 TEGL_ADD_API_CASE(destroy_surface, "eglDestroySurface() negative tests",
724 TestLog& log = m_testCtx.getLog();
725 EGLDisplay display = getDisplay();
727 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
729 expectFalse(eglDestroySurface(EGL_NO_DISPLAY, DE_NULL));
730 expectError(EGL_BAD_DISPLAY);
732 expectFalse(eglDestroySurface((EGLDisplay)-1, DE_NULL));
733 expectError(EGL_BAD_DISPLAY);
735 log << TestLog::EndSection;
737 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
739 expectFalse(eglDestroySurface(display, DE_NULL));
740 expectError(EGL_BAD_SURFACE);
742 expectFalse(eglDestroySurface(display, (EGLSurface)-1));
743 expectError(EGL_BAD_SURFACE);
745 log << TestLog::EndSection;
748 TEGL_ADD_API_CASE(get_config_attrib, "eglGetConfigAttrib() negative tests",
750 TestLog& log = m_testCtx.getLog();
751 EGLDisplay display = getDisplay();
754 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
756 expectFalse(eglGetConfigAttrib(EGL_NO_DISPLAY, DE_NULL, EGL_RED_SIZE, &value));
757 expectError(EGL_BAD_DISPLAY);
759 expectFalse(eglGetConfigAttrib((EGLDisplay)-1, DE_NULL, EGL_RED_SIZE, &value));
760 expectError(EGL_BAD_DISPLAY);
762 log << TestLog::EndSection;
764 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
766 expectFalse(eglGetConfigAttrib(display, (EGLConfig)-1, EGL_RED_SIZE, &value));
767 expectError(EGL_BAD_CONFIG);
769 log << TestLog::EndSection;
772 EGLConfig config = DE_NULL;
773 bool hasConfig = getConfig(&config, FilterList());
775 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid frame buffer configuration attribute");
779 expectFalse(eglGetConfigAttrib(display, config, 0, &value));
780 expectError(EGL_BAD_ATTRIBUTE);
782 expectFalse(eglGetConfigAttrib(display, config, -1, &value));
783 expectError(EGL_BAD_ATTRIBUTE);
786 log << TestLog::EndSection;
789 TEGL_ADD_API_CASE(get_configs, "eglGetConfigs() negative tests",
791 TestLog& log = m_testCtx.getLog();
792 EGLDisplay display = getDisplay();
796 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
798 expectFalse(eglGetConfigs(EGL_NO_DISPLAY, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), &numCfgs));
799 expectError(EGL_BAD_DISPLAY);
801 expectFalse(eglGetConfigs((EGLDisplay)-1, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), &numCfgs));
802 expectError(EGL_BAD_DISPLAY);
804 log << TestLog::EndSection;
806 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if num_config is NULL");
808 expectFalse(eglGetConfigs(display, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), DE_NULL));
809 expectError(EGL_BAD_PARAMETER);
811 log << TestLog::EndSection;
814 TEGL_ADD_API_CASE(initialize, "eglInitialize() negative tests",
816 TestLog& log = m_testCtx.getLog();
820 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
822 expectFalse(eglInitialize(EGL_NO_DISPLAY, &major, &minor));
823 expectError(EGL_BAD_DISPLAY);
825 expectFalse(eglInitialize((EGLDisplay)-1, &major, &minor));
826 expectError(EGL_BAD_DISPLAY);
828 log << TestLog::EndSection;
831 TEGL_ADD_API_CASE(make_current, "eglMakeCurrent() negative tests",
833 TestLog& log = m_testCtx.getLog();
834 EGLDisplay display = getDisplay();
836 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
838 expectFalse(eglMakeCurrent(EGL_NO_DISPLAY, DE_NULL, DE_NULL, DE_NULL));
839 expectError(EGL_BAD_DISPLAY);
841 expectFalse(eglMakeCurrent((EGLDisplay)-1, DE_NULL, DE_NULL, DE_NULL));
842 expectError(EGL_BAD_DISPLAY);
844 log << TestLog::EndSection;
846 // Create simple pbuffer surface.
847 EGLSurface surface = EGL_NO_SURFACE;
850 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
852 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
853 expectError(EGL_SUCCESS);
857 // Create simple ES2 context
858 EGLContext context = EGL_NO_CONTEXT;
861 if (getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT>))
863 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
864 expectError(EGL_SUCCESS);
868 if (surface != EGL_NO_SURFACE && context != EGL_NO_CONTEXT)
870 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
872 expectFalse(eglMakeCurrent(display, (EGLSurface)-1, (EGLSurface)-1, context));
873 expectError(EGL_BAD_SURFACE);
875 expectFalse(eglMakeCurrent(display, surface, (EGLSurface)-1, context));
876 expectError(EGL_BAD_SURFACE);
878 expectFalse(eglMakeCurrent(display, (EGLSurface)-1, surface, context));
879 expectError(EGL_BAD_SURFACE);
881 log << TestLog::EndSection;
886 log << TestLog::Section("Test3", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
888 expectFalse(eglMakeCurrent(display, surface, surface, (EGLContext)-1));
889 expectError(EGL_BAD_CONTEXT);
891 log << TestLog::EndSection;
894 if (surface != EGL_NO_SURFACE)
896 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");
898 expectFalse(eglMakeCurrent(display, surface, EGL_NO_SURFACE, EGL_NO_CONTEXT));
899 expectError(EGL_BAD_MATCH);
901 expectFalse(eglMakeCurrent(display, EGL_NO_SURFACE, surface, EGL_NO_CONTEXT));
902 expectError(EGL_BAD_MATCH);
904 expectFalse(eglMakeCurrent(display, surface, surface, EGL_NO_CONTEXT));
905 expectError(EGL_BAD_MATCH);
907 log << TestLog::EndSection;
912 eglDestroyContext(display, context);
913 expectError(EGL_SUCCESS);
918 eglDestroySurface(display, surface);
919 expectError(EGL_SUCCESS);
923 TEGL_ADD_API_CASE(get_current_context, "eglGetCurrentContext() negative tests",
925 expectNoContext(eglGetCurrentContext());
927 if (isAPISupported(EGL_OPENGL_ES_API))
929 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
930 expectError(EGL_SUCCESS);
932 expectNoContext(eglGetCurrentContext());
933 expectError(EGL_SUCCESS);
937 TEGL_ADD_API_CASE(get_current_surface, "eglGetCurrentSurface() negative tests",
939 TestLog& log = m_testCtx.getLog();
940 EGLDisplay display = getDisplay();
941 EGLConfig config = DE_NULL;
942 EGLContext context = EGL_NO_CONTEXT;
943 EGLSurface surface = EGL_NO_SURFACE;
944 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << surfaceBits<EGL_PBUFFER_BIT>);
948 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
949 expectError(EGL_SUCCESS);
951 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
952 expectError(EGL_SUCCESS);
954 // Create simple pbuffer surface.
955 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
956 expectError(EGL_SUCCESS);
958 expectTrue(eglMakeCurrent(display, surface, surface, context));
959 expectError(EGL_SUCCESS);
961 log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if readdraw is neither EGL_READ nor EGL_DRAW");
963 expectNoSurface(eglGetCurrentSurface(EGL_NONE));
964 expectError(EGL_BAD_PARAMETER);
966 log << TestLog::EndSection;
968 expectTrue(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
969 expectError(EGL_SUCCESS);
971 if (surface != EGL_NO_SURFACE)
973 expectTrue(eglDestroySurface(display, surface));
974 expectError(EGL_SUCCESS);
977 if (context != EGL_NO_CONTEXT)
979 expectTrue(eglDestroyContext(display, context));
980 expectError(EGL_SUCCESS);
985 TEGL_ADD_API_CASE(query_context, "eglQueryContext() negative tests",
987 TestLog& log = m_testCtx.getLog();
988 EGLDisplay display = getDisplay();
991 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
993 expectFalse(eglQueryContext(EGL_NO_DISPLAY, DE_NULL, EGL_CONFIG_ID, &value));
994 expectError(EGL_BAD_DISPLAY);
996 expectFalse(eglQueryContext((EGLDisplay)-1, DE_NULL, EGL_CONFIG_ID, &value));
997 expectError(EGL_BAD_DISPLAY);
999 log << TestLog::EndSection;
1001 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
1003 expectFalse(eglQueryContext(display, DE_NULL, EGL_CONFIG_ID, &value));
1004 expectError(EGL_BAD_CONTEXT);
1006 expectFalse(eglQueryContext(display, DE_NULL, EGL_CONFIG_ID, &value));
1007 expectError(EGL_BAD_CONTEXT);
1009 log << TestLog::EndSection;
1011 // Create ES2 context.
1012 EGLConfig config = DE_NULL;
1013 EGLContext context = DE_NULL;
1014 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
1018 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
1019 expectError(EGL_SUCCESS);
1021 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
1022 expectError(EGL_SUCCESS);
1025 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid context attribute");
1029 expectFalse(eglQueryContext(display, context, 0, &value));
1030 expectError(EGL_BAD_ATTRIBUTE);
1031 expectFalse(eglQueryContext(display, context, -1, &value));
1032 expectError(EGL_BAD_ATTRIBUTE);
1033 expectFalse(eglQueryContext(display, context, EGL_RED_SIZE, &value));
1034 expectError(EGL_BAD_ATTRIBUTE);
1037 log << TestLog::EndSection;
1041 expectTrue(eglDestroyContext(display, context));
1042 expectError(EGL_SUCCESS);
1046 TEGL_ADD_API_CASE(query_string, "eglQueryString() negative tests",
1048 TestLog& log = m_testCtx.getLog();
1049 EGLDisplay display = getDisplay();
1051 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1053 expectNull(eglQueryString(EGL_NO_DISPLAY, EGL_VENDOR));
1054 expectError(EGL_BAD_DISPLAY);
1056 expectNull(eglQueryString((EGLDisplay)-1, EGL_VENDOR));
1057 expectError(EGL_BAD_DISPLAY);
1059 log << TestLog::EndSection;
1061 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if name is not an accepted value");
1063 expectNull(eglQueryString(display, 0));
1064 expectError(EGL_BAD_PARAMETER);
1065 expectNull(eglQueryString(display, -1));
1066 expectError(EGL_BAD_PARAMETER);
1068 log << TestLog::EndSection;
1071 TEGL_ADD_API_CASE(query_surface, "eglQuerySurface() negative tests",
1073 TestLog& log = m_testCtx.getLog();
1074 EGLDisplay display = getDisplay();
1077 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1079 expectFalse(eglQuerySurface(EGL_NO_DISPLAY, DE_NULL, EGL_CONFIG_ID, &value));
1080 expectError(EGL_BAD_DISPLAY);
1082 expectFalse(eglQuerySurface((EGLDisplay)-1, DE_NULL, EGL_CONFIG_ID, &value));
1083 expectError(EGL_BAD_DISPLAY);
1085 log << TestLog::EndSection;
1087 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1089 expectFalse(eglQuerySurface(display, DE_NULL, EGL_CONFIG_ID, &value));
1090 expectError(EGL_BAD_SURFACE);
1092 expectFalse(eglQuerySurface(display, (EGLSurface)-1, EGL_CONFIG_ID, &value));
1093 expectError(EGL_BAD_SURFACE);
1095 log << TestLog::EndSection;
1097 // Create pbuffer surface.
1098 EGLSurface surface = EGL_NO_SURFACE;
1101 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
1103 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1104 expectError(EGL_SUCCESS);
1107 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1110 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid surface attribute");
1114 expectFalse(eglQuerySurface(display, surface, 0, &value));
1115 expectError(EGL_BAD_ATTRIBUTE);
1117 expectFalse(eglQuerySurface(display, surface, -1, &value));
1118 expectError(EGL_BAD_ATTRIBUTE);
1121 log << TestLog::EndSection;
1125 eglDestroySurface(display, surface);
1126 expectError(EGL_SUCCESS);
1130 TEGL_ADD_API_CASE(release_tex_image, "eglReleaseTexImage() negative tests",
1132 TestLog& log = m_testCtx.getLog();
1133 EGLDisplay display = getDisplay();
1135 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1137 expectFalse(eglReleaseTexImage(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1138 expectError(EGL_BAD_DISPLAY);
1140 expectFalse(eglReleaseTexImage((EGLDisplay)-1, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1141 expectError(EGL_BAD_DISPLAY);
1143 log << TestLog::EndSection;
1145 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1147 expectFalse(eglReleaseTexImage(display, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1148 expectError(EGL_BAD_SURFACE);
1150 expectFalse(eglReleaseTexImage(display, (EGLSurface)-1, EGL_BACK_BUFFER));
1151 expectError(EGL_BAD_SURFACE);
1153 log << TestLog::EndSection;
1156 TEGL_ADD_API_CASE(surface_attrib, "eglSurfaceAttrib() negative tests",
1158 TestLog& log = m_testCtx.getLog();
1159 EGLDisplay display = getDisplay();
1161 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1163 expectFalse(eglSurfaceAttrib(EGL_NO_DISPLAY, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1164 expectError(EGL_BAD_DISPLAY);
1166 expectFalse(eglSurfaceAttrib((EGLDisplay)-1, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1167 expectError(EGL_BAD_DISPLAY);
1169 log << TestLog::EndSection;
1171 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1173 expectFalse(eglSurfaceAttrib(display, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1174 expectError(EGL_BAD_SURFACE);
1176 expectFalse(eglSurfaceAttrib(display, (EGLSurface)-1, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1177 expectError(EGL_BAD_SURFACE);
1179 log << TestLog::EndSection;
1182 // Create pbuffer surface.
1183 EGLSurface surface = EGL_NO_SURFACE;
1186 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
1188 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1189 expectError(EGL_SUCCESS);
1192 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1195 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid surface attribute");
1199 expectFalse(eglSurfaceAttrib(display, surface, 0, 0));
1200 expectError(EGL_BAD_ATTRIBUTE);
1202 expectFalse(eglSurfaceAttrib(display, surface, -1, 0));
1203 expectError(EGL_BAD_ATTRIBUTE);
1206 log << TestLog::EndSection;
1210 eglDestroySurface(display, surface);
1211 expectError(EGL_SUCCESS);
1216 // Create pbuffer surface without EGL_MULTISAMPLE_RESOLVE_BOX_BIT.
1217 EGLSurface surface = EGL_NO_SURFACE;
1220 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT> << notSurfaceBits<EGL_MULTISAMPLE_RESOLVE_BOX_BIT>))
1222 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1223 expectError(EGL_SUCCESS);
1226 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1229 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");
1233 expectFalse(eglSurfaceAttrib(display, surface, EGL_MULTISAMPLE_RESOLVE, EGL_MULTISAMPLE_RESOLVE_BOX));
1234 expectError(EGL_BAD_MATCH);
1237 log << TestLog::EndSection;
1241 eglDestroySurface(display, surface);
1242 expectError(EGL_SUCCESS);
1247 // Create pbuffer surface without EGL_SWAP_BEHAVIOR_PRESERVED_BIT.
1248 EGLSurface surface = EGL_NO_SURFACE;
1251 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT> << notSurfaceBits<EGL_SWAP_BEHAVIOR_PRESERVED_BIT>))
1253 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1254 expectError(EGL_SUCCESS);
1257 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1260 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");
1264 expectFalse(eglSurfaceAttrib(display, surface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED));
1265 expectError(EGL_BAD_MATCH);
1268 log << TestLog::EndSection;
1272 eglDestroySurface(display, surface);
1273 expectError(EGL_SUCCESS);
1278 TEGL_ADD_API_CASE(swap_buffers, "eglSwapBuffers() negative tests",
1280 TestLog& log = m_testCtx.getLog();
1281 EGLDisplay display = getDisplay();
1283 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1285 expectFalse(eglSwapBuffers(EGL_NO_DISPLAY, DE_NULL));
1286 expectError(EGL_BAD_DISPLAY);
1288 expectFalse(eglSwapBuffers((EGLDisplay)-1, DE_NULL));
1289 expectError(EGL_BAD_DISPLAY);
1291 log << TestLog::EndSection;
1293 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1295 expectFalse(eglSwapBuffers(display, DE_NULL));
1296 expectError(EGL_BAD_SURFACE);
1298 expectFalse(eglSwapBuffers(display, (EGLSurface)-1));
1299 expectError(EGL_BAD_SURFACE);
1301 log << TestLog::EndSection;
1304 TEGL_ADD_API_CASE(swap_interval, "eglSwapInterval() negative tests",
1306 TestLog& log = m_testCtx.getLog();
1307 EGLDisplay display = getDisplay();
1309 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1311 expectFalse(eglSwapInterval(EGL_NO_DISPLAY, 0));
1312 expectError(EGL_BAD_DISPLAY);
1314 expectFalse(eglSwapInterval((EGLDisplay)-1, 0));
1315 expectError(EGL_BAD_DISPLAY);
1317 log << TestLog::EndSection;
1319 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if there is no current context on the calling thread");
1321 expectFalse(eglSwapInterval(display, 0));
1322 expectError(EGL_BAD_CONTEXT);
1324 log << TestLog::EndSection;
1327 TEGL_ADD_API_CASE(terminate, "eglTerminate() negative tests",
1329 TestLog& log = m_testCtx.getLog();
1331 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1333 expectFalse(eglTerminate(EGL_NO_DISPLAY));
1334 expectError(EGL_BAD_DISPLAY);
1336 expectFalse(eglTerminate((EGLDisplay)-1));
1337 expectError(EGL_BAD_DISPLAY);
1339 log << TestLog::EndSection;
1342 TEGL_ADD_API_CASE(wait_native, "eglWaitNative() negative tests",
1344 EGLConfig config = DE_NULL;
1345 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << surfaceBits<EGL_WINDOW_BIT>);
1349 TestLog& log = m_testCtx.getLog();
1350 const Library& egl = m_eglTestCtx.getLibrary();
1351 EGLDisplay display = getDisplay();
1352 const eglu::NativeWindowFactory& factory = eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
1353 de::UniquePtr<eglu::NativeWindow> window (factory.createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(256, 256, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
1354 eglu::UniqueSurface surface (egl, display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, display, config, DE_NULL));
1355 EGLContext context = EGL_NO_CONTEXT;
1357 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
1358 expectError(EGL_SUCCESS);
1360 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
1361 expectError(EGL_SUCCESS);
1363 expectTrue(eglMakeCurrent(display, *surface, *surface, context));
1364 expectError(EGL_SUCCESS);
1366 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");
1369 expectEitherError(EGL_BAD_PARAMETER, EGL_SUCCESS);
1371 log << TestLog::EndSection;
1373 expectTrue(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
1374 expectError(EGL_SUCCESS);
1376 if (context != EGL_NO_CONTEXT)
1378 expectTrue(eglDestroyContext(display, context));
1379 expectError(EGL_SUCCESS);