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 "binder/Status.h"
20 
21 // FMQ library in IPower does questionable conversions
22 #pragma clang diagnostic push
23 #pragma clang diagnostic ignored "-Wconversion"
24 #include <aidl/android/hardware/power/IPower.h>
25 #pragma clang diagnostic pop
26 
27 #include <gmock/gmock.h>
28 
29 using aidl::android::hardware::power::Boost;
30 using aidl::android::hardware::power::ChannelConfig;
31 using aidl::android::hardware::power::IPower;
32 using aidl::android::hardware::power::IPowerHintSession;
33 using aidl::android::hardware::power::SessionConfig;
34 using aidl::android::hardware::power::SessionTag;
35 
36 using aidl::android::hardware::power::Mode;
37 using android::binder::Status;
38 
39 namespace android::Hwc2::mock {
40 
41 class MockIPower : public IPower {
42 public:
43     MockIPower();
44 
45     MOCK_METHOD(ndk::ScopedAStatus, isBoostSupported, (Boost boost, bool* ret), (override));
46     MOCK_METHOD(ndk::ScopedAStatus, setBoost, (Boost boost, int32_t durationMs), (override));
47     MOCK_METHOD(ndk::ScopedAStatus, isModeSupported, (Mode mode, bool* ret), (override));
48     MOCK_METHOD(ndk::ScopedAStatus, setMode, (Mode mode, bool enabled), (override));
49     MOCK_METHOD(ndk::ScopedAStatus, createHintSession,
50                 (int32_t tgid, int32_t uid, const std::vector<int32_t>& threadIds,
51                  int64_t durationNanos, std::shared_ptr<IPowerHintSession>* session),
52                 (override));
53     MOCK_METHOD(ndk::ScopedAStatus, getHintSessionPreferredRate, (int64_t * rate), (override));
54     MOCK_METHOD(ndk::ScopedAStatus, createHintSessionWithConfig,
55                 (int32_t tgid, int32_t uid, const std::vector<int32_t>& threadIds,
56                  int64_t durationNanos, SessionTag tag, SessionConfig* config,
57                  std::shared_ptr<IPowerHintSession>* _aidl_return),
58                 (override));
59     MOCK_METHOD(ndk::ScopedAStatus, getSessionChannel,
60                 (int32_t tgid, int32_t uid, ChannelConfig* _aidl_return), (override));
61     MOCK_METHOD(ndk::ScopedAStatus, closeSessionChannel, (int32_t tgid, int32_t uid), (override));
62     MOCK_METHOD(ndk::ScopedAStatus, getInterfaceVersion, (int32_t * version), (override));
63     MOCK_METHOD(ndk::ScopedAStatus, getInterfaceHash, (std::string * hash), (override));
64     MOCK_METHOD(ndk::SpAIBinder, asBinder, (), (override));
65     MOCK_METHOD(bool, isRemote, (), (override));
66 };
67 
68 } // namespace android::Hwc2::mock
69