1 /** 2 * Copyright (c) 2020, 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 CPP_WATCHDOG_SERVER_TESTS_MOCKWATCHDOGPROCESSSERVICE_H_ 18 #define CPP_WATCHDOG_SERVER_TESTS_MOCKWATCHDOGPROCESSSERVICE_H_ 19 20 #include "WatchdogProcessService.h" 21 #include "WatchdogServiceHelper.h" 22 23 #include <aidl/android/automotive/watchdog/ICarWatchdogClient.h> 24 #include <aidl/android/automotive/watchdog/internal/ICarWatchdogMonitor.h> 25 #include <aidl/android/automotive/watchdog/internal/ICarWatchdogServiceForSystem.h> 26 #include <aidl/android/automotive/watchdog/internal/PowerCycle.h> 27 #include <aidl/android/automotive/watchdog/internal/ProcessIdentifier.h> 28 #include <aidl/android/automotive/watchdog/internal/UserState.h> 29 #include <android-base/result.h> 30 #include <android/util/ProtoOutputStream.h> 31 #include <binder/Status.h> 32 #include <gmock/gmock.h> 33 #include <utils/String16.h> 34 #include <utils/Vector.h> 35 36 #include <vector> 37 38 namespace android { 39 namespace automotive { 40 namespace watchdog { 41 42 class MockWatchdogProcessService : public WatchdogProcessServiceInterface { 43 public: MockWatchdogProcessService()44 MockWatchdogProcessService() {} 45 MOCK_METHOD(android::base::Result<void>, start, (), (override)); 46 MOCK_METHOD(void, terminate, (), (override)); 47 MOCK_METHOD(void, onDump, (int), (override)); 48 MOCK_METHOD(void, onDumpProto, (android::util::ProtoOutputStream&), (override)); 49 MOCK_METHOD(void, doHealthCheck, (int), (override)); 50 MOCK_METHOD(void, handleBinderDeath, (void*), (override)); 51 MOCK_METHOD(ndk::ScopedAStatus, registerClient, 52 (const std::shared_ptr<aidl::android::automotive::watchdog::ICarWatchdogClient>&, 53 aidl::android::automotive::watchdog::TimeoutLength), 54 (override)); 55 MOCK_METHOD(ndk::ScopedAStatus, unregisterClient, 56 (const std::shared_ptr<aidl::android::automotive::watchdog::ICarWatchdogClient>&), 57 (override)); 58 MOCK_METHOD(ndk::ScopedAStatus, registerCarWatchdogService, 59 (const ndk::SpAIBinder&, const android::sp<WatchdogServiceHelperInterface>&), 60 (override)); 61 MOCK_METHOD(void, unregisterCarWatchdogService, (const ndk::SpAIBinder&), (override)); 62 MOCK_METHOD(ndk::ScopedAStatus, registerMonitor, 63 (const std::shared_ptr< 64 aidl::android::automotive::watchdog::internal::ICarWatchdogMonitor>&), 65 (override)); 66 MOCK_METHOD(ndk::ScopedAStatus, unregisterMonitor, 67 (const std::shared_ptr< 68 aidl::android::automotive::watchdog::internal::ICarWatchdogMonitor>&), 69 (override)); 70 MOCK_METHOD(ndk::ScopedAStatus, tellClientAlive, 71 (const std::shared_ptr<aidl::android::automotive::watchdog::ICarWatchdogClient>&, 72 int32_t), 73 (override)); 74 MOCK_METHOD( 75 ndk::ScopedAStatus, tellCarWatchdogServiceAlive, 76 (const std::shared_ptr< 77 aidl::android::automotive::watchdog::internal::ICarWatchdogServiceForSystem>&, 78 const std::vector<aidl::android::automotive::watchdog::internal::ProcessIdentifier>&, 79 int32_t), 80 (override)); 81 MOCK_METHOD(ndk::ScopedAStatus, tellDumpFinished, 82 (const std::shared_ptr< 83 aidl::android::automotive::watchdog::internal::ICarWatchdogMonitor>&, 84 const aidl::android::automotive::watchdog::internal::ProcessIdentifier&), 85 (override)); 86 MOCK_METHOD(void, setEnabled, (bool), (override)); 87 MOCK_METHOD(void, onUserStateChange, (userid_t, bool), (override)); 88 MOCK_METHOD(void, onAidlVhalPidFetched, (int32_t), (override)); 89 }; 90 91 } // namespace watchdog 92 } // namespace automotive 93 } // namespace android 94 95 #endif // CPP_WATCHDOG_SERVER_TESTS_MOCKWATCHDOGPROCESSSERVICE_H_ 96