1 /* 2 * Copyright 2024 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/power/BnPowerHintSession.h> 20 #include <aidl/android/hardware/power/SessionMode.h> 21 #include <aidl/android/hardware/power/SessionTag.h> 22 #include <gmock/gmock.h> 23 24 namespace aidl::google::hardware::power::mock::pixel { 25 26 class MockPowerHintSession { 27 public: 28 MockPowerHintSession() = default; 29 ~MockPowerHintSession() = default; 30 31 MOCK_METHOD(ndk::ScopedAStatus, close, ()); 32 MOCK_METHOD(ndk::ScopedAStatus, pause, ()); 33 MOCK_METHOD(ndk::ScopedAStatus, resume, ()); 34 MOCK_METHOD(ndk::ScopedAStatus, updateTargetWorkDuration, (int64_t targetDurationNanos)); 35 MOCK_METHOD(ndk::ScopedAStatus, reportActualWorkDuration, 36 (const std::vector<android::hardware::power::WorkDuration> &actualDurations)); 37 MOCK_METHOD(ndk::ScopedAStatus, sendHint, (android::hardware::power::SessionHint hint)); 38 MOCK_METHOD(ndk::ScopedAStatus, setMode, 39 (android::hardware::power::SessionMode mode, bool enabled)); 40 MOCK_METHOD(ndk::ScopedAStatus, setThreads, (const std::vector<int32_t> &threadIds)); 41 MOCK_METHOD(ndk::ScopedAStatus, getSessionConfig, 42 (android::hardware::power::SessionConfig * _aidl_return)); 43 44 MOCK_METHOD(bool, isModeSet, (android::hardware::power::SessionMode mode), (const)); 45 MOCK_METHOD(void, dumpToStream, (std::ostream & stream)); 46 MOCK_METHOD(android::hardware::power::SessionTag, getSessionTag, (), (const)); 47 48 class MockSessionTracker { 49 public: 50 MOCK_METHOD(void, registerSession, 51 (std::shared_ptr<MockPowerHintSession> & session, int64_t sessionId)); 52 MOCK_METHOD(void, unregisterSession, (int64_t sessionId)); 53 MOCK_METHOD(std::shared_ptr<MockPowerHintSession>, getSession, (int64_t sessionId)); 54 }; 55 getTracker()56 static testing::NiceMock<MockSessionTracker> *getTracker() { 57 static testing::NiceMock<MockSessionTracker> instance{}; 58 return &instance; 59 } 60 }; 61 62 } // namespace aidl::google::hardware::power::mock::pixel 63