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
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 @@
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<EGL_OPENGL_ES2_BIT> << surfaceBits<EGL_PBUFFER_BIT>);
- 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",