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/UserState.h> 29 #include <binder/Status.h> 30 #include <gmock/gmock.h> 31 #include <utils/String16.h> 32 #include <utils/Vector.h> 33 34 #include <vector> 35 36 namespace android { 37 namespace automotive { 38 namespace watchdog { 39 40 class MockWatchdogProcessService : public WatchdogProcessService { 41 public: MockWatchdogProcessService()42 MockWatchdogProcessService() : WatchdogProcessService(nullptr) {} 43 MOCK_METHOD(android::base::Result<void>, dump, (int fd, const Vector<android::String16>& args), 44 (override)); 45 MOCK_METHOD(android::base::Result<void>, registerWatchdogServiceHelper, 46 (const android::sp<IWatchdogServiceHelper>& helper), (override)); 47 48 MOCK_METHOD(android::binder::Status, registerClient, 49 (const sp<ICarWatchdogClient>& client, TimeoutLength timeout), (override)); 50 MOCK_METHOD(android::binder::Status, unregisterClient, (const sp<ICarWatchdogClient>& client), 51 (override)); 52 MOCK_METHOD(android::binder::Status, registerCarWatchdogService, 53 (const android::sp<IBinder>& binder), (override)); 54 MOCK_METHOD(void, unregisterCarWatchdogService, (const android::sp<IBinder>& binder), 55 (override)); 56 MOCK_METHOD(android::binder::Status, registerMonitor, 57 (const sp<android::automotive::watchdog::internal::ICarWatchdogMonitor>& monitor), 58 (override)); 59 MOCK_METHOD(android::binder::Status, unregisterMonitor, 60 (const sp<android::automotive::watchdog::internal::ICarWatchdogMonitor>& monitor), 61 (override)); 62 MOCK_METHOD(android::binder::Status, tellClientAlive, 63 (const sp<ICarWatchdogClient>& client, int32_t sessionId), (override)); 64 MOCK_METHOD(android::binder::Status, tellCarWatchdogServiceAlive, 65 (const android::sp< 66 android::automotive::watchdog::internal::ICarWatchdogServiceForSystem>& 67 service, 68 const std::vector<int32_t>& clientsNotResponding, int32_t sessionId), 69 (override)); 70 MOCK_METHOD(android::binder::Status, tellDumpFinished, 71 (const android::sp<android::automotive::watchdog::internal::ICarWatchdogMonitor>& 72 monitor, 73 int32_t pid), 74 (override)); 75 MOCK_METHOD(void, setEnabled, (bool), (override)); 76 MOCK_METHOD(android::binder::Status, notifyUserStateChange, 77 (userid_t userId, android::automotive::watchdog::internal::UserState state), 78 (override)); 79 }; 80 81 } // namespace watchdog 82 } // namespace automotive 83 } // namespace android 84 85 #endif // CPP_WATCHDOG_SERVER_TESTS_MOCKWATCHDOGPROCESSSERVICE_H_ 86