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_MOCKVHALCLIENT_H_ 18 #define CPP_WATCHDOG_SERVER_TESTS_MOCKVHALCLIENT_H_ 19 20 #include "MockSubscriptionClient.h" 21 22 #include <gmock/gmock.h> 23 24 namespace android { 25 namespace automotive { 26 namespace watchdog { 27 28 class MockVhalClient final : public android::frameworks::automotive::vhal::IVhalClient { 29 public: 30 template <class T> 31 using VhalResult = android::hardware::automotive::vehicle::VhalResult<T>; 32 MockVhalClient(const std::shared_ptr<MockVehicle> & vehicle)33 explicit MockVhalClient(const std::shared_ptr<MockVehicle>& vehicle) { mVehicle = vehicle; } ~MockVhalClient()34 ~MockVhalClient() { mVehicle.reset(); } 35 isAidlVhal()36 inline bool isAidlVhal() { return true; } 37 38 std::unique_ptr<android::frameworks::automotive::vhal::ISubscriptionClient> getSubscriptionClient(std::shared_ptr<android::frameworks::automotive::vhal::ISubscriptionCallback> callback)39 getSubscriptionClient( 40 std::shared_ptr<android::frameworks::automotive::vhal::ISubscriptionCallback> callback) 41 override { 42 return std::make_unique<MockSubscriptionClient>(mVehicle, callback); 43 } 44 45 MOCK_METHOD(std::unique_ptr<android::frameworks::automotive::vhal::IHalPropValue>, 46 createHalPropValue, (int32_t), (override)); 47 MOCK_METHOD(std::unique_ptr<android::frameworks::automotive::vhal::IHalPropValue>, 48 createHalPropValue, (int32_t, int32_t), (override)); 49 MOCK_METHOD(void, getValue, 50 (const android::frameworks::automotive::vhal::IHalPropValue&, 51 std::shared_ptr<GetValueCallbackFunc>), 52 (override)); 53 MOCK_METHOD(VhalResult<std::unique_ptr<android::frameworks::automotive::vhal::IHalPropValue>>, 54 getValueSync, (const android::frameworks::automotive::vhal::IHalPropValue&), 55 (override)); 56 MOCK_METHOD(void, setValue, 57 (const android::frameworks::automotive::vhal::IHalPropValue&, 58 std::shared_ptr<SetValueCallbackFunc>), 59 (override)); 60 MOCK_METHOD(VhalResult<void>, setValueSync, 61 (const android::frameworks::automotive::vhal::IHalPropValue&), (override)); 62 MOCK_METHOD(VhalResult<void>, addOnBinderDiedCallback, 63 (std::shared_ptr<OnBinderDiedCallbackFunc>), (override)); 64 MOCK_METHOD(VhalResult<void>, removeOnBinderDiedCallback, 65 (std::shared_ptr<OnBinderDiedCallbackFunc>), (override)); 66 MOCK_METHOD(VhalResult<std::vector< 67 std::unique_ptr<android::frameworks::automotive::vhal::IHalPropConfig>>>, 68 getAllPropConfigs, (), (override)); 69 MOCK_METHOD(VhalResult<std::vector< 70 std::unique_ptr<android::frameworks::automotive::vhal::IHalPropConfig>>>, 71 getPropConfigs, (std::vector<int32_t>), (override)); 72 73 private: 74 std::shared_ptr<MockVehicle> mVehicle; 75 }; 76 77 } // namespace watchdog 78 } // namespace automotive 79 } // namespace android 80 81 #endif // CPP_WATCHDOG_SERVER_TESTS_MOCKVHALCLIENT_H_ 82