1 /* 2 * Copyright 2021 HIMSA II K/S - www.himsa.com. 3 * Represented by EHIMA - www.ehima.com 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 #pragma once 18 19 #include <gmock/gmock.h> 20 21 #include "include/hardware/bluetooth.h" 22 #include "types/raw_address.h" 23 24 namespace bluetooth { 25 namespace storage { 26 27 class BtifStorageInterface { 28 public: 29 virtual void AddLeaudioAutoconnect(RawAddress const& addr, 30 bool autoconnect) = 0; 31 virtual void LeAudioUpdatePacs(RawAddress const& addr) = 0; 32 virtual void LeAudioUpdateAses(RawAddress const& addr) = 0; 33 virtual void LeAudioUpdateHandles(RawAddress const& addr) = 0; 34 virtual void SetLeAudioLocations(RawAddress const& addr, 35 uint32_t sink_location, 36 uint32_t source_location) = 0; 37 virtual void SetLeAudioContexts(RawAddress const& addr, uint16_t sink_context, 38 uint16_t source_context) = 0; 39 virtual void ClearLeAudioServiceData(RawAddress const& addr) = 0; 40 virtual void RemoveLeaudio(RawAddress const& addr) = 0; 41 virtual void AddLeaudioHasDevice(const RawAddress& address, 42 std::vector<uint8_t> presets_bin, 43 uint8_t features, uint8_t active_preset) = 0; 44 virtual void SetLeaudioHasPresets(const RawAddress& address, 45 std::vector<uint8_t> presets_bin) = 0; 46 virtual bool GetLeaudioHasFeatures(const RawAddress& address, 47 uint8_t& features) = 0; 48 virtual void SetLeaudioHasFeatures(const RawAddress& address, 49 uint8_t features) = 0; 50 virtual void SetLeaudioHasActivePreset(const RawAddress& address, 51 uint8_t active_preset) = 0; 52 virtual bool GetLeaudioHasPresets(const RawAddress& address, 53 std::vector<uint8_t>& presets_bin, 54 uint8_t& active_preset) = 0; 55 virtual void RemoveLeaudioHas(const RawAddress& address) = 0; 56 virtual bt_status_t GetRemoteDeviceProperty(const RawAddress* address, 57 bt_property_t* property) = 0; 58 59 virtual ~BtifStorageInterface() = default; 60 }; 61 62 class MockBtifStorageInterface : public BtifStorageInterface { 63 public: 64 MOCK_METHOD((void), AddLeaudioAutoconnect, 65 (RawAddress const& addr, bool autoconnect), (override)); 66 MOCK_METHOD((void), LeAudioUpdatePacs, (RawAddress const& addr), (override)); 67 MOCK_METHOD((void), LeAudioUpdateAses, (RawAddress const& addr), (override)); 68 MOCK_METHOD((void), LeAudioUpdateHandles, (RawAddress const& addr), 69 (override)); 70 MOCK_METHOD((void), SetLeAudioLocations, 71 (RawAddress const& addr, uint32_t sink_location, 72 uint32_t source_location), 73 (override)); 74 MOCK_METHOD((void), SetLeAudioContexts, 75 (RawAddress const& addr, uint16_t sink_context, 76 uint16_t source_context), 77 (override)); 78 MOCK_METHOD((void), ClearLeAudioServiceData, (RawAddress const& addr), 79 (override)); 80 MOCK_METHOD((void), RemoveLeaudio, (RawAddress const& addr), (override)); 81 MOCK_METHOD((void), AddLeaudioHasDevice, 82 (const RawAddress& address, std::vector<uint8_t> presets_bin, 83 uint8_t features, uint8_t active_preset), 84 (override)); 85 MOCK_METHOD((bool), GetLeaudioHasPresets, 86 (const RawAddress& address, std::vector<uint8_t>& presets_bin, 87 uint8_t& active_preset), 88 (override)); 89 MOCK_METHOD((void), SetLeaudioHasPresets, 90 (const RawAddress& address, std::vector<uint8_t> presets_bin), 91 (override)); 92 MOCK_METHOD((bool), GetLeaudioHasFeatures, 93 (const RawAddress& address, uint8_t& features), (override)); 94 MOCK_METHOD((void), SetLeaudioHasFeatures, 95 (const RawAddress& address, uint8_t features), (override)); 96 MOCK_METHOD((void), SetLeaudioHasActivePreset, 97 (const RawAddress& address, uint8_t active_preset), (override)); 98 MOCK_METHOD((void), RemoveLeaudioHas, (const RawAddress& address), 99 (override)); 100 MOCK_METHOD((bt_status_t), GetRemoteDeviceProperty, 101 (const RawAddress* address, bt_property_t* property), (override)); 102 }; 103 104 /** 105 * Set the {@link MockBifStorageInterface} for testing 106 * 107 * @param mock_btif_storage_interface pointer to mock btm security 108 * internal interface, could be null 109 */ 110 void SetMockBtifStorageInterface( 111 MockBtifStorageInterface* mock_btif_storage_interface); 112 113 } // namespace storage 114 } // namespace bluetooth 115