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