1 /** 2 * Copyright (c) 2022, 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_MOCKHIDLSERVICEMANAGER_H_ 18 #define CPP_WATCHDOG_SERVER_TESTS_MOCKHIDLSERVICEMANAGER_H_ 19 20 #include <android/hidl/manager/1.0/IServiceManager.h> 21 #include <gmock/gmock.h> 22 #include <hidl/HidlSupport.h> 23 #include <hidl/Status.h> 24 25 namespace android { 26 namespace automotive { 27 namespace watchdog { 28 29 class MockHidlServiceManager : public android::hidl::manager::V1_0::IServiceManager { 30 public: 31 using IServiceManager = android::hidl::manager::V1_0::IServiceManager; 32 using IBase = android::hidl::base::V1_0::IBase; 33 template <typename T> 34 using Return = android::hardware::Return<T>; 35 using String = const android::hardware::hidl_string&; 36 ~MockHidlServiceManager() = default; 37 38 #define MOCK_METHOD_CB(name) MOCK_METHOD1(name, Return<void>(IServiceManager::name##_cb)) 39 40 MOCK_METHOD2(get, Return<android::sp<IBase>>(String, String)); 41 MOCK_METHOD2(add, Return<bool>(String, const android::sp<IBase>&)); 42 MOCK_METHOD2(getTransport, Return<IServiceManager::Transport>(String, String)); 43 MOCK_METHOD_CB(list); 44 MOCK_METHOD2(listByInterface, Return<void>(String, listByInterface_cb)); 45 MOCK_METHOD3(registerForNotifications, 46 Return<bool>(String, String, 47 const sp<android::hidl::manager::V1_0::IServiceNotification>&)); 48 MOCK_METHOD_CB(debugDump); 49 MOCK_METHOD2(registerPassthroughClient, Return<void>(String, String)); 50 MOCK_METHOD_CB(interfaceChain); 51 MOCK_METHOD2(debug, 52 Return<void>(const android::hardware::hidl_handle&, 53 const android::hardware::hidl_vec<android::hardware::hidl_string>&)); 54 MOCK_METHOD_CB(interfaceDescriptor); 55 MOCK_METHOD_CB(getHashChain); 56 MOCK_METHOD0(setHalInstrumentation, Return<void>()); 57 MOCK_METHOD2(linkToDeath, 58 Return<bool>(const sp<android::hardware::hidl_death_recipient>&, uint64_t)); 59 MOCK_METHOD0(ping, Return<void>()); 60 MOCK_METHOD_CB(getDebugInfo); 61 MOCK_METHOD0(notifySyspropsChanged, Return<void>()); 62 MOCK_METHOD1(unlinkToDeath, Return<bool>(const sp<android::hardware::hidl_death_recipient>&)); 63 }; 64 65 } // namespace watchdog 66 } // namespace automotive 67 } // namespace android 68 69 #endif // CPP_WATCHDOG_SERVER_TESTS_MOCKHIDLSERVICEMANAGER_H_ 70