1 /* 2 * Copyright 2020 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 <base/callback.h> 20 #include <gmock/gmock.h> 21 22 #include <array> 23 24 #include "btm_iso_api_types.h" 25 #include "hcimsgs.h" 26 27 namespace hcic { 28 class HcicInterface { 29 public: 30 // iso_manager::cig_create_params is a workaround for the 10 params function 31 // limitation that gmock sets 32 virtual void SetCigParams( 33 uint8_t cig_id, 34 struct bluetooth::hci::iso_manager::cig_create_params cig_params, 35 base::OnceCallback<void(uint8_t*, uint16_t)> cb) = 0; 36 37 virtual void RemoveCig(uint8_t cig_id, 38 base::OnceCallback<void(uint8_t*, uint16_t)> cb) = 0; 39 40 virtual void CreateCis(uint8_t num_cis, 41 const EXT_CIS_CREATE_CFG* cis_create_cfg, 42 base::OnceCallback<void(uint8_t*, uint16_t)> cb) = 0; 43 44 virtual void Disconnect(uint16_t handle, uint8_t reason) = 0; 45 46 virtual void SetupIsoDataPath( 47 uint16_t iso_handle, uint8_t data_path_dir, uint8_t data_path_id, 48 uint8_t codec_id_format, uint16_t codec_id_company, 49 uint16_t codec_id_vendor, uint32_t controller_delay, 50 std::vector<uint8_t> codec_conf, 51 base::OnceCallback<void(uint8_t*, uint16_t)> cb) = 0; 52 53 virtual void RemoveIsoDataPath( 54 uint16_t iso_handle, uint8_t data_path_dir, 55 base::OnceCallback<void(uint8_t*, uint16_t)> cb) = 0; 56 57 virtual void ReadIsoLinkQuality( 58 uint16_t iso_handle, base::OnceCallback<void(uint8_t*, uint16_t)> cb) = 0; 59 60 // iso_manager::big_create_params is a workaround for the 10 params function 61 // limitation that gmock sets 62 virtual void CreateBig( 63 uint8_t big_handle, 64 struct bluetooth::hci::iso_manager::big_create_params big_params) = 0; 65 66 virtual void TerminateBig(uint8_t big_handle, uint8_t reason) = 0; 67 68 virtual ~HcicInterface() = default; 69 }; 70 71 class MockHcicInterface : public HcicInterface { 72 public: 73 MOCK_METHOD((void), SetCigParams, 74 (uint8_t cig_id, 75 struct bluetooth::hci::iso_manager::cig_create_params cig_params, 76 base::OnceCallback<void(uint8_t*, uint16_t)> cb), 77 (override)); 78 79 MOCK_METHOD((void), RemoveCig, 80 (uint8_t cig_id, base::OnceCallback<void(uint8_t*, uint16_t)> cb), 81 (override)); 82 83 MOCK_METHOD((void), CreateCis, 84 (uint8_t num_cis, const EXT_CIS_CREATE_CFG* cis_create_cfg, 85 base::OnceCallback<void(uint8_t*, uint16_t)> cb), 86 (override)); 87 88 MOCK_METHOD((void), Disconnect, (uint16_t handle, uint8_t reason), 89 (override)); 90 91 MOCK_METHOD((void), SetupIsoDataPath, 92 (uint16_t iso_handle, uint8_t data_path_dir, uint8_t data_path_id, 93 uint8_t codec_id_format, uint16_t codec_id_company, 94 uint16_t codec_id_vendor, uint32_t controller_delay, 95 std::vector<uint8_t> codec_conf, 96 base::OnceCallback<void(uint8_t*, uint16_t)> cb), 97 (override)); 98 99 MOCK_METHOD((void), RemoveIsoDataPath, 100 (uint16_t iso_handle, uint8_t data_path_dir, 101 base::OnceCallback<void(uint8_t*, uint16_t)> cb), 102 (override)); 103 104 MOCK_METHOD((void), ReadIsoLinkQuality, 105 (uint16_t iso_handle, 106 base::OnceCallback<void(uint8_t*, uint16_t)> cb), 107 (override)); 108 109 MOCK_METHOD( 110 (void), CreateBig, 111 (uint8_t big_handle, 112 struct bluetooth::hci::iso_manager::big_create_params big_params), 113 (override)); 114 115 MOCK_METHOD((void), TerminateBig, (uint8_t big_handle, uint8_t reason), 116 (override)); 117 }; 118 119 void SetMockHcicInterface(MockHcicInterface* mock_hcic_interface); 120 121 } // namespace hcic 122