1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef HARDWARE_GOOGLE_CAMERA_HAL_TESTS_MOCK_DEVICE_HWL_H_ 18 #define HARDWARE_GOOGLE_CAMERA_HAL_TESTS_MOCK_DEVICE_HWL_H_ 19 20 #include <camera_buffer_allocator_hwl.h> 21 #include <camera_device_session_hwl.h> 22 #include <unordered_map> 23 24 #include "mock_device_session_hwl.h" 25 26 namespace android { 27 namespace google_camera_hal { 28 29 class MockBufferAllocatorHwl : public CameraBufferAllocatorHwl { 30 public: Create()31 static std::unique_ptr<CameraBufferAllocatorHwl> Create() { 32 auto hwl_buffer_allocator = 33 std::unique_ptr<MockBufferAllocatorHwl>(new MockBufferAllocatorHwl()); 34 35 std::unique_ptr<CameraBufferAllocatorHwl> base_allocator; 36 base_allocator.reset(dynamic_cast<CameraBufferAllocatorHwl*>( 37 hwl_buffer_allocator.release())); 38 39 return base_allocator; 40 } 41 42 // Allocate HWL buffers AllocateBuffers(const HalBufferDescriptor & buffer_descriptor,std::vector<buffer_handle_t> * buffers)43 status_t AllocateBuffers(const HalBufferDescriptor& buffer_descriptor, 44 std::vector<buffer_handle_t>* buffers) { 45 buffers->resize(buffer_descriptor.max_num_buffers); 46 return OK; 47 } 48 49 // Free HWL buffers FreeBuffers(std::vector<buffer_handle_t> * buffers)50 status_t FreeBuffers(std::vector<buffer_handle_t>* buffers) { 51 buffers->clear(); 52 return OK; 53 } 54 IsHwlAllocatedBuffer(buffer_handle_t)55 bool IsHwlAllocatedBuffer(buffer_handle_t /*buffer*/) { 56 return false; 57 } 58 59 protected: 60 MockBufferAllocatorHwl() = default; 61 }; 62 } // namespace google_camera_hal 63 } // namespace android 64 65 #endif // HARDWARE_GOOGLE_CAMERA_HAL_TESTS_MOCK_DEVICE_HWL_H_ 66