From d8ead0ccd4b700e43a78efe9b140d4a069dc343d Mon Sep 17 00:00:00 2001 From: Michael Lentine Date: Tue, 19 May 2015 15:23:43 -0700 Subject: [PATCH] Fix libgui tests. Update IGraphicsBufferProducerTest to the new maximum enum value which is now NATIVE_WINDOW_BUFFER_AGE. Update SurfaceTextureGLToGL_test to use the correct counts for GraphicsBuffer refs. Buf: 18138368 Change-Id: Ie2f7e00b414d63100b16944e3ab36b1ffceecd57 --- .../gui/tests/IGraphicBufferProducer_test.cpp | 2 +- libs/gui/tests/SurfaceTextureGLToGL_test.cpp | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/libs/gui/tests/IGraphicBufferProducer_test.cpp b/libs/gui/tests/IGraphicBufferProducer_test.cpp index ff5842016..4ef9a6984 100644 --- a/libs/gui/tests/IGraphicBufferProducer_test.cpp +++ b/libs/gui/tests/IGraphicBufferProducer_test.cpp @@ -299,7 +299,7 @@ TEST_F(IGraphicBufferProducerTest, Query_ReturnsError) { ASSERT_NO_FATAL_FAILURE(ConnectProducer()); // One past the end of the last 'query' enum value. Update this if we add more enums. - const int NATIVE_WINDOW_QUERY_LAST_OFF_BY_ONE = NATIVE_WINDOW_DEFAULT_DATASPACE + 1; + const int NATIVE_WINDOW_QUERY_LAST_OFF_BY_ONE = NATIVE_WINDOW_BUFFER_AGE + 1; int value; // What was out of range diff --git a/libs/gui/tests/SurfaceTextureGLToGL_test.cpp b/libs/gui/tests/SurfaceTextureGLToGL_test.cpp index f4c796131..6edbfb87a 100644 --- a/libs/gui/tests/SurfaceTextureGLToGL_test.cpp +++ b/libs/gui/tests/SurfaceTextureGLToGL_test.cpp @@ -188,10 +188,10 @@ TEST_F(SurfaceTextureGLToGLTest, EglDestroySurfaceUnrefsBuffers) { // This test should have the only reference to buffer 0. EXPECT_EQ(1, buffers[0]->getStrongCount()); - // The GLConsumer should hold a single reference to buffer 1 in its - // mCurrentBuffer member. All of the references in the slots should have - // been released. - EXPECT_EQ(2, buffers[1]->getStrongCount()); + // The GLConsumer should hold one reference to buffer 1 in its + // mCurrentTextureImage member and another reference in mEglSlots. The third + // reference is in this test. + EXPECT_EQ(3, buffers[1]->getStrongCount()); } TEST_F(SurfaceTextureGLToGLTest, EglDestroySurfaceAfterAbandonUnrefsBuffers) { @@ -235,14 +235,19 @@ TEST_F(SurfaceTextureGLToGLTest, EglDestroySurfaceAfterAbandonUnrefsBuffers) { ASSERT_EQ(EGL_SUCCESS, eglGetError()); mProducerEglSurface = EGL_NO_SURFACE; - EXPECT_EQ(1, buffers[0]->getStrongCount()); EXPECT_EQ(1, buffers[1]->getStrongCount()); // Depending on how lazily the GL driver dequeues buffers, we may end up - // with either two or three total buffers. If there are three, make sure - // the last one was properly down-ref'd. + // with either two or three total buffers. If there are three, each entry + // of the buffers array will be unique and there should only be one + // reference (the one in this test). If there are two the first and last + // element in the array will be equal meaning that buffer representing both + // 0 and 2 will have two references (one for 0 and one for 2). if (buffers[2] != buffers[0]) { + EXPECT_EQ(1, buffers[0]->getStrongCount()); EXPECT_EQ(1, buffers[2]->getStrongCount()); + } else { + EXPECT_EQ(2, buffers[0]->getStrongCount()); } }