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 <android-base/result.h> 24 #include <android/automotive/watchdog/ICarWatchdogClient.h> 25 #include <android/automotive/watchdog/internal/ICarWatchdogMonitor.h> 26 #include <android/automotive/watchdog/internal/ICarWatchdogServiceForSystem.h> 27 #include <android/automotive/watchdog/internal/PowerCycle.h> 28 #include <android/automotive/watchdog/internal/ProcessIdentifier.h> 29 #include <android/automotive/watchdog/internal/UserState.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(android::base::Result<void>, dump, (int fd, const Vector<android::String16>&), 47 (override)); 48 MOCK_METHOD(void, doHealthCheck, (int), (override)); 49 MOCK_METHOD(android::base::Result<void>, registerWatchdogServiceHelper, 50 (const android::sp<WatchdogServiceHelperInterface>&), (override)); 51 52 MOCK_METHOD(android::binder::Status, registerClient, 53 (const sp<ICarWatchdogClient>&, TimeoutLength), (override)); 54 MOCK_METHOD(android::binder::Status, unregisterClient, (const sp<ICarWatchdogClient>&), 55 (override)); 56 MOCK_METHOD(android::binder::Status, registerCarWatchdogService, (const android::sp<IBinder>&), 57 (override)); 58 MOCK_METHOD(void, unregisterCarWatchdogService, (const android::sp<IBinder>&), (override)); 59 MOCK_METHOD(android::binder::Status, registerMonitor, 60 (const sp<android::automotive::watchdog::internal::ICarWatchdogMonitor>&), 61 (override)); 62 MOCK_METHOD(android::binder::Status, unregisterMonitor, 63 (const sp<android::automotive::watchdog::internal::ICarWatchdogMonitor>&), 64 (override)); 65 MOCK_METHOD(android::binder::Status, tellClientAlive, (const sp<ICarWatchdogClient>&, int32_t), 66 (override)); 67 MOCK_METHOD(android::binder::Status, tellCarWatchdogServiceAlive, 68 (const android::sp< 69 android::automotive::watchdog::internal::ICarWatchdogServiceForSystem>&, 70 const std::vector<android::automotive::watchdog::internal::ProcessIdentifier>&, 71 int32_t), 72 (override)); 73 MOCK_METHOD(android::binder::Status, tellDumpFinished, 74 (const android::sp<android::automotive::watchdog::internal::ICarWatchdogMonitor>&, 75 const android::automotive::watchdog::internal::ProcessIdentifier&), 76 (override)); 77 MOCK_METHOD(void, setEnabled, (bool), (override)); 78 MOCK_METHOD(void, onUserStateChange, (userid_t, bool), (override)); 79 }; 80 81 } // namespace watchdog 82 } // namespace automotive 83 } // namespace android 84 85 #endif // CPP_WATCHDOG_SERVER_TESTS_MOCKWATCHDOGPROCESSSERVICE_H_ 86