18 #ifndef MIR_TEST_DOUBLES_MOCK_ANDROID_ALLOC_DEVICE_H_
19 #define MIR_TEST_DOUBLES_MOCK_ANDROID_ALLOC_DEVICE_H_
21 #include <gmock/gmock.h>
22 #include <hardware/gralloc.h>
30 class ICSAllocInterface
33 virtual ~ICSAllocInterface() {}
34 virtual int alloc_interface(alloc_device_t* dev,
int w,
int h,
35 int format,
int usage, buffer_handle_t* handle,
int*
stride) = 0;
36 virtual int free_interface(alloc_device_t* dev, buffer_handle_t handle) = 0;
37 virtual int dump_interface(alloc_device_t* dev,
char *buf,
int len) = 0;
50 using namespace testing;
58 ON_CALL(*
this, alloc_interface(_,_,_,_,_,_,_))
63 ON_CALL(*
this, free_interface(_,_))
64 .WillByDefault(Return(0));
74 int w,
int h,
int format,
int usage,
75 buffer_handle_t* handle,
int*
stride)
78 return mocker->alloc_interface(mock_alloc, w, h, format, usage, handle, stride);
81 static int hook_free(alloc_device_t* mock_alloc, buffer_handle_t handle)
84 return mocker->free_interface(mock_alloc, handle);
87 static void hook_dump(alloc_device_t* mock_alloc,
char* buf,
int buf_len)
90 mocker->dump_interface(mock_alloc, buf, buf_len);
95 native_handle_t *handle;
96 int total=numFd + numInt;
99 handle = (native_handle_t*) malloc(
sizeof(
int) * (header_offset+ total));
100 handle->version = 0x389;
101 handle->numFds = numFd;
102 handle->numInts = numInt;
103 for(
int i=0; i<total; i++)
105 handle->data[i] = i*3;
111 MOCK_METHOD7(alloc_interface,
int(alloc_device_t*,
int,
int,
int,
int, buffer_handle_t*,
int*));
112 MOCK_METHOD2(free_interface,
int(alloc_device_t*, buffer_handle_t));
113 MOCK_METHOD3(dump_interface,
int(alloc_device_t*,
char*,
int));