From 871d6f2dfd3c136f5bc447b10a3965b3c1ad20bc Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 22 Feb 2013 19:34:49 -0800 Subject: [PATCH] Added a test that checks the error behavior of ConsumerBase::abandon We check that calling eglSwapBuffers() on an abandonned BufferQueue return EGL_BAD_ALLOC -- this is to ensure consistancy between drivers. Change-Id: If84b082bc6bdea21673b16e5e717658c78edf405 --- libs/gui/tests/SurfaceTextureClient_test.cpp | 32 +++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/libs/gui/tests/SurfaceTextureClient_test.cpp b/libs/gui/tests/SurfaceTextureClient_test.cpp index 24b60f1af..ce960367b 100644 --- a/libs/gui/tests/SurfaceTextureClient_test.cpp +++ b/libs/gui/tests/SurfaceTextureClient_test.cpp @@ -61,6 +61,7 @@ protected: &myConfig, 1, &numConfigs)); ASSERT_EQ(EGL_SUCCESS, eglGetError()); + mEglConfig = myConfig; EGLint pbufferAttribs[] = { EGL_WIDTH, 16, EGL_HEIGHT, 16, @@ -95,7 +96,7 @@ protected: virtual EGLint const* getConfigAttribs() { static EGLint sDefaultConfigAttribs[] = { - EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, + EGL_SURFACE_TYPE, EGL_PBUFFER_BIT | EGL_WINDOW_BIT, EGL_NONE }; @@ -109,6 +110,7 @@ protected: EGLDisplay mEglDisplay; EGLSurface mEglSurface; EGLContext mEglContext; + EGLConfig mEglConfig; }; TEST_F(SurfaceTextureClientTest, GetISurfaceTextureIsNotNull) { @@ -169,6 +171,34 @@ TEST_F(SurfaceTextureClientTest, EglCreateWindowSurfaceSucceeds) { eglTerminate(dpy); } +TEST_F(SurfaceTextureClientTest, EglSwapBuffersAbandonErrorIsEglBadSurface) { + + EGLSurface eglSurface = eglCreateWindowSurface(mEglDisplay, mEglConfig, mANW.get(), NULL); + EXPECT_NE(EGL_NO_SURFACE, eglSurface); + EXPECT_EQ(EGL_SUCCESS, eglGetError()); + + EGLBoolean success = eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, mEglContext); + EXPECT_EQ(EGL_TRUE, success); + + glClear(GL_COLOR_BUFFER_BIT); + success = eglSwapBuffers(mEglDisplay, eglSurface); + EXPECT_EQ(EGL_TRUE, success); + + mST->abandon(); + + glClear(GL_COLOR_BUFFER_BIT); + success = eglSwapBuffers(mEglDisplay, eglSurface); + EXPECT_EQ(EGL_FALSE, success); + EXPECT_EQ(EGL_BAD_SURFACE, eglGetError()); + + success = eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext); + ASSERT_EQ(EGL_TRUE, success); + + if (eglSurface != EGL_NO_SURFACE) { + eglDestroySurface(mEglDisplay, eglSurface); + } +} + TEST_F(SurfaceTextureClientTest, BufferGeometryInvalidSizesFail) { EXPECT_GT(OK, native_window_set_buffers_geometry(mANW.get(), -1, 0, 0)); EXPECT_GT(OK, native_window_set_buffers_geometry(mANW.get(), 0, -1, 0));