blob: 6eac350bc23f33d5be72e72ee208f18d7d3df8bb [file] [log] [blame]
Jarkko Poyry3c827362014-09-02 11:48:52 +03001/*-------------------------------------------------------------------------
2 * drawElements Quality Program EGL Module
3 * ---------------------------------------
4 *
5 * Copyright 2014 The Android Open Source Project
6 *
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
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
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.
18 *
19 *//*!
20 * \file
21 * \brief Negative API Tests.
22 *//*--------------------------------------------------------------------*/
23
24#include "teglNegativeApiTests.hpp"
25#include "teglApiCase.hpp"
26
Mika Isojärvi33142312015-03-18 17:36:00 -070027#include "egluNativeDisplay.hpp"
28#include "egluNativeWindow.hpp"
29#include "egluUtil.hpp"
30#include "egluUnique.hpp"
31
Jarkko Poyry3c827362014-09-02 11:48:52 +030032#include <memory>
33
34using tcu::TestLog;
35
36namespace deqp
37{
38namespace egl
39{
40
Pyry Haulos3c67e4f2014-12-19 15:45:39 -080041using namespace eglw;
42
43template <deUint32 Type>
44static bool renderable (const eglu::CandidateConfig& c)
45{
46 return (c.renderableType() & Type) == Type;
47}
48
49template <deUint32 Type>
50static bool notRenderable (const eglu::CandidateConfig& c)
51{
52 return (c.renderableType() & Type) == 0;
53}
54
55template <deUint32 Bits>
56static bool surfaceBits (const eglu::CandidateConfig& c)
57{
58 return (c.surfaceType() & Bits) == Bits;
59}
60
61template <deUint32 Bits>
62static bool notSurfaceBits (const eglu::CandidateConfig& c)
63{
64 return (c.surfaceType() & Bits) == 0;
65}
66
Jarkko Poyry3c827362014-09-02 11:48:52 +030067NegativeApiTests::NegativeApiTests (EglTestContext& eglTestCtx)
68 : TestCaseGroup(eglTestCtx, "negative_api", "Negative API Tests")
69{
70}
71
72NegativeApiTests::~NegativeApiTests (void)
73{
74}
75
76void NegativeApiTests::init (void)
77{
78 // \todo [2012-10-02 pyry] Add tests for EGL_NOT_INITIALIZED to all functions taking in EGLDisplay
79 // \todo [2012-10-02 pyry] Implement negative cases for following non-trivial cases:
80 // * eglBindTexImage()
81 // - EGL_BAD_ACCESS is generated if buffer is already bound to a texture
82 // - EGL_BAD_MATCH is generated if the surface attribute EGL_TEXTURE_FORMAT is set to EGL_NO_TEXTURE
83 // - EGL_BAD_MATCH is generated if buffer is not a valid buffer (currently only EGL_BACK_BUFFER may be specified)
84 // - EGL_BAD_SURFACE is generated if surface is not a pbuffer surface supporting texture binding
85 // * eglCopyBuffers()
86 // - EGL_BAD_NATIVE_PIXMAP is generated if the implementation does not support native pixmaps
87 // - EGL_BAD_NATIVE_PIXMAP may be generated if native_pixmap is not a valid native pixmap
88 // - EGL_BAD_MATCH is generated if the format of native_pixmap is not compatible with the color buffer of surface
89 // * eglCreateContext()
90 // - EGL_BAD_MATCH is generated if the current rendering API is EGL_NONE
91 // - EGL_BAD_MATCH is generated if the server context state for share_context exists in an address space which cannot be shared with the newly created context
92 // - EGL_BAD_CONTEXT is generated if share_context is not an EGL rendering context of the same client API type as the newly created context and is not EGL_NO_CONTEXT
93 // * eglCreatePbufferFromClientBuffer()
94 // - various BAD_MATCH, BAD_ACCESS etc. conditions
95 // * eglCreatePbufferSurface()
96 // - EGL_BAD_MATCH is generated if the EGL_TEXTURE_FORMAT attribute is not EGL_NO_TEXTURE, and EGL_WIDTH and/or EGL_HEIGHT specify an invalid size
97 // * eglCreatePixmapSurface()
98 // - EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid pixmap attribute
99 // - EGL_BAD_MATCH is generated if the attributes of native_pixmap do not correspond to config or if config does not support rendering to pixmaps
100 // - EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute
101 // * eglCreateWindowSurface()
102 // - EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid window attribute
103 // - EGL_BAD_MATCH is generated if the attributes of native_window do not correspond to config or if config does not support rendering to windows
104 // - EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute
105 // * eglMakeCurrent()
106 // - EGL_BAD_MATCH is generated if draw or read are not compatible with context
107 // - EGL_BAD_MATCH is generated if context is set to EGL_NO_CONTEXT and draw or read are not set to EGL_NO_SURFACE
108 // - EGL_BAD_MATCH is generated if draw or read are set to EGL_NO_SURFACE and context is not set to EGL_NO_CONTEXT
109 // - EGL_BAD_ACCESS is generated if context is current to some other thread
110 // - EGL_BAD_NATIVE_PIXMAP may be generated if a native pixmap underlying either draw or read is no longer valid
111 // - EGL_BAD_NATIVE_WINDOW may be generated if a native window underlying either draw or read is no longer valid
112 // * eglReleaseTexImage()
113 // - EGL_BAD_MATCH is generated if buffer is not a valid buffer (currently only EGL_BACK_BUFFER may be specified)
114 // * eglSwapInterval()
115 // - EGL_BAD_SURFACE is generated if there is no surface bound to the current context
116 // * eglWaitNative()
117 // - EGL_BAD_CURRENT_SURFACE is generated if the surface associated with the current context has a native window or pixmap, and that window or pixmap is no longer valid
118
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800119 using namespace eglw;
Jarkko Poyry3c827362014-09-02 11:48:52 +0300120 using namespace eglu;
121
122 static const EGLint s_emptyAttribList[] = { EGL_NONE };
123 static const EGLint s_es1ContextAttribList[] = { EGL_CONTEXT_CLIENT_VERSION, 1, EGL_NONE };
124 static const EGLint s_es2ContextAttribList[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
125
126 static const EGLenum s_renderAPIs[] = { EGL_OPENGL_API, EGL_OPENGL_ES_API, EGL_OPENVG_API };
127
128 TEGL_ADD_API_CASE(bind_api, "eglBindAPI() negative tests",
129 {
130 TestLog& log = m_testCtx.getLog();
131 log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if api is not one of the accepted tokens");
132
133 expectFalse(eglBindAPI(0));
134 expectError(EGL_BAD_PARAMETER);
135
136 expectFalse(eglBindAPI(0xfdfdfdfd));
137 expectError(EGL_BAD_PARAMETER);
138
139 expectFalse(eglBindAPI((EGLenum)0xffffffff));
140 expectError(EGL_BAD_PARAMETER);
141
142 log << TestLog::EndSection;
143
144 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if the specified client API is not supported by the EGL implementation");
145
146 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_renderAPIs); ndx++)
147 {
148 if (!isAPISupported(s_renderAPIs[ndx]))
149 {
150 expectFalse(eglBindAPI(s_renderAPIs[ndx]));
151 expectError(EGL_BAD_PARAMETER);
152 }
153 }
154
155 log << TestLog::EndSection;
156 });
157
158 TEGL_ADD_API_CASE(bind_tex_image, "eglBindTexImage() negative tests",
159 {
160 TestLog& log = m_testCtx.getLog();
161 EGLDisplay display = getDisplay();
162
163 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
164
165 expectFalse(eglBindTexImage(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_BACK_BUFFER));
166 expectError(EGL_BAD_DISPLAY);
167
168 expectFalse(eglBindTexImage((EGLDisplay)-1, EGL_NO_SURFACE, EGL_BACK_BUFFER));
169 expectError(EGL_BAD_DISPLAY);
170
171 log << TestLog::EndSection;
172
173 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
174
175 expectFalse(eglBindTexImage(display, EGL_NO_SURFACE, EGL_BACK_BUFFER));
176 expectError(EGL_BAD_SURFACE);
177
178 expectFalse(eglBindTexImage(display, (EGLSurface)-1, EGL_BACK_BUFFER));
179 expectError(EGL_BAD_SURFACE);
180
181 log << TestLog::EndSection;
182 });
183
184 TEGL_ADD_API_CASE(copy_buffers, "eglCopyBuffers() negative tests",
185 {
186 TestLog& log = m_testCtx.getLog();
187 EGLDisplay display = getDisplay();
188
189 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
190
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800191 expectFalse(eglCopyBuffers(EGL_NO_DISPLAY, EGL_NO_SURFACE, (EGLNativePixmapType)0));
Jarkko Poyry3c827362014-09-02 11:48:52 +0300192 expectError(EGL_BAD_DISPLAY);
193
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800194 expectFalse(eglCopyBuffers((EGLDisplay)-1, EGL_NO_SURFACE, (EGLNativePixmapType)0));
Jarkko Poyry3c827362014-09-02 11:48:52 +0300195 expectError(EGL_BAD_DISPLAY);
196
197 log << TestLog::EndSection;
198
199 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
200
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800201 expectFalse(eglCopyBuffers(display, EGL_NO_SURFACE, (EGLNativePixmapType)0));
Jarkko Poyry3c827362014-09-02 11:48:52 +0300202 expectError(EGL_BAD_SURFACE);
203
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800204 expectFalse(eglCopyBuffers(display, (EGLSurface)-1, (EGLNativePixmapType)0));
Jarkko Poyry3c827362014-09-02 11:48:52 +0300205 expectError(EGL_BAD_SURFACE);
206
207 log << TestLog::EndSection;
208 });
209
210 static const EGLint s_invalidChooseConfigAttribList0[] = { 0, EGL_NONE };
211 static const EGLint s_invalidChooseConfigAttribList1[] = { (EGLint)0xffffffff };
212 static const EGLint s_invalidChooseConfigAttribList2[] = { EGL_BIND_TO_TEXTURE_RGB, 4, EGL_NONE };
213 static const EGLint s_invalidChooseConfigAttribList3[] = { EGL_BIND_TO_TEXTURE_RGBA, 5, EGL_NONE };
214 static const EGLint s_invalidChooseConfigAttribList4[] = { EGL_COLOR_BUFFER_TYPE, 0, EGL_NONE };
215 static const EGLint s_invalidChooseConfigAttribList5[] = { EGL_MATCH_NATIVE_PIXMAP, -1, EGL_NONE };
216 static const EGLint s_invalidChooseConfigAttribList6[] = { EGL_NATIVE_RENDERABLE, 6, EGL_NONE };
217 static const EGLint s_invalidChooseConfigAttribList7[] = { EGL_TRANSPARENT_TYPE, 6, EGL_NONE };
218 static const EGLint* s_invalidChooseConfigAttribLists[] =
219 {
220 &s_invalidChooseConfigAttribList0[0],
221 &s_invalidChooseConfigAttribList1[0],
222 &s_invalidChooseConfigAttribList2[0],
223 &s_invalidChooseConfigAttribList3[0],
224 &s_invalidChooseConfigAttribList4[0],
225 &s_invalidChooseConfigAttribList5[0],
226 &s_invalidChooseConfigAttribList6[0],
227 &s_invalidChooseConfigAttribList7[0]
228 };
229
230 TEGL_ADD_API_CASE(choose_config, "eglChooseConfig() negative tests",
231 {
232 TestLog& log = m_testCtx.getLog();
233 EGLDisplay display = getDisplay();
234 EGLConfig configs[1];
235 EGLint numConfigs;
236
237 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
238
239 expectFalse(eglChooseConfig(EGL_NO_DISPLAY, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
240 expectError(EGL_BAD_DISPLAY);
241
242 expectFalse(eglChooseConfig((EGLDisplay)-1, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
243 expectError(EGL_BAD_DISPLAY);
244
245 log << TestLog::EndSection;
246
247 log << TestLog::Section("Test2", "EGL_BAD_ATTRIBUTE is generated if attribute_list contains an invalid frame buffer configuration attribute");
248
249 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidChooseConfigAttribLists); ndx++)
250 {
251 expectFalse(eglChooseConfig(display, s_invalidChooseConfigAttribLists[ndx], &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
252 expectError(EGL_BAD_ATTRIBUTE);
253 }
254
255 log << TestLog::EndSection;
256
257 log << TestLog::Section("Test3", "EGL_BAD_PARAMETER is generated if num_config is NULL");
258
259 expectFalse(eglChooseConfig(display, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), DE_NULL));
260 expectError(EGL_BAD_PARAMETER);
261
262 log << TestLog::EndSection;
263 });
264
265 static const EGLint s_invalidCreateContextAttribList0[] = { 0, EGL_NONE };
266 static const EGLint s_invalidCreateContextAttribList1[] = { (EGLint)0xffffffff };
267
268 TEGL_ADD_API_CASE(create_context, "eglCreateContext() negative tests",
269 {
270 TestLog& log = m_testCtx.getLog();
271 EGLDisplay display = getDisplay();
272
273 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
274
275 expectNoContext(eglCreateContext(EGL_NO_DISPLAY, DE_NULL, EGL_NO_CONTEXT, s_emptyAttribList));
276 expectError(EGL_BAD_DISPLAY);
277
278 expectNoContext(eglCreateContext((EGLDisplay)-1, DE_NULL, EGL_NO_CONTEXT, s_emptyAttribList));
279 expectError(EGL_BAD_DISPLAY);
280
281 log << TestLog::EndSection;
282
283 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
284
285 expectNoContext(eglCreateContext(display, (EGLConfig)-1, EGL_NO_CONTEXT, s_emptyAttribList));
286 expectError(EGL_BAD_CONFIG);
287
288 log << TestLog::EndSection;
289
290 log << TestLog::Section("Test3", "EGL_BAD_CONFIG is generated if config does not support the current rendering API");
291
292 if (isAPISupported(EGL_OPENGL_API))
293 {
294 EGLConfig es1OnlyConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800295 if (getConfig(&es1OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT> << notRenderable<EGL_OPENGL_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300296 {
297 expectTrue(eglBindAPI(EGL_OPENGL_API));
298 expectNoContext(eglCreateContext(display, es1OnlyConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
299 expectError(EGL_BAD_CONFIG);
300 }
301
302 EGLConfig es2OnlyConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800303 if (getConfig(&es2OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << notRenderable<EGL_OPENGL_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300304 {
305 expectTrue(eglBindAPI(EGL_OPENGL_API));
306 expectNoContext(eglCreateContext(display, es2OnlyConfig, EGL_NO_CONTEXT, s_es2ContextAttribList));
307 expectError(EGL_BAD_CONFIG);
308 }
309
310 EGLConfig vgOnlyConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800311 if (getConfig(&vgOnlyConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notRenderable<EGL_OPENGL_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300312 {
313 expectTrue(eglBindAPI(EGL_OPENGL_API));
314 expectNoContext(eglCreateContext(display, vgOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
315 expectError(EGL_BAD_CONFIG);
316 }
317 }
318
319 if (isAPISupported(EGL_OPENGL_ES_API))
320 {
321 EGLConfig glOnlyConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800322 if (getConfig(&glOnlyConfig, FilterList() << renderable<EGL_OPENGL_BIT> << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300323 {
324 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
325 expectNoContext(eglCreateContext(display, glOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
326 expectError(EGL_BAD_CONFIG);
327 }
328
329 EGLConfig vgOnlyConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800330 if (getConfig(&vgOnlyConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300331 {
332 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
333 expectNoContext(eglCreateContext(display, vgOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
334 expectError(EGL_BAD_CONFIG);
335 }
336 }
337
338 if (isAPISupported(EGL_OPENVG_API))
339 {
340 EGLConfig glOnlyConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800341 if (getConfig(&glOnlyConfig, FilterList() << renderable<EGL_OPENGL_BIT> << notRenderable<EGL_OPENVG_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300342 {
Mika Isojärvic3dc61b2014-10-24 11:42:52 +0300343 expectTrue(eglBindAPI(EGL_OPENVG_API));
Jarkko Poyry3c827362014-09-02 11:48:52 +0300344 expectNoContext(eglCreateContext(display, glOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
345 expectError(EGL_BAD_CONFIG);
346 }
347
348 EGLConfig es1OnlyConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800349 if (getConfig(&es1OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT> << notRenderable<EGL_OPENVG_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300350 {
Mika Isojärvic3dc61b2014-10-24 11:42:52 +0300351 expectTrue(eglBindAPI(EGL_OPENVG_API));
Jarkko Poyry3c827362014-09-02 11:48:52 +0300352 expectNoContext(eglCreateContext(display, es1OnlyConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
353 expectError(EGL_BAD_CONFIG);
354 }
355
356 EGLConfig es2OnlyConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800357 if (getConfig(&es2OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << notRenderable<EGL_OPENVG_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300358 {
Mika Isojärvic3dc61b2014-10-24 11:42:52 +0300359 expectTrue(eglBindAPI(EGL_OPENVG_API));
Jarkko Poyry3c827362014-09-02 11:48:52 +0300360 expectNoContext(eglCreateContext(display, es2OnlyConfig, EGL_NO_CONTEXT, s_es2ContextAttribList));
361 expectError(EGL_BAD_CONFIG);
362 }
363 }
364
365 log << TestLog::EndSection;
366
367 log << TestLog::Section("Test4", "EGL_BAD_CONFIG is generated if OpenGL ES 1.x context is requested and EGL_RENDERABLE_TYPE attribute of config does not contain EGL_OPENGL_ES_BIT");
368
369 if (isAPISupported(EGL_OPENGL_ES_API))
370 {
371 EGLConfig notES1Config;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800372 if (getConfig(&notES1Config, FilterList() << notRenderable<EGL_OPENGL_ES_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300373 {
374 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
375 expectNoContext(eglCreateContext(display, notES1Config, EGL_NO_CONTEXT, s_es1ContextAttribList));
376 expectError(EGL_BAD_CONFIG);
377 }
378 }
379
380 log << TestLog::EndSection;
381
382 log << TestLog::Section("Test5", "EGL_BAD_CONFIG is generated if OpenGL ES 2.x context is requested and EGL_RENDERABLE_TYPE attribute of config does not contain EGL_OPENGL_ES2_BIT");
383
384 if (isAPISupported(EGL_OPENGL_ES_API))
385 {
386 EGLConfig notES2Config;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800387 if (getConfig(&notES2Config, FilterList() << notRenderable<EGL_OPENGL_ES2_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300388 {
389 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
390 expectNoContext(eglCreateContext(display, notES2Config, EGL_NO_CONTEXT, s_es2ContextAttribList));
391 expectError(EGL_BAD_CONFIG);
392 }
393 }
394
395 log << TestLog::EndSection;
396
397 log << TestLog::Section("Test6", "EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid context attribute");
398
399 if (isAPISupported(EGL_OPENGL_API))
400 {
401 EGLConfig glConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800402 if (getConfig(&glConfig, FilterList() << renderable<EGL_OPENGL_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300403 {
404 expectTrue(eglBindAPI(EGL_OPENGL_API));
405 expectNoContext(eglCreateContext(display, glConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
406 expectError(EGL_BAD_ATTRIBUTE);
407 }
408 }
409
410 if (isAPISupported(EGL_OPENVG_API))
411 {
412 EGLConfig vgConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800413 if (getConfig(&vgConfig, FilterList() << renderable<EGL_OPENVG_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300414 {
415 expectTrue(eglBindAPI(EGL_OPENVG_API));
416 expectNoContext(eglCreateContext(display, vgConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
417 expectError(EGL_BAD_ATTRIBUTE);
418 }
419 }
420
421 if (isAPISupported(EGL_OPENGL_ES_API))
422 {
423 bool gotConfig = false;
424 EGLConfig esConfig;
425
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800426 gotConfig = getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT>) ||
427 getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300428
429 if (gotConfig)
430 {
431 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
432 expectNoContext(eglCreateContext(display, esConfig, EGL_NO_CONTEXT, s_invalidCreateContextAttribList0));
433 expectError(EGL_BAD_ATTRIBUTE);
434 expectNoContext(eglCreateContext(display, esConfig, EGL_NO_CONTEXT, s_invalidCreateContextAttribList1));
435 expectError(EGL_BAD_ATTRIBUTE);
436 }
437 }
438
439 log << TestLog::EndSection;
440 });
441
442 TEGL_ADD_API_CASE(create_pbuffer_from_client_buffer, "eglCreatePbufferFromClientBuffer() negative tests",
443 {
444 TestLog& log = m_testCtx.getLog();
445 EGLDisplay display = getDisplay();
446 EGLConfig anyConfig;
447 EGLint unused = 0;
448
449 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
450
451 expectNoSurface(eglCreatePbufferFromClientBuffer(EGL_NO_DISPLAY, EGL_OPENVG_IMAGE, 0, (EGLConfig)0, DE_NULL));
452 expectError(EGL_BAD_DISPLAY);
453
454 expectNoSurface(eglCreatePbufferFromClientBuffer((EGLDisplay)-1, EGL_OPENVG_IMAGE, 0, (EGLConfig)0, DE_NULL));
455 expectError(EGL_BAD_DISPLAY);
456
457 log << TestLog::EndSection;
458
Mika Isojärvif5f7ab72016-01-26 11:47:20 -0800459 if (isAPISupported(EGL_OPENVG_API))
460 {
461 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");
Jarkko Poyry3c827362014-09-02 11:48:52 +0300462
Mika Isojärvif5f7ab72016-01-26 11:47:20 -0800463 expectNoSurface(eglCreatePbufferFromClientBuffer(display, EGL_OPENVG_IMAGE, (EGLClientBuffer)-1, (EGLConfig)-1, DE_NULL));
464 expectEitherError(EGL_BAD_CONFIG, EGL_BAD_PARAMETER);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300465
Mika Isojärvif5f7ab72016-01-26 11:47:20 -0800466 log << TestLog::EndSection;
Jarkko Poyry3c827362014-09-02 11:48:52 +0300467
Mika Isojärvif5f7ab72016-01-26 11:47:20 -0800468 log << TestLog::Section("Test3", "EGL_BAD_PARAMETER is generated if buftype is not EGL_OPENVG_IMAGE");
Jarkko Poyry3c827362014-09-02 11:48:52 +0300469
Mika Isojärvif5f7ab72016-01-26 11:47:20 -0800470 expectTrue(eglGetConfigs(display, &anyConfig, 1, &unused));
Mika Isojärvic3dc61b2014-10-24 11:42:52 +0300471
Mika Isojärvif5f7ab72016-01-26 11:47:20 -0800472 log << TestLog::EndSection;
Jarkko Poyry3c827362014-09-02 11:48:52 +0300473
Mika Isojärvif5f7ab72016-01-26 11:47:20 -0800474 log << TestLog::Section("Test4", "EGL_BAD_PARAMETER is generated if buffer is not valid OpenVG image");
475 expectNoSurface(eglCreatePbufferFromClientBuffer(display, EGL_OPENVG_IMAGE, (EGLClientBuffer)-1, anyConfig, DE_NULL));
476 expectError(EGL_BAD_PARAMETER);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300477
Mika Isojärvif5f7ab72016-01-26 11:47:20 -0800478 log << TestLog::EndSection;
479 }
Jarkko Poyry3c827362014-09-02 11:48:52 +0300480 });
481
482 static const EGLint s_validGenericPbufferAttrib[] = { EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
483
484 static const EGLint s_invalidGenericPbufferAttrib0[] = { 0, EGL_NONE };
485 static const EGLint s_invalidGenericPbufferAttrib1[] = { (EGLint)0xffffffff };
Mika Isojärvideac1542015-03-18 16:25:07 -0700486 static const EGLint s_negativeWidthPbufferAttrib[] = { EGL_WIDTH, -1, EGL_HEIGHT, 64, EGL_NONE };
487 static const EGLint s_negativeHeightPbufferAttrib[] = { EGL_WIDTH, 64, EGL_HEIGHT, -1, EGL_NONE };
488 static const EGLint s_negativeWidthAndHeightPbufferAttrib[] = { EGL_WIDTH, -1, EGL_HEIGHT, -1, EGL_NONE };
Jarkko Poyry3c827362014-09-02 11:48:52 +0300489 static const EGLint* s_invalidGenericPbufferAttribs[] =
490 {
491 s_invalidGenericPbufferAttrib0,
492 s_invalidGenericPbufferAttrib1,
Jarkko Poyry3c827362014-09-02 11:48:52 +0300493 };
494
495 static const EGLint s_invalidNoEsPbufferAttrib0[] = { EGL_MIPMAP_TEXTURE, EGL_TRUE, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
496 static const EGLint s_invalidNoEsPbufferAttrib1[] = { EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
497 static const EGLint s_invalidNoEsPbufferAttrib2[] = { EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
498 static const EGLint* s_invalidNoEsPbufferAttribs[] =
499 {
500 s_invalidNoEsPbufferAttrib0,
501 s_invalidNoEsPbufferAttrib1,
502 s_invalidNoEsPbufferAttrib2
503 };
504
505 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 };
506 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 };
507 static const EGLint* s_invalidEsPbufferAttribs[] =
508 {
509 s_invalidEsPbufferAttrib0,
510 s_invalidEsPbufferAttrib1
511 };
512
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800513 static const EGLint s_vgPreMultAlphaPbufferAttrib[] = { EGL_ALPHA_FORMAT, EGL_ALPHA_FORMAT_PRE, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
514 static const EGLint s_vgLinearColorspacePbufferAttrib[] = { EGL_COLORSPACE, EGL_VG_COLORSPACE_LINEAR, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
Jarkko Poyry3c827362014-09-02 11:48:52 +0300515
516 TEGL_ADD_API_CASE(create_pbuffer_surface, "eglCreatePbufferSurface() negative tests",
517 {
518 TestLog& log = m_testCtx.getLog();
519 EGLDisplay display = getDisplay();
520
521 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
522
523 expectNoSurface(eglCreatePbufferSurface(EGL_NO_DISPLAY, DE_NULL, s_emptyAttribList));
524 expectError(EGL_BAD_DISPLAY);
525
526 expectNoSurface(eglCreatePbufferSurface((EGLDisplay)-1, DE_NULL, s_emptyAttribList));
527 expectError(EGL_BAD_DISPLAY);
528
529 log << TestLog::EndSection;
530
531 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
532
533 expectNoSurface(eglCreatePbufferSurface(display, (EGLConfig)-1, s_emptyAttribList));
534 expectError(EGL_BAD_CONFIG);
535
536 log << TestLog::EndSection;
537
538 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid pixel buffer attribute");
539
540 // Generic pbuffer-capable config
541 EGLConfig genericConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800542 if (getConfig(&genericConfig, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300543 {
544 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidGenericPbufferAttribs); ndx++)
545 {
546 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_invalidGenericPbufferAttribs[ndx]));
547 expectError(EGL_BAD_ATTRIBUTE);
548 }
549 }
550
551 log << TestLog::EndSection;
552
553 log << TestLog::Section("Test4", "EGL_BAD_MATCH is generated if config does not support rendering to pixel buffers");
554
555 EGLConfig noPbufferConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800556 if (getConfig(&noPbufferConfig, FilterList() << notSurfaceBits<EGL_PBUFFER_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300557 {
558 expectNoSurface(eglCreatePbufferSurface(display, noPbufferConfig, s_validGenericPbufferAttrib));
559 expectError(EGL_BAD_MATCH);
560 }
561
562 log << TestLog::EndSection;
563
564 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");
565
566 EGLConfig noEsConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800567 if (getConfig(&noEsConfig, FilterList() << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300568 {
569 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidNoEsPbufferAttribs); ndx++)
570 {
571 expectNoSurface(eglCreatePbufferSurface(display, noEsConfig, s_invalidNoEsPbufferAttribs[ndx]));
572 expectError(EGL_BAD_MATCH);
573 }
574 }
575
576 log << TestLog::EndSection;
577
578 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");
579
580 // ES1 or ES2 config.
581 EGLConfig esConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800582 bool gotEsConfig = getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT>) ||
583 getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300584 if (gotEsConfig)
585 {
586 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidEsPbufferAttribs); ndx++)
587 {
588 expectNoSurface(eglCreatePbufferSurface(display, esConfig, s_invalidEsPbufferAttribs[ndx]));
589 expectError(EGL_BAD_MATCH);
590 }
591 }
592
593 log << TestLog::EndSection;
594
595 log << TestLog::Section("Test7", "EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute");
596
597 EGLConfig vgNoPreConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800598 if (getConfig(&vgNoPreConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notSurfaceBits<EGL_VG_ALPHA_FORMAT_PRE_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300599 {
600 expectNoSurface(eglCreatePbufferSurface(display, vgNoPreConfig, s_vgPreMultAlphaPbufferAttrib));
601 expectError(EGL_BAD_MATCH);
602 }
603
604 EGLConfig vgNoLinearConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800605 if (getConfig(&vgNoLinearConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notSurfaceBits<EGL_VG_COLORSPACE_LINEAR_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300606 {
607 expectNoSurface(eglCreatePbufferSurface(display, vgNoLinearConfig, s_vgLinearColorspacePbufferAttrib));
608 expectError(EGL_BAD_MATCH);
609 }
610
611 log << TestLog::EndSection;
Mika Isojärvideac1542015-03-18 16:25:07 -0700612
613 log << TestLog::Section("Test8", "EGL_BAD_PARAMETER is generated if EGL_WIDTH or EGL_HEIGHT is negative");
614
615 if (getConfig(&genericConfig, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
616 {
617 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeWidthPbufferAttrib));
618 expectError(EGL_BAD_PARAMETER);
619
620 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeHeightPbufferAttrib));
621 expectError(EGL_BAD_PARAMETER);
622
623 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeWidthAndHeightPbufferAttrib));
624 expectError(EGL_BAD_PARAMETER);
625 }
626
627 log << TestLog::EndSection;
628
Jarkko Poyry3c827362014-09-02 11:48:52 +0300629 });
630
631 TEGL_ADD_API_CASE(create_pixmap_surface, "eglCreatePixmapSurface() negative tests",
632 {
633 TestLog& log = m_testCtx.getLog();
634 EGLDisplay display = getDisplay();
635
636 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
637
638 expectNoSurface(eglCreatePixmapSurface(EGL_NO_DISPLAY, DE_NULL, DE_NULL, s_emptyAttribList));
639 expectError(EGL_BAD_DISPLAY);
640
641 expectNoSurface(eglCreatePixmapSurface((EGLDisplay)-1, DE_NULL, DE_NULL, s_emptyAttribList));
642 expectError(EGL_BAD_DISPLAY);
643
644 log << TestLog::EndSection;
645
646 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
647
648 expectNoSurface(eglCreatePixmapSurface(display, (EGLConfig)-1, DE_NULL, s_emptyAttribList));
649 expectError(EGL_BAD_CONFIG);
650
651 log << TestLog::EndSection;
652
653 log << TestLog::Section("Test3", "EGL_BAD_NATIVE_PIXMAP may be generated if native_pixmap is not a valid native pixmap");
654
655 // Any pixmap-capable config.
656 EGLConfig pixmapConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800657 if (getConfig(&pixmapConfig, FilterList() << surfaceBits<EGL_PIXMAP_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300658 {
659 expectNoSurface(eglCreatePixmapSurface(display, pixmapConfig, DE_NULL, s_emptyAttribList));
660 expectError(EGL_BAD_NATIVE_PIXMAP);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300661 }
662
663 log << TestLog::EndSection;
664 });
665
666 TEGL_ADD_API_CASE(create_window_surface, "eglCreateWindowSurface() negative tests",
667 {
668 TestLog& log = m_testCtx.getLog();
669 EGLDisplay display = getDisplay();
670
671 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
672
673 expectNoSurface(eglCreateWindowSurface(EGL_NO_DISPLAY, DE_NULL, DE_NULL, s_emptyAttribList));
674 expectError(EGL_BAD_DISPLAY);
675
676 expectNoSurface(eglCreateWindowSurface((EGLDisplay)-1, DE_NULL, DE_NULL, s_emptyAttribList));
677 expectError(EGL_BAD_DISPLAY);
678
679 log << TestLog::EndSection;
680
681 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
682
683 expectNoSurface(eglCreateWindowSurface(display, (EGLConfig)-1, DE_NULL, s_emptyAttribList));
684 expectError(EGL_BAD_CONFIG);
685
686 log << TestLog::EndSection;
Jarkko Poyry3c827362014-09-02 11:48:52 +0300687 });
688
689 TEGL_ADD_API_CASE(destroy_context, "eglDestroyContext() negative tests",
690 {
691 TestLog& log = m_testCtx.getLog();
692 EGLDisplay display = getDisplay();
693
694 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
695
696 expectFalse(eglDestroyContext(EGL_NO_DISPLAY, DE_NULL));
697 expectError(EGL_BAD_DISPLAY);
698
699 expectFalse(eglDestroyContext((EGLDisplay)-1, DE_NULL));
700 expectError(EGL_BAD_DISPLAY);
701
702 log << TestLog::EndSection;
703
704 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
705
706 expectFalse(eglDestroyContext(display, DE_NULL));
707 expectError(EGL_BAD_CONTEXT);
708
709 expectFalse(eglDestroyContext(display, (EGLContext)-1));
710 expectError(EGL_BAD_CONTEXT);
711
712 log << TestLog::EndSection;
713 });
714
715 TEGL_ADD_API_CASE(destroy_surface, "eglDestroySurface() negative tests",
716 {
717 TestLog& log = m_testCtx.getLog();
718 EGLDisplay display = getDisplay();
719
720 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
721
722 expectFalse(eglDestroySurface(EGL_NO_DISPLAY, DE_NULL));
723 expectError(EGL_BAD_DISPLAY);
724
725 expectFalse(eglDestroySurface((EGLDisplay)-1, DE_NULL));
726 expectError(EGL_BAD_DISPLAY);
727
728 log << TestLog::EndSection;
729
730 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
731
732 expectFalse(eglDestroySurface(display, DE_NULL));
733 expectError(EGL_BAD_SURFACE);
734
735 expectFalse(eglDestroySurface(display, (EGLSurface)-1));
736 expectError(EGL_BAD_SURFACE);
737
738 log << TestLog::EndSection;
739 });
740
741 TEGL_ADD_API_CASE(get_config_attrib, "eglGetConfigAttrib() negative tests",
742 {
743 TestLog& log = m_testCtx.getLog();
744 EGLDisplay display = getDisplay();
745 EGLint value = 0;
746
747 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
748
749 expectFalse(eglGetConfigAttrib(EGL_NO_DISPLAY, DE_NULL, EGL_RED_SIZE, &value));
750 expectError(EGL_BAD_DISPLAY);
751
752 expectFalse(eglGetConfigAttrib((EGLDisplay)-1, DE_NULL, EGL_RED_SIZE, &value));
753 expectError(EGL_BAD_DISPLAY);
754
755 log << TestLog::EndSection;
756
757 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
758
759 expectFalse(eglGetConfigAttrib(display, (EGLConfig)-1, EGL_RED_SIZE, &value));
760 expectError(EGL_BAD_CONFIG);
761
762 log << TestLog::EndSection;
763
764 // Any config.
765 EGLConfig config = DE_NULL;
766 bool hasConfig = getConfig(&config, FilterList());
767
768 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid frame buffer configuration attribute");
769
770 if (hasConfig)
771 {
772 expectFalse(eglGetConfigAttrib(display, config, 0, &value));
773 expectError(EGL_BAD_ATTRIBUTE);
774
775 expectFalse(eglGetConfigAttrib(display, config, -1, &value));
776 expectError(EGL_BAD_ATTRIBUTE);
777 }
778
779 log << TestLog::EndSection;
780 });
781
782 TEGL_ADD_API_CASE(get_configs, "eglGetConfigs() negative tests",
783 {
784 TestLog& log = m_testCtx.getLog();
785 EGLDisplay display = getDisplay();
786 EGLConfig cfgs[1];
787 EGLint numCfgs = 0;
788
789 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
790
791 expectFalse(eglGetConfigs(EGL_NO_DISPLAY, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), &numCfgs));
792 expectError(EGL_BAD_DISPLAY);
793
794 expectFalse(eglGetConfigs((EGLDisplay)-1, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), &numCfgs));
795 expectError(EGL_BAD_DISPLAY);
796
797 log << TestLog::EndSection;
798
799 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if num_config is NULL");
800
801 expectFalse(eglGetConfigs(display, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), DE_NULL));
802 expectError(EGL_BAD_PARAMETER);
803
804 log << TestLog::EndSection;
805 });
806
807 TEGL_ADD_API_CASE(get_display, "eglGetDisplay() negative tests",
808 {
809 expectNoDisplay(eglGetDisplay((EGLNativeDisplayType)-1));
810 expectError(EGL_SUCCESS);
811 });
812
813 TEGL_ADD_API_CASE(initialize, "eglInitialize() negative tests",
814 {
815 TestLog& log = m_testCtx.getLog();
816 EGLint major = 0;
817 EGLint minor = 0;
818
819 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
820
821 expectFalse(eglInitialize(EGL_NO_DISPLAY, &major, &minor));
822 expectError(EGL_BAD_DISPLAY);
823
824 expectFalse(eglInitialize((EGLDisplay)-1, &major, &minor));
825 expectError(EGL_BAD_DISPLAY);
826
827 log << TestLog::EndSection;
828 });
829
830 TEGL_ADD_API_CASE(make_current, "eglMakeCurrent() negative tests",
831 {
832 TestLog& log = m_testCtx.getLog();
833 EGLDisplay display = getDisplay();
834
835 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
836
837 expectFalse(eglMakeCurrent(EGL_NO_DISPLAY, DE_NULL, DE_NULL, DE_NULL));
838 expectError(EGL_BAD_DISPLAY);
839
840 expectFalse(eglMakeCurrent((EGLDisplay)-1, DE_NULL, DE_NULL, DE_NULL));
841 expectError(EGL_BAD_DISPLAY);
842
843 log << TestLog::EndSection;
844
845 // Create simple pbuffer surface.
846 EGLSurface surface = EGL_NO_SURFACE;
847 {
848 EGLConfig config;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800849 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300850 {
851 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
852 expectError(EGL_SUCCESS);
853 }
854 }
855
Mika Isojärvi83a0aac2015-03-20 14:40:10 -0700856 // Create simple ES2 context
857 EGLContext context = EGL_NO_CONTEXT;
Jarkko Poyry3c827362014-09-02 11:48:52 +0300858 {
Mika Isojärvi83a0aac2015-03-20 14:40:10 -0700859 EGLConfig config;
860 if (getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT>))
861 {
862 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
863 expectError(EGL_SUCCESS);
864 }
Jarkko Poyry3c827362014-09-02 11:48:52 +0300865 }
866
Mika Isojärvi83a0aac2015-03-20 14:40:10 -0700867 if (surface != EGL_NO_SURFACE && context != EGL_NO_CONTEXT)
868 {
869 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
Jarkko Poyry3c827362014-09-02 11:48:52 +0300870
Mika Isojärvi83a0aac2015-03-20 14:40:10 -0700871 expectFalse(eglMakeCurrent(display, (EGLSurface)-1, (EGLSurface)-1, context));
872 expectError(EGL_BAD_SURFACE);
873
874 expectFalse(eglMakeCurrent(display, surface, (EGLSurface)-1, context));
875 expectError(EGL_BAD_SURFACE);
876
877 expectFalse(eglMakeCurrent(display, (EGLSurface)-1, surface, context));
878 expectError(EGL_BAD_SURFACE);
879
880 log << TestLog::EndSection;
881 }
Jarkko Poyry3c827362014-09-02 11:48:52 +0300882
883 if (surface)
884 {
Mika Isojärvi83a0aac2015-03-20 14:40:10 -0700885 log << TestLog::Section("Test3", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
886
Jarkko Poyry3c827362014-09-02 11:48:52 +0300887 expectFalse(eglMakeCurrent(display, surface, surface, (EGLContext)-1));
888 expectError(EGL_BAD_CONTEXT);
Mika Isojärvi83a0aac2015-03-20 14:40:10 -0700889
890 log << TestLog::EndSection;
Jarkko Poyry3c827362014-09-02 11:48:52 +0300891 }
892
Mika Isojärvi83a0aac2015-03-20 14:40:10 -0700893 if (surface != EGL_NO_SURFACE)
894 {
895 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");
896
897 expectFalse(eglMakeCurrent(display, surface, EGL_NO_SURFACE, EGL_NO_CONTEXT));
898 expectError(EGL_BAD_MATCH);
899
900 expectFalse(eglMakeCurrent(display, EGL_NO_SURFACE, surface, EGL_NO_CONTEXT));
901 expectError(EGL_BAD_MATCH);
902
903 expectFalse(eglMakeCurrent(display, surface, surface, EGL_NO_CONTEXT));
904 expectError(EGL_BAD_MATCH);
905
906 log << TestLog::EndSection;
907 }
908
909 if (context)
910 {
911 eglDestroyContext(display, context);
912 expectError(EGL_SUCCESS);
913 }
Jarkko Poyry3c827362014-09-02 11:48:52 +0300914
915 if (surface)
916 {
917 eglDestroySurface(display, surface);
918 expectError(EGL_SUCCESS);
919 }
920 });
921
922 TEGL_ADD_API_CASE(get_current_context, "eglGetCurrentContext() negative tests",
923 {
924 expectNoContext(eglGetCurrentContext());
925
926 if (isAPISupported(EGL_OPENGL_ES_API))
927 {
928 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
929 expectError(EGL_SUCCESS);
930
931 expectNoContext(eglGetCurrentContext());
932 expectError(EGL_SUCCESS);
933 }
934 });
935
936 TEGL_ADD_API_CASE(get_current_surface, "eglGetCurrentSurface() negative tests",
937 {
938 TestLog& log = m_testCtx.getLog();
Mika Isojärvicd521812015-03-18 17:21:10 -0700939 EGLDisplay display = getDisplay();
940 EGLConfig config = DE_NULL;
941 EGLContext context = EGL_NO_CONTEXT;
942 EGLSurface surface = EGL_NO_SURFACE;
943 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << surfaceBits<EGL_PBUFFER_BIT>);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300944
Mika Isojärvicd521812015-03-18 17:21:10 -0700945 if (gotConfig)
946 {
947 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
948 expectError(EGL_SUCCESS);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300949
Mika Isojärvicd521812015-03-18 17:21:10 -0700950 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
951 expectError(EGL_SUCCESS);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300952
Mika Isojärvicd521812015-03-18 17:21:10 -0700953 // Create simple pbuffer surface.
954 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
955 expectError(EGL_SUCCESS);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300956
Mika Isojärvicd521812015-03-18 17:21:10 -0700957 expectTrue(eglMakeCurrent(display, surface, surface, context));
958 expectError(EGL_SUCCESS);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300959
Mika Isojärvicd521812015-03-18 17:21:10 -0700960 log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if readdraw is neither EGL_READ nor EGL_DRAW");
961
962 expectNoSurface(eglGetCurrentSurface(EGL_NONE));
963 expectError(EGL_BAD_PARAMETER);
964
965 log << TestLog::EndSection;
966
967 expectTrue(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
968 expectError(EGL_SUCCESS);
969
970 if (surface != EGL_NO_SURFACE)
971 {
972 expectTrue(eglDestroySurface(display, surface));
973 expectError(EGL_SUCCESS);
974 }
975
976 if (context != EGL_NO_CONTEXT)
977 {
978 expectTrue(eglDestroyContext(display, context));
979 expectError(EGL_SUCCESS);
980 }
981 }
Jarkko Poyry3c827362014-09-02 11:48:52 +0300982 });
983
984 TEGL_ADD_API_CASE(query_context, "eglQueryContext() negative tests",
985 {
986 TestLog& log = m_testCtx.getLog();
987 EGLDisplay display = getDisplay();
988 EGLint value = 0;
989
990 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
991
992 expectFalse(eglQueryContext(EGL_NO_DISPLAY, DE_NULL, EGL_CONFIG_ID, &value));
993 expectError(EGL_BAD_DISPLAY);
994
995 expectFalse(eglQueryContext((EGLDisplay)-1, DE_NULL, EGL_CONFIG_ID, &value));
996 expectError(EGL_BAD_DISPLAY);
997
998 log << TestLog::EndSection;
999
1000 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
1001
1002 expectFalse(eglQueryContext(display, DE_NULL, EGL_CONFIG_ID, &value));
1003 expectError(EGL_BAD_CONTEXT);
1004
1005 expectFalse(eglQueryContext(display, DE_NULL, EGL_CONFIG_ID, &value));
1006 expectError(EGL_BAD_CONTEXT);
1007
1008 log << TestLog::EndSection;
1009
1010 // Create ES2 context.
1011 EGLConfig config = DE_NULL;
1012 EGLContext context = DE_NULL;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -08001013 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
Jarkko Poyry3c827362014-09-02 11:48:52 +03001014
1015 if (gotConfig)
1016 {
1017 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
1018 expectError(EGL_SUCCESS);
1019
1020 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
1021 expectError(EGL_SUCCESS);
1022 }
1023
1024 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid context attribute");
1025
1026 if (context)
1027 {
1028 expectFalse(eglQueryContext(display, context, 0, &value));
1029 expectError(EGL_BAD_ATTRIBUTE);
1030 expectFalse(eglQueryContext(display, context, -1, &value));
1031 expectError(EGL_BAD_ATTRIBUTE);
1032 expectFalse(eglQueryContext(display, context, EGL_RED_SIZE, &value));
1033 expectError(EGL_BAD_ATTRIBUTE);
1034 }
1035
1036 log << TestLog::EndSection;
1037
1038 if (context)
1039 {
1040 expectTrue(eglDestroyContext(display, context));
1041 expectError(EGL_SUCCESS);
1042 }
1043 });
1044
1045 TEGL_ADD_API_CASE(query_string, "eglQueryString() negative tests",
1046 {
1047 TestLog& log = m_testCtx.getLog();
1048 EGLDisplay display = getDisplay();
1049
1050 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1051
1052 expectNull(eglQueryString(EGL_NO_DISPLAY, EGL_VENDOR));
1053 expectError(EGL_BAD_DISPLAY);
1054
1055 expectNull(eglQueryString((EGLDisplay)-1, EGL_VENDOR));
1056 expectError(EGL_BAD_DISPLAY);
1057
1058 log << TestLog::EndSection;
1059
1060 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if name is not an accepted value");
1061
1062 expectNull(eglQueryString(display, 0));
1063 expectError(EGL_BAD_PARAMETER);
1064 expectNull(eglQueryString(display, -1));
1065 expectError(EGL_BAD_PARAMETER);
1066
1067 log << TestLog::EndSection;
1068 });
1069
1070 TEGL_ADD_API_CASE(query_surface, "eglQuerySurface() negative tests",
1071 {
1072 TestLog& log = m_testCtx.getLog();
1073 EGLDisplay display = getDisplay();
1074 EGLint value = 0;
1075
1076 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1077
1078 expectFalse(eglQuerySurface(EGL_NO_DISPLAY, DE_NULL, EGL_CONFIG_ID, &value));
1079 expectError(EGL_BAD_DISPLAY);
1080
1081 expectFalse(eglQuerySurface((EGLDisplay)-1, DE_NULL, EGL_CONFIG_ID, &value));
1082 expectError(EGL_BAD_DISPLAY);
1083
1084 log << TestLog::EndSection;
1085
1086 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1087
1088 expectFalse(eglQuerySurface(display, DE_NULL, EGL_CONFIG_ID, &value));
1089 expectError(EGL_BAD_SURFACE);
1090
1091 expectFalse(eglQuerySurface(display, (EGLSurface)-1, EGL_CONFIG_ID, &value));
1092 expectError(EGL_BAD_SURFACE);
1093
1094 log << TestLog::EndSection;
1095
1096 // Create pbuffer surface.
1097 EGLSurface surface = EGL_NO_SURFACE;
1098 {
1099 EGLConfig config;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -08001100 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +03001101 {
1102 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1103 expectError(EGL_SUCCESS);
1104 }
1105 else
1106 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1107 }
1108
1109 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid surface attribute");
1110
1111 if (surface)
1112 {
1113 expectFalse(eglQuerySurface(display, surface, 0, &value));
1114 expectError(EGL_BAD_ATTRIBUTE);
1115
1116 expectFalse(eglQuerySurface(display, surface, -1, &value));
1117 expectError(EGL_BAD_ATTRIBUTE);
1118 }
1119
1120 log << TestLog::EndSection;
1121
1122 if (surface)
1123 {
1124 eglDestroySurface(display, surface);
1125 expectError(EGL_SUCCESS);
1126 }
1127 });
1128
1129 TEGL_ADD_API_CASE(release_tex_image, "eglReleaseTexImage() negative tests",
1130 {
1131 TestLog& log = m_testCtx.getLog();
1132 EGLDisplay display = getDisplay();
1133
1134 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1135
1136 expectFalse(eglReleaseTexImage(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1137 expectError(EGL_BAD_DISPLAY);
1138
1139 expectFalse(eglReleaseTexImage((EGLDisplay)-1, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1140 expectError(EGL_BAD_DISPLAY);
1141
1142 log << TestLog::EndSection;
1143
1144 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1145
1146 expectFalse(eglReleaseTexImage(display, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1147 expectError(EGL_BAD_SURFACE);
1148
1149 expectFalse(eglReleaseTexImage(display, (EGLSurface)-1, EGL_BACK_BUFFER));
1150 expectError(EGL_BAD_SURFACE);
1151
1152 log << TestLog::EndSection;
1153 });
1154
1155 TEGL_ADD_API_CASE(surface_attrib, "eglSurfaceAttrib() negative tests",
1156 {
1157 TestLog& log = m_testCtx.getLog();
1158 EGLDisplay display = getDisplay();
1159
1160 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1161
1162 expectFalse(eglSurfaceAttrib(EGL_NO_DISPLAY, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1163 expectError(EGL_BAD_DISPLAY);
1164
1165 expectFalse(eglSurfaceAttrib((EGLDisplay)-1, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1166 expectError(EGL_BAD_DISPLAY);
1167
1168 log << TestLog::EndSection;
1169
1170 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1171
1172 expectFalse(eglSurfaceAttrib(display, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1173 expectError(EGL_BAD_SURFACE);
1174
1175 expectFalse(eglSurfaceAttrib(display, (EGLSurface)-1, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1176 expectError(EGL_BAD_SURFACE);
1177
1178 log << TestLog::EndSection;
1179
1180 {
1181 // Create pbuffer surface.
1182 EGLSurface surface = EGL_NO_SURFACE;
1183 {
1184 EGLConfig config;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -08001185 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +03001186 {
1187 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1188 expectError(EGL_SUCCESS);
1189 }
1190 else
1191 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1192 }
1193
1194 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid surface attribute");
1195
1196 if (surface)
1197 {
1198 expectFalse(eglSurfaceAttrib(display, surface, 0, 0));
1199 expectError(EGL_BAD_ATTRIBUTE);
1200
1201 expectFalse(eglSurfaceAttrib(display, surface, -1, 0));
1202 expectError(EGL_BAD_ATTRIBUTE);
1203 }
1204
1205 log << TestLog::EndSection;
1206
1207 if (surface)
1208 {
1209 eglDestroySurface(display, surface);
1210 expectError(EGL_SUCCESS);
1211 }
1212 }
1213
1214 {
1215 // Create pbuffer surface without EGL_MULTISAMPLE_RESOLVE_BOX_BIT.
1216 EGLSurface surface = EGL_NO_SURFACE;
1217 {
1218 EGLConfig config;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -08001219 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT> << notSurfaceBits<EGL_MULTISAMPLE_RESOLVE_BOX_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +03001220 {
1221 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1222 expectError(EGL_SUCCESS);
1223 }
1224 else
1225 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1226 }
1227
1228 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");
1229
1230 if (surface)
1231 {
1232 expectFalse(eglSurfaceAttrib(display, surface, EGL_MULTISAMPLE_RESOLVE, EGL_MULTISAMPLE_RESOLVE_BOX));
1233 expectError(EGL_BAD_MATCH);
1234 }
1235
1236 log << TestLog::EndSection;
1237
1238 if (surface)
1239 {
1240 eglDestroySurface(display, surface);
1241 expectError(EGL_SUCCESS);
1242 }
1243 }
1244
1245 {
1246 // Create pbuffer surface without EGL_SWAP_BEHAVIOR_PRESERVED_BIT.
1247 EGLSurface surface = EGL_NO_SURFACE;
1248 {
1249 EGLConfig config;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -08001250 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT> << notSurfaceBits<EGL_SWAP_BEHAVIOR_PRESERVED_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +03001251 {
1252 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1253 expectError(EGL_SUCCESS);
1254 }
1255 else
1256 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1257 }
1258
1259 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");
1260
1261 if (surface)
1262 {
1263 expectFalse(eglSurfaceAttrib(display, surface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED));
1264 expectError(EGL_BAD_MATCH);
1265 }
1266
1267 log << TestLog::EndSection;
1268
1269 if (surface)
1270 {
1271 eglDestroySurface(display, surface);
1272 expectError(EGL_SUCCESS);
1273 }
1274 }
1275 });
1276
1277 TEGL_ADD_API_CASE(swap_buffers, "eglSwapBuffers() negative tests",
1278 {
1279 TestLog& log = m_testCtx.getLog();
1280 EGLDisplay display = getDisplay();
1281
1282 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1283
1284 expectFalse(eglSwapBuffers(EGL_NO_DISPLAY, DE_NULL));
1285 expectError(EGL_BAD_DISPLAY);
1286
1287 expectFalse(eglSwapBuffers((EGLDisplay)-1, DE_NULL));
1288 expectError(EGL_BAD_DISPLAY);
1289
1290 log << TestLog::EndSection;
1291
1292 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1293
1294 expectFalse(eglSwapBuffers(display, DE_NULL));
1295 expectError(EGL_BAD_SURFACE);
1296
1297 expectFalse(eglSwapBuffers(display, (EGLSurface)-1));
1298 expectError(EGL_BAD_SURFACE);
1299
1300 log << TestLog::EndSection;
1301 });
1302
1303 TEGL_ADD_API_CASE(swap_interval, "eglSwapInterval() negative tests",
1304 {
1305 TestLog& log = m_testCtx.getLog();
1306 EGLDisplay display = getDisplay();
1307
1308 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1309
1310 expectFalse(eglSwapInterval(EGL_NO_DISPLAY, 0));
1311 expectError(EGL_BAD_DISPLAY);
1312
1313 expectFalse(eglSwapInterval((EGLDisplay)-1, 0));
1314 expectError(EGL_BAD_DISPLAY);
1315
1316 log << TestLog::EndSection;
1317
1318 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if there is no current context on the calling thread");
1319
1320 expectFalse(eglSwapInterval(display, 0));
1321 expectError(EGL_BAD_CONTEXT);
1322
1323 log << TestLog::EndSection;
1324 });
1325
1326 TEGL_ADD_API_CASE(terminate, "eglTerminate() negative tests",
1327 {
1328 TestLog& log = m_testCtx.getLog();
1329
1330 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1331
1332 expectFalse(eglTerminate(EGL_NO_DISPLAY));
1333 expectError(EGL_BAD_DISPLAY);
1334
1335 expectFalse(eglTerminate((EGLDisplay)-1));
1336 expectError(EGL_BAD_DISPLAY);
1337
1338 log << TestLog::EndSection;
1339 });
1340
1341 TEGL_ADD_API_CASE(wait_native, "eglWaitNative() negative tests",
1342 {
Mika Isojärvi33142312015-03-18 17:36:00 -07001343 EGLConfig config = DE_NULL;
1344 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << surfaceBits<EGL_WINDOW_BIT>);
Jarkko Poyry3c827362014-09-02 11:48:52 +03001345
Mika Isojärvi33142312015-03-18 17:36:00 -07001346 if (gotConfig)
1347 {
1348 TestLog& log = m_testCtx.getLog();
1349 const Library& egl = m_eglTestCtx.getLibrary();
1350 EGLDisplay display = getDisplay();
1351 const eglu::NativeWindowFactory& factory = eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
1352 de::UniquePtr<eglu::NativeWindow> window (factory.createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(256, 256, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
1353 eglu::UniqueSurface surface (egl, display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, display, config, DE_NULL));
1354 EGLContext context = EGL_NO_CONTEXT;
Jarkko Poyry3c827362014-09-02 11:48:52 +03001355
Mika Isojärvi33142312015-03-18 17:36:00 -07001356 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
1357 expectError(EGL_SUCCESS);
Jarkko Poyry3c827362014-09-02 11:48:52 +03001358
Mika Isojärvi33142312015-03-18 17:36:00 -07001359 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
1360 expectError(EGL_SUCCESS);
1361
1362 expectTrue(eglMakeCurrent(display, *surface, *surface, context));
1363 expectError(EGL_SUCCESS);
1364
Mika Isojärvi62ca5942015-04-13 14:39:04 -07001365 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");
Mika Isojärvi33142312015-03-18 17:36:00 -07001366
Mika Isojärvi62ca5942015-04-13 14:39:04 -07001367 eglWaitNative(-1);
Jarkko Pöyrye087d552015-06-23 11:10:46 -07001368 expectEitherError(EGL_BAD_PARAMETER, EGL_SUCCESS);
Mika Isojärvi33142312015-03-18 17:36:00 -07001369
1370 log << TestLog::EndSection;
1371
1372 expectTrue(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
1373 expectError(EGL_SUCCESS);
1374
1375 if (context != EGL_NO_CONTEXT)
1376 {
1377 expectTrue(eglDestroyContext(display, context));
1378 expectError(EGL_SUCCESS);
1379 }
1380 }
Jarkko Poyry3c827362014-09-02 11:48:52 +03001381 });
1382}
1383
1384} // egl
1385} // deqp