1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program EGL Module
3*35238bceSAndroid Build Coastguard Worker * ---------------------------------------
4*35238bceSAndroid Build Coastguard Worker *
5*35238bceSAndroid Build Coastguard Worker * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker *
7*35238bceSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker *
11*35238bceSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker *
13*35238bceSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker *
19*35238bceSAndroid Build Coastguard Worker *//*!
20*35238bceSAndroid Build Coastguard Worker * \file
21*35238bceSAndroid Build Coastguard Worker * \brief Negative API Tests.
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "teglNegativeApiTests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "teglApiCase.hpp"
26*35238bceSAndroid Build Coastguard Worker
27*35238bceSAndroid Build Coastguard Worker #include "egluNativeDisplay.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "egluNativeWindow.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "egluUtil.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "egluUtil.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "egluUnique.hpp"
32*35238bceSAndroid Build Coastguard Worker
33*35238bceSAndroid Build Coastguard Worker #include "eglwLibrary.hpp"
34*35238bceSAndroid Build Coastguard Worker
35*35238bceSAndroid Build Coastguard Worker #include <memory>
36*35238bceSAndroid Build Coastguard Worker
37*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
38*35238bceSAndroid Build Coastguard Worker
39*35238bceSAndroid Build Coastguard Worker namespace deqp
40*35238bceSAndroid Build Coastguard Worker {
41*35238bceSAndroid Build Coastguard Worker namespace egl
42*35238bceSAndroid Build Coastguard Worker {
43*35238bceSAndroid Build Coastguard Worker
44*35238bceSAndroid Build Coastguard Worker using namespace eglw;
45*35238bceSAndroid Build Coastguard Worker
46*35238bceSAndroid Build Coastguard Worker template <uint32_t Type>
renderable(const eglu::CandidateConfig & c)47*35238bceSAndroid Build Coastguard Worker static bool renderable(const eglu::CandidateConfig &c)
48*35238bceSAndroid Build Coastguard Worker {
49*35238bceSAndroid Build Coastguard Worker return (c.renderableType() & Type) == Type;
50*35238bceSAndroid Build Coastguard Worker }
51*35238bceSAndroid Build Coastguard Worker
52*35238bceSAndroid Build Coastguard Worker template <uint32_t Type>
notRenderable(const eglu::CandidateConfig & c)53*35238bceSAndroid Build Coastguard Worker static bool notRenderable(const eglu::CandidateConfig &c)
54*35238bceSAndroid Build Coastguard Worker {
55*35238bceSAndroid Build Coastguard Worker return (c.renderableType() & Type) == 0;
56*35238bceSAndroid Build Coastguard Worker }
57*35238bceSAndroid Build Coastguard Worker
58*35238bceSAndroid Build Coastguard Worker template <uint32_t Bits>
surfaceBits(const eglu::CandidateConfig & c)59*35238bceSAndroid Build Coastguard Worker static bool surfaceBits(const eglu::CandidateConfig &c)
60*35238bceSAndroid Build Coastguard Worker {
61*35238bceSAndroid Build Coastguard Worker return (c.surfaceType() & Bits) == Bits;
62*35238bceSAndroid Build Coastguard Worker }
63*35238bceSAndroid Build Coastguard Worker
64*35238bceSAndroid Build Coastguard Worker template <uint32_t Bits>
notSurfaceBits(const eglu::CandidateConfig & c)65*35238bceSAndroid Build Coastguard Worker static bool notSurfaceBits(const eglu::CandidateConfig &c)
66*35238bceSAndroid Build Coastguard Worker {
67*35238bceSAndroid Build Coastguard Worker return (c.surfaceType() & Bits) == 0;
68*35238bceSAndroid Build Coastguard Worker }
69*35238bceSAndroid Build Coastguard Worker
NegativeApiTests(EglTestContext & eglTestCtx)70*35238bceSAndroid Build Coastguard Worker NegativeApiTests::NegativeApiTests(EglTestContext &eglTestCtx)
71*35238bceSAndroid Build Coastguard Worker : TestCaseGroup(eglTestCtx, "negative_api", "Negative API Tests")
72*35238bceSAndroid Build Coastguard Worker {
73*35238bceSAndroid Build Coastguard Worker }
74*35238bceSAndroid Build Coastguard Worker
~NegativeApiTests(void)75*35238bceSAndroid Build Coastguard Worker NegativeApiTests::~NegativeApiTests(void)
76*35238bceSAndroid Build Coastguard Worker {
77*35238bceSAndroid Build Coastguard Worker }
78*35238bceSAndroid Build Coastguard Worker
init(void)79*35238bceSAndroid Build Coastguard Worker void NegativeApiTests::init(void)
80*35238bceSAndroid Build Coastguard Worker {
81*35238bceSAndroid Build Coastguard Worker // \todo [2012-10-02 pyry] Add tests for EGL_NOT_INITIALIZED to all functions taking in EGLDisplay
82*35238bceSAndroid Build Coastguard Worker // \todo [2012-10-02 pyry] Implement negative cases for following non-trivial cases:
83*35238bceSAndroid Build Coastguard Worker // * eglBindTexImage()
84*35238bceSAndroid Build Coastguard Worker // - EGL_BAD_ACCESS is generated if buffer is already bound to a texture
85*35238bceSAndroid Build Coastguard Worker // - EGL_BAD_MATCH is generated if the surface attribute EGL_TEXTURE_FORMAT is set to EGL_NO_TEXTURE
86*35238bceSAndroid Build Coastguard Worker // - EGL_BAD_MATCH is generated if buffer is not a valid buffer (currently only EGL_BACK_BUFFER may be specified)
87*35238bceSAndroid Build Coastguard Worker // - EGL_BAD_SURFACE is generated if surface is not a pbuffer surface supporting texture binding
88*35238bceSAndroid Build Coastguard Worker // * eglCopyBuffers()
89*35238bceSAndroid Build Coastguard Worker // - EGL_BAD_NATIVE_PIXMAP is generated if the implementation does not support native pixmaps
90*35238bceSAndroid Build Coastguard Worker // - EGL_BAD_NATIVE_PIXMAP may be generated if native_pixmap is not a valid native pixmap
91*35238bceSAndroid Build Coastguard Worker // - EGL_BAD_MATCH is generated if the format of native_pixmap is not compatible with the color buffer of surface
92*35238bceSAndroid Build Coastguard Worker // * eglCreateContext()
93*35238bceSAndroid Build Coastguard Worker // - EGL_BAD_MATCH is generated if the current rendering API is EGL_NONE
94*35238bceSAndroid Build Coastguard Worker // - 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*35238bceSAndroid Build Coastguard Worker // - 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*35238bceSAndroid Build Coastguard Worker // * eglCreatePbufferFromClientBuffer()
97*35238bceSAndroid Build Coastguard Worker // - various BAD_MATCH, BAD_ACCESS etc. conditions
98*35238bceSAndroid Build Coastguard Worker // * eglCreatePbufferSurface()
99*35238bceSAndroid Build Coastguard Worker // - 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*35238bceSAndroid Build Coastguard Worker // * eglCreatePixmapSurface()
101*35238bceSAndroid Build Coastguard Worker // - EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid pixmap attribute
102*35238bceSAndroid Build Coastguard Worker // - 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*35238bceSAndroid Build Coastguard Worker // - EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute
104*35238bceSAndroid Build Coastguard Worker // * eglCreateWindowSurface()
105*35238bceSAndroid Build Coastguard Worker // - EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid window attribute
106*35238bceSAndroid Build Coastguard Worker // - 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*35238bceSAndroid Build Coastguard Worker // - EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute
108*35238bceSAndroid Build Coastguard Worker // * eglMakeCurrent()
109*35238bceSAndroid Build Coastguard Worker // - EGL_BAD_MATCH is generated if draw or read are not compatible with context
110*35238bceSAndroid Build Coastguard Worker // - 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*35238bceSAndroid Build Coastguard Worker // - 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*35238bceSAndroid Build Coastguard Worker // - EGL_BAD_ACCESS is generated if context is current to some other thread
113*35238bceSAndroid Build Coastguard Worker // - EGL_BAD_NATIVE_PIXMAP may be generated if a native pixmap underlying either draw or read is no longer valid
114*35238bceSAndroid Build Coastguard Worker // - EGL_BAD_NATIVE_WINDOW may be generated if a native window underlying either draw or read is no longer valid
115*35238bceSAndroid Build Coastguard Worker // * eglReleaseTexImage()
116*35238bceSAndroid Build Coastguard Worker // - EGL_BAD_MATCH is generated if buffer is not a valid buffer (currently only EGL_BACK_BUFFER may be specified)
117*35238bceSAndroid Build Coastguard Worker // * eglSwapInterval()
118*35238bceSAndroid Build Coastguard Worker // - EGL_BAD_SURFACE is generated if there is no surface bound to the current context
119*35238bceSAndroid Build Coastguard Worker // * eglWaitNative()
120*35238bceSAndroid Build Coastguard Worker // - 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
121*35238bceSAndroid Build Coastguard Worker
122*35238bceSAndroid Build Coastguard Worker using namespace eglw;
123*35238bceSAndroid Build Coastguard Worker using namespace eglu;
124*35238bceSAndroid Build Coastguard Worker
125*35238bceSAndroid Build Coastguard Worker static const EGLint s_emptyAttribList[] = {EGL_NONE};
126*35238bceSAndroid Build Coastguard Worker static const EGLint s_es1ContextAttribList[] = {EGL_CONTEXT_CLIENT_VERSION, 1, EGL_NONE};
127*35238bceSAndroid Build Coastguard Worker static const EGLint s_es2ContextAttribList[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE};
128*35238bceSAndroid Build Coastguard Worker
129*35238bceSAndroid Build Coastguard Worker static const EGLenum s_renderAPIs[] = {EGL_OPENGL_API, EGL_OPENGL_ES_API, EGL_OPENVG_API};
130*35238bceSAndroid Build Coastguard Worker static const eglu::ConfigFilter s_renderAPIFilters[] = {renderable<EGL_OPENGL_BIT>, renderable<EGL_OPENGL_ES_BIT>,
131*35238bceSAndroid Build Coastguard Worker renderable<EGL_OPENVG_BIT>};
132*35238bceSAndroid Build Coastguard Worker
133*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(bind_api, "eglBindAPI() negative tests", {
134*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
135*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if api is not one of the accepted tokens");
136*35238bceSAndroid Build Coastguard Worker
137*35238bceSAndroid Build Coastguard Worker expectFalse(eglBindAPI(0));
138*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_PARAMETER);
139*35238bceSAndroid Build Coastguard Worker
140*35238bceSAndroid Build Coastguard Worker expectFalse(eglBindAPI(0xfdfdfdfd));
141*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_PARAMETER);
142*35238bceSAndroid Build Coastguard Worker
143*35238bceSAndroid Build Coastguard Worker expectFalse(eglBindAPI((EGLenum)0xffffffff));
144*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_PARAMETER);
145*35238bceSAndroid Build Coastguard Worker
146*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
147*35238bceSAndroid Build Coastguard Worker
148*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if the specified client API is not supported "
149*35238bceSAndroid Build Coastguard Worker "by the EGL display, or no configuration is provided for the specified API.");
150*35238bceSAndroid Build Coastguard Worker
151*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_renderAPIs); ndx++)
152*35238bceSAndroid Build Coastguard Worker {
153*35238bceSAndroid Build Coastguard Worker if (!isAPISupported(s_renderAPIs[ndx]))
154*35238bceSAndroid Build Coastguard Worker {
155*35238bceSAndroid Build Coastguard Worker if (!eglBindAPI(s_renderAPIs[ndx]))
156*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_PARAMETER);
157*35238bceSAndroid Build Coastguard Worker else
158*35238bceSAndroid Build Coastguard Worker {
159*35238bceSAndroid Build Coastguard Worker EGLConfig eglConfig;
160*35238bceSAndroid Build Coastguard Worker expectFalse(getConfig(&eglConfig, FilterList() << s_renderAPIFilters[ndx]));
161*35238bceSAndroid Build Coastguard Worker }
162*35238bceSAndroid Build Coastguard Worker }
163*35238bceSAndroid Build Coastguard Worker }
164*35238bceSAndroid Build Coastguard Worker
165*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
166*35238bceSAndroid Build Coastguard Worker });
167*35238bceSAndroid Build Coastguard Worker
168*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(bind_tex_image, "eglBindTexImage() negative tests", {
169*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
170*35238bceSAndroid Build Coastguard Worker EGLDisplay display = getDisplay();
171*35238bceSAndroid Build Coastguard Worker
172*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
173*35238bceSAndroid Build Coastguard Worker
174*35238bceSAndroid Build Coastguard Worker expectFalse(eglBindTexImage(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_BACK_BUFFER));
175*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
176*35238bceSAndroid Build Coastguard Worker
177*35238bceSAndroid Build Coastguard Worker expectFalse(eglBindTexImage((EGLDisplay)-1, EGL_NO_SURFACE, EGL_BACK_BUFFER));
178*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
179*35238bceSAndroid Build Coastguard Worker
180*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
181*35238bceSAndroid Build Coastguard Worker
182*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
183*35238bceSAndroid Build Coastguard Worker
184*35238bceSAndroid Build Coastguard Worker expectFalse(eglBindTexImage(display, EGL_NO_SURFACE, EGL_BACK_BUFFER));
185*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_SURFACE);
186*35238bceSAndroid Build Coastguard Worker
187*35238bceSAndroid Build Coastguard Worker expectFalse(eglBindTexImage(display, (EGLSurface)-1, EGL_BACK_BUFFER));
188*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_SURFACE);
189*35238bceSAndroid Build Coastguard Worker
190*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
191*35238bceSAndroid Build Coastguard Worker });
192*35238bceSAndroid Build Coastguard Worker
193*35238bceSAndroid Build Coastguard Worker static const EGLint s_validGenericPbufferAttrib[] = {EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE};
194*35238bceSAndroid Build Coastguard Worker
195*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(copy_buffers, "eglCopyBuffers() negative tests", {
196*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
197*35238bceSAndroid Build Coastguard Worker const eglw::Library &egl = m_eglTestCtx.getLibrary();
198*35238bceSAndroid Build Coastguard Worker EGLDisplay display = getDisplay();
199*35238bceSAndroid Build Coastguard Worker const eglu::NativePixmapFactory &factory =
200*35238bceSAndroid Build Coastguard Worker eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
201*35238bceSAndroid Build Coastguard Worker de::UniquePtr<eglu::NativePixmap> pixmap(factory.createPixmap(&m_eglTestCtx.getNativeDisplay(), 64, 64));
202*35238bceSAndroid Build Coastguard Worker EGLConfig config;
203*35238bceSAndroid Build Coastguard Worker
204*35238bceSAndroid Build Coastguard Worker {
205*35238bceSAndroid Build Coastguard Worker if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
206*35238bceSAndroid Build Coastguard Worker {
207*35238bceSAndroid Build Coastguard Worker eglu::UniqueSurface surface(egl, display,
208*35238bceSAndroid Build Coastguard Worker egl.createPbufferSurface(display, config, s_validGenericPbufferAttrib));
209*35238bceSAndroid Build Coastguard Worker
210*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1",
211*35238bceSAndroid Build Coastguard Worker "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
212*35238bceSAndroid Build Coastguard Worker
213*35238bceSAndroid Build Coastguard Worker expectFalse(eglCopyBuffers(EGL_NO_DISPLAY, EGL_NO_SURFACE, pixmap->getLegacyNative()));
214*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
215*35238bceSAndroid Build Coastguard Worker
216*35238bceSAndroid Build Coastguard Worker expectFalse(eglCopyBuffers((EGLDisplay)-1, EGL_NO_SURFACE, pixmap->getLegacyNative()));
217*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
218*35238bceSAndroid Build Coastguard Worker
219*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
220*35238bceSAndroid Build Coastguard Worker }
221*35238bceSAndroid Build Coastguard Worker }
222*35238bceSAndroid Build Coastguard Worker
223*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
224*35238bceSAndroid Build Coastguard Worker
225*35238bceSAndroid Build Coastguard Worker expectFalse(eglCopyBuffers(display, EGL_NO_SURFACE, pixmap->getLegacyNative()));
226*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_SURFACE);
227*35238bceSAndroid Build Coastguard Worker
228*35238bceSAndroid Build Coastguard Worker expectFalse(eglCopyBuffers(display, (EGLSurface)-1, pixmap->getLegacyNative()));
229*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_SURFACE);
230*35238bceSAndroid Build Coastguard Worker
231*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
232*35238bceSAndroid Build Coastguard Worker });
233*35238bceSAndroid Build Coastguard Worker
234*35238bceSAndroid Build Coastguard Worker static const EGLint s_invalidChooseConfigAttribList0[] = {0, EGL_NONE};
235*35238bceSAndroid Build Coastguard Worker static const EGLint s_invalidChooseConfigAttribList1[] = {(EGLint)0xffffffff};
236*35238bceSAndroid Build Coastguard Worker static const EGLint s_invalidChooseConfigAttribList2[] = {EGL_BIND_TO_TEXTURE_RGB, 4, EGL_NONE};
237*35238bceSAndroid Build Coastguard Worker static const EGLint s_invalidChooseConfigAttribList3[] = {EGL_BIND_TO_TEXTURE_RGBA, 5, EGL_NONE};
238*35238bceSAndroid Build Coastguard Worker static const EGLint s_invalidChooseConfigAttribList4[] = {EGL_COLOR_BUFFER_TYPE, 0, EGL_NONE};
239*35238bceSAndroid Build Coastguard Worker static const EGLint s_invalidChooseConfigAttribList5[] = {EGL_NATIVE_RENDERABLE, 6, EGL_NONE};
240*35238bceSAndroid Build Coastguard Worker static const EGLint s_invalidChooseConfigAttribList6[] = {EGL_TRANSPARENT_TYPE, 6, EGL_NONE};
241*35238bceSAndroid Build Coastguard Worker static const EGLint *s_invalidChooseConfigAttribLists[] = {
242*35238bceSAndroid Build Coastguard Worker &s_invalidChooseConfigAttribList0[0], &s_invalidChooseConfigAttribList1[0],
243*35238bceSAndroid Build Coastguard Worker &s_invalidChooseConfigAttribList2[0], &s_invalidChooseConfigAttribList3[0],
244*35238bceSAndroid Build Coastguard Worker &s_invalidChooseConfigAttribList4[0], &s_invalidChooseConfigAttribList5[0],
245*35238bceSAndroid Build Coastguard Worker &s_invalidChooseConfigAttribList6[0]};
246*35238bceSAndroid Build Coastguard Worker
247*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(choose_config, "eglChooseConfig() negative tests", {
248*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
249*35238bceSAndroid Build Coastguard Worker EGLDisplay display = getDisplay();
250*35238bceSAndroid Build Coastguard Worker EGLConfig configs[1];
251*35238bceSAndroid Build Coastguard Worker EGLint numConfigs;
252*35238bceSAndroid Build Coastguard Worker
253*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
254*35238bceSAndroid Build Coastguard Worker
255*35238bceSAndroid Build Coastguard Worker expectFalse(
256*35238bceSAndroid Build Coastguard Worker eglChooseConfig(EGL_NO_DISPLAY, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
257*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
258*35238bceSAndroid Build Coastguard Worker
259*35238bceSAndroid Build Coastguard Worker expectFalse(
260*35238bceSAndroid Build Coastguard Worker eglChooseConfig((EGLDisplay)-1, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
261*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
262*35238bceSAndroid Build Coastguard Worker
263*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
264*35238bceSAndroid Build Coastguard Worker
265*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test2", "EGL_BAD_ATTRIBUTE is generated if attribute_list contains an invalid frame "
266*35238bceSAndroid Build Coastguard Worker "buffer configuration attribute");
267*35238bceSAndroid Build Coastguard Worker
268*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidChooseConfigAttribLists); ndx++)
269*35238bceSAndroid Build Coastguard Worker {
270*35238bceSAndroid Build Coastguard Worker expectFalse(eglChooseConfig(display, s_invalidChooseConfigAttribLists[ndx], &configs[0],
271*35238bceSAndroid Build Coastguard Worker DE_LENGTH_OF_ARRAY(configs), &numConfigs));
272*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_ATTRIBUTE);
273*35238bceSAndroid Build Coastguard Worker }
274*35238bceSAndroid Build Coastguard Worker
275*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
276*35238bceSAndroid Build Coastguard Worker
277*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test3", "EGL_BAD_PARAMETER is generated if num_config is NULL");
278*35238bceSAndroid Build Coastguard Worker
279*35238bceSAndroid Build Coastguard Worker expectFalse(eglChooseConfig(display, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), DE_NULL));
280*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_PARAMETER);
281*35238bceSAndroid Build Coastguard Worker
282*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
283*35238bceSAndroid Build Coastguard Worker });
284*35238bceSAndroid Build Coastguard Worker
285*35238bceSAndroid Build Coastguard Worker static const EGLint s_invalidCreateContextAttribList0[] = {0, EGL_NONE};
286*35238bceSAndroid Build Coastguard Worker static const EGLint s_invalidCreateContextAttribList1[] = {(EGLint)0xffffffff};
287*35238bceSAndroid Build Coastguard Worker
288*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(create_context, "eglCreateContext() negative tests", {
289*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
290*35238bceSAndroid Build Coastguard Worker EGLDisplay display = getDisplay();
291*35238bceSAndroid Build Coastguard Worker
292*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
293*35238bceSAndroid Build Coastguard Worker
294*35238bceSAndroid Build Coastguard Worker expectNoContext(eglCreateContext(EGL_NO_DISPLAY, DE_NULL, EGL_NO_CONTEXT, s_emptyAttribList));
295*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
296*35238bceSAndroid Build Coastguard Worker
297*35238bceSAndroid Build Coastguard Worker expectNoContext(eglCreateContext((EGLDisplay)-1, DE_NULL, EGL_NO_CONTEXT, s_emptyAttribList));
298*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
299*35238bceSAndroid Build Coastguard Worker
300*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
301*35238bceSAndroid Build Coastguard Worker
302*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test2",
303*35238bceSAndroid Build Coastguard Worker "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
304*35238bceSAndroid Build Coastguard Worker
305*35238bceSAndroid Build Coastguard Worker expectNoContext(eglCreateContext(display, (EGLConfig)-1, EGL_NO_CONTEXT, s_emptyAttribList));
306*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_CONFIG);
307*35238bceSAndroid Build Coastguard Worker
308*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
309*35238bceSAndroid Build Coastguard Worker
310*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test3",
311*35238bceSAndroid Build Coastguard Worker "EGL_BAD_CONFIG is generated if config does not support the current rendering API");
312*35238bceSAndroid Build Coastguard Worker
313*35238bceSAndroid Build Coastguard Worker if (isAPISupported(EGL_OPENGL_API))
314*35238bceSAndroid Build Coastguard Worker {
315*35238bceSAndroid Build Coastguard Worker EGLConfig es1OnlyConfig;
316*35238bceSAndroid Build Coastguard Worker if (getConfig(&es1OnlyConfig, FilterList()
317*35238bceSAndroid Build Coastguard Worker << renderable<EGL_OPENGL_ES_BIT> << notRenderable<EGL_OPENGL_BIT>))
318*35238bceSAndroid Build Coastguard Worker {
319*35238bceSAndroid Build Coastguard Worker expectTrue(eglBindAPI(EGL_OPENGL_API));
320*35238bceSAndroid Build Coastguard Worker expectNoContext(eglCreateContext(display, es1OnlyConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
321*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_CONFIG);
322*35238bceSAndroid Build Coastguard Worker }
323*35238bceSAndroid Build Coastguard Worker
324*35238bceSAndroid Build Coastguard Worker EGLConfig es2OnlyConfig;
325*35238bceSAndroid Build Coastguard Worker if (getConfig(&es2OnlyConfig, FilterList()
326*35238bceSAndroid Build Coastguard Worker << renderable<EGL_OPENGL_ES2_BIT> << notRenderable<EGL_OPENGL_BIT>))
327*35238bceSAndroid Build Coastguard Worker {
328*35238bceSAndroid Build Coastguard Worker expectTrue(eglBindAPI(EGL_OPENGL_API));
329*35238bceSAndroid Build Coastguard Worker expectNoContext(eglCreateContext(display, es2OnlyConfig, EGL_NO_CONTEXT, s_es2ContextAttribList));
330*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_CONFIG);
331*35238bceSAndroid Build Coastguard Worker }
332*35238bceSAndroid Build Coastguard Worker
333*35238bceSAndroid Build Coastguard Worker EGLConfig vgOnlyConfig;
334*35238bceSAndroid Build Coastguard Worker if (getConfig(&vgOnlyConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notRenderable<EGL_OPENGL_BIT>))
335*35238bceSAndroid Build Coastguard Worker {
336*35238bceSAndroid Build Coastguard Worker expectTrue(eglBindAPI(EGL_OPENGL_API));
337*35238bceSAndroid Build Coastguard Worker expectNoContext(eglCreateContext(display, vgOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
338*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_CONFIG);
339*35238bceSAndroid Build Coastguard Worker }
340*35238bceSAndroid Build Coastguard Worker }
341*35238bceSAndroid Build Coastguard Worker
342*35238bceSAndroid Build Coastguard Worker if (isAPISupported(EGL_OPENGL_ES_API))
343*35238bceSAndroid Build Coastguard Worker {
344*35238bceSAndroid Build Coastguard Worker EGLConfig glOnlyConfig;
345*35238bceSAndroid Build Coastguard Worker if (getConfig(&glOnlyConfig,
346*35238bceSAndroid Build Coastguard Worker FilterList() << renderable<
347*35238bceSAndroid Build Coastguard Worker EGL_OPENGL_BIT> << notRenderable<EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT>))
348*35238bceSAndroid Build Coastguard Worker {
349*35238bceSAndroid Build Coastguard Worker expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
350*35238bceSAndroid Build Coastguard Worker expectNoContext(eglCreateContext(display, glOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
351*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_CONFIG);
352*35238bceSAndroid Build Coastguard Worker }
353*35238bceSAndroid Build Coastguard Worker
354*35238bceSAndroid Build Coastguard Worker EGLConfig vgOnlyConfig;
355*35238bceSAndroid Build Coastguard Worker if (getConfig(&vgOnlyConfig,
356*35238bceSAndroid Build Coastguard Worker FilterList() << renderable<
357*35238bceSAndroid Build Coastguard Worker EGL_OPENVG_BIT> << notRenderable<EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT>))
358*35238bceSAndroid Build Coastguard Worker {
359*35238bceSAndroid Build Coastguard Worker expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
360*35238bceSAndroid Build Coastguard Worker expectNoContext(eglCreateContext(display, vgOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
361*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_CONFIG);
362*35238bceSAndroid Build Coastguard Worker }
363*35238bceSAndroid Build Coastguard Worker }
364*35238bceSAndroid Build Coastguard Worker
365*35238bceSAndroid Build Coastguard Worker if (isAPISupported(EGL_OPENVG_API))
366*35238bceSAndroid Build Coastguard Worker {
367*35238bceSAndroid Build Coastguard Worker EGLConfig glOnlyConfig;
368*35238bceSAndroid Build Coastguard Worker if (getConfig(&glOnlyConfig, FilterList() << renderable<EGL_OPENGL_BIT> << notRenderable<EGL_OPENVG_BIT>))
369*35238bceSAndroid Build Coastguard Worker {
370*35238bceSAndroid Build Coastguard Worker expectTrue(eglBindAPI(EGL_OPENVG_API));
371*35238bceSAndroid Build Coastguard Worker expectNoContext(eglCreateContext(display, glOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
372*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_CONFIG);
373*35238bceSAndroid Build Coastguard Worker }
374*35238bceSAndroid Build Coastguard Worker
375*35238bceSAndroid Build Coastguard Worker EGLConfig es1OnlyConfig;
376*35238bceSAndroid Build Coastguard Worker if (getConfig(&es1OnlyConfig, FilterList()
377*35238bceSAndroid Build Coastguard Worker << renderable<EGL_OPENGL_ES_BIT> << notRenderable<EGL_OPENVG_BIT>))
378*35238bceSAndroid Build Coastguard Worker {
379*35238bceSAndroid Build Coastguard Worker expectTrue(eglBindAPI(EGL_OPENVG_API));
380*35238bceSAndroid Build Coastguard Worker expectNoContext(eglCreateContext(display, es1OnlyConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
381*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_CONFIG);
382*35238bceSAndroid Build Coastguard Worker }
383*35238bceSAndroid Build Coastguard Worker
384*35238bceSAndroid Build Coastguard Worker EGLConfig es2OnlyConfig;
385*35238bceSAndroid Build Coastguard Worker if (getConfig(&es2OnlyConfig, FilterList()
386*35238bceSAndroid Build Coastguard Worker << renderable<EGL_OPENGL_ES2_BIT> << notRenderable<EGL_OPENVG_BIT>))
387*35238bceSAndroid Build Coastguard Worker {
388*35238bceSAndroid Build Coastguard Worker expectTrue(eglBindAPI(EGL_OPENVG_API));
389*35238bceSAndroid Build Coastguard Worker expectNoContext(eglCreateContext(display, es2OnlyConfig, EGL_NO_CONTEXT, s_es2ContextAttribList));
390*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_CONFIG);
391*35238bceSAndroid Build Coastguard Worker }
392*35238bceSAndroid Build Coastguard Worker }
393*35238bceSAndroid Build Coastguard Worker
394*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
395*35238bceSAndroid Build Coastguard Worker
396*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test4",
397*35238bceSAndroid Build Coastguard Worker "EGL_BAD_CONFIG or EGL_BAD_MATCH is generated if OpenGL ES 1.x context is requested "
398*35238bceSAndroid Build Coastguard Worker "and EGL_RENDERABLE_TYPE attribute of config does not contain EGL_OPENGL_ES_BIT");
399*35238bceSAndroid Build Coastguard Worker
400*35238bceSAndroid Build Coastguard Worker if (isAPISupported(EGL_OPENGL_ES_API))
401*35238bceSAndroid Build Coastguard Worker {
402*35238bceSAndroid Build Coastguard Worker EGLConfig notES1Config;
403*35238bceSAndroid Build Coastguard Worker if (getConfig(¬ES1Config, FilterList() << notRenderable<EGL_OPENGL_ES_BIT>))
404*35238bceSAndroid Build Coastguard Worker {
405*35238bceSAndroid Build Coastguard Worker // EGL 1.4, EGL 1.5, and EGL_KHR_create_context contain contradictory language about the expected error.
406*35238bceSAndroid Build Coastguard Worker Version version = eglu::getVersion(m_eglTestCtx.getLibrary(), display);
407*35238bceSAndroid Build Coastguard Worker bool hasKhrCreateContext =
408*35238bceSAndroid Build Coastguard Worker eglu::hasExtension(m_eglTestCtx.getLibrary(), display, "EGL_KHR_create_context");
409*35238bceSAndroid Build Coastguard Worker
410*35238bceSAndroid Build Coastguard Worker expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
411*35238bceSAndroid Build Coastguard Worker expectNoContext(eglCreateContext(display, notES1Config, EGL_NO_CONTEXT, s_es1ContextAttribList));
412*35238bceSAndroid Build Coastguard Worker if (hasKhrCreateContext)
413*35238bceSAndroid Build Coastguard Worker expectEitherError(EGL_BAD_CONFIG, EGL_BAD_MATCH);
414*35238bceSAndroid Build Coastguard Worker else
415*35238bceSAndroid Build Coastguard Worker {
416*35238bceSAndroid Build Coastguard Worker if (version >= eglu::Version(1, 5))
417*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_MATCH);
418*35238bceSAndroid Build Coastguard Worker else
419*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_CONFIG);
420*35238bceSAndroid Build Coastguard Worker }
421*35238bceSAndroid Build Coastguard Worker }
422*35238bceSAndroid Build Coastguard Worker }
423*35238bceSAndroid Build Coastguard Worker
424*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
425*35238bceSAndroid Build Coastguard Worker
426*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test5",
427*35238bceSAndroid Build Coastguard Worker "EGL_BAD_CONFIG or EGL_BAD_MATCH is generated if OpenGL ES 2.x context is requested "
428*35238bceSAndroid Build Coastguard Worker "and EGL_RENDERABLE_TYPE attribute of config does not contain EGL_OPENGL_ES2_BIT");
429*35238bceSAndroid Build Coastguard Worker
430*35238bceSAndroid Build Coastguard Worker if (isAPISupported(EGL_OPENGL_ES_API))
431*35238bceSAndroid Build Coastguard Worker {
432*35238bceSAndroid Build Coastguard Worker EGLConfig notES2Config;
433*35238bceSAndroid Build Coastguard Worker if (getConfig(¬ES2Config, FilterList() << notRenderable<EGL_OPENGL_ES2_BIT>))
434*35238bceSAndroid Build Coastguard Worker {
435*35238bceSAndroid Build Coastguard Worker // EGL 1.4, EGL 1.5, and EGL_KHR_create_context contain contradictory language about the expected error.
436*35238bceSAndroid Build Coastguard Worker Version version = eglu::getVersion(m_eglTestCtx.getLibrary(), display);
437*35238bceSAndroid Build Coastguard Worker bool hasKhrCreateContext =
438*35238bceSAndroid Build Coastguard Worker eglu::hasExtension(m_eglTestCtx.getLibrary(), display, "EGL_KHR_create_context");
439*35238bceSAndroid Build Coastguard Worker
440*35238bceSAndroid Build Coastguard Worker expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
441*35238bceSAndroid Build Coastguard Worker expectNoContext(eglCreateContext(display, notES2Config, EGL_NO_CONTEXT, s_es2ContextAttribList));
442*35238bceSAndroid Build Coastguard Worker if (hasKhrCreateContext)
443*35238bceSAndroid Build Coastguard Worker expectEitherError(EGL_BAD_CONFIG, EGL_BAD_MATCH);
444*35238bceSAndroid Build Coastguard Worker else
445*35238bceSAndroid Build Coastguard Worker {
446*35238bceSAndroid Build Coastguard Worker if (version >= eglu::Version(1, 5))
447*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_MATCH);
448*35238bceSAndroid Build Coastguard Worker else
449*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_CONFIG);
450*35238bceSAndroid Build Coastguard Worker }
451*35238bceSAndroid Build Coastguard Worker }
452*35238bceSAndroid Build Coastguard Worker }
453*35238bceSAndroid Build Coastguard Worker
454*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
455*35238bceSAndroid Build Coastguard Worker
456*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test6",
457*35238bceSAndroid Build Coastguard Worker "EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid context attribute");
458*35238bceSAndroid Build Coastguard Worker
459*35238bceSAndroid Build Coastguard Worker if (isAPISupported(EGL_OPENGL_API) &&
460*35238bceSAndroid Build Coastguard Worker !eglu::hasExtension(m_eglTestCtx.getLibrary(), display, "EGL_KHR_create_context"))
461*35238bceSAndroid Build Coastguard Worker {
462*35238bceSAndroid Build Coastguard Worker EGLConfig glConfig;
463*35238bceSAndroid Build Coastguard Worker if (getConfig(&glConfig, FilterList() << renderable<EGL_OPENGL_BIT>))
464*35238bceSAndroid Build Coastguard Worker {
465*35238bceSAndroid Build Coastguard Worker expectTrue(eglBindAPI(EGL_OPENGL_API));
466*35238bceSAndroid Build Coastguard Worker expectNoContext(eglCreateContext(display, glConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
467*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_ATTRIBUTE);
468*35238bceSAndroid Build Coastguard Worker }
469*35238bceSAndroid Build Coastguard Worker }
470*35238bceSAndroid Build Coastguard Worker
471*35238bceSAndroid Build Coastguard Worker if (isAPISupported(EGL_OPENVG_API))
472*35238bceSAndroid Build Coastguard Worker {
473*35238bceSAndroid Build Coastguard Worker EGLConfig vgConfig;
474*35238bceSAndroid Build Coastguard Worker if (getConfig(&vgConfig, FilterList() << renderable<EGL_OPENVG_BIT>))
475*35238bceSAndroid Build Coastguard Worker {
476*35238bceSAndroid Build Coastguard Worker expectTrue(eglBindAPI(EGL_OPENVG_API));
477*35238bceSAndroid Build Coastguard Worker expectNoContext(eglCreateContext(display, vgConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
478*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_ATTRIBUTE);
479*35238bceSAndroid Build Coastguard Worker }
480*35238bceSAndroid Build Coastguard Worker }
481*35238bceSAndroid Build Coastguard Worker
482*35238bceSAndroid Build Coastguard Worker if (isAPISupported(EGL_OPENGL_ES_API))
483*35238bceSAndroid Build Coastguard Worker {
484*35238bceSAndroid Build Coastguard Worker bool gotConfig = false;
485*35238bceSAndroid Build Coastguard Worker EGLConfig esConfig;
486*35238bceSAndroid Build Coastguard Worker
487*35238bceSAndroid Build Coastguard Worker gotConfig = getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT>) ||
488*35238bceSAndroid Build Coastguard Worker getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
489*35238bceSAndroid Build Coastguard Worker
490*35238bceSAndroid Build Coastguard Worker if (gotConfig)
491*35238bceSAndroid Build Coastguard Worker {
492*35238bceSAndroid Build Coastguard Worker expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
493*35238bceSAndroid Build Coastguard Worker expectNoContext(eglCreateContext(display, esConfig, EGL_NO_CONTEXT, s_invalidCreateContextAttribList0));
494*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_ATTRIBUTE);
495*35238bceSAndroid Build Coastguard Worker expectNoContext(eglCreateContext(display, esConfig, EGL_NO_CONTEXT, s_invalidCreateContextAttribList1));
496*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_ATTRIBUTE);
497*35238bceSAndroid Build Coastguard Worker }
498*35238bceSAndroid Build Coastguard Worker }
499*35238bceSAndroid Build Coastguard Worker
500*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
501*35238bceSAndroid Build Coastguard Worker });
502*35238bceSAndroid Build Coastguard Worker
503*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(create_pbuffer_from_client_buffer, "eglCreatePbufferFromClientBuffer() negative tests", {
504*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
505*35238bceSAndroid Build Coastguard Worker EGLDisplay display = getDisplay();
506*35238bceSAndroid Build Coastguard Worker EGLConfig anyConfig;
507*35238bceSAndroid Build Coastguard Worker EGLint unused = 0;
508*35238bceSAndroid Build Coastguard Worker
509*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
510*35238bceSAndroid Build Coastguard Worker
511*35238bceSAndroid Build Coastguard Worker expectNoSurface(eglCreatePbufferFromClientBuffer(EGL_NO_DISPLAY, EGL_OPENVG_IMAGE, 0, (EGLConfig)0, DE_NULL));
512*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
513*35238bceSAndroid Build Coastguard Worker
514*35238bceSAndroid Build Coastguard Worker expectNoSurface(eglCreatePbufferFromClientBuffer((EGLDisplay)-1, EGL_OPENVG_IMAGE, 0, (EGLConfig)0, DE_NULL));
515*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
516*35238bceSAndroid Build Coastguard Worker
517*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
518*35238bceSAndroid Build Coastguard Worker
519*35238bceSAndroid Build Coastguard Worker if (isAPISupported(EGL_OPENVG_API))
520*35238bceSAndroid Build Coastguard Worker {
521*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test2", "EGL_BAD_CONFIG or EGL_BAD_PARAMETER is generated if config is not an EGL "
522*35238bceSAndroid Build Coastguard Worker "frame buffer configuration and if buffer is not valid OpenVG image");
523*35238bceSAndroid Build Coastguard Worker
524*35238bceSAndroid Build Coastguard Worker expectNoSurface(eglCreatePbufferFromClientBuffer(display, EGL_OPENVG_IMAGE, (EGLClientBuffer)-1,
525*35238bceSAndroid Build Coastguard Worker (EGLConfig)-1, DE_NULL));
526*35238bceSAndroid Build Coastguard Worker expectEitherError(EGL_BAD_CONFIG, EGL_BAD_PARAMETER);
527*35238bceSAndroid Build Coastguard Worker
528*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
529*35238bceSAndroid Build Coastguard Worker
530*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test3", "EGL_BAD_PARAMETER is generated if buftype is not EGL_OPENVG_IMAGE");
531*35238bceSAndroid Build Coastguard Worker
532*35238bceSAndroid Build Coastguard Worker expectTrue(eglGetConfigs(display, &anyConfig, 1, &unused));
533*35238bceSAndroid Build Coastguard Worker
534*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
535*35238bceSAndroid Build Coastguard Worker
536*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test4", "EGL_BAD_PARAMETER is generated if buffer is not valid OpenVG image");
537*35238bceSAndroid Build Coastguard Worker expectNoSurface(
538*35238bceSAndroid Build Coastguard Worker eglCreatePbufferFromClientBuffer(display, EGL_OPENVG_IMAGE, (EGLClientBuffer)-1, anyConfig, DE_NULL));
539*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_PARAMETER);
540*35238bceSAndroid Build Coastguard Worker
541*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
542*35238bceSAndroid Build Coastguard Worker }
543*35238bceSAndroid Build Coastguard Worker });
544*35238bceSAndroid Build Coastguard Worker
545*35238bceSAndroid Build Coastguard Worker static const EGLint s_invalidGenericPbufferAttrib0[] = {0, EGL_NONE};
546*35238bceSAndroid Build Coastguard Worker static const EGLint s_invalidGenericPbufferAttrib1[] = {(EGLint)0xffffffff};
547*35238bceSAndroid Build Coastguard Worker static const EGLint s_negativeWidthPbufferAttrib[] = {EGL_WIDTH, -1, EGL_HEIGHT, 64, EGL_NONE};
548*35238bceSAndroid Build Coastguard Worker static const EGLint s_negativeHeightPbufferAttrib[] = {EGL_WIDTH, 64, EGL_HEIGHT, -1, EGL_NONE};
549*35238bceSAndroid Build Coastguard Worker static const EGLint s_negativeWidthAndHeightPbufferAttrib[] = {EGL_WIDTH, -1, EGL_HEIGHT, -1, EGL_NONE};
550*35238bceSAndroid Build Coastguard Worker static const EGLint *s_invalidGenericPbufferAttribs[] = {
551*35238bceSAndroid Build Coastguard Worker s_invalidGenericPbufferAttrib0,
552*35238bceSAndroid Build Coastguard Worker s_invalidGenericPbufferAttrib1,
553*35238bceSAndroid Build Coastguard Worker };
554*35238bceSAndroid Build Coastguard Worker
555*35238bceSAndroid Build Coastguard Worker static const EGLint s_invalidNoEsPbufferAttrib0[] = {EGL_MIPMAP_TEXTURE, EGL_TRUE, EGL_WIDTH, 64,
556*35238bceSAndroid Build Coastguard Worker EGL_HEIGHT, 64, EGL_NONE};
557*35238bceSAndroid Build Coastguard Worker static const EGLint s_invalidNoEsPbufferAttrib1[] = {
558*35238bceSAndroid Build Coastguard Worker EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE};
559*35238bceSAndroid Build Coastguard Worker static const EGLint s_invalidNoEsPbufferAttrib2[] = {
560*35238bceSAndroid Build Coastguard Worker EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE};
561*35238bceSAndroid Build Coastguard Worker static const EGLint *s_invalidNoEsPbufferAttribs[] = {s_invalidNoEsPbufferAttrib0, s_invalidNoEsPbufferAttrib1,
562*35238bceSAndroid Build Coastguard Worker s_invalidNoEsPbufferAttrib2};
563*35238bceSAndroid Build Coastguard Worker
564*35238bceSAndroid Build Coastguard Worker static const EGLint s_invalidEsPbufferAttrib0[] = {EGL_TEXTURE_FORMAT,
565*35238bceSAndroid Build Coastguard Worker EGL_NO_TEXTURE,
566*35238bceSAndroid Build Coastguard Worker EGL_TEXTURE_TARGET,
567*35238bceSAndroid Build Coastguard Worker EGL_TEXTURE_2D,
568*35238bceSAndroid Build Coastguard Worker EGL_WIDTH,
569*35238bceSAndroid Build Coastguard Worker 64,
570*35238bceSAndroid Build Coastguard Worker EGL_HEIGHT,
571*35238bceSAndroid Build Coastguard Worker 64,
572*35238bceSAndroid Build Coastguard Worker EGL_NONE};
573*35238bceSAndroid Build Coastguard Worker static const EGLint s_invalidEsPbufferAttrib1[] = {EGL_TEXTURE_FORMAT,
574*35238bceSAndroid Build Coastguard Worker EGL_TEXTURE_RGBA,
575*35238bceSAndroid Build Coastguard Worker EGL_TEXTURE_TARGET,
576*35238bceSAndroid Build Coastguard Worker EGL_NO_TEXTURE,
577*35238bceSAndroid Build Coastguard Worker EGL_WIDTH,
578*35238bceSAndroid Build Coastguard Worker 64,
579*35238bceSAndroid Build Coastguard Worker EGL_HEIGHT,
580*35238bceSAndroid Build Coastguard Worker 64,
581*35238bceSAndroid Build Coastguard Worker EGL_NONE};
582*35238bceSAndroid Build Coastguard Worker static const EGLint *s_invalidEsPbufferAttribs[] = {s_invalidEsPbufferAttrib0, s_invalidEsPbufferAttrib1};
583*35238bceSAndroid Build Coastguard Worker
584*35238bceSAndroid Build Coastguard Worker static const EGLint s_vgPreMultAlphaPbufferAttrib[] = {
585*35238bceSAndroid Build Coastguard Worker EGL_ALPHA_FORMAT, EGL_ALPHA_FORMAT_PRE, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE};
586*35238bceSAndroid Build Coastguard Worker static const EGLint s_vgLinearColorspacePbufferAttrib[] = {
587*35238bceSAndroid Build Coastguard Worker EGL_COLORSPACE, EGL_VG_COLORSPACE_LINEAR, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE};
588*35238bceSAndroid Build Coastguard Worker
589*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(create_pbuffer_surface, "eglCreatePbufferSurface() negative tests", {
590*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
591*35238bceSAndroid Build Coastguard Worker EGLDisplay display = getDisplay();
592*35238bceSAndroid Build Coastguard Worker
593*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
594*35238bceSAndroid Build Coastguard Worker
595*35238bceSAndroid Build Coastguard Worker expectNoSurface(eglCreatePbufferSurface(EGL_NO_DISPLAY, DE_NULL, s_emptyAttribList));
596*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
597*35238bceSAndroid Build Coastguard Worker
598*35238bceSAndroid Build Coastguard Worker expectNoSurface(eglCreatePbufferSurface((EGLDisplay)-1, DE_NULL, s_emptyAttribList));
599*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
600*35238bceSAndroid Build Coastguard Worker
601*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
602*35238bceSAndroid Build Coastguard Worker
603*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test2",
604*35238bceSAndroid Build Coastguard Worker "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
605*35238bceSAndroid Build Coastguard Worker
606*35238bceSAndroid Build Coastguard Worker expectNoSurface(eglCreatePbufferSurface(display, (EGLConfig)-1, s_emptyAttribList));
607*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_CONFIG);
608*35238bceSAndroid Build Coastguard Worker
609*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
610*35238bceSAndroid Build Coastguard Worker
611*35238bceSAndroid Build Coastguard Worker log << TestLog::Section(
612*35238bceSAndroid Build Coastguard Worker "Test3", "EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid pixel buffer attribute");
613*35238bceSAndroid Build Coastguard Worker
614*35238bceSAndroid Build Coastguard Worker // Generic pbuffer-capable config
615*35238bceSAndroid Build Coastguard Worker EGLConfig genericConfig;
616*35238bceSAndroid Build Coastguard Worker if (getConfig(&genericConfig, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
617*35238bceSAndroid Build Coastguard Worker {
618*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidGenericPbufferAttribs); ndx++)
619*35238bceSAndroid Build Coastguard Worker {
620*35238bceSAndroid Build Coastguard Worker expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_invalidGenericPbufferAttribs[ndx]));
621*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_ATTRIBUTE);
622*35238bceSAndroid Build Coastguard Worker }
623*35238bceSAndroid Build Coastguard Worker }
624*35238bceSAndroid Build Coastguard Worker
625*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
626*35238bceSAndroid Build Coastguard Worker
627*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test4",
628*35238bceSAndroid Build Coastguard Worker "EGL_BAD_MATCH is generated if config does not support rendering to pixel buffers");
629*35238bceSAndroid Build Coastguard Worker
630*35238bceSAndroid Build Coastguard Worker EGLConfig noPbufferConfig;
631*35238bceSAndroid Build Coastguard Worker if (getConfig(&noPbufferConfig, FilterList() << notSurfaceBits<EGL_PBUFFER_BIT>))
632*35238bceSAndroid Build Coastguard Worker {
633*35238bceSAndroid Build Coastguard Worker expectNoSurface(eglCreatePbufferSurface(display, noPbufferConfig, s_validGenericPbufferAttrib));
634*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_MATCH);
635*35238bceSAndroid Build Coastguard Worker }
636*35238bceSAndroid Build Coastguard Worker
637*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
638*35238bceSAndroid Build Coastguard Worker
639*35238bceSAndroid Build Coastguard Worker log << TestLog::Section(
640*35238bceSAndroid Build Coastguard Worker "Test5", "EGL_BAD_ATTRIBUTE is generated if attrib_list contains any of the attributes EGL_MIPMAP_TEXTURE, "
641*35238bceSAndroid Build Coastguard Worker "EGL_TEXTURE_FORMAT, or EGL_TEXTURE_TARGET, and config does not support OpenGL ES rendering");
642*35238bceSAndroid Build Coastguard Worker
643*35238bceSAndroid Build Coastguard Worker EGLConfig noEsConfig;
644*35238bceSAndroid Build Coastguard Worker if (getConfig(&noEsConfig, FilterList() << notRenderable<EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT>))
645*35238bceSAndroid Build Coastguard Worker {
646*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidNoEsPbufferAttribs); ndx++)
647*35238bceSAndroid Build Coastguard Worker {
648*35238bceSAndroid Build Coastguard Worker expectNoSurface(eglCreatePbufferSurface(display, noEsConfig, s_invalidNoEsPbufferAttribs[ndx]));
649*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_MATCH);
650*35238bceSAndroid Build Coastguard Worker }
651*35238bceSAndroid Build Coastguard Worker }
652*35238bceSAndroid Build Coastguard Worker
653*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
654*35238bceSAndroid Build Coastguard Worker
655*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test6",
656*35238bceSAndroid Build Coastguard Worker "EGL_BAD_MATCH is generated if the EGL_TEXTURE_FORMAT attribute is EGL_NO_TEXTURE, and "
657*35238bceSAndroid Build Coastguard Worker "EGL_TEXTURE_TARGET is something other than EGL_NO_TEXTURE; or, EGL_TEXTURE_FORMAT is "
658*35238bceSAndroid Build Coastguard Worker "something other than EGL_NO_TEXTURE, and EGL_TEXTURE_TARGET is EGL_NO_TEXTURE");
659*35238bceSAndroid Build Coastguard Worker
660*35238bceSAndroid Build Coastguard Worker // ES1 or ES2 config.
661*35238bceSAndroid Build Coastguard Worker EGLConfig esConfig;
662*35238bceSAndroid Build Coastguard Worker bool gotEsConfig = getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT>) ||
663*35238bceSAndroid Build Coastguard Worker getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
664*35238bceSAndroid Build Coastguard Worker if (gotEsConfig)
665*35238bceSAndroid Build Coastguard Worker {
666*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidEsPbufferAttribs); ndx++)
667*35238bceSAndroid Build Coastguard Worker {
668*35238bceSAndroid Build Coastguard Worker expectNoSurface(eglCreatePbufferSurface(display, esConfig, s_invalidEsPbufferAttribs[ndx]));
669*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_MATCH);
670*35238bceSAndroid Build Coastguard Worker }
671*35238bceSAndroid Build Coastguard Worker }
672*35238bceSAndroid Build Coastguard Worker
673*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
674*35238bceSAndroid Build Coastguard Worker
675*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test7", "EGL_BAD_MATCH is generated if config does not support the specified OpenVG "
676*35238bceSAndroid Build Coastguard Worker "alpha format attribute or colorspace attribute");
677*35238bceSAndroid Build Coastguard Worker
678*35238bceSAndroid Build Coastguard Worker EGLConfig vgNoPreConfig;
679*35238bceSAndroid Build Coastguard Worker if (getConfig(&vgNoPreConfig, FilterList()
680*35238bceSAndroid Build Coastguard Worker << renderable<EGL_OPENVG_BIT> << notSurfaceBits<EGL_VG_ALPHA_FORMAT_PRE_BIT>))
681*35238bceSAndroid Build Coastguard Worker {
682*35238bceSAndroid Build Coastguard Worker expectNoSurface(eglCreatePbufferSurface(display, vgNoPreConfig, s_vgPreMultAlphaPbufferAttrib));
683*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_MATCH);
684*35238bceSAndroid Build Coastguard Worker }
685*35238bceSAndroid Build Coastguard Worker
686*35238bceSAndroid Build Coastguard Worker EGLConfig vgNoLinearConfig;
687*35238bceSAndroid Build Coastguard Worker if (getConfig(&vgNoLinearConfig,
688*35238bceSAndroid Build Coastguard Worker FilterList() << renderable<EGL_OPENVG_BIT> << notSurfaceBits<EGL_VG_COLORSPACE_LINEAR_BIT>))
689*35238bceSAndroid Build Coastguard Worker {
690*35238bceSAndroid Build Coastguard Worker expectNoSurface(eglCreatePbufferSurface(display, vgNoLinearConfig, s_vgLinearColorspacePbufferAttrib));
691*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_MATCH);
692*35238bceSAndroid Build Coastguard Worker }
693*35238bceSAndroid Build Coastguard Worker
694*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
695*35238bceSAndroid Build Coastguard Worker
696*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test8", "EGL_BAD_PARAMETER is generated if EGL_WIDTH or EGL_HEIGHT is negative");
697*35238bceSAndroid Build Coastguard Worker
698*35238bceSAndroid Build Coastguard Worker if (getConfig(&genericConfig, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
699*35238bceSAndroid Build Coastguard Worker {
700*35238bceSAndroid Build Coastguard Worker expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeWidthPbufferAttrib));
701*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_PARAMETER);
702*35238bceSAndroid Build Coastguard Worker
703*35238bceSAndroid Build Coastguard Worker expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeHeightPbufferAttrib));
704*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_PARAMETER);
705*35238bceSAndroid Build Coastguard Worker
706*35238bceSAndroid Build Coastguard Worker expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeWidthAndHeightPbufferAttrib));
707*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_PARAMETER);
708*35238bceSAndroid Build Coastguard Worker }
709*35238bceSAndroid Build Coastguard Worker
710*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
711*35238bceSAndroid Build Coastguard Worker });
712*35238bceSAndroid Build Coastguard Worker
713*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(create_pixmap_surface, "eglCreatePixmapSurface() negative tests", {
714*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
715*35238bceSAndroid Build Coastguard Worker EGLDisplay display = getDisplay();
716*35238bceSAndroid Build Coastguard Worker
717*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
718*35238bceSAndroid Build Coastguard Worker
719*35238bceSAndroid Build Coastguard Worker expectNoSurface(eglCreatePixmapSurface(EGL_NO_DISPLAY, DE_NULL, DE_NULL, s_emptyAttribList));
720*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
721*35238bceSAndroid Build Coastguard Worker
722*35238bceSAndroid Build Coastguard Worker expectNoSurface(eglCreatePixmapSurface((EGLDisplay)-1, DE_NULL, DE_NULL, s_emptyAttribList));
723*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
724*35238bceSAndroid Build Coastguard Worker
725*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
726*35238bceSAndroid Build Coastguard Worker
727*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test2", "EGL_BAD_CONFIG or EGL_BAD_PARAMETER is generated if config is not an EGL "
728*35238bceSAndroid Build Coastguard Worker "frame buffer configuration or if the PixmapSurface call is not supported");
729*35238bceSAndroid Build Coastguard Worker
730*35238bceSAndroid Build Coastguard Worker expectNoSurface(eglCreatePixmapSurface(display, (EGLConfig)-1, DE_NULL, s_emptyAttribList));
731*35238bceSAndroid Build Coastguard Worker expectEitherError(EGL_BAD_CONFIG, EGL_BAD_PARAMETER);
732*35238bceSAndroid Build Coastguard Worker
733*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
734*35238bceSAndroid Build Coastguard Worker });
735*35238bceSAndroid Build Coastguard Worker
736*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(create_window_surface, "eglCreateWindowSurface() negative tests", {
737*35238bceSAndroid Build Coastguard Worker EGLConfig config = DE_NULL;
738*35238bceSAndroid Build Coastguard Worker bool gotConfig =
739*35238bceSAndroid Build Coastguard Worker getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << surfaceBits<EGL_WINDOW_BIT>);
740*35238bceSAndroid Build Coastguard Worker
741*35238bceSAndroid Build Coastguard Worker if (gotConfig)
742*35238bceSAndroid Build Coastguard Worker {
743*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
744*35238bceSAndroid Build Coastguard Worker EGLDisplay display = getDisplay();
745*35238bceSAndroid Build Coastguard Worker const eglu::NativeWindowFactory &factory =
746*35238bceSAndroid Build Coastguard Worker eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
747*35238bceSAndroid Build Coastguard Worker de::UniquePtr<eglu::NativeWindow> window(factory.createWindow(
748*35238bceSAndroid Build Coastguard Worker &m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL,
749*35238bceSAndroid Build Coastguard Worker eglu::WindowParams(256, 256, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
750*35238bceSAndroid Build Coastguard Worker
751*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1",
752*35238bceSAndroid Build Coastguard Worker "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
753*35238bceSAndroid Build Coastguard Worker
754*35238bceSAndroid Build Coastguard Worker expectNoSurface(
755*35238bceSAndroid Build Coastguard Worker eglCreateWindowSurface(EGL_NO_DISPLAY, config, window->getLegacyNative(), s_emptyAttribList));
756*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
757*35238bceSAndroid Build Coastguard Worker
758*35238bceSAndroid Build Coastguard Worker expectNoSurface(
759*35238bceSAndroid Build Coastguard Worker eglCreateWindowSurface((EGLDisplay)-1, config, window->getLegacyNative(), s_emptyAttribList));
760*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
761*35238bceSAndroid Build Coastguard Worker
762*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
763*35238bceSAndroid Build Coastguard Worker }
764*35238bceSAndroid Build Coastguard Worker });
765*35238bceSAndroid Build Coastguard Worker
766*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(destroy_context, "eglDestroyContext() negative tests", {
767*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
768*35238bceSAndroid Build Coastguard Worker EGLDisplay display = getDisplay();
769*35238bceSAndroid Build Coastguard Worker
770*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
771*35238bceSAndroid Build Coastguard Worker
772*35238bceSAndroid Build Coastguard Worker expectFalse(eglDestroyContext(EGL_NO_DISPLAY, DE_NULL));
773*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
774*35238bceSAndroid Build Coastguard Worker
775*35238bceSAndroid Build Coastguard Worker expectFalse(eglDestroyContext((EGLDisplay)-1, DE_NULL));
776*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
777*35238bceSAndroid Build Coastguard Worker
778*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
779*35238bceSAndroid Build Coastguard Worker
780*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
781*35238bceSAndroid Build Coastguard Worker
782*35238bceSAndroid Build Coastguard Worker expectFalse(eglDestroyContext(display, DE_NULL));
783*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_CONTEXT);
784*35238bceSAndroid Build Coastguard Worker
785*35238bceSAndroid Build Coastguard Worker expectFalse(eglDestroyContext(display, (EGLContext)-1));
786*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_CONTEXT);
787*35238bceSAndroid Build Coastguard Worker
788*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
789*35238bceSAndroid Build Coastguard Worker });
790*35238bceSAndroid Build Coastguard Worker
791*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(destroy_surface, "eglDestroySurface() negative tests", {
792*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
793*35238bceSAndroid Build Coastguard Worker EGLDisplay display = getDisplay();
794*35238bceSAndroid Build Coastguard Worker
795*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
796*35238bceSAndroid Build Coastguard Worker
797*35238bceSAndroid Build Coastguard Worker expectFalse(eglDestroySurface(EGL_NO_DISPLAY, DE_NULL));
798*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
799*35238bceSAndroid Build Coastguard Worker
800*35238bceSAndroid Build Coastguard Worker expectFalse(eglDestroySurface((EGLDisplay)-1, DE_NULL));
801*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
802*35238bceSAndroid Build Coastguard Worker
803*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
804*35238bceSAndroid Build Coastguard Worker
805*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
806*35238bceSAndroid Build Coastguard Worker
807*35238bceSAndroid Build Coastguard Worker expectFalse(eglDestroySurface(display, DE_NULL));
808*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_SURFACE);
809*35238bceSAndroid Build Coastguard Worker
810*35238bceSAndroid Build Coastguard Worker expectFalse(eglDestroySurface(display, (EGLSurface)-1));
811*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_SURFACE);
812*35238bceSAndroid Build Coastguard Worker
813*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
814*35238bceSAndroid Build Coastguard Worker });
815*35238bceSAndroid Build Coastguard Worker
816*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(get_config_attrib, "eglGetConfigAttrib() negative tests", {
817*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
818*35238bceSAndroid Build Coastguard Worker EGLDisplay display = getDisplay();
819*35238bceSAndroid Build Coastguard Worker EGLint value = 0;
820*35238bceSAndroid Build Coastguard Worker
821*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
822*35238bceSAndroid Build Coastguard Worker
823*35238bceSAndroid Build Coastguard Worker expectFalse(eglGetConfigAttrib(EGL_NO_DISPLAY, DE_NULL, EGL_RED_SIZE, &value));
824*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
825*35238bceSAndroid Build Coastguard Worker
826*35238bceSAndroid Build Coastguard Worker expectFalse(eglGetConfigAttrib((EGLDisplay)-1, DE_NULL, EGL_RED_SIZE, &value));
827*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
828*35238bceSAndroid Build Coastguard Worker
829*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
830*35238bceSAndroid Build Coastguard Worker
831*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test2",
832*35238bceSAndroid Build Coastguard Worker "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
833*35238bceSAndroid Build Coastguard Worker
834*35238bceSAndroid Build Coastguard Worker expectFalse(eglGetConfigAttrib(display, (EGLConfig)-1, EGL_RED_SIZE, &value));
835*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_CONFIG);
836*35238bceSAndroid Build Coastguard Worker
837*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
838*35238bceSAndroid Build Coastguard Worker
839*35238bceSAndroid Build Coastguard Worker // Any config.
840*35238bceSAndroid Build Coastguard Worker EGLConfig config = DE_NULL;
841*35238bceSAndroid Build Coastguard Worker bool hasConfig = getConfig(&config, FilterList());
842*35238bceSAndroid Build Coastguard Worker
843*35238bceSAndroid Build Coastguard Worker log << TestLog::Section(
844*35238bceSAndroid Build Coastguard Worker "Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid frame buffer configuration attribute");
845*35238bceSAndroid Build Coastguard Worker
846*35238bceSAndroid Build Coastguard Worker if (hasConfig)
847*35238bceSAndroid Build Coastguard Worker {
848*35238bceSAndroid Build Coastguard Worker expectFalse(eglGetConfigAttrib(display, config, 0, &value));
849*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_ATTRIBUTE);
850*35238bceSAndroid Build Coastguard Worker
851*35238bceSAndroid Build Coastguard Worker expectFalse(eglGetConfigAttrib(display, config, -1, &value));
852*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_ATTRIBUTE);
853*35238bceSAndroid Build Coastguard Worker }
854*35238bceSAndroid Build Coastguard Worker
855*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
856*35238bceSAndroid Build Coastguard Worker });
857*35238bceSAndroid Build Coastguard Worker
858*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(get_configs, "eglGetConfigs() negative tests", {
859*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
860*35238bceSAndroid Build Coastguard Worker EGLDisplay display = getDisplay();
861*35238bceSAndroid Build Coastguard Worker EGLConfig cfgs[1];
862*35238bceSAndroid Build Coastguard Worker EGLint numCfgs = 0;
863*35238bceSAndroid Build Coastguard Worker
864*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
865*35238bceSAndroid Build Coastguard Worker
866*35238bceSAndroid Build Coastguard Worker expectFalse(eglGetConfigs(EGL_NO_DISPLAY, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), &numCfgs));
867*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
868*35238bceSAndroid Build Coastguard Worker
869*35238bceSAndroid Build Coastguard Worker expectFalse(eglGetConfigs((EGLDisplay)-1, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), &numCfgs));
870*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
871*35238bceSAndroid Build Coastguard Worker
872*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
873*35238bceSAndroid Build Coastguard Worker
874*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if num_config is NULL");
875*35238bceSAndroid Build Coastguard Worker
876*35238bceSAndroid Build Coastguard Worker expectFalse(eglGetConfigs(display, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), DE_NULL));
877*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_PARAMETER);
878*35238bceSAndroid Build Coastguard Worker
879*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
880*35238bceSAndroid Build Coastguard Worker });
881*35238bceSAndroid Build Coastguard Worker
882*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(initialize, "eglInitialize() negative tests", {
883*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
884*35238bceSAndroid Build Coastguard Worker EGLint major = 0;
885*35238bceSAndroid Build Coastguard Worker EGLint minor = 0;
886*35238bceSAndroid Build Coastguard Worker
887*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
888*35238bceSAndroid Build Coastguard Worker
889*35238bceSAndroid Build Coastguard Worker expectFalse(eglInitialize(EGL_NO_DISPLAY, &major, &minor));
890*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
891*35238bceSAndroid Build Coastguard Worker
892*35238bceSAndroid Build Coastguard Worker expectFalse(eglInitialize((EGLDisplay)-1, &major, &minor));
893*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
894*35238bceSAndroid Build Coastguard Worker
895*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
896*35238bceSAndroid Build Coastguard Worker });
897*35238bceSAndroid Build Coastguard Worker
898*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(make_current, "eglMakeCurrent() negative tests", {
899*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
900*35238bceSAndroid Build Coastguard Worker EGLDisplay display = getDisplay();
901*35238bceSAndroid Build Coastguard Worker
902*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
903*35238bceSAndroid Build Coastguard Worker
904*35238bceSAndroid Build Coastguard Worker expectFalse(eglMakeCurrent(EGL_NO_DISPLAY, DE_NULL, DE_NULL, DE_NULL));
905*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
906*35238bceSAndroid Build Coastguard Worker
907*35238bceSAndroid Build Coastguard Worker expectFalse(eglMakeCurrent((EGLDisplay)-1, DE_NULL, DE_NULL, DE_NULL));
908*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
909*35238bceSAndroid Build Coastguard Worker
910*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
911*35238bceSAndroid Build Coastguard Worker
912*35238bceSAndroid Build Coastguard Worker // Create simple pbuffer surface.
913*35238bceSAndroid Build Coastguard Worker EGLSurface surface = EGL_NO_SURFACE;
914*35238bceSAndroid Build Coastguard Worker {
915*35238bceSAndroid Build Coastguard Worker EGLConfig config;
916*35238bceSAndroid Build Coastguard Worker if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
917*35238bceSAndroid Build Coastguard Worker {
918*35238bceSAndroid Build Coastguard Worker surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
919*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
920*35238bceSAndroid Build Coastguard Worker }
921*35238bceSAndroid Build Coastguard Worker }
922*35238bceSAndroid Build Coastguard Worker
923*35238bceSAndroid Build Coastguard Worker // Create simple ES2 context
924*35238bceSAndroid Build Coastguard Worker EGLContext context = EGL_NO_CONTEXT;
925*35238bceSAndroid Build Coastguard Worker {
926*35238bceSAndroid Build Coastguard Worker EGLConfig config;
927*35238bceSAndroid Build Coastguard Worker if (getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT>))
928*35238bceSAndroid Build Coastguard Worker {
929*35238bceSAndroid Build Coastguard Worker context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
930*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
931*35238bceSAndroid Build Coastguard Worker }
932*35238bceSAndroid Build Coastguard Worker }
933*35238bceSAndroid Build Coastguard Worker
934*35238bceSAndroid Build Coastguard Worker if (surface != EGL_NO_SURFACE && context != EGL_NO_CONTEXT)
935*35238bceSAndroid Build Coastguard Worker {
936*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
937*35238bceSAndroid Build Coastguard Worker
938*35238bceSAndroid Build Coastguard Worker expectFalse(eglMakeCurrent(display, (EGLSurface)-1, (EGLSurface)-1, context));
939*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_SURFACE);
940*35238bceSAndroid Build Coastguard Worker
941*35238bceSAndroid Build Coastguard Worker expectFalse(eglMakeCurrent(display, surface, (EGLSurface)-1, context));
942*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_SURFACE);
943*35238bceSAndroid Build Coastguard Worker
944*35238bceSAndroid Build Coastguard Worker expectFalse(eglMakeCurrent(display, (EGLSurface)-1, surface, context));
945*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_SURFACE);
946*35238bceSAndroid Build Coastguard Worker
947*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
948*35238bceSAndroid Build Coastguard Worker }
949*35238bceSAndroid Build Coastguard Worker
950*35238bceSAndroid Build Coastguard Worker if (surface)
951*35238bceSAndroid Build Coastguard Worker {
952*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test3", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
953*35238bceSAndroid Build Coastguard Worker
954*35238bceSAndroid Build Coastguard Worker expectFalse(eglMakeCurrent(display, surface, surface, (EGLContext)-1));
955*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_CONTEXT);
956*35238bceSAndroid Build Coastguard Worker
957*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
958*35238bceSAndroid Build Coastguard Worker }
959*35238bceSAndroid Build Coastguard Worker
960*35238bceSAndroid Build Coastguard Worker if (surface != EGL_NO_SURFACE)
961*35238bceSAndroid Build Coastguard Worker {
962*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test4", "EGL_BAD_MATCH is generated if read or draw surface is not EGL_NO_SURFACE "
963*35238bceSAndroid Build Coastguard Worker "and context is EGL_NO_CONTEXT");
964*35238bceSAndroid Build Coastguard Worker
965*35238bceSAndroid Build Coastguard Worker expectFalse(eglMakeCurrent(display, surface, EGL_NO_SURFACE, EGL_NO_CONTEXT));
966*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_MATCH);
967*35238bceSAndroid Build Coastguard Worker
968*35238bceSAndroid Build Coastguard Worker expectFalse(eglMakeCurrent(display, EGL_NO_SURFACE, surface, EGL_NO_CONTEXT));
969*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_MATCH);
970*35238bceSAndroid Build Coastguard Worker
971*35238bceSAndroid Build Coastguard Worker expectFalse(eglMakeCurrent(display, surface, surface, EGL_NO_CONTEXT));
972*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_MATCH);
973*35238bceSAndroid Build Coastguard Worker
974*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
975*35238bceSAndroid Build Coastguard Worker }
976*35238bceSAndroid Build Coastguard Worker
977*35238bceSAndroid Build Coastguard Worker if (context)
978*35238bceSAndroid Build Coastguard Worker {
979*35238bceSAndroid Build Coastguard Worker eglDestroyContext(display, context);
980*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
981*35238bceSAndroid Build Coastguard Worker }
982*35238bceSAndroid Build Coastguard Worker
983*35238bceSAndroid Build Coastguard Worker if (surface)
984*35238bceSAndroid Build Coastguard Worker {
985*35238bceSAndroid Build Coastguard Worker eglDestroySurface(display, surface);
986*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
987*35238bceSAndroid Build Coastguard Worker }
988*35238bceSAndroid Build Coastguard Worker });
989*35238bceSAndroid Build Coastguard Worker
990*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(get_current_context, "eglGetCurrentContext() negative tests", {
991*35238bceSAndroid Build Coastguard Worker expectNoContext(eglGetCurrentContext());
992*35238bceSAndroid Build Coastguard Worker
993*35238bceSAndroid Build Coastguard Worker if (isAPISupported(EGL_OPENGL_ES_API))
994*35238bceSAndroid Build Coastguard Worker {
995*35238bceSAndroid Build Coastguard Worker expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
996*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
997*35238bceSAndroid Build Coastguard Worker
998*35238bceSAndroid Build Coastguard Worker expectNoContext(eglGetCurrentContext());
999*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1000*35238bceSAndroid Build Coastguard Worker }
1001*35238bceSAndroid Build Coastguard Worker });
1002*35238bceSAndroid Build Coastguard Worker
1003*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(get_current_surface, "eglGetCurrentSurface() negative tests", {
1004*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
1005*35238bceSAndroid Build Coastguard Worker EGLDisplay display = getDisplay();
1006*35238bceSAndroid Build Coastguard Worker EGLConfig config = DE_NULL;
1007*35238bceSAndroid Build Coastguard Worker EGLContext context = EGL_NO_CONTEXT;
1008*35238bceSAndroid Build Coastguard Worker EGLSurface surface = EGL_NO_SURFACE;
1009*35238bceSAndroid Build Coastguard Worker bool gotConfig =
1010*35238bceSAndroid Build Coastguard Worker getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << surfaceBits<EGL_PBUFFER_BIT>);
1011*35238bceSAndroid Build Coastguard Worker
1012*35238bceSAndroid Build Coastguard Worker if (gotConfig)
1013*35238bceSAndroid Build Coastguard Worker {
1014*35238bceSAndroid Build Coastguard Worker expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
1015*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1016*35238bceSAndroid Build Coastguard Worker
1017*35238bceSAndroid Build Coastguard Worker context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
1018*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1019*35238bceSAndroid Build Coastguard Worker
1020*35238bceSAndroid Build Coastguard Worker // Create simple pbuffer surface.
1021*35238bceSAndroid Build Coastguard Worker surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1022*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1023*35238bceSAndroid Build Coastguard Worker
1024*35238bceSAndroid Build Coastguard Worker expectTrue(eglMakeCurrent(display, surface, surface, context));
1025*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1026*35238bceSAndroid Build Coastguard Worker
1027*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1",
1028*35238bceSAndroid Build Coastguard Worker "EGL_BAD_PARAMETER is generated if readdraw is neither EGL_READ nor EGL_DRAW");
1029*35238bceSAndroid Build Coastguard Worker
1030*35238bceSAndroid Build Coastguard Worker expectNoSurface(eglGetCurrentSurface(EGL_NONE));
1031*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_PARAMETER);
1032*35238bceSAndroid Build Coastguard Worker
1033*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
1034*35238bceSAndroid Build Coastguard Worker
1035*35238bceSAndroid Build Coastguard Worker expectTrue(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
1036*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1037*35238bceSAndroid Build Coastguard Worker
1038*35238bceSAndroid Build Coastguard Worker if (surface != EGL_NO_SURFACE)
1039*35238bceSAndroid Build Coastguard Worker {
1040*35238bceSAndroid Build Coastguard Worker expectTrue(eglDestroySurface(display, surface));
1041*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1042*35238bceSAndroid Build Coastguard Worker }
1043*35238bceSAndroid Build Coastguard Worker
1044*35238bceSAndroid Build Coastguard Worker if (context != EGL_NO_CONTEXT)
1045*35238bceSAndroid Build Coastguard Worker {
1046*35238bceSAndroid Build Coastguard Worker expectTrue(eglDestroyContext(display, context));
1047*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1048*35238bceSAndroid Build Coastguard Worker }
1049*35238bceSAndroid Build Coastguard Worker }
1050*35238bceSAndroid Build Coastguard Worker });
1051*35238bceSAndroid Build Coastguard Worker
1052*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(query_context, "eglQueryContext() negative tests", {
1053*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
1054*35238bceSAndroid Build Coastguard Worker EGLDisplay display = getDisplay();
1055*35238bceSAndroid Build Coastguard Worker EGLint value = 0;
1056*35238bceSAndroid Build Coastguard Worker
1057*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1058*35238bceSAndroid Build Coastguard Worker
1059*35238bceSAndroid Build Coastguard Worker expectFalse(eglQueryContext(EGL_NO_DISPLAY, DE_NULL, EGL_CONFIG_ID, &value));
1060*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
1061*35238bceSAndroid Build Coastguard Worker
1062*35238bceSAndroid Build Coastguard Worker expectFalse(eglQueryContext((EGLDisplay)-1, DE_NULL, EGL_CONFIG_ID, &value));
1063*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
1064*35238bceSAndroid Build Coastguard Worker
1065*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
1066*35238bceSAndroid Build Coastguard Worker
1067*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
1068*35238bceSAndroid Build Coastguard Worker
1069*35238bceSAndroid Build Coastguard Worker expectFalse(eglQueryContext(display, DE_NULL, EGL_CONFIG_ID, &value));
1070*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_CONTEXT);
1071*35238bceSAndroid Build Coastguard Worker
1072*35238bceSAndroid Build Coastguard Worker expectFalse(eglQueryContext(display, DE_NULL, EGL_CONFIG_ID, &value));
1073*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_CONTEXT);
1074*35238bceSAndroid Build Coastguard Worker
1075*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
1076*35238bceSAndroid Build Coastguard Worker
1077*35238bceSAndroid Build Coastguard Worker // Create ES2 context.
1078*35238bceSAndroid Build Coastguard Worker EGLConfig config = DE_NULL;
1079*35238bceSAndroid Build Coastguard Worker EGLContext context = DE_NULL;
1080*35238bceSAndroid Build Coastguard Worker bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
1081*35238bceSAndroid Build Coastguard Worker
1082*35238bceSAndroid Build Coastguard Worker if (gotConfig)
1083*35238bceSAndroid Build Coastguard Worker {
1084*35238bceSAndroid Build Coastguard Worker expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
1085*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1086*35238bceSAndroid Build Coastguard Worker
1087*35238bceSAndroid Build Coastguard Worker context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
1088*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1089*35238bceSAndroid Build Coastguard Worker }
1090*35238bceSAndroid Build Coastguard Worker
1091*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test3",
1092*35238bceSAndroid Build Coastguard Worker "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid context attribute");
1093*35238bceSAndroid Build Coastguard Worker
1094*35238bceSAndroid Build Coastguard Worker if (context)
1095*35238bceSAndroid Build Coastguard Worker {
1096*35238bceSAndroid Build Coastguard Worker expectFalse(eglQueryContext(display, context, 0, &value));
1097*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_ATTRIBUTE);
1098*35238bceSAndroid Build Coastguard Worker expectFalse(eglQueryContext(display, context, -1, &value));
1099*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_ATTRIBUTE);
1100*35238bceSAndroid Build Coastguard Worker expectFalse(eglQueryContext(display, context, EGL_RED_SIZE, &value));
1101*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_ATTRIBUTE);
1102*35238bceSAndroid Build Coastguard Worker }
1103*35238bceSAndroid Build Coastguard Worker
1104*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
1105*35238bceSAndroid Build Coastguard Worker
1106*35238bceSAndroid Build Coastguard Worker if (context)
1107*35238bceSAndroid Build Coastguard Worker {
1108*35238bceSAndroid Build Coastguard Worker expectTrue(eglDestroyContext(display, context));
1109*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1110*35238bceSAndroid Build Coastguard Worker }
1111*35238bceSAndroid Build Coastguard Worker });
1112*35238bceSAndroid Build Coastguard Worker
1113*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(query_string, "eglQueryString() negative tests", {
1114*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
1115*35238bceSAndroid Build Coastguard Worker EGLDisplay display = getDisplay();
1116*35238bceSAndroid Build Coastguard Worker
1117*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1118*35238bceSAndroid Build Coastguard Worker
1119*35238bceSAndroid Build Coastguard Worker expectNull(eglQueryString(EGL_NO_DISPLAY, EGL_VENDOR));
1120*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
1121*35238bceSAndroid Build Coastguard Worker
1122*35238bceSAndroid Build Coastguard Worker expectNull(eglQueryString((EGLDisplay)-1, EGL_VENDOR));
1123*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
1124*35238bceSAndroid Build Coastguard Worker
1125*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
1126*35238bceSAndroid Build Coastguard Worker
1127*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if name is not an accepted value");
1128*35238bceSAndroid Build Coastguard Worker
1129*35238bceSAndroid Build Coastguard Worker expectNull(eglQueryString(display, 0));
1130*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_PARAMETER);
1131*35238bceSAndroid Build Coastguard Worker expectNull(eglQueryString(display, -1));
1132*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_PARAMETER);
1133*35238bceSAndroid Build Coastguard Worker
1134*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
1135*35238bceSAndroid Build Coastguard Worker });
1136*35238bceSAndroid Build Coastguard Worker
1137*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(query_surface, "eglQuerySurface() negative tests", {
1138*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
1139*35238bceSAndroid Build Coastguard Worker EGLDisplay display = getDisplay();
1140*35238bceSAndroid Build Coastguard Worker EGLint value = 0;
1141*35238bceSAndroid Build Coastguard Worker
1142*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1143*35238bceSAndroid Build Coastguard Worker
1144*35238bceSAndroid Build Coastguard Worker expectFalse(eglQuerySurface(EGL_NO_DISPLAY, DE_NULL, EGL_CONFIG_ID, &value));
1145*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
1146*35238bceSAndroid Build Coastguard Worker
1147*35238bceSAndroid Build Coastguard Worker expectFalse(eglQuerySurface((EGLDisplay)-1, DE_NULL, EGL_CONFIG_ID, &value));
1148*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
1149*35238bceSAndroid Build Coastguard Worker
1150*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
1151*35238bceSAndroid Build Coastguard Worker
1152*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1153*35238bceSAndroid Build Coastguard Worker
1154*35238bceSAndroid Build Coastguard Worker expectFalse(eglQuerySurface(display, DE_NULL, EGL_CONFIG_ID, &value));
1155*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_SURFACE);
1156*35238bceSAndroid Build Coastguard Worker
1157*35238bceSAndroid Build Coastguard Worker expectFalse(eglQuerySurface(display, (EGLSurface)-1, EGL_CONFIG_ID, &value));
1158*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_SURFACE);
1159*35238bceSAndroid Build Coastguard Worker
1160*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
1161*35238bceSAndroid Build Coastguard Worker
1162*35238bceSAndroid Build Coastguard Worker // Create pbuffer surface.
1163*35238bceSAndroid Build Coastguard Worker EGLSurface surface = EGL_NO_SURFACE;
1164*35238bceSAndroid Build Coastguard Worker {
1165*35238bceSAndroid Build Coastguard Worker EGLConfig config;
1166*35238bceSAndroid Build Coastguard Worker if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
1167*35238bceSAndroid Build Coastguard Worker {
1168*35238bceSAndroid Build Coastguard Worker surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1169*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1170*35238bceSAndroid Build Coastguard Worker }
1171*35238bceSAndroid Build Coastguard Worker else
1172*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete"
1173*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1174*35238bceSAndroid Build Coastguard Worker }
1175*35238bceSAndroid Build Coastguard Worker
1176*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test3",
1177*35238bceSAndroid Build Coastguard Worker "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid surface attribute");
1178*35238bceSAndroid Build Coastguard Worker
1179*35238bceSAndroid Build Coastguard Worker if (surface)
1180*35238bceSAndroid Build Coastguard Worker {
1181*35238bceSAndroid Build Coastguard Worker expectFalse(eglQuerySurface(display, surface, 0, &value));
1182*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_ATTRIBUTE);
1183*35238bceSAndroid Build Coastguard Worker
1184*35238bceSAndroid Build Coastguard Worker expectFalse(eglQuerySurface(display, surface, -1, &value));
1185*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_ATTRIBUTE);
1186*35238bceSAndroid Build Coastguard Worker }
1187*35238bceSAndroid Build Coastguard Worker
1188*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
1189*35238bceSAndroid Build Coastguard Worker
1190*35238bceSAndroid Build Coastguard Worker if (surface)
1191*35238bceSAndroid Build Coastguard Worker {
1192*35238bceSAndroid Build Coastguard Worker eglDestroySurface(display, surface);
1193*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1194*35238bceSAndroid Build Coastguard Worker }
1195*35238bceSAndroid Build Coastguard Worker });
1196*35238bceSAndroid Build Coastguard Worker
1197*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(release_tex_image, "eglReleaseTexImage() negative tests", {
1198*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
1199*35238bceSAndroid Build Coastguard Worker EGLDisplay display = getDisplay();
1200*35238bceSAndroid Build Coastguard Worker
1201*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1202*35238bceSAndroid Build Coastguard Worker
1203*35238bceSAndroid Build Coastguard Worker expectFalse(eglReleaseTexImage(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1204*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
1205*35238bceSAndroid Build Coastguard Worker
1206*35238bceSAndroid Build Coastguard Worker expectFalse(eglReleaseTexImage((EGLDisplay)-1, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1207*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
1208*35238bceSAndroid Build Coastguard Worker
1209*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
1210*35238bceSAndroid Build Coastguard Worker
1211*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1212*35238bceSAndroid Build Coastguard Worker
1213*35238bceSAndroid Build Coastguard Worker expectFalse(eglReleaseTexImage(display, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1214*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_SURFACE);
1215*35238bceSAndroid Build Coastguard Worker
1216*35238bceSAndroid Build Coastguard Worker expectFalse(eglReleaseTexImage(display, (EGLSurface)-1, EGL_BACK_BUFFER));
1217*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_SURFACE);
1218*35238bceSAndroid Build Coastguard Worker
1219*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
1220*35238bceSAndroid Build Coastguard Worker });
1221*35238bceSAndroid Build Coastguard Worker
1222*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(surface_attrib, "eglSurfaceAttrib() negative tests", {
1223*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
1224*35238bceSAndroid Build Coastguard Worker EGLDisplay display = getDisplay();
1225*35238bceSAndroid Build Coastguard Worker
1226*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1227*35238bceSAndroid Build Coastguard Worker
1228*35238bceSAndroid Build Coastguard Worker expectFalse(eglSurfaceAttrib(EGL_NO_DISPLAY, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1229*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
1230*35238bceSAndroid Build Coastguard Worker
1231*35238bceSAndroid Build Coastguard Worker expectFalse(eglSurfaceAttrib((EGLDisplay)-1, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1232*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
1233*35238bceSAndroid Build Coastguard Worker
1234*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
1235*35238bceSAndroid Build Coastguard Worker
1236*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1237*35238bceSAndroid Build Coastguard Worker
1238*35238bceSAndroid Build Coastguard Worker expectFalse(eglSurfaceAttrib(display, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1239*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_SURFACE);
1240*35238bceSAndroid Build Coastguard Worker
1241*35238bceSAndroid Build Coastguard Worker expectFalse(eglSurfaceAttrib(display, (EGLSurface)-1, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1242*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_SURFACE);
1243*35238bceSAndroid Build Coastguard Worker
1244*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
1245*35238bceSAndroid Build Coastguard Worker
1246*35238bceSAndroid Build Coastguard Worker {
1247*35238bceSAndroid Build Coastguard Worker // Create pbuffer surface.
1248*35238bceSAndroid Build Coastguard Worker EGLSurface surface = EGL_NO_SURFACE;
1249*35238bceSAndroid Build Coastguard Worker {
1250*35238bceSAndroid Build Coastguard Worker EGLConfig config;
1251*35238bceSAndroid Build Coastguard Worker if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
1252*35238bceSAndroid Build Coastguard Worker {
1253*35238bceSAndroid Build Coastguard Worker surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1254*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1255*35238bceSAndroid Build Coastguard Worker }
1256*35238bceSAndroid Build Coastguard Worker else
1257*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete"
1258*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1259*35238bceSAndroid Build Coastguard Worker }
1260*35238bceSAndroid Build Coastguard Worker
1261*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test3",
1262*35238bceSAndroid Build Coastguard Worker "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid surface attribute");
1263*35238bceSAndroid Build Coastguard Worker
1264*35238bceSAndroid Build Coastguard Worker if (surface)
1265*35238bceSAndroid Build Coastguard Worker {
1266*35238bceSAndroid Build Coastguard Worker expectFalse(eglSurfaceAttrib(display, surface, 0, 0));
1267*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_ATTRIBUTE);
1268*35238bceSAndroid Build Coastguard Worker
1269*35238bceSAndroid Build Coastguard Worker expectFalse(eglSurfaceAttrib(display, surface, -1, 0));
1270*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_ATTRIBUTE);
1271*35238bceSAndroid Build Coastguard Worker }
1272*35238bceSAndroid Build Coastguard Worker
1273*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
1274*35238bceSAndroid Build Coastguard Worker
1275*35238bceSAndroid Build Coastguard Worker if (surface)
1276*35238bceSAndroid Build Coastguard Worker {
1277*35238bceSAndroid Build Coastguard Worker eglDestroySurface(display, surface);
1278*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1279*35238bceSAndroid Build Coastguard Worker }
1280*35238bceSAndroid Build Coastguard Worker }
1281*35238bceSAndroid Build Coastguard Worker
1282*35238bceSAndroid Build Coastguard Worker {
1283*35238bceSAndroid Build Coastguard Worker // Create pbuffer surface without EGL_MULTISAMPLE_RESOLVE_BOX_BIT.
1284*35238bceSAndroid Build Coastguard Worker EGLSurface surface = EGL_NO_SURFACE;
1285*35238bceSAndroid Build Coastguard Worker {
1286*35238bceSAndroid Build Coastguard Worker EGLConfig config;
1287*35238bceSAndroid Build Coastguard Worker if (getConfig(&config,
1288*35238bceSAndroid Build Coastguard Worker FilterList()
1289*35238bceSAndroid Build Coastguard Worker << surfaceBits<EGL_PBUFFER_BIT> << notSurfaceBits<EGL_MULTISAMPLE_RESOLVE_BOX_BIT>))
1290*35238bceSAndroid Build Coastguard Worker {
1291*35238bceSAndroid Build Coastguard Worker surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1292*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1293*35238bceSAndroid Build Coastguard Worker }
1294*35238bceSAndroid Build Coastguard Worker else
1295*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete"
1296*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1297*35238bceSAndroid Build Coastguard Worker }
1298*35238bceSAndroid Build Coastguard Worker
1299*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test4",
1300*35238bceSAndroid Build Coastguard Worker "EGL_BAD_MATCH is generated if attribute is EGL_MULTISAMPLE_RESOLVE, value is "
1301*35238bceSAndroid Build Coastguard Worker "EGL_MULTISAMPLE_RESOLVE_BOX, and the EGL_SURFACE_TYPE attribute of the EGLConfig "
1302*35238bceSAndroid Build Coastguard Worker "used to create surface does not contain EGL_MULTISAMPLE_RESOLVE_BOX_BIT");
1303*35238bceSAndroid Build Coastguard Worker
1304*35238bceSAndroid Build Coastguard Worker if (surface)
1305*35238bceSAndroid Build Coastguard Worker {
1306*35238bceSAndroid Build Coastguard Worker expectFalse(eglSurfaceAttrib(display, surface, EGL_MULTISAMPLE_RESOLVE, EGL_MULTISAMPLE_RESOLVE_BOX));
1307*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_MATCH);
1308*35238bceSAndroid Build Coastguard Worker }
1309*35238bceSAndroid Build Coastguard Worker
1310*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
1311*35238bceSAndroid Build Coastguard Worker
1312*35238bceSAndroid Build Coastguard Worker if (surface)
1313*35238bceSAndroid Build Coastguard Worker {
1314*35238bceSAndroid Build Coastguard Worker eglDestroySurface(display, surface);
1315*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1316*35238bceSAndroid Build Coastguard Worker }
1317*35238bceSAndroid Build Coastguard Worker }
1318*35238bceSAndroid Build Coastguard Worker
1319*35238bceSAndroid Build Coastguard Worker {
1320*35238bceSAndroid Build Coastguard Worker // Create pbuffer surface without EGL_SWAP_BEHAVIOR_PRESERVED_BIT.
1321*35238bceSAndroid Build Coastguard Worker EGLSurface surface = EGL_NO_SURFACE;
1322*35238bceSAndroid Build Coastguard Worker {
1323*35238bceSAndroid Build Coastguard Worker EGLConfig config;
1324*35238bceSAndroid Build Coastguard Worker if (getConfig(&config,
1325*35238bceSAndroid Build Coastguard Worker FilterList()
1326*35238bceSAndroid Build Coastguard Worker << surfaceBits<EGL_PBUFFER_BIT> << notSurfaceBits<EGL_SWAP_BEHAVIOR_PRESERVED_BIT>))
1327*35238bceSAndroid Build Coastguard Worker {
1328*35238bceSAndroid Build Coastguard Worker surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1329*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1330*35238bceSAndroid Build Coastguard Worker }
1331*35238bceSAndroid Build Coastguard Worker else
1332*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete"
1333*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1334*35238bceSAndroid Build Coastguard Worker }
1335*35238bceSAndroid Build Coastguard Worker
1336*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test5",
1337*35238bceSAndroid Build Coastguard Worker "EGL_BAD_MATCH is generated if attribute is EGL_SWAP_BEHAVIOR, value is "
1338*35238bceSAndroid Build Coastguard Worker "EGL_BUFFER_PRESERVED, and the EGL_SURFACE_TYPE attribute of the EGLConfig used to "
1339*35238bceSAndroid Build Coastguard Worker "create surface does not contain EGL_SWAP_BEHAVIOR_PRESERVED_BIT");
1340*35238bceSAndroid Build Coastguard Worker
1341*35238bceSAndroid Build Coastguard Worker if (surface)
1342*35238bceSAndroid Build Coastguard Worker {
1343*35238bceSAndroid Build Coastguard Worker expectFalse(eglSurfaceAttrib(display, surface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED));
1344*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_MATCH);
1345*35238bceSAndroid Build Coastguard Worker }
1346*35238bceSAndroid Build Coastguard Worker
1347*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
1348*35238bceSAndroid Build Coastguard Worker
1349*35238bceSAndroid Build Coastguard Worker if (surface)
1350*35238bceSAndroid Build Coastguard Worker {
1351*35238bceSAndroid Build Coastguard Worker eglDestroySurface(display, surface);
1352*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1353*35238bceSAndroid Build Coastguard Worker }
1354*35238bceSAndroid Build Coastguard Worker }
1355*35238bceSAndroid Build Coastguard Worker });
1356*35238bceSAndroid Build Coastguard Worker
1357*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(swap_buffers, "eglSwapBuffers() negative tests", {
1358*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
1359*35238bceSAndroid Build Coastguard Worker EGLDisplay display = getDisplay();
1360*35238bceSAndroid Build Coastguard Worker
1361*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1362*35238bceSAndroid Build Coastguard Worker
1363*35238bceSAndroid Build Coastguard Worker expectFalse(eglSwapBuffers(EGL_NO_DISPLAY, DE_NULL));
1364*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
1365*35238bceSAndroid Build Coastguard Worker
1366*35238bceSAndroid Build Coastguard Worker expectFalse(eglSwapBuffers((EGLDisplay)-1, DE_NULL));
1367*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
1368*35238bceSAndroid Build Coastguard Worker
1369*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
1370*35238bceSAndroid Build Coastguard Worker
1371*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1372*35238bceSAndroid Build Coastguard Worker
1373*35238bceSAndroid Build Coastguard Worker expectFalse(eglSwapBuffers(display, DE_NULL));
1374*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_SURFACE);
1375*35238bceSAndroid Build Coastguard Worker
1376*35238bceSAndroid Build Coastguard Worker expectFalse(eglSwapBuffers(display, (EGLSurface)-1));
1377*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_SURFACE);
1378*35238bceSAndroid Build Coastguard Worker
1379*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
1380*35238bceSAndroid Build Coastguard Worker });
1381*35238bceSAndroid Build Coastguard Worker
1382*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(swap_interval, "eglSwapInterval() negative tests", {
1383*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
1384*35238bceSAndroid Build Coastguard Worker EGLDisplay display = getDisplay();
1385*35238bceSAndroid Build Coastguard Worker
1386*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1387*35238bceSAndroid Build Coastguard Worker
1388*35238bceSAndroid Build Coastguard Worker expectFalse(eglSwapInterval(EGL_NO_DISPLAY, 0));
1389*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
1390*35238bceSAndroid Build Coastguard Worker
1391*35238bceSAndroid Build Coastguard Worker expectFalse(eglSwapInterval((EGLDisplay)-1, 0));
1392*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
1393*35238bceSAndroid Build Coastguard Worker
1394*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
1395*35238bceSAndroid Build Coastguard Worker
1396*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test2",
1397*35238bceSAndroid Build Coastguard Worker "EGL_BAD_CONTEXT is generated if there is no current context on the calling thread");
1398*35238bceSAndroid Build Coastguard Worker
1399*35238bceSAndroid Build Coastguard Worker expectFalse(eglSwapInterval(display, 0));
1400*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_CONTEXT);
1401*35238bceSAndroid Build Coastguard Worker
1402*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
1403*35238bceSAndroid Build Coastguard Worker });
1404*35238bceSAndroid Build Coastguard Worker
1405*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(terminate, "eglTerminate() negative tests", {
1406*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
1407*35238bceSAndroid Build Coastguard Worker
1408*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1409*35238bceSAndroid Build Coastguard Worker
1410*35238bceSAndroid Build Coastguard Worker expectFalse(eglTerminate(EGL_NO_DISPLAY));
1411*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
1412*35238bceSAndroid Build Coastguard Worker
1413*35238bceSAndroid Build Coastguard Worker expectFalse(eglTerminate((EGLDisplay)-1));
1414*35238bceSAndroid Build Coastguard Worker expectError(EGL_BAD_DISPLAY);
1415*35238bceSAndroid Build Coastguard Worker
1416*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
1417*35238bceSAndroid Build Coastguard Worker });
1418*35238bceSAndroid Build Coastguard Worker
1419*35238bceSAndroid Build Coastguard Worker TEGL_ADD_API_CASE(wait_native, "eglWaitNative() negative tests", {
1420*35238bceSAndroid Build Coastguard Worker EGLConfig config = DE_NULL;
1421*35238bceSAndroid Build Coastguard Worker bool gotConfig =
1422*35238bceSAndroid Build Coastguard Worker getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << surfaceBits<EGL_WINDOW_BIT>);
1423*35238bceSAndroid Build Coastguard Worker
1424*35238bceSAndroid Build Coastguard Worker if (gotConfig)
1425*35238bceSAndroid Build Coastguard Worker {
1426*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
1427*35238bceSAndroid Build Coastguard Worker const Library &egl = m_eglTestCtx.getLibrary();
1428*35238bceSAndroid Build Coastguard Worker EGLDisplay display = getDisplay();
1429*35238bceSAndroid Build Coastguard Worker const eglu::NativeWindowFactory &factory =
1430*35238bceSAndroid Build Coastguard Worker eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
1431*35238bceSAndroid Build Coastguard Worker de::UniquePtr<eglu::NativeWindow> window(factory.createWindow(
1432*35238bceSAndroid Build Coastguard Worker &m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL,
1433*35238bceSAndroid Build Coastguard Worker eglu::WindowParams(256, 256, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
1434*35238bceSAndroid Build Coastguard Worker eglu::UniqueSurface surface(
1435*35238bceSAndroid Build Coastguard Worker egl, display,
1436*35238bceSAndroid Build Coastguard Worker eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, display, config, DE_NULL));
1437*35238bceSAndroid Build Coastguard Worker EGLContext context = EGL_NO_CONTEXT;
1438*35238bceSAndroid Build Coastguard Worker
1439*35238bceSAndroid Build Coastguard Worker expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
1440*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1441*35238bceSAndroid Build Coastguard Worker
1442*35238bceSAndroid Build Coastguard Worker context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
1443*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1444*35238bceSAndroid Build Coastguard Worker
1445*35238bceSAndroid Build Coastguard Worker expectTrue(eglMakeCurrent(display, *surface, *surface, context));
1446*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1447*35238bceSAndroid Build Coastguard Worker
1448*35238bceSAndroid Build Coastguard Worker log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if engine is not a recognized marking "
1449*35238bceSAndroid Build Coastguard Worker "engine and native rendering is supported by current surface");
1450*35238bceSAndroid Build Coastguard Worker
1451*35238bceSAndroid Build Coastguard Worker eglWaitNative(-1);
1452*35238bceSAndroid Build Coastguard Worker expectEitherError(EGL_BAD_PARAMETER, EGL_SUCCESS);
1453*35238bceSAndroid Build Coastguard Worker
1454*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSection;
1455*35238bceSAndroid Build Coastguard Worker
1456*35238bceSAndroid Build Coastguard Worker expectTrue(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
1457*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1458*35238bceSAndroid Build Coastguard Worker
1459*35238bceSAndroid Build Coastguard Worker if (context != EGL_NO_CONTEXT)
1460*35238bceSAndroid Build Coastguard Worker {
1461*35238bceSAndroid Build Coastguard Worker expectTrue(eglDestroyContext(display, context));
1462*35238bceSAndroid Build Coastguard Worker expectError(EGL_SUCCESS);
1463*35238bceSAndroid Build Coastguard Worker }
1464*35238bceSAndroid Build Coastguard Worker }
1465*35238bceSAndroid Build Coastguard Worker });
1466*35238bceSAndroid Build Coastguard Worker }
1467*35238bceSAndroid Build Coastguard Worker
1468*35238bceSAndroid Build Coastguard Worker } // namespace egl
1469*35238bceSAndroid Build Coastguard Worker } // namespace deqp
1470