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 <android/hardware/automotive/evs/1.1/IEvsCamera.h>
20 #include <android/hardware/automotive/evs/1.1/IEvsCameraStream.h>
21 #include <android/hardware/automotive/evs/1.1/IEvsDisplay.h>
22 #include <android/hardware/automotive/evs/1.1/types.h>
23 #include <gmock/gmock.h>
24 #include <gtest/gtest.h>
25 
26 namespace aidl::android::automotive::evs::implementation {
27 
28 namespace hidlevs = ::android::hardware::automotive::evs;
29 
30 class MockHidlEvsCamera : public hidlevs::V1_1::IEvsCamera {
31 public:
MockHidlEvsCamera(const std::string & deviceId)32     MockHidlEvsCamera(const std::string& deviceId) : mDeviceId(deviceId) {}
33     virtual ~MockHidlEvsCamera() = default;
34 
35     // Methods from hardware::automotive::evs::V1_0::IEvsCamera follow.
36     MOCK_METHOD(::android::hardware::Return<void>, getCameraInfo, (getCameraInfo_cb), (override));
37     MOCK_METHOD(::android::hardware::Return<hidlevs::V1_0::EvsResult>, setMaxFramesInFlight,
38                 (uint32_t), (override));
39     MOCK_METHOD(::android::hardware::Return<hidlevs::V1_0::EvsResult>, startVideoStream,
40                 (const ::android::sp<hidlevs::V1_0::IEvsCameraStream>&), (override));
41     MOCK_METHOD(::android::hardware::Return<void>, doneWithFrame,
42                 (const hidlevs::V1_0::BufferDesc&), (override));
43     MOCK_METHOD(::android::hardware::Return<void>, stopVideoStream, (), (override));
44     MOCK_METHOD(::android::hardware::Return<int32_t>, getExtendedInfo, (uint32_t), (override));
45     MOCK_METHOD(::android::hardware::Return<hidlevs::V1_0::EvsResult>, setExtendedInfo,
46                 (uint32_t, int32_t), (override));
47 
48     // Methods from hardware::automotive::evs::V1_1::IEvsCamera follow.
49     MOCK_METHOD(::android::hardware::Return<void>, getCameraInfo_1_1, (getCameraInfo_1_1_cb),
50                 (override));
51     MOCK_METHOD(::android::hardware::Return<void>, getPhysicalCameraInfo,
52                 (const ::android::hardware::hidl_string&, getPhysicalCameraInfo_cb), (override));
53     MOCK_METHOD(::android::hardware::Return<hidlevs::V1_0::EvsResult>, doneWithFrame_1_1,
54                 (const ::android::hardware::hidl_vec<hidlevs::V1_1::BufferDesc>&), (override));
55     MOCK_METHOD(::android::hardware::Return<hidlevs::V1_0::EvsResult>, pauseVideoStream, (),
56                 (override));
57     MOCK_METHOD(::android::hardware::Return<hidlevs::V1_0::EvsResult>, resumeVideoStream, (),
58                 (override));
59     MOCK_METHOD(::android::hardware::Return<hidlevs::V1_0::EvsResult>, setMaster, (), (override));
60     MOCK_METHOD(::android::hardware::Return<hidlevs::V1_0::EvsResult>, forceMaster,
61                 (const ::android::sp<hidlevs::V1_0::IEvsDisplay>&), (override));
62     MOCK_METHOD(::android::hardware::Return<hidlevs::V1_0::EvsResult>, unsetMaster, (), (override));
63     MOCK_METHOD(::android::hardware::Return<void>, getParameterList, (getParameterList_cb),
64                 (override));
65     MOCK_METHOD(::android::hardware::Return<void>, getIntParameterRange,
66                 (hidlevs::V1_1::CameraParam, getIntParameterRange_cb), (override));
67     MOCK_METHOD(::android::hardware::Return<void>, setIntParameter,
68                 (hidlevs::V1_1::CameraParam, int32_t, setIntParameter_cb), (override));
69     MOCK_METHOD(::android::hardware::Return<void>, getIntParameter,
70                 (hidlevs::V1_1::CameraParam, getIntParameter_cb), (override));
71     MOCK_METHOD(::android::hardware::Return<hidlevs::V1_0::EvsResult>, setExtendedInfo_1_1,
72                 (uint32_t, const ::android::hardware::hidl_vec<uint8_t>&), (override));
73     MOCK_METHOD(::android::hardware::Return<void>, getExtendedInfo_1_1,
74                 (uint32_t, getExtendedInfo_1_1_cb), (override));
75     MOCK_METHOD(::android::hardware::Return<void>, importExternalBuffers,
76                 (const ::android::hardware::hidl_vec<hidlevs::V1_1::BufferDesc>&,
77                  importExternalBuffers_cb),
78                 (override));
79 
getId()80     std::string getId() const { return mDeviceId; }
81 
82 private:
83     std::string mDeviceId;
84 };
85 
86 using NiceMockHidlEvsCamera = ::testing::NiceMock<MockHidlEvsCamera>;
87 
88 }  // namespace aidl::android::automotive::evs::implementation
89