From cd521810662827147fc3a4c24fa22ac7aadec5b8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mika=20Isoj=C3=A4rvi?= Date: Wed, 18 Mar 2015 17:21:10 -0700 Subject: [PATCH] Fix negative eglGetCurrentSurface tests. Set current context and current surface before calling eglGetCurrentSurface. eglGetCurrentSurface doesn't report any errors unless there is current context. Bug: 19821499 Change-Id: I197d245f062fd3dcfe2a30263638d6f5438c5ca2 --- modules/egl/teglNegativeApiTests.cpp | 46 +++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/modules/egl/teglNegativeApiTests.cpp b/modules/egl/teglNegativeApiTests.cpp index 3961eaa..3e5a5bc 100755 --- a/modules/egl/teglNegativeApiTests.cpp +++ b/modules/egl/teglNegativeApiTests.cpp @@ -897,19 +897,49 @@ void NegativeApiTests::init (void) TEGL_ADD_API_CASE(get_current_surface, "eglGetCurrentSurface() negative tests", { TestLog& log = m_testCtx.getLog(); + EGLDisplay display = getDisplay(); + EGLConfig config = DE_NULL; + EGLContext context = EGL_NO_CONTEXT; + EGLSurface surface = EGL_NO_SURFACE; + bool gotConfig = getConfig(&config, FilterList() << renderable << surfaceBits); - log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if readdraw is neither EGL_READ nor EGL_DRAW"); + if (gotConfig) + { + expectTrue(eglBindAPI(EGL_OPENGL_ES_API)); + expectError(EGL_SUCCESS); - expectNoSurface(eglGetCurrentSurface(EGL_NONE)); - expectError(EGL_BAD_PARAMETER); + context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList); + expectError(EGL_SUCCESS); - log << TestLog::EndSection; + // Create simple pbuffer surface. + surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib); + expectError(EGL_SUCCESS); - expectNoSurface(eglGetCurrentSurface(EGL_READ)); - expectError(EGL_SUCCESS); + expectTrue(eglMakeCurrent(display, surface, surface, context)); + expectError(EGL_SUCCESS); - expectNoSurface(eglGetCurrentSurface(EGL_DRAW)); - expectError(EGL_SUCCESS); + log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if readdraw is neither EGL_READ nor EGL_DRAW"); + + expectNoSurface(eglGetCurrentSurface(EGL_NONE)); + expectError(EGL_BAD_PARAMETER); + + log << TestLog::EndSection; + + expectTrue(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)); + expectError(EGL_SUCCESS); + + if (surface != EGL_NO_SURFACE) + { + expectTrue(eglDestroySurface(display, surface)); + expectError(EGL_SUCCESS); + } + + if (context != EGL_NO_CONTEXT) + { + expectTrue(eglDestroyContext(display, context)); + expectError(EGL_SUCCESS); + } + } }); TEGL_ADD_API_CASE(query_context, "eglQueryContext() negative tests", -- 2.7.4