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 #pragma once 18 19 #include "WatchdogProcessService.h" 20 #include "WatchdogServiceHelper.h" 21 22 #include <aidl/android/automotive/watchdog/ICarWatchdogClient.h> 23 #include <aidl/android/automotive/watchdog/internal/ICarWatchdogMonitor.h> 24 #include <aidl/android/automotive/watchdog/internal/ICarWatchdogServiceForSystem.h> 25 #include <aidl/android/automotive/watchdog/internal/PowerCycle.h> 26 #include <aidl/android/automotive/watchdog/internal/ProcessIdentifier.h> 27 #include <aidl/android/automotive/watchdog/internal/UserState.h> 28 #include <android-base/result.h> 29 #include <android/util/ProtoOutputStream.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, onDumpProto, (android::util::ProtoOutputStream&), (override)); 48 MOCK_METHOD(void, doHealthCheck, (int), (override)); 49 MOCK_METHOD(void, handleBinderDeath, (void*), (override)); 50 MOCK_METHOD(ndk::ScopedAStatus, registerClient, 51 (const std::shared_ptr<aidl::android::automotive::watchdog::ICarWatchdogClient>&, 52 aidl::android::automotive::watchdog::TimeoutLength), 53 (override)); 54 MOCK_METHOD(ndk::ScopedAStatus, unregisterClient, 55 (const std::shared_ptr<aidl::android::automotive::watchdog::ICarWatchdogClient>&), 56 (override)); 57 MOCK_METHOD(ndk::ScopedAStatus, registerCarWatchdogService, 58 (const ndk::SpAIBinder&, const android::sp<WatchdogServiceHelperInterface>&), 59 (override)); 60 MOCK_METHOD(void, unregisterCarWatchdogService, (const ndk::SpAIBinder&), (override)); 61 MOCK_METHOD(ndk::ScopedAStatus, registerMonitor, 62 (const std::shared_ptr< 63 aidl::android::automotive::watchdog::internal::ICarWatchdogMonitor>&), 64 (override)); 65 MOCK_METHOD(ndk::ScopedAStatus, unregisterMonitor, 66 (const std::shared_ptr< 67 aidl::android::automotive::watchdog::internal::ICarWatchdogMonitor>&), 68 (override)); 69 MOCK_METHOD(ndk::ScopedAStatus, tellClientAlive, 70 (const std::shared_ptr<aidl::android::automotive::watchdog::ICarWatchdogClient>&, 71 int32_t), 72 (override)); 73 MOCK_METHOD( 74 ndk::ScopedAStatus, tellCarWatchdogServiceAlive, 75 (const std::shared_ptr< 76 aidl::android::automotive::watchdog::internal::ICarWatchdogServiceForSystem>&, 77 const std::vector<aidl::android::automotive::watchdog::internal::ProcessIdentifier>&, 78 int32_t), 79 (override)); 80 MOCK_METHOD(ndk::ScopedAStatus, tellDumpFinished, 81 (const std::shared_ptr< 82 aidl::android::automotive::watchdog::internal::ICarWatchdogMonitor>&, 83 const aidl::android::automotive::watchdog::internal::ProcessIdentifier&), 84 (override)); 85 MOCK_METHOD(void, setEnabled, (bool), (override)); 86 MOCK_METHOD(void, onUserStateChange, (userid_t, bool), (override)); 87 MOCK_METHOD(void, onAidlVhalPidFetched, (int32_t), (override)); 88 }; 89 90 } // namespace watchdog 91 } // namespace automotive 92 } // namespace android 93