am fece8306: am 56f1f16c: Merge "libgui: Fix some bitrot/warnings in tests"

* commit 'fece83060e9640636f00a97fe236aff353d78c71':
  libgui: Fix some bitrot/warnings in tests
This commit is contained in:
Dan Stoza 2015-04-23 23:13:56 +00:00 committed by Android Git Automerger
commit 65f68d5cb4
9 changed files with 112 additions and 81 deletions

View File

@ -3,6 +3,8 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_CLANG := true
LOCAL_MODULE := libgui_test LOCAL_MODULE := libgui_test
LOCAL_MODULE_TAGS := tests LOCAL_MODULE_TAGS := tests

View File

@ -73,6 +73,8 @@ struct DummyConsumer : public BnConsumerListener {
virtual void onSidebandStreamChanged() {} virtual void onSidebandStreamChanged() {}
}; };
static const uint32_t TEST_DATA = 0x12345678u;
// XXX: Tests that fork a process to hold the BufferQueue must run before tests // XXX: Tests that fork a process to hold the BufferQueue must run before tests
// that use a local BufferQueue, or else Binder will get unhappy // that use a local BufferQueue, or else Binder will get unhappy
TEST_F(BufferQueueTest, BufferQueueInAnotherProcess) { TEST_F(BufferQueueTest, BufferQueueInAnotherProcess) {
@ -122,7 +124,7 @@ TEST_F(BufferQueueTest, BufferQueueInAnotherProcess) {
uint32_t* dataIn; uint32_t* dataIn;
ASSERT_EQ(OK, buffer->lock(GraphicBuffer::USAGE_SW_WRITE_OFTEN, ASSERT_EQ(OK, buffer->lock(GraphicBuffer::USAGE_SW_WRITE_OFTEN,
reinterpret_cast<void**>(&dataIn))); reinterpret_cast<void**>(&dataIn)));
*dataIn = 0x12345678; *dataIn = TEST_DATA;
ASSERT_EQ(OK, buffer->unlock()); ASSERT_EQ(OK, buffer->unlock());
IGraphicBufferProducer::QueueBufferInput input(0, false, IGraphicBufferProducer::QueueBufferInput input(0, false,
@ -136,7 +138,7 @@ TEST_F(BufferQueueTest, BufferQueueInAnotherProcess) {
uint32_t* dataOut; uint32_t* dataOut;
ASSERT_EQ(OK, item.mGraphicBuffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN, ASSERT_EQ(OK, item.mGraphicBuffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN,
reinterpret_cast<void**>(&dataOut))); reinterpret_cast<void**>(&dataOut)));
ASSERT_EQ(*dataOut, 0x12345678); ASSERT_EQ(*dataOut, TEST_DATA);
ASSERT_EQ(OK, item.mGraphicBuffer->unlock()); ASSERT_EQ(OK, item.mGraphicBuffer->unlock());
} }
@ -239,7 +241,7 @@ TEST_F(BufferQueueTest, DetachAndReattachOnProducerSide) {
uint32_t* dataIn; uint32_t* dataIn;
ASSERT_EQ(OK, buffer->lock(GraphicBuffer::USAGE_SW_WRITE_OFTEN, ASSERT_EQ(OK, buffer->lock(GraphicBuffer::USAGE_SW_WRITE_OFTEN,
reinterpret_cast<void**>(&dataIn))); reinterpret_cast<void**>(&dataIn)));
*dataIn = 0x12345678; *dataIn = TEST_DATA;
ASSERT_EQ(OK, buffer->unlock()); ASSERT_EQ(OK, buffer->unlock());
int newSlot; int newSlot;
@ -258,7 +260,7 @@ TEST_F(BufferQueueTest, DetachAndReattachOnProducerSide) {
uint32_t* dataOut; uint32_t* dataOut;
ASSERT_EQ(OK, item.mGraphicBuffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN, ASSERT_EQ(OK, item.mGraphicBuffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN,
reinterpret_cast<void**>(&dataOut))); reinterpret_cast<void**>(&dataOut)));
ASSERT_EQ(*dataOut, 0x12345678); ASSERT_EQ(*dataOut, TEST_DATA);
ASSERT_EQ(OK, item.mGraphicBuffer->unlock()); ASSERT_EQ(OK, item.mGraphicBuffer->unlock());
} }
@ -297,7 +299,7 @@ TEST_F(BufferQueueTest, DetachAndReattachOnConsumerSide) {
ASSERT_EQ(OK, item.mGraphicBuffer->lock( ASSERT_EQ(OK, item.mGraphicBuffer->lock(
GraphicBuffer::USAGE_SW_WRITE_OFTEN, GraphicBuffer::USAGE_SW_WRITE_OFTEN,
reinterpret_cast<void**>(&dataIn))); reinterpret_cast<void**>(&dataIn)));
*dataIn = 0x12345678; *dataIn = TEST_DATA;
ASSERT_EQ(OK, item.mGraphicBuffer->unlock()); ASSERT_EQ(OK, item.mGraphicBuffer->unlock());
int newSlot; int newSlot;
@ -317,7 +319,7 @@ TEST_F(BufferQueueTest, DetachAndReattachOnConsumerSide) {
uint32_t* dataOut; uint32_t* dataOut;
ASSERT_EQ(OK, buffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN, ASSERT_EQ(OK, buffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN,
reinterpret_cast<void**>(&dataOut))); reinterpret_cast<void**>(&dataOut)));
ASSERT_EQ(*dataOut, 0x12345678); ASSERT_EQ(*dataOut, TEST_DATA);
ASSERT_EQ(OK, buffer->unlock()); ASSERT_EQ(OK, buffer->unlock());
} }
@ -340,7 +342,7 @@ TEST_F(BufferQueueTest, MoveFromConsumerToProducer) {
uint32_t* dataIn; uint32_t* dataIn;
ASSERT_EQ(OK, buffer->lock(GraphicBuffer::USAGE_SW_WRITE_OFTEN, ASSERT_EQ(OK, buffer->lock(GraphicBuffer::USAGE_SW_WRITE_OFTEN,
reinterpret_cast<void**>(&dataIn))); reinterpret_cast<void**>(&dataIn)));
*dataIn = 0x12345678; *dataIn = TEST_DATA;
ASSERT_EQ(OK, buffer->unlock()); ASSERT_EQ(OK, buffer->unlock());
IGraphicBufferProducer::QueueBufferInput input(0, false, IGraphicBufferProducer::QueueBufferInput input(0, false,
@ -360,7 +362,7 @@ TEST_F(BufferQueueTest, MoveFromConsumerToProducer) {
uint32_t* dataOut; uint32_t* dataOut;
ASSERT_EQ(OK, item.mGraphicBuffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN, ASSERT_EQ(OK, item.mGraphicBuffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN,
reinterpret_cast<void**>(&dataOut))); reinterpret_cast<void**>(&dataOut)));
ASSERT_EQ(*dataOut, 0x12345678); ASSERT_EQ(*dataOut, TEST_DATA);
ASSERT_EQ(OK, item.mGraphicBuffer->unlock()); ASSERT_EQ(OK, item.mGraphicBuffer->unlock());
} }

View File

@ -94,7 +94,7 @@ protected:
mPendingFrames--; mPendingFrames--;
} }
virtual void onFrameAvailable() { virtual void onFrameAvailable(const BufferItem&) {
Mutex::Autolock lock(mMutex); Mutex::Autolock lock(mMutex);
mPendingFrames++; mPendingFrames++;
mCondition.signal(); mCondition.signal();
@ -125,7 +125,7 @@ protected:
mPendingFrames--; mPendingFrames--;
} }
virtual void onFrameAvailable() { virtual void onFrameAvailable(const BufferItem&) {
Mutex::Autolock lock(mMutex); Mutex::Autolock lock(mMutex);
mPendingFrames++; mPendingFrames++;
mFrameCondition.signal(); mFrameCondition.signal();
@ -457,9 +457,12 @@ void configureANW(const sp<ANativeWindow>& anw,
const CpuConsumerTestParams& params, const CpuConsumerTestParams& params,
int maxBufferSlack) { int maxBufferSlack) {
status_t err; status_t err;
err = native_window_set_buffers_geometry(anw.get(), err = native_window_set_buffers_dimensions(anw.get(),
params.width, params.height, params.format); params.width, params.height);
ASSERT_NO_ERROR(err, "set_buffers_geometry error: "); ASSERT_NO_ERROR(err, "set_buffers_dimensions error: ");
err = native_window_set_buffers_format(anw.get(), params.format);
ASSERT_NO_ERROR(err, "set_buffers_format error: ");
err = native_window_set_usage(anw.get(), err = native_window_set_usage(anw.get(),
GRALLOC_USAGE_SW_WRITE_OFTEN); GRALLOC_USAGE_SW_WRITE_OFTEN);

View File

@ -38,31 +38,31 @@
#define TEST_CONTROLLED_BY_APP false #define TEST_CONTROLLED_BY_APP false
#define TEST_PRODUCER_USAGE_BITS (0) #define TEST_PRODUCER_USAGE_BITS (0)
// TODO: Make these public constants in a header
enum {
// Default dimensions before setDefaultBufferSize is called
DEFAULT_WIDTH = 1,
DEFAULT_HEIGHT = 1,
// Default format before setDefaultBufferFormat is called
DEFAULT_FORMAT = HAL_PIXEL_FORMAT_RGBA_8888,
// Default transform hint before setTransformHint is called
DEFAULT_TRANSFORM_HINT = 0,
};
namespace android { namespace android {
namespace { namespace {
// Parameters for a generic "valid" input for queueBuffer. // Default dimensions before setDefaultBufferSize is called
const int64_t QUEUE_BUFFER_INPUT_TIMESTAMP = 1384888611; const uint32_t DEFAULT_WIDTH = 1;
const bool QUEUE_BUFFER_INPUT_IS_AUTO_TIMESTAMP = false; const uint32_t DEFAULT_HEIGHT = 1;
const android_dataspace QUEUE_BUFFER_INPUT_DATASPACE = HAL_DATASPACE_UNKNOWN;
const Rect QUEUE_BUFFER_INPUT_RECT = Rect(DEFAULT_WIDTH, DEFAULT_HEIGHT); // Default format before setDefaultBufferFormat is called
const int QUEUE_BUFFER_INPUT_SCALING_MODE = 0; const PixelFormat DEFAULT_FORMAT = HAL_PIXEL_FORMAT_RGBA_8888;
const int QUEUE_BUFFER_INPUT_TRANSFORM = 0;
const bool QUEUE_BUFFER_INPUT_ASYNC = false; // Default transform hint before setTransformHint is called
const sp<Fence> QUEUE_BUFFER_INPUT_FENCE = Fence::NO_FENCE; const uint32_t DEFAULT_TRANSFORM_HINT = 0;
// TODO: Make these constants in header
const int DEFAULT_CONSUMER_USAGE_BITS = 0;
// Parameters for a generic "valid" input for queueBuffer.
const int64_t QUEUE_BUFFER_INPUT_TIMESTAMP = 1384888611;
const bool QUEUE_BUFFER_INPUT_IS_AUTO_TIMESTAMP = false;
const android_dataspace QUEUE_BUFFER_INPUT_DATASPACE = HAL_DATASPACE_UNKNOWN;
const Rect QUEUE_BUFFER_INPUT_RECT = Rect(DEFAULT_WIDTH, DEFAULT_HEIGHT);
const int QUEUE_BUFFER_INPUT_SCALING_MODE = 0;
const int QUEUE_BUFFER_INPUT_TRANSFORM = 0;
const bool QUEUE_BUFFER_INPUT_ASYNC = false;
const sp<Fence> QUEUE_BUFFER_INPUT_FENCE = Fence::NO_FENCE;
}; // namespace anonymous }; // namespace anonymous
struct DummyConsumer : public BnConsumerListener { struct DummyConsumer : public BnConsumerListener {
@ -273,15 +273,12 @@ TEST_F(IGraphicBufferProducerTest, Disconnect_ReturnsError) {
TEST_F(IGraphicBufferProducerTest, Query_Succeeds) { TEST_F(IGraphicBufferProducerTest, Query_Succeeds) {
ASSERT_NO_FATAL_FAILURE(ConnectProducer()); ASSERT_NO_FATAL_FAILURE(ConnectProducer());
// TODO: Make these constants in header int32_t value = -1;
const int DEFAULT_CONSUMER_USAGE_BITS = 0;
int value = -1;
EXPECT_OK(mProducer->query(NATIVE_WINDOW_WIDTH, &value)); EXPECT_OK(mProducer->query(NATIVE_WINDOW_WIDTH, &value));
EXPECT_EQ(DEFAULT_WIDTH, value); EXPECT_EQ(DEFAULT_WIDTH, static_cast<uint32_t>(value));
EXPECT_OK(mProducer->query(NATIVE_WINDOW_HEIGHT, &value)); EXPECT_OK(mProducer->query(NATIVE_WINDOW_HEIGHT, &value));
EXPECT_EQ(DEFAULT_HEIGHT, value); EXPECT_EQ(DEFAULT_HEIGHT, static_cast<uint32_t>(value));
EXPECT_OK(mProducer->query(NATIVE_WINDOW_FORMAT, &value)); EXPECT_OK(mProducer->query(NATIVE_WINDOW_FORMAT, &value));
EXPECT_EQ(DEFAULT_FORMAT, value); EXPECT_EQ(DEFAULT_FORMAT, value);
@ -302,7 +299,7 @@ TEST_F(IGraphicBufferProducerTest, Query_ReturnsError) {
ASSERT_NO_FATAL_FAILURE(ConnectProducer()); ASSERT_NO_FATAL_FAILURE(ConnectProducer());
// One past the end of the last 'query' enum value. Update this if we add more enums. // 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_CONSUMER_USAGE_BITS + 1; const int NATIVE_WINDOW_QUERY_LAST_OFF_BY_ONE = NATIVE_WINDOW_DEFAULT_DATASPACE + 1;
int value; int value;
// What was out of range // What was out of range
@ -369,7 +366,7 @@ TEST_F(IGraphicBufferProducerTest, Queue_Succeeds) {
EXPECT_EQ(DEFAULT_WIDTH, width); EXPECT_EQ(DEFAULT_WIDTH, width);
EXPECT_EQ(DEFAULT_HEIGHT, height); EXPECT_EQ(DEFAULT_HEIGHT, height);
EXPECT_EQ(DEFAULT_TRANSFORM_HINT, transformHint); EXPECT_EQ(DEFAULT_TRANSFORM_HINT, transformHint);
EXPECT_EQ(1, numPendingBuffers); // since queueBuffer was called exactly once EXPECT_EQ(1u, numPendingBuffers); // since queueBuffer was called exactly once
} }
// Buffer was not in the dequeued state // Buffer was not in the dequeued state

View File

@ -17,6 +17,10 @@
#define LOG_TAG "SRGB_test" #define LOG_TAG "SRGB_test"
//#define LOG_NDEBUG 0 //#define LOG_NDEBUG 0
// Ignore for this file because it flags every instance of
// ASSERT_EQ(GL_NO_ERROR, glGetError());
#pragma clang diagnostic ignored "-Wsign-compare"
#include "GLTest.h" #include "GLTest.h"
#include <math.h> #include <math.h>
@ -329,9 +333,9 @@ private:
ANativeWindow_Buffer outBuffer; ANativeWindow_Buffer outBuffer;
ARect outBufferBounds; ARect outBufferBounds;
mOutputSurface->lock(&outBuffer, &outBufferBounds); mOutputSurface->lock(&outBuffer, &outBufferBounds);
ASSERT_EQ(mLockedBuffer.width, outBuffer.width); ASSERT_EQ(mLockedBuffer.width, static_cast<uint32_t>(outBuffer.width));
ASSERT_EQ(mLockedBuffer.height, outBuffer.height); ASSERT_EQ(mLockedBuffer.height, static_cast<uint32_t>(outBuffer.height));
ASSERT_EQ(mLockedBuffer.stride, outBuffer.stride); ASSERT_EQ(mLockedBuffer.stride, static_cast<uint32_t>(outBuffer.stride));
if (mLockedBuffer.format == outBuffer.format) { if (mLockedBuffer.format == outBuffer.format) {
memcpy(outBuffer.bits, mLockedBuffer.data, bufferSize); memcpy(outBuffer.bits, mLockedBuffer.data, bufferSize);
@ -401,7 +405,8 @@ TEST_F(SRGBTest, GLRenderFromSRGBTexture) {
// the debug surface if necessary // the debug surface if necessary
} }
TEST_F(SRGBTest, RenderToSRGBSurface) { // XXX: Disabled since we don't currently expect this to work
TEST_F(SRGBTest, DISABLED_RenderToSRGBSurface) {
ASSERT_NO_FATAL_FAILURE(initShaders()); ASSERT_NO_FATAL_FAILURE(initShaders());
// By default, the first buffer we write into will be RGB // By default, the first buffer we write into will be RGB

View File

@ -76,6 +76,8 @@ private:
int mAllocCount; int mAllocCount;
}; };
static const uint32_t TEST_DATA = 0x12345678u;
TEST_F(StreamSplitterTest, OneInputOneOutput) { TEST_F(StreamSplitterTest, OneInputOneOutput) {
sp<CountedAllocator> allocator(new CountedAllocator); sp<CountedAllocator> allocator(new CountedAllocator);
@ -108,7 +110,7 @@ TEST_F(StreamSplitterTest, OneInputOneOutput) {
uint32_t* dataIn; uint32_t* dataIn;
ASSERT_EQ(OK, buffer->lock(GraphicBuffer::USAGE_SW_WRITE_OFTEN, ASSERT_EQ(OK, buffer->lock(GraphicBuffer::USAGE_SW_WRITE_OFTEN,
reinterpret_cast<void**>(&dataIn))); reinterpret_cast<void**>(&dataIn)));
*dataIn = 0x12345678; *dataIn = TEST_DATA;
ASSERT_EQ(OK, buffer->unlock()); ASSERT_EQ(OK, buffer->unlock());
IGraphicBufferProducer::QueueBufferInput qbInput(0, false, IGraphicBufferProducer::QueueBufferInput qbInput(0, false,
@ -123,7 +125,7 @@ TEST_F(StreamSplitterTest, OneInputOneOutput) {
uint32_t* dataOut; uint32_t* dataOut;
ASSERT_EQ(OK, item.mGraphicBuffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN, ASSERT_EQ(OK, item.mGraphicBuffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN,
reinterpret_cast<void**>(&dataOut))); reinterpret_cast<void**>(&dataOut)));
ASSERT_EQ(*dataOut, 0x12345678); ASSERT_EQ(*dataOut, TEST_DATA);
ASSERT_EQ(OK, item.mGraphicBuffer->unlock()); ASSERT_EQ(OK, item.mGraphicBuffer->unlock());
ASSERT_EQ(OK, outputConsumer->releaseBuffer(item.mBuf, item.mFrameNumber, ASSERT_EQ(OK, outputConsumer->releaseBuffer(item.mBuf, item.mFrameNumber,
@ -175,7 +177,7 @@ TEST_F(StreamSplitterTest, OneInputMultipleOutputs) {
uint32_t* dataIn; uint32_t* dataIn;
ASSERT_EQ(OK, buffer->lock(GraphicBuffer::USAGE_SW_WRITE_OFTEN, ASSERT_EQ(OK, buffer->lock(GraphicBuffer::USAGE_SW_WRITE_OFTEN,
reinterpret_cast<void**>(&dataIn))); reinterpret_cast<void**>(&dataIn)));
*dataIn = 0x12345678; *dataIn = TEST_DATA;
ASSERT_EQ(OK, buffer->unlock()); ASSERT_EQ(OK, buffer->unlock());
IGraphicBufferProducer::QueueBufferInput qbInput(0, false, IGraphicBufferProducer::QueueBufferInput qbInput(0, false,
@ -191,7 +193,7 @@ TEST_F(StreamSplitterTest, OneInputMultipleOutputs) {
uint32_t* dataOut; uint32_t* dataOut;
ASSERT_EQ(OK, item.mGraphicBuffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN, ASSERT_EQ(OK, item.mGraphicBuffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN,
reinterpret_cast<void**>(&dataOut))); reinterpret_cast<void**>(&dataOut)));
ASSERT_EQ(*dataOut, 0x12345678); ASSERT_EQ(*dataOut, TEST_DATA);
ASSERT_EQ(OK, item.mGraphicBuffer->unlock()); ASSERT_EQ(OK, item.mGraphicBuffer->unlock());
ASSERT_EQ(OK, outputConsumers[output]->releaseBuffer(item.mBuf, ASSERT_EQ(OK, outputConsumers[output]->releaseBuffer(item.mBuf,

View File

@ -207,12 +207,8 @@ TEST_F(SurfaceTextureClientTest, EglSwapBuffersAbandonErrorIsEglBadSurface) {
} }
TEST_F(SurfaceTextureClientTest, BufferGeometryInvalidSizesFail) { TEST_F(SurfaceTextureClientTest, BufferGeometryInvalidSizesFail) {
EXPECT_GT(OK, native_window_set_buffers_geometry(mANW.get(), -1, 0, 0)); EXPECT_GT(OK, native_window_set_buffers_dimensions(mANW.get(), 0, 8));
EXPECT_GT(OK, native_window_set_buffers_geometry(mANW.get(), 0, -1, 0)); EXPECT_GT(OK, native_window_set_buffers_dimensions(mANW.get(), 8, 0));
EXPECT_GT(OK, native_window_set_buffers_geometry(mANW.get(), 0, 0, -1));
EXPECT_GT(OK, native_window_set_buffers_geometry(mANW.get(), -1, -1, 0));
EXPECT_GT(OK, native_window_set_buffers_geometry(mANW.get(), 0, 8, 0));
EXPECT_GT(OK, native_window_set_buffers_geometry(mANW.get(), 8, 0, 0));
} }
TEST_F(SurfaceTextureClientTest, DefaultGeometryValues) { TEST_F(SurfaceTextureClientTest, DefaultGeometryValues) {
@ -226,7 +222,8 @@ TEST_F(SurfaceTextureClientTest, DefaultGeometryValues) {
TEST_F(SurfaceTextureClientTest, BufferGeometryCanBeSet) { TEST_F(SurfaceTextureClientTest, BufferGeometryCanBeSet) {
ANativeWindowBuffer* buf; ANativeWindowBuffer* buf;
EXPECT_EQ(OK, native_window_set_buffers_geometry(mANW.get(), 16, 8, PIXEL_FORMAT_RGB_565)); EXPECT_EQ(OK, native_window_set_buffers_dimensions(mANW.get(), 16, 8));
EXPECT_EQ(OK, native_window_set_buffers_format(mANW.get(), PIXEL_FORMAT_RGB_565));
ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf)); ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf));
EXPECT_EQ(16, buf->width); EXPECT_EQ(16, buf->width);
EXPECT_EQ(8, buf->height); EXPECT_EQ(8, buf->height);
@ -236,7 +233,8 @@ TEST_F(SurfaceTextureClientTest, BufferGeometryCanBeSet) {
TEST_F(SurfaceTextureClientTest, BufferGeometryDefaultSizeSetFormat) { TEST_F(SurfaceTextureClientTest, BufferGeometryDefaultSizeSetFormat) {
ANativeWindowBuffer* buf; ANativeWindowBuffer* buf;
EXPECT_EQ(OK, native_window_set_buffers_geometry(mANW.get(), 0, 0, PIXEL_FORMAT_RGB_565)); EXPECT_EQ(OK, native_window_set_buffers_dimensions(mANW.get(), 0, 0));
EXPECT_EQ(OK, native_window_set_buffers_format(mANW.get(), PIXEL_FORMAT_RGB_565));
ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf)); ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf));
EXPECT_EQ(1, buf->width); EXPECT_EQ(1, buf->width);
EXPECT_EQ(1, buf->height); EXPECT_EQ(1, buf->height);
@ -246,7 +244,8 @@ TEST_F(SurfaceTextureClientTest, BufferGeometryDefaultSizeSetFormat) {
TEST_F(SurfaceTextureClientTest, BufferGeometrySetSizeDefaultFormat) { TEST_F(SurfaceTextureClientTest, BufferGeometrySetSizeDefaultFormat) {
ANativeWindowBuffer* buf; ANativeWindowBuffer* buf;
EXPECT_EQ(OK, native_window_set_buffers_geometry(mANW.get(), 16, 8, 0)); EXPECT_EQ(OK, native_window_set_buffers_dimensions(mANW.get(), 16, 8));
EXPECT_EQ(OK, native_window_set_buffers_format(mANW.get(), 0));
ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf)); ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf));
EXPECT_EQ(16, buf->width); EXPECT_EQ(16, buf->width);
EXPECT_EQ(8, buf->height); EXPECT_EQ(8, buf->height);
@ -256,13 +255,15 @@ TEST_F(SurfaceTextureClientTest, BufferGeometrySetSizeDefaultFormat) {
TEST_F(SurfaceTextureClientTest, BufferGeometrySizeCanBeUnset) { TEST_F(SurfaceTextureClientTest, BufferGeometrySizeCanBeUnset) {
ANativeWindowBuffer* buf; ANativeWindowBuffer* buf;
EXPECT_EQ(OK, native_window_set_buffers_geometry(mANW.get(), 16, 8, 0)); EXPECT_EQ(OK, native_window_set_buffers_dimensions(mANW.get(), 16, 8));
EXPECT_EQ(OK, native_window_set_buffers_format(mANW.get(), 0));
ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf)); ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf));
EXPECT_EQ(16, buf->width); EXPECT_EQ(16, buf->width);
EXPECT_EQ(8, buf->height); EXPECT_EQ(8, buf->height);
EXPECT_EQ(PIXEL_FORMAT_RGBA_8888, buf->format); EXPECT_EQ(PIXEL_FORMAT_RGBA_8888, buf->format);
ASSERT_EQ(OK, mANW->cancelBuffer(mANW.get(), buf, -1)); ASSERT_EQ(OK, mANW->cancelBuffer(mANW.get(), buf, -1));
EXPECT_EQ(OK, native_window_set_buffers_geometry(mANW.get(), 0, 0, 0)); EXPECT_EQ(OK, native_window_set_buffers_dimensions(mANW.get(), 0, 0));
EXPECT_EQ(OK, native_window_set_buffers_format(mANW.get(), 0));
ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf)); ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf));
EXPECT_EQ(1, buf->width); EXPECT_EQ(1, buf->width);
EXPECT_EQ(1, buf->height); EXPECT_EQ(1, buf->height);
@ -272,7 +273,8 @@ TEST_F(SurfaceTextureClientTest, BufferGeometrySizeCanBeUnset) {
TEST_F(SurfaceTextureClientTest, BufferGeometrySizeCanBeChangedWithoutFormat) { TEST_F(SurfaceTextureClientTest, BufferGeometrySizeCanBeChangedWithoutFormat) {
ANativeWindowBuffer* buf; ANativeWindowBuffer* buf;
EXPECT_EQ(OK, native_window_set_buffers_geometry(mANW.get(), 0, 0, PIXEL_FORMAT_RGB_565)); EXPECT_EQ(OK, native_window_set_buffers_dimensions(mANW.get(), 0, 0));
EXPECT_EQ(OK, native_window_set_buffers_format(mANW.get(), PIXEL_FORMAT_RGB_565));
ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf)); ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf));
EXPECT_EQ(1, buf->width); EXPECT_EQ(1, buf->width);
EXPECT_EQ(1, buf->height); EXPECT_EQ(1, buf->height);
@ -330,7 +332,8 @@ TEST_F(SurfaceTextureClientTest, SurfaceTextureSetDefaultSizeVsGeometry) {
EXPECT_EQ(8, buf[1]->height); EXPECT_EQ(8, buf[1]->height);
ASSERT_EQ(OK, mANW->cancelBuffer(mANW.get(), buf[0], -1)); ASSERT_EQ(OK, mANW->cancelBuffer(mANW.get(), buf[0], -1));
ASSERT_EQ(OK, mANW->cancelBuffer(mANW.get(), buf[1], -1)); ASSERT_EQ(OK, mANW->cancelBuffer(mANW.get(), buf[1], -1));
EXPECT_EQ(OK, native_window_set_buffers_geometry(mANW.get(), 12, 24, 0)); EXPECT_EQ(OK, native_window_set_buffers_dimensions(mANW.get(), 12, 24));
EXPECT_EQ(OK, native_window_set_buffers_format(mANW.get(), 0));
ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf[0])); ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf[0]));
ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf[1])); ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf[1]));
EXPECT_NE(buf[0], buf[1]); EXPECT_NE(buf[0], buf[1]);
@ -468,7 +471,8 @@ TEST_F(SurfaceTextureClientTest, SurfaceTextureSyncModeMinUndequeued) {
// Once we've queued a buffer, however we should not be able to dequeue more // Once we've queued a buffer, however we should not be able to dequeue more
// than (buffer-count - MIN_UNDEQUEUED_BUFFERS), which is 2 in this case. // than (buffer-count - MIN_UNDEQUEUED_BUFFERS), which is 2 in this case.
EXPECT_EQ(-EBUSY, native_window_dequeue_buffer_and_wait(mANW.get(), &buf[1])); EXPECT_EQ(INVALID_OPERATION,
native_window_dequeue_buffer_and_wait(mANW.get(), &buf[1]));
ASSERT_EQ(OK, mANW->cancelBuffer(mANW.get(), buf[0], -1)); ASSERT_EQ(OK, mANW->cancelBuffer(mANW.get(), buf[0], -1));
ASSERT_EQ(OK, mANW->cancelBuffer(mANW.get(), buf[2], -1)); ASSERT_EQ(OK, mANW->cancelBuffer(mANW.get(), buf[2], -1));
@ -620,7 +624,8 @@ TEST_F(SurfaceTextureClientTest, GetTransformMatrixSucceedsAfterFreeingBuffersWi
crop.bottom = 5; crop.bottom = 5;
ASSERT_EQ(OK, native_window_set_buffer_count(mANW.get(), 4)); ASSERT_EQ(OK, native_window_set_buffer_count(mANW.get(), 4));
ASSERT_EQ(OK, native_window_set_buffers_geometry(mANW.get(), 8, 8, 0)); ASSERT_EQ(OK, native_window_set_buffers_dimensions(mANW.get(), 8, 8));
ASSERT_EQ(OK, native_window_set_buffers_format(mANW.get(), 0));
ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf[0])); ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf[0]));
ASSERT_EQ(OK, native_window_set_crop(mANW.get(), &crop)); ASSERT_EQ(OK, native_window_set_crop(mANW.get(), &crop));
ASSERT_EQ(OK, mANW->queueBuffer(mANW.get(), buf[0], -1)); ASSERT_EQ(OK, mANW->queueBuffer(mANW.get(), buf[0], -1));
@ -668,7 +673,8 @@ TEST_F(SurfaceTextureClientTest, QueryFormatAfterSettingWorks) {
const int numFmts = (sizeof(fmts) / sizeof(fmts[0])); const int numFmts = (sizeof(fmts) / sizeof(fmts[0]));
for (int i = 0; i < numFmts; i++) { for (int i = 0; i < numFmts; i++) {
int fmt = -1; int fmt = -1;
ASSERT_EQ(OK, native_window_set_buffers_geometry(anw.get(), 0, 0, fmts[i])); ASSERT_EQ(OK, native_window_set_buffers_dimensions(anw.get(), 0, 0));
ASSERT_EQ(OK, native_window_set_buffers_format(anw.get(), fmts[i]));
ASSERT_EQ(OK, anw->query(anw.get(), NATIVE_WINDOW_FORMAT, &fmt)); ASSERT_EQ(OK, anw->query(anw.get(), NATIVE_WINDOW_FORMAT, &fmt));
EXPECT_EQ(fmts[i], fmt); EXPECT_EQ(fmts[i], fmt);
} }

View File

@ -27,8 +27,10 @@ TEST_F(SurfaceTextureFBOTest, BlitFromCpuFilledBufferToFbo) {
const int texWidth = 64; const int texWidth = 64;
const int texHeight = 64; const int texHeight = 64;
ASSERT_EQ(NO_ERROR, native_window_set_buffers_geometry(mANW.get(), ASSERT_EQ(NO_ERROR, native_window_set_buffers_dimensions(mANW.get(),
texWidth, texHeight, HAL_PIXEL_FORMAT_RGBA_8888)); texWidth, texHeight));
ASSERT_EQ(NO_ERROR, native_window_set_buffers_format(mANW.get(),
HAL_PIXEL_FORMAT_RGBA_8888));
ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(), ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN)); GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN));

View File

@ -28,8 +28,10 @@ TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledYV12BufferNpot) {
const int texWidth = 64; const int texWidth = 64;
const int texHeight = 66; const int texHeight = 66;
ASSERT_EQ(NO_ERROR, native_window_set_buffers_geometry(mANW.get(), ASSERT_EQ(NO_ERROR, native_window_set_buffers_dimensions(mANW.get(),
texWidth, texHeight, HAL_PIXEL_FORMAT_YV12)); texWidth, texHeight));
ASSERT_EQ(NO_ERROR, native_window_set_buffers_format(mANW.get(),
HAL_PIXEL_FORMAT_YV12));
ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(), ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN)); GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN));
@ -74,8 +76,10 @@ TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledYV12BufferPow2) {
const int texWidth = 64; const int texWidth = 64;
const int texHeight = 64; const int texHeight = 64;
ASSERT_EQ(NO_ERROR, native_window_set_buffers_geometry(mANW.get(), ASSERT_EQ(NO_ERROR, native_window_set_buffers_dimensions(mANW.get(),
texWidth, texHeight, HAL_PIXEL_FORMAT_YV12)); texWidth, texHeight));
ASSERT_EQ(NO_ERROR, native_window_set_buffers_format(mANW.get(),
HAL_PIXEL_FORMAT_YV12));
ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(), ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN)); GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN));
@ -120,8 +124,10 @@ TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledYV12BufferWithCrop) {
const int texWidth = 64; const int texWidth = 64;
const int texHeight = 66; const int texHeight = 66;
ASSERT_EQ(NO_ERROR, native_window_set_buffers_geometry(mANW.get(), ASSERT_EQ(NO_ERROR, native_window_set_buffers_dimensions(mANW.get(),
texWidth, texHeight, HAL_PIXEL_FORMAT_YV12)); texWidth, texHeight));
ASSERT_EQ(NO_ERROR, native_window_set_buffers_format(mANW.get(),
HAL_PIXEL_FORMAT_YV12));
ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(), ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN)); GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN));
@ -185,8 +191,10 @@ TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledYV12BuffersRepeatedly) {
enum { numFrames = 1024 }; enum { numFrames = 1024 };
ASSERT_EQ(NO_ERROR, mST->setDefaultMaxBufferCount(2)); ASSERT_EQ(NO_ERROR, mST->setDefaultMaxBufferCount(2));
ASSERT_EQ(NO_ERROR, native_window_set_buffers_geometry(mANW.get(), ASSERT_EQ(NO_ERROR, native_window_set_buffers_dimensions(mANW.get(),
texWidth, texHeight, HAL_PIXEL_FORMAT_YV12)); texWidth, texHeight));
ASSERT_EQ(NO_ERROR, native_window_set_buffers_format(mANW.get(),
HAL_PIXEL_FORMAT_YV12));
ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(), ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
GRALLOC_USAGE_SW_WRITE_OFTEN)); GRALLOC_USAGE_SW_WRITE_OFTEN));
@ -326,8 +334,10 @@ TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledRGBABufferNpot) {
const int texWidth = 64; const int texWidth = 64;
const int texHeight = 66; const int texHeight = 66;
ASSERT_EQ(NO_ERROR, native_window_set_buffers_geometry(mANW.get(), ASSERT_EQ(NO_ERROR, native_window_set_buffers_dimensions(mANW.get(),
texWidth, texHeight, HAL_PIXEL_FORMAT_RGBA_8888)); texWidth, texHeight));
ASSERT_EQ(NO_ERROR, native_window_set_buffers_format(mANW.get(),
HAL_PIXEL_FORMAT_RGBA_8888));
ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(), ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN)); GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN));
@ -368,8 +378,10 @@ TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledRGBABufferPow2) {
const int texWidth = 64; const int texWidth = 64;
const int texHeight = 64; const int texHeight = 64;
ASSERT_EQ(NO_ERROR, native_window_set_buffers_geometry(mANW.get(), ASSERT_EQ(NO_ERROR, native_window_set_buffers_dimensions(mANW.get(),
texWidth, texHeight, HAL_PIXEL_FORMAT_RGBA_8888)); texWidth, texHeight));
ASSERT_EQ(NO_ERROR, native_window_set_buffers_format(mANW.get(),
HAL_PIXEL_FORMAT_RGBA_8888));
ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(), ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN)); GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN));