Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9c42794a authored by Nolan Scobie's avatar Nolan Scobie
Browse files

Ensure usage flags are always passed to dequeueBuffer in libgui_tests

Bug: 277347398
Bug: 257123981
Test: libgui_test via TEST_MAPPING with selective exclusions in child patch
Change-Id: I7bd56f6006378e4800ab36e4b7c5151017693921
parent cfa41bf6
Loading
Loading
Loading
Loading
+82 −34
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#define LOG_TAG "BufferQueue_test"
//#define LOG_NDEBUG 0

#include "Constants.h"
#include "MockConsumer.h"

#include <gui/BufferItem.h>
@@ -521,7 +522,8 @@ TEST_F(BufferQueueTest, TestGenerationNumbers) {
    int slot;
    sp<Fence> fence;
    ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
              mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr));
              mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS, nullptr,
                                       nullptr));

    sp<GraphicBuffer> buffer;
    ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buffer));
@@ -564,7 +566,8 @@ TEST_F(BufferQueueTest, TestSharedBufferModeWithoutAutoRefresh) {
    sp<Fence> fence;
    sp<GraphicBuffer> buffer;
    ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
              mProducer->dequeueBuffer(&sharedSlot, &fence, 0, 0, 0, 0, nullptr, nullptr));
              mProducer->dequeueBuffer(&sharedSlot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS,
                                       nullptr, nullptr));
    ASSERT_EQ(OK, mProducer->requestBuffer(sharedSlot, &buffer));

    // Queue the buffer
@@ -578,7 +581,9 @@ TEST_F(BufferQueueTest, TestSharedBufferModeWithoutAutoRefresh) {
    // always the same one and because async mode gets enabled.
    int slot;
    for (int i = 0; i < 5; i++) {
        ASSERT_EQ(OK, mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr));
        ASSERT_EQ(OK,
                  mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS,
                                           nullptr, nullptr));
        ASSERT_EQ(sharedSlot, slot);
        ASSERT_EQ(OK, mProducer->queueBuffer(sharedSlot, input, &output));
    }
@@ -615,7 +620,8 @@ TEST_F(BufferQueueTest, TestSharedBufferModeWithAutoRefresh) {
    sp<Fence> fence;
    sp<GraphicBuffer> buffer;
    ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
              mProducer->dequeueBuffer(&sharedSlot, &fence, 0, 0, 0, 0, nullptr, nullptr));
              mProducer->dequeueBuffer(&sharedSlot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS,
                                       nullptr, nullptr));
    ASSERT_EQ(OK, mProducer->requestBuffer(sharedSlot, &buffer));

    // Queue the buffer
@@ -642,7 +648,9 @@ TEST_F(BufferQueueTest, TestSharedBufferModeWithAutoRefresh) {
    // always return the same one.
    int slot;
    for (int i = 0; i < 5; i++) {
        ASSERT_EQ(OK, mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr));
        ASSERT_EQ(OK,
                  mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS,
                                           nullptr, nullptr));
        ASSERT_EQ(sharedSlot, slot);
        ASSERT_EQ(OK, mProducer->queueBuffer(sharedSlot, input, &output));
    }
@@ -681,7 +689,8 @@ TEST_F(BufferQueueTest, TestSharedBufferModeUsingAlreadyDequeuedBuffer) {
    sp<Fence> fence;
    sp<GraphicBuffer> buffer;
    ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
              mProducer->dequeueBuffer(&sharedSlot, &fence, 0, 0, 0, 0, nullptr, nullptr));
              mProducer->dequeueBuffer(&sharedSlot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS,
                                       nullptr, nullptr));
    ASSERT_EQ(OK, mProducer->requestBuffer(sharedSlot, &buffer));

    // Enable shared buffer mode
@@ -698,7 +707,9 @@ TEST_F(BufferQueueTest, TestSharedBufferModeUsingAlreadyDequeuedBuffer) {
    // always the same one and because async mode gets enabled.
    int slot;
    for (int i = 0; i < 5; i++) {
        ASSERT_EQ(OK, mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr));
        ASSERT_EQ(OK,
                  mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS,
                                           nullptr, nullptr));
        ASSERT_EQ(sharedSlot, slot);
        ASSERT_EQ(OK, mProducer->queueBuffer(sharedSlot, input, &output));
    }
@@ -733,7 +744,8 @@ TEST_F(BufferQueueTest, TestTimeouts) {
    for (int i = 0; i < 5; ++i) {
        int slot = BufferQueue::INVALID_BUFFER_SLOT;
        sp<Fence> fence = Fence::NO_FENCE;
        auto result = mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr);
        auto result = mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS,
                                               nullptr, nullptr);
        if (i < 2) {
            ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
                    result);
@@ -760,7 +772,9 @@ TEST_F(BufferQueueTest, TestTimeouts) {
    for (int i = 0; i < 2; ++i) {
        int slot = BufferQueue::INVALID_BUFFER_SLOT;
        sp<Fence> fence = Fence::NO_FENCE;
        ASSERT_EQ(OK, mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr));
        ASSERT_EQ(OK,
                  mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS,
                                           nullptr, nullptr));
        ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buffer));
        IGraphicBufferProducer::QueueBufferInput input(0ull, true,
                HAL_DATASPACE_UNKNOWN, Rect::INVALID_RECT,
@@ -771,7 +785,9 @@ TEST_F(BufferQueueTest, TestTimeouts) {
    int slot = BufferQueue::INVALID_BUFFER_SLOT;
    sp<Fence> fence = Fence::NO_FENCE;
    auto startTime = systemTime();
    ASSERT_EQ(TIMED_OUT, mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr));
    ASSERT_EQ(TIMED_OUT,
              mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS, nullptr,
                                       nullptr));
    ASSERT_GE(systemTime() - startTime, TIMEOUT);

    // We're technically attaching the same buffer multiple times (since we
@@ -792,7 +808,8 @@ TEST_F(BufferQueueTest, CanAttachWhileDisallowingAllocation) {
    int slot = BufferQueue::INVALID_BUFFER_SLOT;
    sp<Fence> sourceFence;
    ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
              mProducer->dequeueBuffer(&slot, &sourceFence, 0, 0, 0, 0, nullptr, nullptr));
              mProducer->dequeueBuffer(&slot, &sourceFence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS,
                                       nullptr, nullptr));
    sp<GraphicBuffer> buffer;
    ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buffer));
    ASSERT_EQ(OK, mProducer->detachBuffer(slot));
@@ -815,7 +832,8 @@ TEST_F(BufferQueueTest, CanRetrieveLastQueuedBuffer) {
    int slot = BufferQueue::INVALID_BUFFER_SLOT;
    sp<Fence> fence;
    ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
              mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr));
              mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS, nullptr,
                                       nullptr));
    sp<GraphicBuffer> firstBuffer;
    ASSERT_EQ(OK, mProducer->requestBuffer(slot, &firstBuffer));

@@ -827,7 +845,8 @@ TEST_F(BufferQueueTest, CanRetrieveLastQueuedBuffer) {
    // Dequeue a second buffer
    slot = BufferQueue::INVALID_BUFFER_SLOT;
    ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
              mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr));
              mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS, nullptr,
                                       nullptr));
    sp<GraphicBuffer> secondBuffer;
    ASSERT_EQ(OK, mProducer->requestBuffer(slot, &secondBuffer));

@@ -878,8 +897,8 @@ TEST_F(BufferQueueTest, TestOccupancyHistory) {
    int slots[3] = {};
    mProducer->setMaxDequeuedBufferCount(3);
    for (size_t i = 0; i < 3; ++i) {
        status_t result =
                mProducer->dequeueBuffer(&slots[i], &fence, 0, 0, 0, 0, nullptr, nullptr);
        status_t result = mProducer->dequeueBuffer(&slots[i], &fence, 0, 0, 0,
                                                   TEST_PRODUCER_USAGE_BITS, nullptr, nullptr);
        ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION, result);
        ASSERT_EQ(OK, mProducer->requestBuffer(slots[i], &buffer));
    }
@@ -892,7 +911,9 @@ TEST_F(BufferQueueTest, TestOccupancyHistory) {
    // The first segment is a two-buffer segment, so we only put one buffer into
    // the queue at a time
    for (size_t i = 0; i < 5; ++i) {
        ASSERT_EQ(OK, mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr));
        ASSERT_EQ(OK,
                  mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS,
                                           nullptr, nullptr));
        ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
        ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, 0));
        ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber,
@@ -907,16 +928,22 @@ TEST_F(BufferQueueTest, TestOccupancyHistory) {
    // two-buffer segment, but then at the end, we put two buffers in the queue
    // at the same time before draining it.
    for (size_t i = 0; i < 5; ++i) {
        ASSERT_EQ(OK, mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr));
        ASSERT_EQ(OK,
                  mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS,
                                           nullptr, nullptr));
        ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
        ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, 0));
        ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber,
                EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, Fence::NO_FENCE));
        std::this_thread::sleep_for(16ms);
    }
    ASSERT_EQ(OK, mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr));
    ASSERT_EQ(OK,
              mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS, nullptr,
                                       nullptr));
    ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
    ASSERT_EQ(OK, mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr));
    ASSERT_EQ(OK,
              mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS, nullptr,
                                       nullptr));
    ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
    ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, 0));
    ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber,
@@ -931,10 +958,14 @@ TEST_F(BufferQueueTest, TestOccupancyHistory) {

    // The third segment is a triple-buffer segment, so the queue is switching
    // between one buffer and two buffers deep.
    ASSERT_EQ(OK, mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr));
    ASSERT_EQ(OK,
              mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS, nullptr,
                                       nullptr));
    ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
    for (size_t i = 0; i < 5; ++i) {
        ASSERT_EQ(OK, mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr));
        ASSERT_EQ(OK,
                  mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS,
                                           nullptr, nullptr));
        ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
        ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, 0));
        ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber,
@@ -1033,8 +1064,8 @@ TEST_F(BufferQueueTest, TestDiscardFreeBuffers) {
    int slots[4] = {};
    mProducer->setMaxDequeuedBufferCount(4);
    for (size_t i = 0; i < 4; ++i) {
        status_t result =
                mProducer->dequeueBuffer(&slots[i], &fence, 0, 0, 0, 0, nullptr, nullptr);
        status_t result = mProducer->dequeueBuffer(&slots[i], &fence, 0, 0, 0,
                                                   TEST_PRODUCER_USAGE_BITS, nullptr, nullptr);
        ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION, result);
        ASSERT_EQ(OK, mProducer->requestBuffer(slots[i], &buffer));
    }
@@ -1045,14 +1076,22 @@ TEST_F(BufferQueueTest, TestDiscardFreeBuffers) {
    // Get buffers in all states: dequeued, filled, acquired, free

    // Fill 3 buffers
    ASSERT_EQ(OK, mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr));
    ASSERT_EQ(OK,
              mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS, nullptr,
                                       nullptr));
    ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
    ASSERT_EQ(OK, mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr));
    ASSERT_EQ(OK,
              mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS, nullptr,
                                       nullptr));
    ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
    ASSERT_EQ(OK, mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr));
    ASSERT_EQ(OK,
              mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS, nullptr,
                                       nullptr));
    ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
    // Dequeue 1 buffer
    ASSERT_EQ(OK, mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr));
    ASSERT_EQ(OK,
              mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS, nullptr,
                                       nullptr));

    // Acquire and free 1 buffer
    ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, 0));
@@ -1118,8 +1157,8 @@ TEST_F(BufferQueueTest, TestBufferReplacedInQueueBuffer) {
    int slots[2] = {};
    ASSERT_EQ(OK, mProducer->setMaxDequeuedBufferCount(2));
    for (size_t i = 0; i < 2; ++i) {
        status_t result =
                mProducer->dequeueBuffer(&slots[i], &fence, 0, 0, 0, 0, nullptr, nullptr);
        status_t result = mProducer->dequeueBuffer(&slots[i], &fence, 0, 0, 0,
                                                   TEST_PRODUCER_USAGE_BITS, nullptr, nullptr);
        ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION, result);
        ASSERT_EQ(OK, mProducer->requestBuffer(slots[i], &buffer));
    }
@@ -1129,10 +1168,14 @@ TEST_F(BufferQueueTest, TestBufferReplacedInQueueBuffer) {

    // Fill 2 buffers without consumer consuming them. Verify that all
    // queued buffer returns proper bufferReplaced flag
    ASSERT_EQ(OK, mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr));
    ASSERT_EQ(OK,
              mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS, nullptr,
                                       nullptr));
    ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
    ASSERT_EQ(false, output.bufferReplaced);
    ASSERT_EQ(OK, mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr));
    ASSERT_EQ(OK,
              mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS, nullptr,
                                       nullptr));
    ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
    ASSERT_EQ(true, output.bufferReplaced);
}
@@ -1153,7 +1196,8 @@ TEST_F(BufferQueueTest, TestStaleBufferHandleSentAfterDisconnect) {
            NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, Fence::NO_FENCE);

    // Dequeue, request, and queue one buffer
    status_t result = mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr);
    status_t result = mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS,
                                               nullptr, nullptr);
    ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION, result);
    ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buffer));
    ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
@@ -1168,7 +1212,9 @@ TEST_F(BufferQueueTest, TestStaleBufferHandleSentAfterDisconnect) {
            EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, Fence::NO_FENCE));

    // Dequeue and queue the buffer again
    ASSERT_EQ(OK, mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr));
    ASSERT_EQ(OK,
              mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS, nullptr,
                                       nullptr));
    ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));

    // Acquire and release the buffer again. Upon acquiring, the buffer handle
@@ -1180,7 +1226,9 @@ TEST_F(BufferQueueTest, TestStaleBufferHandleSentAfterDisconnect) {
            EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, Fence::NO_FENCE));

    // Dequeue and queue the buffer again
    ASSERT_EQ(OK, mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0, nullptr, nullptr));
    ASSERT_EQ(OK,
              mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, TEST_PRODUCER_USAGE_BITS, nullptr,
                                       nullptr));
    ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));

    // Disconnect the producer end. This should clear all of the slots and mark
+22 −0
Original line number Diff line number Diff line
/*
 * Copyright 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <hardware/gralloc.h>

// Arbitrary non-zero usage flag.
constexpr uint64_t TEST_PRODUCER_USAGE_BITS = GRALLOC_USAGE_SW_READ_RARELY;
+1 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#define LOG_TAG "IGraphicBufferProducer_test"
//#define LOG_NDEBUG 0

#include "Constants.h"
#include "MockConsumer.h"

#include <gtest/gtest.h>
@@ -40,7 +41,6 @@
#define TEST_API NATIVE_WINDOW_API_CPU
#define TEST_API_OTHER NATIVE_WINDOW_API_EGL // valid API that's not TEST_API
#define TEST_CONTROLLED_BY_APP false
#define TEST_PRODUCER_USAGE_BITS (0)

namespace android {

+0 −4
Original line number Diff line number Diff line
@@ -151,7 +151,6 @@ TEST(Malicious, Bug36991414Max) {
    sp<MaliciousBQP> malicious = getMaliciousBQP();
    sp<Surface> surface = new Surface(malicious);

    ASSERT_EQ(NO_ERROR, surface->connect(NATIVE_WINDOW_API_CPU, nullptr, false));
    ANativeWindow_Buffer buffer;
    ASSERT_EQ(NO_ERROR, surface->lock(&buffer, nullptr));
    ASSERT_EQ(NO_ERROR, surface->unlockAndPost());
@@ -165,7 +164,6 @@ TEST(Malicious, Bug36991414Min) {
    sp<MaliciousBQP> malicious = getMaliciousBQP();
    sp<Surface> surface = new Surface(malicious);

    ASSERT_EQ(NO_ERROR, surface->connect(NATIVE_WINDOW_API_CPU, nullptr, false));
    ANativeWindow_Buffer buffer;
    ASSERT_EQ(NO_ERROR, surface->lock(&buffer, nullptr));
    ASSERT_EQ(NO_ERROR, surface->unlockAndPost());
@@ -179,7 +177,6 @@ TEST(Malicious, Bug36991414NegativeOne) {
    sp<MaliciousBQP> malicious = getMaliciousBQP();
    sp<Surface> surface = new Surface(malicious);

    ASSERT_EQ(NO_ERROR, surface->connect(NATIVE_WINDOW_API_CPU, nullptr, false));
    ANativeWindow_Buffer buffer;
    ASSERT_EQ(NO_ERROR, surface->lock(&buffer, nullptr));
    ASSERT_EQ(NO_ERROR, surface->unlockAndPost());
@@ -193,7 +190,6 @@ TEST(Malicious, Bug36991414NumSlots) {
    sp<MaliciousBQP> malicious = getMaliciousBQP();
    sp<Surface> surface = new Surface(malicious);

    ASSERT_EQ(NO_ERROR, surface->connect(NATIVE_WINDOW_API_CPU, nullptr, false));
    ANativeWindow_Buffer buffer;
    ASSERT_EQ(NO_ERROR, surface->lock(&buffer, nullptr));
    ASSERT_EQ(NO_ERROR, surface->unlockAndPost());
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#ifndef ANDROID_SURFACE_TEXTURE_GL_H
#define ANDROID_SURFACE_TEXTURE_GL_H

#include "Constants.h"
#include "GLTest.h"

#include "FrameWaiter.h"
@@ -43,6 +44,7 @@ protected:
                true, false);
        mSTC = new Surface(producer);
        mANW = mSTC;
        ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(), TEST_PRODUCER_USAGE_BITS));
        mTextureRenderer = new TextureRenderer(TEX_ID, mST);
        ASSERT_NO_FATAL_FAILURE(mTextureRenderer->SetUp());
        mFW = new FrameWaiter;
Loading