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