Merge "Added a test that checks the error behavior of ConsumerBase::abandon" into jb-mr2-dev

This commit is contained in:
Mathias Agopian 2013-02-26 00:53:28 +00:00 committed by Android (Google) Code Review
commit 30055f1e96
1 changed files with 31 additions and 1 deletions

View File

@ -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));