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 or EGL_BAD_MATCH 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 // EGL 1.4, EGL 1.5, and EGL_KHR_create_context contain contradictory language about the expected error.
395 Version version = eglu::getVersion(m_eglTestCtx.getLibrary(), display);
396 bool hasKhrCreateContext = eglu::hasExtension(m_eglTestCtx.getLibrary(), display, "EGL_KHR_create_context");
398 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
399 expectNoContext(eglCreateContext(display, notES1Config, EGL_NO_CONTEXT, s_es1ContextAttribList));
400 if (hasKhrCreateContext)
401 expectEitherError(EGL_BAD_CONFIG, EGL_BAD_MATCH);
404 if (version >= eglu::Version(1, 5))
405 expectError(EGL_BAD_MATCH);
407 expectError(EGL_BAD_CONFIG);
412 log << TestLog::EndSection;
414 log << TestLog::Section("Test5", "EGL_BAD_CONFIG or EGL_BAD_MATCH is generated if OpenGL ES 2.x context is requested and EGL_RENDERABLE_TYPE attribute of config does not contain EGL_OPENGL_ES2_BIT");
416 if (isAPISupported(EGL_OPENGL_ES_API))
418 EGLConfig notES2Config;
419 if (getConfig(¬ES2Config, FilterList() << notRenderable<EGL_OPENGL_ES2_BIT>))
421 // EGL 1.4, EGL 1.5, and EGL_KHR_create_context contain contradictory language about the expected error.
422 Version version = eglu::getVersion(m_eglTestCtx.getLibrary(), display);
423 bool hasKhrCreateContext = eglu::hasExtension(m_eglTestCtx.getLibrary(), display, "EGL_KHR_create_context");
425 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
426 expectNoContext(eglCreateContext(display, notES2Config, EGL_NO_CONTEXT, s_es2ContextAttribList));
427 if (hasKhrCreateContext)
428 expectEitherError(EGL_BAD_CONFIG, EGL_BAD_MATCH);
431 if (version >= eglu::Version(1, 5))
432 expectError(EGL_BAD_MATCH);
434 expectError(EGL_BAD_CONFIG);
439 log << TestLog::EndSection;
441 log << TestLog::Section("Test6", "EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid context attribute");
443 if (isAPISupported(EGL_OPENGL_API) && !eglu::hasExtension(m_eglTestCtx.getLibrary(), display, "EGL_KHR_create_context"))
446 if (getConfig(&glConfig, FilterList() << renderable<EGL_OPENGL_BIT>))
448 expectTrue(eglBindAPI(EGL_OPENGL_API));
449 expectNoContext(eglCreateContext(display, glConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
450 expectError(EGL_BAD_ATTRIBUTE);
454 if (isAPISupported(EGL_OPENVG_API))
457 if (getConfig(&vgConfig, FilterList() << renderable<EGL_OPENVG_BIT>))
459 expectTrue(eglBindAPI(EGL_OPENVG_API));
460 expectNoContext(eglCreateContext(display, vgConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
461 expectError(EGL_BAD_ATTRIBUTE);
465 if (isAPISupported(EGL_OPENGL_ES_API))
467 bool gotConfig = false;
470 gotConfig = getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT>) ||
471 getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
475 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
476 expectNoContext(eglCreateContext(display, esConfig, EGL_NO_CONTEXT, s_invalidCreateContextAttribList0));
477 expectError(EGL_BAD_ATTRIBUTE);
478 expectNoContext(eglCreateContext(display, esConfig, EGL_NO_CONTEXT, s_invalidCreateContextAttribList1));
479 expectError(EGL_BAD_ATTRIBUTE);
483 log << TestLog::EndSection;
486 TEGL_ADD_API_CASE(create_pbuffer_from_client_buffer, "eglCreatePbufferFromClientBuffer() negative tests",
488 TestLog& log = m_testCtx.getLog();
489 EGLDisplay display = getDisplay();
493 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
495 expectNoSurface(eglCreatePbufferFromClientBuffer(EGL_NO_DISPLAY, EGL_OPENVG_IMAGE, 0, (EGLConfig)0, DE_NULL));
496 expectError(EGL_BAD_DISPLAY);
498 expectNoSurface(eglCreatePbufferFromClientBuffer((EGLDisplay)-1, EGL_OPENVG_IMAGE, 0, (EGLConfig)0, DE_NULL));
499 expectError(EGL_BAD_DISPLAY);
501 log << TestLog::EndSection;
503 if (isAPISupported(EGL_OPENVG_API))
505 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");
507 expectNoSurface(eglCreatePbufferFromClientBuffer(display, EGL_OPENVG_IMAGE, (EGLClientBuffer)-1, (EGLConfig)-1, DE_NULL));
508 expectEitherError(EGL_BAD_CONFIG, EGL_BAD_PARAMETER);
510 log << TestLog::EndSection;
512 log << TestLog::Section("Test3", "EGL_BAD_PARAMETER is generated if buftype is not EGL_OPENVG_IMAGE");
514 expectTrue(eglGetConfigs(display, &anyConfig, 1, &unused));
516 log << TestLog::EndSection;
518 log << TestLog::Section("Test4", "EGL_BAD_PARAMETER is generated if buffer is not valid OpenVG image");
519 expectNoSurface(eglCreatePbufferFromClientBuffer(display, EGL_OPENVG_IMAGE, (EGLClientBuffer)-1, anyConfig, DE_NULL));
520 expectError(EGL_BAD_PARAMETER);
522 log << TestLog::EndSection;
526 static const EGLint s_invalidGenericPbufferAttrib0[] = { 0, EGL_NONE };
527 static const EGLint s_invalidGenericPbufferAttrib1[] = { (EGLint)0xffffffff };
528 static const EGLint s_negativeWidthPbufferAttrib[] = { EGL_WIDTH, -1, EGL_HEIGHT, 64, EGL_NONE };
529 static const EGLint s_negativeHeightPbufferAttrib[] = { EGL_WIDTH, 64, EGL_HEIGHT, -1, EGL_NONE };
530 static const EGLint s_negativeWidthAndHeightPbufferAttrib[] = { EGL_WIDTH, -1, EGL_HEIGHT, -1, EGL_NONE };
531 static const EGLint* s_invalidGenericPbufferAttribs[] =
533 s_invalidGenericPbufferAttrib0,
534 s_invalidGenericPbufferAttrib1,
537 static const EGLint s_invalidNoEsPbufferAttrib0[] = { EGL_MIPMAP_TEXTURE, EGL_TRUE, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
538 static const EGLint s_invalidNoEsPbufferAttrib1[] = { EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
539 static const EGLint s_invalidNoEsPbufferAttrib2[] = { EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
540 static const EGLint* s_invalidNoEsPbufferAttribs[] =
542 s_invalidNoEsPbufferAttrib0,
543 s_invalidNoEsPbufferAttrib1,
544 s_invalidNoEsPbufferAttrib2
547 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 };
548 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 };
549 static const EGLint* s_invalidEsPbufferAttribs[] =
551 s_invalidEsPbufferAttrib0,
552 s_invalidEsPbufferAttrib1
555 static const EGLint s_vgPreMultAlphaPbufferAttrib[] = { EGL_ALPHA_FORMAT, EGL_ALPHA_FORMAT_PRE, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
556 static const EGLint s_vgLinearColorspacePbufferAttrib[] = { EGL_COLORSPACE, EGL_VG_COLORSPACE_LINEAR, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
558 TEGL_ADD_API_CASE(create_pbuffer_surface, "eglCreatePbufferSurface() negative tests",
560 TestLog& log = m_testCtx.getLog();
561 EGLDisplay display = getDisplay();
563 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
565 expectNoSurface(eglCreatePbufferSurface(EGL_NO_DISPLAY, DE_NULL, s_emptyAttribList));
566 expectError(EGL_BAD_DISPLAY);
568 expectNoSurface(eglCreatePbufferSurface((EGLDisplay)-1, DE_NULL, s_emptyAttribList));
569 expectError(EGL_BAD_DISPLAY);
571 log << TestLog::EndSection;
573 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
575 expectNoSurface(eglCreatePbufferSurface(display, (EGLConfig)-1, s_emptyAttribList));
576 expectError(EGL_BAD_CONFIG);
578 log << TestLog::EndSection;
580 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid pixel buffer attribute");
582 // Generic pbuffer-capable config
583 EGLConfig genericConfig;
584 if (getConfig(&genericConfig, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
586 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidGenericPbufferAttribs); ndx++)
588 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_invalidGenericPbufferAttribs[ndx]));
589 expectError(EGL_BAD_ATTRIBUTE);
593 log << TestLog::EndSection;
595 log << TestLog::Section("Test4", "EGL_BAD_MATCH is generated if config does not support rendering to pixel buffers");
597 EGLConfig noPbufferConfig;
598 if (getConfig(&noPbufferConfig, FilterList() << notSurfaceBits<EGL_PBUFFER_BIT>))
600 expectNoSurface(eglCreatePbufferSurface(display, noPbufferConfig, s_validGenericPbufferAttrib));
601 expectError(EGL_BAD_MATCH);
604 log << TestLog::EndSection;
606 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");
608 EGLConfig noEsConfig;
609 if (getConfig(&noEsConfig, FilterList() << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>))
611 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidNoEsPbufferAttribs); ndx++)
613 expectNoSurface(eglCreatePbufferSurface(display, noEsConfig, s_invalidNoEsPbufferAttribs[ndx]));
614 expectError(EGL_BAD_MATCH);
618 log << TestLog::EndSection;
620 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");
622 // ES1 or ES2 config.
624 bool gotEsConfig = getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT>) ||
625 getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
628 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidEsPbufferAttribs); ndx++)
630 expectNoSurface(eglCreatePbufferSurface(display, esConfig, s_invalidEsPbufferAttribs[ndx]));
631 expectError(EGL_BAD_MATCH);
635 log << TestLog::EndSection;
637 log << TestLog::Section("Test7", "EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute");
639 EGLConfig vgNoPreConfig;
640 if (getConfig(&vgNoPreConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notSurfaceBits<EGL_VG_ALPHA_FORMAT_PRE_BIT>))
642 expectNoSurface(eglCreatePbufferSurface(display, vgNoPreConfig, s_vgPreMultAlphaPbufferAttrib));
643 expectError(EGL_BAD_MATCH);
646 EGLConfig vgNoLinearConfig;
647 if (getConfig(&vgNoLinearConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notSurfaceBits<EGL_VG_COLORSPACE_LINEAR_BIT>))
649 expectNoSurface(eglCreatePbufferSurface(display, vgNoLinearConfig, s_vgLinearColorspacePbufferAttrib));
650 expectError(EGL_BAD_MATCH);
653 log << TestLog::EndSection;
655 log << TestLog::Section("Test8", "EGL_BAD_PARAMETER is generated if EGL_WIDTH or EGL_HEIGHT is negative");
657 if (getConfig(&genericConfig, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
659 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeWidthPbufferAttrib));
660 expectError(EGL_BAD_PARAMETER);
662 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeHeightPbufferAttrib));
663 expectError(EGL_BAD_PARAMETER);
665 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeWidthAndHeightPbufferAttrib));
666 expectError(EGL_BAD_PARAMETER);
669 log << TestLog::EndSection;
673 TEGL_ADD_API_CASE(create_pixmap_surface, "eglCreatePixmapSurface() negative tests",
675 TestLog& log = m_testCtx.getLog();
676 EGLDisplay display = getDisplay();
678 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
680 expectNoSurface(eglCreatePixmapSurface(EGL_NO_DISPLAY, DE_NULL, DE_NULL, s_emptyAttribList));
681 expectError(EGL_BAD_DISPLAY);
683 expectNoSurface(eglCreatePixmapSurface((EGLDisplay)-1, DE_NULL, DE_NULL, s_emptyAttribList));
684 expectError(EGL_BAD_DISPLAY);
686 log << TestLog::EndSection;
688 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
690 expectNoSurface(eglCreatePixmapSurface(display, (EGLConfig)-1, DE_NULL, s_emptyAttribList));
691 expectError(EGL_BAD_CONFIG);
693 log << TestLog::EndSection;
696 TEGL_ADD_API_CASE(create_window_surface, "eglCreateWindowSurface() negative tests",
698 EGLConfig config = DE_NULL;
699 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << surfaceBits<EGL_WINDOW_BIT>);
703 TestLog& log = m_testCtx.getLog();
704 EGLDisplay display = getDisplay();
705 const eglu::NativeWindowFactory& factory = eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
706 de::UniquePtr<eglu::NativeWindow> window (factory.createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(256, 256, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
708 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
710 expectNoSurface(eglCreateWindowSurface(EGL_NO_DISPLAY, config, window->getLegacyNative(), s_emptyAttribList));
711 expectError(EGL_BAD_DISPLAY);
713 expectNoSurface(eglCreateWindowSurface((EGLDisplay)-1, config, window->getLegacyNative(), s_emptyAttribList));
714 expectError(EGL_BAD_DISPLAY);
716 log << TestLog::EndSection;
720 TEGL_ADD_API_CASE(destroy_context, "eglDestroyContext() negative tests",
722 TestLog& log = m_testCtx.getLog();
723 EGLDisplay display = getDisplay();
725 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
727 expectFalse(eglDestroyContext(EGL_NO_DISPLAY, DE_NULL));
728 expectError(EGL_BAD_DISPLAY);
730 expectFalse(eglDestroyContext((EGLDisplay)-1, DE_NULL));
731 expectError(EGL_BAD_DISPLAY);
733 log << TestLog::EndSection;
735 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
737 expectFalse(eglDestroyContext(display, DE_NULL));
738 expectError(EGL_BAD_CONTEXT);
740 expectFalse(eglDestroyContext(display, (EGLContext)-1));
741 expectError(EGL_BAD_CONTEXT);
743 log << TestLog::EndSection;
746 TEGL_ADD_API_CASE(destroy_surface, "eglDestroySurface() negative tests",
748 TestLog& log = m_testCtx.getLog();
749 EGLDisplay display = getDisplay();
751 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
753 expectFalse(eglDestroySurface(EGL_NO_DISPLAY, DE_NULL));
754 expectError(EGL_BAD_DISPLAY);
756 expectFalse(eglDestroySurface((EGLDisplay)-1, DE_NULL));
757 expectError(EGL_BAD_DISPLAY);
759 log << TestLog::EndSection;
761 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
763 expectFalse(eglDestroySurface(display, DE_NULL));
764 expectError(EGL_BAD_SURFACE);
766 expectFalse(eglDestroySurface(display, (EGLSurface)-1));
767 expectError(EGL_BAD_SURFACE);
769 log << TestLog::EndSection;
772 TEGL_ADD_API_CASE(get_config_attrib, "eglGetConfigAttrib() negative tests",
774 TestLog& log = m_testCtx.getLog();
775 EGLDisplay display = getDisplay();
778 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
780 expectFalse(eglGetConfigAttrib(EGL_NO_DISPLAY, DE_NULL, EGL_RED_SIZE, &value));
781 expectError(EGL_BAD_DISPLAY);
783 expectFalse(eglGetConfigAttrib((EGLDisplay)-1, DE_NULL, EGL_RED_SIZE, &value));
784 expectError(EGL_BAD_DISPLAY);
786 log << TestLog::EndSection;
788 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
790 expectFalse(eglGetConfigAttrib(display, (EGLConfig)-1, EGL_RED_SIZE, &value));
791 expectError(EGL_BAD_CONFIG);
793 log << TestLog::EndSection;
796 EGLConfig config = DE_NULL;
797 bool hasConfig = getConfig(&config, FilterList());
799 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid frame buffer configuration attribute");
803 expectFalse(eglGetConfigAttrib(display, config, 0, &value));
804 expectError(EGL_BAD_ATTRIBUTE);
806 expectFalse(eglGetConfigAttrib(display, config, -1, &value));
807 expectError(EGL_BAD_ATTRIBUTE);
810 log << TestLog::EndSection;
813 TEGL_ADD_API_CASE(get_configs, "eglGetConfigs() negative tests",
815 TestLog& log = m_testCtx.getLog();
816 EGLDisplay display = getDisplay();
820 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
822 expectFalse(eglGetConfigs(EGL_NO_DISPLAY, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), &numCfgs));
823 expectError(EGL_BAD_DISPLAY);
825 expectFalse(eglGetConfigs((EGLDisplay)-1, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), &numCfgs));
826 expectError(EGL_BAD_DISPLAY);
828 log << TestLog::EndSection;
830 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if num_config is NULL");
832 expectFalse(eglGetConfigs(display, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), DE_NULL));
833 expectError(EGL_BAD_PARAMETER);
835 log << TestLog::EndSection;
838 TEGL_ADD_API_CASE(initialize, "eglInitialize() negative tests",
840 TestLog& log = m_testCtx.getLog();
844 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
846 expectFalse(eglInitialize(EGL_NO_DISPLAY, &major, &minor));
847 expectError(EGL_BAD_DISPLAY);
849 expectFalse(eglInitialize((EGLDisplay)-1, &major, &minor));
850 expectError(EGL_BAD_DISPLAY);
852 log << TestLog::EndSection;
855 TEGL_ADD_API_CASE(make_current, "eglMakeCurrent() negative tests",
857 TestLog& log = m_testCtx.getLog();
858 EGLDisplay display = getDisplay();
860 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
862 expectFalse(eglMakeCurrent(EGL_NO_DISPLAY, DE_NULL, DE_NULL, DE_NULL));
863 expectError(EGL_BAD_DISPLAY);
865 expectFalse(eglMakeCurrent((EGLDisplay)-1, DE_NULL, DE_NULL, DE_NULL));
866 expectError(EGL_BAD_DISPLAY);
868 log << TestLog::EndSection;
870 // Create simple pbuffer surface.
871 EGLSurface surface = EGL_NO_SURFACE;
874 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
876 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
877 expectError(EGL_SUCCESS);
881 // Create simple ES2 context
882 EGLContext context = EGL_NO_CONTEXT;
885 if (getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT>))
887 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
888 expectError(EGL_SUCCESS);
892 if (surface != EGL_NO_SURFACE && context != EGL_NO_CONTEXT)
894 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
896 expectFalse(eglMakeCurrent(display, (EGLSurface)-1, (EGLSurface)-1, context));
897 expectError(EGL_BAD_SURFACE);
899 expectFalse(eglMakeCurrent(display, surface, (EGLSurface)-1, context));
900 expectError(EGL_BAD_SURFACE);
902 expectFalse(eglMakeCurrent(display, (EGLSurface)-1, surface, context));
903 expectError(EGL_BAD_SURFACE);
905 log << TestLog::EndSection;
910 log << TestLog::Section("Test3", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
912 expectFalse(eglMakeCurrent(display, surface, surface, (EGLContext)-1));
913 expectError(EGL_BAD_CONTEXT);
915 log << TestLog::EndSection;
918 if (surface != EGL_NO_SURFACE)
920 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");
922 expectFalse(eglMakeCurrent(display, surface, EGL_NO_SURFACE, EGL_NO_CONTEXT));
923 expectError(EGL_BAD_MATCH);
925 expectFalse(eglMakeCurrent(display, EGL_NO_SURFACE, surface, EGL_NO_CONTEXT));
926 expectError(EGL_BAD_MATCH);
928 expectFalse(eglMakeCurrent(display, surface, surface, EGL_NO_CONTEXT));
929 expectError(EGL_BAD_MATCH);
931 log << TestLog::EndSection;
936 eglDestroyContext(display, context);
937 expectError(EGL_SUCCESS);
942 eglDestroySurface(display, surface);
943 expectError(EGL_SUCCESS);
947 TEGL_ADD_API_CASE(get_current_context, "eglGetCurrentContext() negative tests",
949 expectNoContext(eglGetCurrentContext());
951 if (isAPISupported(EGL_OPENGL_ES_API))
953 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
954 expectError(EGL_SUCCESS);
956 expectNoContext(eglGetCurrentContext());
957 expectError(EGL_SUCCESS);
961 TEGL_ADD_API_CASE(get_current_surface, "eglGetCurrentSurface() negative tests",
963 TestLog& log = m_testCtx.getLog();
964 EGLDisplay display = getDisplay();
965 EGLConfig config = DE_NULL;
966 EGLContext context = EGL_NO_CONTEXT;
967 EGLSurface surface = EGL_NO_SURFACE;
968 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << surfaceBits<EGL_PBUFFER_BIT>);
972 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
973 expectError(EGL_SUCCESS);
975 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
976 expectError(EGL_SUCCESS);
978 // Create simple pbuffer surface.
979 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
980 expectError(EGL_SUCCESS);
982 expectTrue(eglMakeCurrent(display, surface, surface, context));
983 expectError(EGL_SUCCESS);
985 log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if readdraw is neither EGL_READ nor EGL_DRAW");
987 expectNoSurface(eglGetCurrentSurface(EGL_NONE));
988 expectError(EGL_BAD_PARAMETER);
990 log << TestLog::EndSection;
992 expectTrue(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
993 expectError(EGL_SUCCESS);
995 if (surface != EGL_NO_SURFACE)
997 expectTrue(eglDestroySurface(display, surface));
998 expectError(EGL_SUCCESS);
1001 if (context != EGL_NO_CONTEXT)
1003 expectTrue(eglDestroyContext(display, context));
1004 expectError(EGL_SUCCESS);
1009 TEGL_ADD_API_CASE(query_context, "eglQueryContext() negative tests",
1011 TestLog& log = m_testCtx.getLog();
1012 EGLDisplay display = getDisplay();
1015 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1017 expectFalse(eglQueryContext(EGL_NO_DISPLAY, DE_NULL, EGL_CONFIG_ID, &value));
1018 expectError(EGL_BAD_DISPLAY);
1020 expectFalse(eglQueryContext((EGLDisplay)-1, DE_NULL, EGL_CONFIG_ID, &value));
1021 expectError(EGL_BAD_DISPLAY);
1023 log << TestLog::EndSection;
1025 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
1027 expectFalse(eglQueryContext(display, DE_NULL, EGL_CONFIG_ID, &value));
1028 expectError(EGL_BAD_CONTEXT);
1030 expectFalse(eglQueryContext(display, DE_NULL, EGL_CONFIG_ID, &value));
1031 expectError(EGL_BAD_CONTEXT);
1033 log << TestLog::EndSection;
1035 // Create ES2 context.
1036 EGLConfig config = DE_NULL;
1037 EGLContext context = DE_NULL;
1038 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
1042 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
1043 expectError(EGL_SUCCESS);
1045 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
1046 expectError(EGL_SUCCESS);
1049 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid context attribute");
1053 expectFalse(eglQueryContext(display, context, 0, &value));
1054 expectError(EGL_BAD_ATTRIBUTE);
1055 expectFalse(eglQueryContext(display, context, -1, &value));
1056 expectError(EGL_BAD_ATTRIBUTE);
1057 expectFalse(eglQueryContext(display, context, EGL_RED_SIZE, &value));
1058 expectError(EGL_BAD_ATTRIBUTE);
1061 log << TestLog::EndSection;
1065 expectTrue(eglDestroyContext(display, context));
1066 expectError(EGL_SUCCESS);
1070 TEGL_ADD_API_CASE(query_string, "eglQueryString() negative tests",
1072 TestLog& log = m_testCtx.getLog();
1073 EGLDisplay display = getDisplay();
1075 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1077 expectNull(eglQueryString(EGL_NO_DISPLAY, EGL_VENDOR));
1078 expectError(EGL_BAD_DISPLAY);
1080 expectNull(eglQueryString((EGLDisplay)-1, EGL_VENDOR));
1081 expectError(EGL_BAD_DISPLAY);
1083 log << TestLog::EndSection;
1085 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if name is not an accepted value");
1087 expectNull(eglQueryString(display, 0));
1088 expectError(EGL_BAD_PARAMETER);
1089 expectNull(eglQueryString(display, -1));
1090 expectError(EGL_BAD_PARAMETER);
1092 log << TestLog::EndSection;
1095 TEGL_ADD_API_CASE(query_surface, "eglQuerySurface() negative tests",
1097 TestLog& log = m_testCtx.getLog();
1098 EGLDisplay display = getDisplay();
1101 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1103 expectFalse(eglQuerySurface(EGL_NO_DISPLAY, DE_NULL, EGL_CONFIG_ID, &value));
1104 expectError(EGL_BAD_DISPLAY);
1106 expectFalse(eglQuerySurface((EGLDisplay)-1, DE_NULL, EGL_CONFIG_ID, &value));
1107 expectError(EGL_BAD_DISPLAY);
1109 log << TestLog::EndSection;
1111 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1113 expectFalse(eglQuerySurface(display, DE_NULL, EGL_CONFIG_ID, &value));
1114 expectError(EGL_BAD_SURFACE);
1116 expectFalse(eglQuerySurface(display, (EGLSurface)-1, EGL_CONFIG_ID, &value));
1117 expectError(EGL_BAD_SURFACE);
1119 log << TestLog::EndSection;
1121 // Create pbuffer surface.
1122 EGLSurface surface = EGL_NO_SURFACE;
1125 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
1127 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1128 expectError(EGL_SUCCESS);
1131 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1134 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid surface attribute");
1138 expectFalse(eglQuerySurface(display, surface, 0, &value));
1139 expectError(EGL_BAD_ATTRIBUTE);
1141 expectFalse(eglQuerySurface(display, surface, -1, &value));
1142 expectError(EGL_BAD_ATTRIBUTE);
1145 log << TestLog::EndSection;
1149 eglDestroySurface(display, surface);
1150 expectError(EGL_SUCCESS);
1154 TEGL_ADD_API_CASE(release_tex_image, "eglReleaseTexImage() negative tests",
1156 TestLog& log = m_testCtx.getLog();
1157 EGLDisplay display = getDisplay();
1159 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1161 expectFalse(eglReleaseTexImage(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1162 expectError(EGL_BAD_DISPLAY);
1164 expectFalse(eglReleaseTexImage((EGLDisplay)-1, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1165 expectError(EGL_BAD_DISPLAY);
1167 log << TestLog::EndSection;
1169 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1171 expectFalse(eglReleaseTexImage(display, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1172 expectError(EGL_BAD_SURFACE);
1174 expectFalse(eglReleaseTexImage(display, (EGLSurface)-1, EGL_BACK_BUFFER));
1175 expectError(EGL_BAD_SURFACE);
1177 log << TestLog::EndSection;
1180 TEGL_ADD_API_CASE(surface_attrib, "eglSurfaceAttrib() negative tests",
1182 TestLog& log = m_testCtx.getLog();
1183 EGLDisplay display = getDisplay();
1185 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1187 expectFalse(eglSurfaceAttrib(EGL_NO_DISPLAY, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1188 expectError(EGL_BAD_DISPLAY);
1190 expectFalse(eglSurfaceAttrib((EGLDisplay)-1, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1191 expectError(EGL_BAD_DISPLAY);
1193 log << TestLog::EndSection;
1195 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1197 expectFalse(eglSurfaceAttrib(display, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1198 expectError(EGL_BAD_SURFACE);
1200 expectFalse(eglSurfaceAttrib(display, (EGLSurface)-1, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1201 expectError(EGL_BAD_SURFACE);
1203 log << TestLog::EndSection;
1206 // Create pbuffer surface.
1207 EGLSurface surface = EGL_NO_SURFACE;
1210 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
1212 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1213 expectError(EGL_SUCCESS);
1216 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1219 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid surface attribute");
1223 expectFalse(eglSurfaceAttrib(display, surface, 0, 0));
1224 expectError(EGL_BAD_ATTRIBUTE);
1226 expectFalse(eglSurfaceAttrib(display, surface, -1, 0));
1227 expectError(EGL_BAD_ATTRIBUTE);
1230 log << TestLog::EndSection;
1234 eglDestroySurface(display, surface);
1235 expectError(EGL_SUCCESS);
1240 // Create pbuffer surface without EGL_MULTISAMPLE_RESOLVE_BOX_BIT.
1241 EGLSurface surface = EGL_NO_SURFACE;
1244 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT> << notSurfaceBits<EGL_MULTISAMPLE_RESOLVE_BOX_BIT>))
1246 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1247 expectError(EGL_SUCCESS);
1250 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1253 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");
1257 expectFalse(eglSurfaceAttrib(display, surface, EGL_MULTISAMPLE_RESOLVE, EGL_MULTISAMPLE_RESOLVE_BOX));
1258 expectError(EGL_BAD_MATCH);
1261 log << TestLog::EndSection;
1265 eglDestroySurface(display, surface);
1266 expectError(EGL_SUCCESS);
1271 // Create pbuffer surface without EGL_SWAP_BEHAVIOR_PRESERVED_BIT.
1272 EGLSurface surface = EGL_NO_SURFACE;
1275 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT> << notSurfaceBits<EGL_SWAP_BEHAVIOR_PRESERVED_BIT>))
1277 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1278 expectError(EGL_SUCCESS);
1281 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1284 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");
1288 expectFalse(eglSurfaceAttrib(display, surface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED));
1289 expectError(EGL_BAD_MATCH);
1292 log << TestLog::EndSection;
1296 eglDestroySurface(display, surface);
1297 expectError(EGL_SUCCESS);
1302 TEGL_ADD_API_CASE(swap_buffers, "eglSwapBuffers() negative tests",
1304 TestLog& log = m_testCtx.getLog();
1305 EGLDisplay display = getDisplay();
1307 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1309 expectFalse(eglSwapBuffers(EGL_NO_DISPLAY, DE_NULL));
1310 expectError(EGL_BAD_DISPLAY);
1312 expectFalse(eglSwapBuffers((EGLDisplay)-1, DE_NULL));
1313 expectError(EGL_BAD_DISPLAY);
1315 log << TestLog::EndSection;
1317 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1319 expectFalse(eglSwapBuffers(display, DE_NULL));
1320 expectError(EGL_BAD_SURFACE);
1322 expectFalse(eglSwapBuffers(display, (EGLSurface)-1));
1323 expectError(EGL_BAD_SURFACE);
1325 log << TestLog::EndSection;
1328 TEGL_ADD_API_CASE(swap_interval, "eglSwapInterval() negative tests",
1330 TestLog& log = m_testCtx.getLog();
1331 EGLDisplay display = getDisplay();
1333 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1335 expectFalse(eglSwapInterval(EGL_NO_DISPLAY, 0));
1336 expectError(EGL_BAD_DISPLAY);
1338 expectFalse(eglSwapInterval((EGLDisplay)-1, 0));
1339 expectError(EGL_BAD_DISPLAY);
1341 log << TestLog::EndSection;
1343 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if there is no current context on the calling thread");
1345 expectFalse(eglSwapInterval(display, 0));
1346 expectError(EGL_BAD_CONTEXT);
1348 log << TestLog::EndSection;
1351 TEGL_ADD_API_CASE(terminate, "eglTerminate() negative tests",
1353 TestLog& log = m_testCtx.getLog();
1355 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1357 expectFalse(eglTerminate(EGL_NO_DISPLAY));
1358 expectError(EGL_BAD_DISPLAY);
1360 expectFalse(eglTerminate((EGLDisplay)-1));
1361 expectError(EGL_BAD_DISPLAY);
1363 log << TestLog::EndSection;
1366 TEGL_ADD_API_CASE(wait_native, "eglWaitNative() negative tests",
1368 EGLConfig config = DE_NULL;
1369 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << surfaceBits<EGL_WINDOW_BIT>);
1373 TestLog& log = m_testCtx.getLog();
1374 const Library& egl = m_eglTestCtx.getLibrary();
1375 EGLDisplay display = getDisplay();
1376 const eglu::NativeWindowFactory& factory = eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
1377 de::UniquePtr<eglu::NativeWindow> window (factory.createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(256, 256, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
1378 eglu::UniqueSurface surface (egl, display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, display, config, DE_NULL));
1379 EGLContext context = EGL_NO_CONTEXT;
1381 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
1382 expectError(EGL_SUCCESS);
1384 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
1385 expectError(EGL_SUCCESS);
1387 expectTrue(eglMakeCurrent(display, *surface, *surface, context));
1388 expectError(EGL_SUCCESS);
1390 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");
1393 expectEitherError(EGL_BAD_PARAMETER, EGL_SUCCESS);
1395 log << TestLog::EndSection;
1397 expectTrue(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
1398 expectError(EGL_SUCCESS);
1400 if (context != EGL_NO_CONTEXT)
1402 expectTrue(eglDestroyContext(display, context));
1403 expectError(EGL_SUCCESS);