From deb91680bac3cda4284cc5ffe96d76b32243868a Mon Sep 17 00:00:00 2001 From: Gaurav Shah Date: Thu, 11 May 2017 11:57:46 -0700 Subject: [PATCH] Remove libbufferhub mocks/ It is not used anywhere. Bug: 36040117 Test: built. no code changes, only dead code removal. Change-Id: Ia9c52379ac2dabf0179f92c0c2d5ffd4ff92d357 --- .../mocks/client/private/dvr/buffer_hub_client.h | 57 ---------------- libs/vr/libbufferhub/mocks/gralloc/BUILD.gn | 23 ------- libs/vr/libbufferhub/mocks/gralloc/gralloc.cpp | 68 ------------------- libs/vr/libbufferhub/mocks/gralloc/gralloc_mock.h | 23 ------- .../mocks/ion_buffer/private/dvr/ion_buffer.h | 78 ---------------------- 5 files changed, 249 deletions(-) delete mode 100644 libs/vr/libbufferhub/mocks/client/private/dvr/buffer_hub_client.h delete mode 100644 libs/vr/libbufferhub/mocks/gralloc/BUILD.gn delete mode 100644 libs/vr/libbufferhub/mocks/gralloc/gralloc.cpp delete mode 100644 libs/vr/libbufferhub/mocks/gralloc/gralloc_mock.h delete mode 100644 libs/vr/libbufferhub/mocks/ion_buffer/private/dvr/ion_buffer.h diff --git a/libs/vr/libbufferhub/mocks/client/private/dvr/buffer_hub_client.h b/libs/vr/libbufferhub/mocks/client/private/dvr/buffer_hub_client.h deleted file mode 100644 index 33816fad04..0000000000 --- a/libs/vr/libbufferhub/mocks/client/private/dvr/buffer_hub_client.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef LIB_LIBBUFFERHUB_PRIVATE_DVR_BUFFER_HUB_CLIENT_H_ // NOLINT -#define LIB_LIBBUFFERHUB_PRIVATE_DVR_BUFFER_HUB_CLIENT_H_ -#include -#include - -// TODO(jwcai) mock not need for now -class native_handle_t; - -namespace android { -namespace dvr { - -// TODO(jwcai) mock not need for now -class IonBuffer; - -class BufferHubBuffer { - public: - MOCK_METHOD1(Poll, int(int timeout_ms)); - MOCK_METHOD6(Lock, bool(int usage, int x, int y, int width, int height, - void** addr)); - MOCK_METHOD0(Unlock, int()); - - MOCK_METHOD0(native_handle, native_handle_t*()); - MOCK_METHOD0(buffer, IonBuffer*()); - MOCK_METHOD0(event_fd, int()); - - MOCK_METHOD0(id, int()); - MOCK_METHOD0(width, int()); - MOCK_METHOD0(height, int()); - MOCK_METHOD0(stride, int()); - MOCK_METHOD0(format, int()); - MOCK_METHOD0(usage, int()); -}; - -class BufferProducer : public BufferHubBuffer { - public: - // Note that static method |CreateBuffer| and |Import| are not mocked - // here, they are just implementation details and thus not needed. - MOCK_METHOD2(Post, int(int ready_fence, uint64_t sequence)); - MOCK_METHOD1(Gain, int(int* release_fence)); - - static BufferProducer* staticObject; -}; - -class BufferConsumer : public BufferHubBuffer { - public: - MOCK_METHOD2(Acquire, int(int* ready_fence, uint64_t* sequence)); - MOCK_METHOD1(Release, int(int release_fence)); - MOCK_METHOD0(Discard, int()); - MOCK_METHOD3(DoAcquire, - int(int* ready_fence, void* meta, size_t meta_size_bytes)); - - static BufferConsumer* staticObject; -}; - -} // namespace dvr -} // namespace android -#endif // LIB_LIBBUFFERHUB_PRIVATE_DVR_BUFFER_HUB_CLIENT_H_ //NOLINT diff --git a/libs/vr/libbufferhub/mocks/gralloc/BUILD.gn b/libs/vr/libbufferhub/mocks/gralloc/BUILD.gn deleted file mode 100644 index 9674c7cc27..0000000000 --- a/libs/vr/libbufferhub/mocks/gralloc/BUILD.gn +++ /dev/null @@ -1,23 +0,0 @@ -config("gralloc_config") { - include_dirs = [ "." ] -} - -static_library("gralloc") { - testonly = true - - sources = [ - "gralloc.cpp", - "gralloc.h", - ] - - include_dirs = [ - "//system/core/include", - "//hardware/libhardware/include", - ] - - public_deps = [ - "//dreamos/external/gmock", - ] - - public_configs = [ ":gralloc_config" ] -} diff --git a/libs/vr/libbufferhub/mocks/gralloc/gralloc.cpp b/libs/vr/libbufferhub/mocks/gralloc/gralloc.cpp deleted file mode 100644 index 4a923ece06..0000000000 --- a/libs/vr/libbufferhub/mocks/gralloc/gralloc.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include - -static alloc_device_t sdevice; - -static int local_registerBuffer(struct gralloc_module_t const*, - buffer_handle_t handle) { - return GrallocMock::staticObject->registerBuffer(handle); -} - -static int local_unregisterBuffer(struct gralloc_module_t const*, - buffer_handle_t handle) { - return GrallocMock::staticObject->unregisterBuffer(handle); -} - -static int local_unlock(struct gralloc_module_t const*, - buffer_handle_t handle) { - return GrallocMock::staticObject->unlock(handle); -} - -static int local_lock(struct gralloc_module_t const*, buffer_handle_t handle, - int usage, int l, int t, int w, int h, void** vaddr) { - return GrallocMock::staticObject->lock(handle, usage, l, t, w, h, vaddr); -} - -static int local_alloc(struct alloc_device_t*, int w, int h, int format, - int usage, buffer_handle_t* handle, int* stride) { - return GrallocMock::staticObject->alloc(w, h, format, usage, handle, stride); -} - -static int local_free(struct alloc_device_t*, buffer_handle_t handle) { - return GrallocMock::staticObject->free(handle); -} - -static int local_open(const struct hw_module_t*, const char*, - struct hw_device_t** device) { - sdevice.alloc = local_alloc; - sdevice.free = local_free; - *device = reinterpret_cast(&sdevice); - return 0; -} - -static hw_module_methods_t smethods; - -static gralloc_module_t smodule; - -int hw_get_module(const char*, const struct hw_module_t** module) { - smodule.registerBuffer = local_registerBuffer; - smodule.unregisterBuffer = local_unregisterBuffer; - smodule.lock = local_lock; - smodule.unlock = local_unlock; - smethods.open = local_open; - smodule.common.methods = &smethods; - *module = reinterpret_cast(&smodule); - return 0; -} - -int native_handle_close(const native_handle_t* handle) { - return GrallocMock::staticObject->native_handle_close(handle); -} - -int native_handle_delete(native_handle_t* handle) { - return GrallocMock::staticObject->native_handle_delete(handle); -} - -native_handle_t* native_handle_create(int numFds, int numInts) { - return GrallocMock::staticObject->native_handle_create(numFds, numInts); -} diff --git a/libs/vr/libbufferhub/mocks/gralloc/gralloc_mock.h b/libs/vr/libbufferhub/mocks/gralloc/gralloc_mock.h deleted file mode 100644 index f62f579e6d..0000000000 --- a/libs/vr/libbufferhub/mocks/gralloc/gralloc_mock.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef LIB_LIBBUFFERHUB_MOCKS_GRALLOC_GRALLOC_MOCK_H_ -#define LIB_LIBBUFFERHUB_MOCKS_GRALLOC_GRALLOC_MOCK_H_ -#include -#include -#include - -// IonBuffer is an abstraction of Ion/Gralloc buffers. -class GrallocMock { - public: - // Add methods here. - MOCK_METHOD1(native_handle_close, int(const native_handle_t*)); - MOCK_METHOD1(native_handle_delete, int(native_handle_t*)); - MOCK_METHOD2(native_handle_create, native_handle_t*(int, int)); - MOCK_METHOD1(registerBuffer, int(buffer_handle_t)); - MOCK_METHOD1(unregisterBuffer, int(buffer_handle_t)); - MOCK_METHOD7(lock, int(buffer_handle_t, int, int, int, int, int, void**)); - MOCK_METHOD1(unlock, int(buffer_handle_t)); - MOCK_METHOD6(alloc, int(int, int, int, int, buffer_handle_t*, int*)); - MOCK_METHOD1(free, int(buffer_handle_t)); - static GrallocMock* staticObject; -}; - -#endif // LIB_LIBBUFFERHUB_MOCKS_GRALLOC_GRALLOC_MOCK_H_ diff --git a/libs/vr/libbufferhub/mocks/ion_buffer/private/dvr/ion_buffer.h b/libs/vr/libbufferhub/mocks/ion_buffer/private/dvr/ion_buffer.h deleted file mode 100644 index 8929c95f48..0000000000 --- a/libs/vr/libbufferhub/mocks/ion_buffer/private/dvr/ion_buffer.h +++ /dev/null @@ -1,78 +0,0 @@ -// This file has a big hack, it "mocks" the actual IonBuffer by redefining -// it with mock methods and using the same header guard to prevent the original -// definition from being included in the same context. -#ifndef LIB_LIBBUFFERHUB_PRIVATE_DVR_ION_BUFFER_H_ // NOLINT -#define LIB_LIBBUFFERHUB_PRIVATE_DVR_ION_BUFFER_H_ -#include -#include - -#include - -namespace android { -namespace dvr { - -// IonBuffer is an abstraction of Ion/Gralloc buffers. -class IonBufferMock { - public: - IonBufferMock() {} - MOCK_METHOD0(GetGrallocModuleImpl, gralloc_module_t const*()); - MOCK_METHOD6(Import, int(buffer_handle_t handle, int width, int height, - int layer_count, int stride, int format, int usage)); - MOCK_METHOD9(Import, - int(const int* fd_array, int fd_count, const int* int_array, - int int_count, int width, int height, int layer_count, - int stride, int format, int usage)); - MOCK_METHOD6(Lock, int(int usage, int x, int y, int width, int height, - void** address)); - MOCK_METHOD0(Unlock, int()); - MOCK_CONST_METHOD0(handle, buffer_handle_t()); - MOCK_CONST_METHOD0(width, int()); - MOCK_CONST_METHOD0(height, int()); - MOCK_CONST_METHOD0(layer_count, int()); - MOCK_CONST_METHOD0(stride, int()); - MOCK_CONST_METHOD0(format, int()); - MOCK_CONST_METHOD0(usage, int()); -}; - -// IonBuffer is an abstraction of Ion/Gralloc buffers. -class IonBuffer { - public: - IonBuffer() : mock_(new IonBufferMock) { - if (initializer) { - initializer(mock_.get()); - } - } - IonBuffer(IonBuffer&& other) = default; - static gralloc_module_t const* GetGrallocModule() { - return staticObject->GetGrallocModuleImpl(); - } - int Import(buffer_handle_t handle, int width, int height, int layer_count, - int stride, int format, int usage) { - return mock_->Import(handle, width, height, layer_count, stride, format, - usage); - } - int Import(const int* fd_array, int fd_count, const int* int_array, - int int_count, int width, int height, int layer_count, int stride, - int format, int usage) { - return mock_->Import(fd_array, fd_count, int_array, int_count, width, - height, layer_count, stride, format, usage); - } - int Lock(int usage, int x, int y, int width, int height, void** address) { - return mock_->Lock(usage, x, y, width, height, address); - } - int Unlock() { return mock_->Unlock(); } - buffer_handle_t handle() const { return mock_->handle(); } - int width() const { return mock_->width(); } - int height() const { return mock_->height(); } - int layer_count() const { return mock_->layer_count(); } - int stride() const { return mock_->stride(); } - int format() const { return mock_->format(); } - int usage() const { return mock_->usage(); } - std::unique_ptr mock_; - static IonBufferMock* staticObject; - static void (*initializer)(IonBufferMock* target); -}; - -} // namespace dvr -} // namespace android -#endif // LIB_LIBBUFFERHUB_PRIVATE_DVR_ION_BUFFER_H_ - NOLINT -- 2.11.0