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 "types/raw_address.h" 22 23 namespace bluetooth { 24 namespace storage { 25 26 class BtifStorageInterface { 27 public: 28 virtual void AddLeaudioAutoconnect(RawAddress const& addr, 29 bool autoconnect) = 0; 30 virtual void LeAudioUpdatePacs(RawAddress const& addr) = 0; 31 virtual void LeAudioUpdateAses(RawAddress const& addr) = 0; 32 virtual void LeAudioUpdateHandles(RawAddress const& addr) = 0; 33 virtual void SetLeAudioLocations(RawAddress const& addr, 34 uint32_t sink_location, 35 uint32_t source_location) = 0; 36 virtual void SetLeAudioContexts(RawAddress const& addr, uint16_t sink_context, 37 uint16_t source_context) = 0; 38 virtual void RemoveLeaudio(RawAddress const& addr) = 0; 39 virtual void AddLeaudioHasDevice(const RawAddress& address, 40 std::vector<uint8_t> presets_bin, 41 uint8_t features, uint8_t active_preset) = 0; 42 virtual void SetLeaudioHasPresets(const RawAddress& address, 43 std::vector<uint8_t> presets_bin) = 0; 44 virtual bool GetLeaudioHasFeatures(const RawAddress& address, 45 uint8_t& features) = 0; 46 virtual void SetLeaudioHasFeatures(const RawAddress& address, 47 uint8_t features) = 0; 48 virtual void SetLeaudioHasActivePreset(const RawAddress& address, 49 uint8_t active_preset) = 0; 50 virtual bool GetLeaudioHasPresets(const RawAddress& address, 51 std::vector<uint8_t>& presets_bin, 52 uint8_t& active_preset) = 0; 53 virtual void RemoveLeaudioHas(const RawAddress& address) = 0; 54 55 virtual ~BtifStorageInterface() = default; 56 }; 57 58 class MockBtifStorageInterface : public BtifStorageInterface { 59 public: 60 MOCK_METHOD((void), AddLeaudioAutoconnect, 61 (RawAddress const& addr, bool autoconnect), (override)); 62 MOCK_METHOD((void), LeAudioUpdatePacs, (RawAddress const& addr), (override)); 63 MOCK_METHOD((void), LeAudioUpdateAses, (RawAddress const& addr), (override)); 64 MOCK_METHOD((void), LeAudioUpdateHandles, (RawAddress const& addr), 65 (override)); 66 MOCK_METHOD((void), SetLeAudioLocations, 67 (RawAddress const& addr, uint32_t sink_location, 68 uint32_t source_location), 69 (override)); 70 MOCK_METHOD((void), SetLeAudioContexts, 71 (RawAddress const& addr, uint16_t sink_context, 72 uint16_t source_context), 73 (override)); 74 MOCK_METHOD((void), RemoveLeaudio, (RawAddress const& addr), (override)); 75 MOCK_METHOD((void), AddLeaudioHasDevice, 76 (const RawAddress& address, std::vector<uint8_t> presets_bin, 77 uint8_t features, uint8_t active_preset), 78 (override)); 79 MOCK_METHOD((bool), GetLeaudioHasPresets, 80 (const RawAddress& address, std::vector<uint8_t>& presets_bin, 81 uint8_t& active_preset), 82 (override)); 83 MOCK_METHOD((void), SetLeaudioHasPresets, 84 (const RawAddress& address, std::vector<uint8_t> presets_bin), 85 (override)); 86 MOCK_METHOD((bool), GetLeaudioHasFeatures, 87 (const RawAddress& address, uint8_t& features), (override)); 88 MOCK_METHOD((void), SetLeaudioHasFeatures, 89 (const RawAddress& address, uint8_t features), (override)); 90 MOCK_METHOD((void), SetLeaudioHasActivePreset, 91 (const RawAddress& address, uint8_t active_preset), (override)); 92 MOCK_METHOD((void), RemoveLeaudioHas, (const RawAddress& address), 93 (override)); 94 }; 95 96 /** 97 * Set the {@link MockBifStorageInterface} for testing 98 * 99 * @param mock_btif_storage_interface pointer to mock btm security 100 * internal interface, could be null 101 */ 102 void SetMockBtifStorageInterface( 103 MockBtifStorageInterface* mock_btif_storage_interface); 104 105 } // namespace storage 106 } // namespace bluetooth 107