1 /*
2  * Copyright 2022 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 #pragma once
18 
19 #include <aidl/android/hardware/automotive/evs/BnEvsCamera.h>
20 #include <aidl/android/hardware/automotive/evs/BufferDesc.h>
21 #include <aidl/android/hardware/automotive/evs/CameraDesc.h>
22 #include <aidl/android/hardware/automotive/evs/CameraParam.h>
23 #include <aidl/android/hardware/automotive/evs/EvsEventDesc.h>
24 #include <aidl/android/hardware/automotive/evs/EvsResult.h>
25 #include <aidl/android/hardware/automotive/evs/IEvsCameraStream.h>
26 #include <aidl/android/hardware/automotive/evs/IEvsDisplay.h>
27 #include <aidl/android/hardware/automotive/evs/ParameterRange.h>
28 #include <aidl/android/hardware/automotive/evs/Stream.h>
29 #include <gmock/gmock.h>
30 #include <gtest/gtest.h>
31 
32 namespace aidl::android::automotive::evs::implementation {
33 
34 namespace aidlevs = ::aidl::android::hardware::automotive::evs;
35 
36 class MockEvsCamera : public aidlevs::BnEvsCamera {
37 public:
MockEvsCamera(const std::string & deviceId)38     MockEvsCamera(const std::string& deviceId) : mDeviceId(deviceId) {}
39     virtual ~MockEvsCamera() = default;
40 
41     MOCK_METHOD(::ndk::ScopedAStatus, doneWithFrame,
42                 (const std::vector<aidlevs::BufferDesc>& buffers), (override));
43     MOCK_METHOD(::ndk::ScopedAStatus, forcePrimaryClient,
44                 (const std::shared_ptr<aidlevs::IEvsDisplay>& display), (override));
45     MOCK_METHOD(::ndk::ScopedAStatus, getCameraInfo, (aidlevs::CameraDesc * _aidl_return),
46                 (override));
47     MOCK_METHOD(::ndk::ScopedAStatus, getExtendedInfo,
48                 (int32_t opaqueIdentifier, std::vector<uint8_t>* value), (override));
49     MOCK_METHOD(::ndk::ScopedAStatus, getIntParameter,
50                 (aidlevs::CameraParam id, std::vector<int32_t>* value), (override));
51     MOCK_METHOD(::ndk::ScopedAStatus, getIntParameterRange,
52                 (aidlevs::CameraParam id, aidlevs::ParameterRange* _aidl_return), (override));
53     MOCK_METHOD(::ndk::ScopedAStatus, getParameterList,
54                 (std::vector<aidlevs::CameraParam> * _aidl_return), (override));
55     MOCK_METHOD(::ndk::ScopedAStatus, getPhysicalCameraInfo,
56                 (const std::string& deviceId, aidlevs::CameraDesc* _aidl_return), (override));
57     MOCK_METHOD(::ndk::ScopedAStatus, importExternalBuffers,
58                 (const std::vector<aidlevs::BufferDesc>& buffers, int32_t* _aidl_return),
59                 (override));
60     MOCK_METHOD(::ndk::ScopedAStatus, pauseVideoStream, (), (override));
61     MOCK_METHOD(::ndk::ScopedAStatus, resumeVideoStream, (), (override));
62     MOCK_METHOD(::ndk::ScopedAStatus, setExtendedInfo,
63                 (int32_t opaqueIdentifier, const std::vector<uint8_t>& opaqueValue), (override));
64     MOCK_METHOD(::ndk::ScopedAStatus, setIntParameter,
65                 (aidlevs::CameraParam id, int32_t value, std::vector<int32_t>* effectiveValue),
66                 (override));
67     MOCK_METHOD(::ndk::ScopedAStatus, setPrimaryClient, (), (override));
68     MOCK_METHOD(::ndk::ScopedAStatus, setMaxFramesInFlight, (int32_t bufferCount), (override));
69     MOCK_METHOD(::ndk::ScopedAStatus, startVideoStream,
70                 (const std::shared_ptr<aidlevs::IEvsCameraStream>& receiver), (override));
71     MOCK_METHOD(::ndk::ScopedAStatus, stopVideoStream, (), (override));
72     MOCK_METHOD(::ndk::ScopedAStatus, unsetPrimaryClient, (), (override));
73 
getId()74     std::string getId() const { return mDeviceId; }
75 
76 private:
77     std::string mDeviceId;
78 };
79 
80 using NiceMockEvsCamera = ::testing::NiceMock<MockEvsCamera>;
81 
82 }  // namespace aidl::android::automotive::evs::implementation
83