1 /*
2  * Copyright 2021 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 /*
18  * Generated mock file from original source file
19  *   Functions generated:45
20  *
21  *  mockcify.pl ver 0.2
22  */
23 
24 #include <cstdint>
25 #include <functional>
26 #include <map>
27 #include <string>
28 
29 extern std::map<std::string, int> mock_function_count_map;
30 
31 // Mock include file to share data between tests and mock
32 #include "test/mock/mock_main_shim_l2cap_api.h"
33 
34 // Mocked compile conditionals, if any
35 #ifndef UNUSED_ATTR
36 #define UNUSED_ATTR
37 #endif
38 
39 // Mocked internal structures, if any
40 
41 namespace test {
42 namespace mock {
43 namespace main_shim_l2cap_api {
44 
45 // Function state capture and return values, if needed
46 struct L2CA_ReadRemoteVersion L2CA_ReadRemoteVersion;
47 struct L2CA_ReadRemoteFeatures L2CA_ReadRemoteFeatures;
48 struct L2CA_UseLegacySecurityModule L2CA_UseLegacySecurityModule;
49 struct L2CA_Register L2CA_Register;
50 struct L2CA_Deregister L2CA_Deregister;
51 struct L2CA_ConnectReq L2CA_ConnectReq;
52 struct L2CA_DisconnectReq L2CA_DisconnectReq;
53 struct L2CA_DataWrite L2CA_DataWrite;
54 struct L2CA_ReconfigCreditBasedConnsReq L2CA_ReconfigCreditBasedConnsReq;
55 struct L2CA_ConnectCreditBasedReq L2CA_ConnectCreditBasedReq;
56 struct L2CA_ConnectCreditBasedRsp L2CA_ConnectCreditBasedRsp;
57 struct L2CA_SetIdleTimeoutByBdAddr L2CA_SetIdleTimeoutByBdAddr;
58 struct L2CA_SetAclPriority L2CA_SetAclPriority;
59 struct L2CA_SetAclPriority2 L2CA_SetAclPriority2;
60 struct L2CA_GetPeerFeatures L2CA_GetPeerFeatures;
61 struct L2CA_RegisterFixedChannel L2CA_RegisterFixedChannel;
62 struct L2CA_ConnectFixedChnl L2CA_ConnectFixedChnl;
63 struct L2CA_SendFixedChnlData L2CA_SendFixedChnlData;
64 struct L2CA_RemoveFixedChnl L2CA_RemoveFixedChnl;
65 struct L2CA_GetLeHandle L2CA_GetLeHandle;
66 struct L2CA_LeConnectionUpdate L2CA_LeConnectionUpdate;
67 struct L2CA_EnableUpdateBleConnParams L2CA_EnableUpdateBleConnParams;
68 struct L2CA_GetRemoteCid L2CA_GetRemoteCid;
69 struct L2CA_SetTxPriority L2CA_SetTxPriority;
70 struct L2CA_SetLeGattTimeout L2CA_SetLeGattTimeout;
71 struct L2CA_SetChnlFlushability L2CA_SetChnlFlushability;
72 struct L2CA_FlushChannel L2CA_FlushChannel;
73 struct L2CA_IsLinkEstablished L2CA_IsLinkEstablished;
74 struct L2CA_IsLeLink L2CA_IsLeLink;
75 struct L2CA_ReadConnectionAddr L2CA_ReadConnectionAddr;
76 struct L2CA_ReadRemoteConnectionAddr L2CA_ReadRemoteConnectionAddr;
77 struct L2CA_GetBleConnRole L2CA_GetBleConnRole;
78 struct L2CA_ConnectForSecurity L2CA_ConnectForSecurity;
79 struct L2CA_SetBondingState L2CA_SetBondingState;
80 struct L2CA_DisconnectLink L2CA_DisconnectLink;
81 struct L2CA_GetNumLinks L2CA_GetNumLinks;
82 struct L2CA_AllocateLePSM L2CA_AllocateLePSM;
83 struct L2CA_FreeLePSM L2CA_FreeLePSM;
84 struct L2CA_RegisterLECoc L2CA_RegisterLECoc;
85 struct L2CA_DeregisterLECoc L2CA_DeregisterLECoc;
86 struct L2CA_ConnectLECocReq L2CA_ConnectLECocReq;
87 struct L2CA_GetPeerLECocConfig L2CA_GetPeerLECocConfig;
88 struct L2CA_DisconnectLECocReq L2CA_DisconnectLECocReq;
89 struct L2CA_LECocDataWrite L2CA_LECocDataWrite;
90 struct L2CA_SwitchRoleToCentral L2CA_SwitchRoleToCentral;
91 
92 }  // namespace main_shim_l2cap_api
93 }  // namespace mock
94 }  // namespace test
95 
96 // Mocked functions, if any
L2CA_ReadRemoteVersion(const RawAddress & addr,uint8_t * lmp_version,uint16_t * manufacturer,uint16_t * lmp_sub_version)97 bool bluetooth::shim::L2CA_ReadRemoteVersion(const RawAddress& addr,
98                                              uint8_t* lmp_version,
99                                              uint16_t* manufacturer,
100                                              uint16_t* lmp_sub_version) {
101   mock_function_count_map[__func__]++;
102   return test::mock::main_shim_l2cap_api::L2CA_ReadRemoteVersion(
103       addr, lmp_version, manufacturer, lmp_sub_version);
104 }
L2CA_ReadRemoteFeatures(const RawAddress & addr)105 uint8_t* bluetooth::shim::L2CA_ReadRemoteFeatures(const RawAddress& addr) {
106   mock_function_count_map[__func__]++;
107   return test::mock::main_shim_l2cap_api::L2CA_ReadRemoteFeatures(addr);
108 }
L2CA_UseLegacySecurityModule()109 void bluetooth::shim::L2CA_UseLegacySecurityModule() {
110   mock_function_count_map[__func__]++;
111   test::mock::main_shim_l2cap_api::L2CA_UseLegacySecurityModule();
112 }
L2CA_Register(uint16_t client_psm,const tL2CAP_APPL_INFO & callbacks,bool enable_snoop,tL2CAP_ERTM_INFO * p_ertm_info,uint16_t my_mtu,uint16_t required_remote_mtu,uint16_t sec_level)113 uint16_t bluetooth::shim::L2CA_Register(
114     uint16_t client_psm, const tL2CAP_APPL_INFO& callbacks, bool enable_snoop,
115     tL2CAP_ERTM_INFO* p_ertm_info, uint16_t my_mtu,
116     uint16_t required_remote_mtu, uint16_t sec_level) {
117   mock_function_count_map[__func__]++;
118   return test::mock::main_shim_l2cap_api::L2CA_Register(
119       client_psm, callbacks, enable_snoop, p_ertm_info, my_mtu,
120       required_remote_mtu, sec_level);
121 }
L2CA_Deregister(uint16_t psm)122 void bluetooth::shim::L2CA_Deregister(uint16_t psm) {
123   mock_function_count_map[__func__]++;
124   test::mock::main_shim_l2cap_api::L2CA_Deregister(psm);
125 }
L2CA_ConnectReq(uint16_t psm,const RawAddress & raw_address)126 uint16_t bluetooth::shim::L2CA_ConnectReq(uint16_t psm,
127                                           const RawAddress& raw_address) {
128   mock_function_count_map[__func__]++;
129   return test::mock::main_shim_l2cap_api::L2CA_ConnectReq(psm, raw_address);
130 }
L2CA_DisconnectReq(uint16_t cid)131 bool bluetooth::shim::L2CA_DisconnectReq(uint16_t cid) {
132   mock_function_count_map[__func__]++;
133   return test::mock::main_shim_l2cap_api::L2CA_DisconnectReq(cid);
134 }
L2CA_DataWrite(uint16_t cid,BT_HDR * p_data)135 uint8_t bluetooth::shim::L2CA_DataWrite(uint16_t cid, BT_HDR* p_data) {
136   mock_function_count_map[__func__]++;
137   return test::mock::main_shim_l2cap_api::L2CA_DataWrite(cid, p_data);
138 }
L2CA_ReconfigCreditBasedConnsReq(const RawAddress & bd_addr,std::vector<uint16_t> & lcids,tL2CAP_LE_CFG_INFO * p_cfg)139 bool bluetooth::shim::L2CA_ReconfigCreditBasedConnsReq(
140     const RawAddress& bd_addr, std::vector<uint16_t>& lcids,
141     tL2CAP_LE_CFG_INFO* p_cfg) {
142   mock_function_count_map[__func__]++;
143   return test::mock::main_shim_l2cap_api::L2CA_ReconfigCreditBasedConnsReq(
144       bd_addr, lcids, p_cfg);
145 }
L2CA_ConnectCreditBasedReq(uint16_t psm,const RawAddress & p_bd_addr,tL2CAP_LE_CFG_INFO * p_cfg)146 std::vector<uint16_t> bluetooth::shim::L2CA_ConnectCreditBasedReq(
147     uint16_t psm, const RawAddress& p_bd_addr, tL2CAP_LE_CFG_INFO* p_cfg) {
148   mock_function_count_map[__func__]++;
149   return test::mock::main_shim_l2cap_api::L2CA_ConnectCreditBasedReq(
150       psm, p_bd_addr, p_cfg);
151 }
L2CA_ConnectCreditBasedRsp(const RawAddress & bd_addr,uint8_t id,std::vector<uint16_t> & accepted_lcids,uint16_t result,tL2CAP_LE_CFG_INFO * p_cfg)152 bool bluetooth::shim::L2CA_ConnectCreditBasedRsp(
153     const RawAddress& bd_addr, uint8_t id,
154     std::vector<uint16_t>& accepted_lcids, uint16_t result,
155     tL2CAP_LE_CFG_INFO* p_cfg) {
156   mock_function_count_map[__func__]++;
157   return test::mock::main_shim_l2cap_api::L2CA_ConnectCreditBasedRsp(
158       bd_addr, id, accepted_lcids, result, p_cfg);
159 }
L2CA_SetIdleTimeoutByBdAddr(const RawAddress & bd_addr,uint16_t timeout,tBT_TRANSPORT transport)160 bool bluetooth::shim::L2CA_SetIdleTimeoutByBdAddr(const RawAddress& bd_addr,
161                                                   uint16_t timeout,
162                                                   tBT_TRANSPORT transport) {
163   mock_function_count_map[__func__]++;
164   return test::mock::main_shim_l2cap_api::L2CA_SetIdleTimeoutByBdAddr(
165       bd_addr, timeout, transport);
166 }
L2CA_SetAclPriority(uint16_t handle,bool high_priority)167 bool bluetooth::shim::L2CA_SetAclPriority(uint16_t handle, bool high_priority) {
168   mock_function_count_map[__func__]++;
169   return test::mock::main_shim_l2cap_api::L2CA_SetAclPriority(handle,
170                                                               high_priority);
171 }
L2CA_SetAclPriority(const RawAddress & bd_addr,tL2CAP_PRIORITY priority)172 bool bluetooth::shim::L2CA_SetAclPriority(const RawAddress& bd_addr,
173                                           tL2CAP_PRIORITY priority) {
174   mock_function_count_map[__func__]++;
175   return test::mock::main_shim_l2cap_api::L2CA_SetAclPriority2(bd_addr,
176                                                                priority);
177 }
L2CA_GetPeerFeatures(const RawAddress & bd_addr,uint32_t * p_ext_feat,uint8_t * p_chnl_mask)178 bool bluetooth::shim::L2CA_GetPeerFeatures(const RawAddress& bd_addr,
179                                            uint32_t* p_ext_feat,
180                                            uint8_t* p_chnl_mask) {
181   mock_function_count_map[__func__]++;
182   return test::mock::main_shim_l2cap_api::L2CA_GetPeerFeatures(
183       bd_addr, p_ext_feat, p_chnl_mask);
184 }
L2CA_RegisterFixedChannel(uint16_t cid,tL2CAP_FIXED_CHNL_REG * p_freg)185 bool bluetooth::shim::L2CA_RegisterFixedChannel(uint16_t cid,
186                                                 tL2CAP_FIXED_CHNL_REG* p_freg) {
187   mock_function_count_map[__func__]++;
188   return test::mock::main_shim_l2cap_api::L2CA_RegisterFixedChannel(cid,
189                                                                     p_freg);
190 }
L2CA_ConnectFixedChnl(uint16_t cid,const RawAddress & rem_bda)191 bool bluetooth::shim::L2CA_ConnectFixedChnl(uint16_t cid,
192                                             const RawAddress& rem_bda) {
193   mock_function_count_map[__func__]++;
194   return test::mock::main_shim_l2cap_api::L2CA_ConnectFixedChnl(cid, rem_bda);
195 }
L2CA_SendFixedChnlData(uint16_t cid,const RawAddress & rem_bda,BT_HDR * p_buf)196 uint16_t bluetooth::shim::L2CA_SendFixedChnlData(uint16_t cid,
197                                                  const RawAddress& rem_bda,
198                                                  BT_HDR* p_buf) {
199   mock_function_count_map[__func__]++;
200   return test::mock::main_shim_l2cap_api::L2CA_SendFixedChnlData(cid, rem_bda,
201                                                                  p_buf);
202 }
L2CA_RemoveFixedChnl(uint16_t cid,const RawAddress & rem_bda)203 bool bluetooth::shim::L2CA_RemoveFixedChnl(uint16_t cid,
204                                            const RawAddress& rem_bda) {
205   mock_function_count_map[__func__]++;
206   return test::mock::main_shim_l2cap_api::L2CA_RemoveFixedChnl(cid, rem_bda);
207 }
L2CA_GetLeHandle(const RawAddress & rem_bda)208 uint16_t bluetooth::shim::L2CA_GetLeHandle(const RawAddress& rem_bda) {
209   mock_function_count_map[__func__]++;
210   return test::mock::main_shim_l2cap_api::L2CA_GetLeHandle(rem_bda);
211 }
L2CA_LeConnectionUpdate(const RawAddress & rem_bda,uint16_t min_int,uint16_t max_int,uint16_t latency,uint16_t timeout,uint16_t min_ce_len,uint16_t max_ce_len)212 void bluetooth::shim::L2CA_LeConnectionUpdate(
213     const RawAddress& rem_bda, uint16_t min_int, uint16_t max_int,
214     uint16_t latency, uint16_t timeout, uint16_t min_ce_len,
215     uint16_t max_ce_len) {
216   mock_function_count_map[__func__]++;
217   test::mock::main_shim_l2cap_api::L2CA_LeConnectionUpdate(
218       rem_bda, min_int, max_int, latency, timeout, min_ce_len, max_ce_len);
219 }
L2CA_EnableUpdateBleConnParams(const RawAddress & rem_bda,bool enable)220 bool bluetooth::shim::L2CA_EnableUpdateBleConnParams(const RawAddress& rem_bda,
221                                                      bool enable) {
222   mock_function_count_map[__func__]++;
223   return test::mock::main_shim_l2cap_api::L2CA_EnableUpdateBleConnParams(
224       rem_bda, enable);
225 }
L2CA_GetRemoteCid(uint16_t lcid,uint16_t * rcid)226 bool bluetooth::shim::L2CA_GetRemoteCid(uint16_t lcid, uint16_t* rcid) {
227   mock_function_count_map[__func__]++;
228   return test::mock::main_shim_l2cap_api::L2CA_GetRemoteCid(lcid, rcid);
229 }
L2CA_SetTxPriority(uint16_t cid,tL2CAP_CHNL_PRIORITY priority)230 bool bluetooth::shim::L2CA_SetTxPriority(uint16_t cid,
231                                          tL2CAP_CHNL_PRIORITY priority) {
232   mock_function_count_map[__func__]++;
233   return test::mock::main_shim_l2cap_api::L2CA_SetTxPriority(cid, priority);
234 }
L2CA_SetLeGattTimeout(const RawAddress & rem_bda,uint16_t idle_tout)235 bool bluetooth::shim::L2CA_SetLeGattTimeout(const RawAddress& rem_bda,
236                                             uint16_t idle_tout) {
237   mock_function_count_map[__func__]++;
238   return test::mock::main_shim_l2cap_api::L2CA_SetLeGattTimeout(rem_bda,
239                                                                 idle_tout);
240 }
L2CA_SetChnlFlushability(uint16_t cid,bool is_flushable)241 bool bluetooth::shim::L2CA_SetChnlFlushability(uint16_t cid,
242                                                bool is_flushable) {
243   mock_function_count_map[__func__]++;
244   return test::mock::main_shim_l2cap_api::L2CA_SetChnlFlushability(
245       cid, is_flushable);
246 }
L2CA_FlushChannel(uint16_t lcid,uint16_t num_to_flush)247 uint16_t bluetooth::shim::L2CA_FlushChannel(uint16_t lcid,
248                                             uint16_t num_to_flush) {
249   mock_function_count_map[__func__]++;
250   return test::mock::main_shim_l2cap_api::L2CA_FlushChannel(lcid, num_to_flush);
251 }
L2CA_IsLinkEstablished(const RawAddress & bd_addr,tBT_TRANSPORT transport)252 bool bluetooth::shim::L2CA_IsLinkEstablished(const RawAddress& bd_addr,
253                                              tBT_TRANSPORT transport) {
254   mock_function_count_map[__func__]++;
255   return test::mock::main_shim_l2cap_api::L2CA_IsLinkEstablished(bd_addr,
256                                                                  transport);
257 }
L2CA_IsLeLink(uint16_t acl_handle)258 bool bluetooth::shim::L2CA_IsLeLink(uint16_t acl_handle) {
259   mock_function_count_map[__func__]++;
260   return test::mock::main_shim_l2cap_api::L2CA_IsLeLink(acl_handle);
261 }
L2CA_ReadConnectionAddr(const RawAddress & pseudo_addr,RawAddress & conn_addr,uint8_t * p_addr_type)262 void bluetooth::shim::L2CA_ReadConnectionAddr(const RawAddress& pseudo_addr,
263                                               RawAddress& conn_addr,
264                                               uint8_t* p_addr_type) {
265   mock_function_count_map[__func__]++;
266   test::mock::main_shim_l2cap_api::L2CA_ReadConnectionAddr(
267       pseudo_addr, conn_addr, p_addr_type);
268 }
L2CA_ReadRemoteConnectionAddr(const RawAddress & pseudo_addr,RawAddress & conn_addr,uint8_t * p_addr_type)269 bool bluetooth::shim::L2CA_ReadRemoteConnectionAddr(
270     const RawAddress& pseudo_addr, RawAddress& conn_addr,
271     uint8_t* p_addr_type) {
272   mock_function_count_map[__func__]++;
273   return test::mock::main_shim_l2cap_api::L2CA_ReadRemoteConnectionAddr(
274       pseudo_addr, conn_addr, p_addr_type);
275 }
L2CA_GetBleConnRole(const RawAddress & bd_addr)276 hci_role_t bluetooth::shim::L2CA_GetBleConnRole(const RawAddress& bd_addr) {
277   mock_function_count_map[__func__]++;
278   return test::mock::main_shim_l2cap_api::L2CA_GetBleConnRole(bd_addr);
279 }
L2CA_ConnectForSecurity(const RawAddress & bd_addr)280 void bluetooth::shim::L2CA_ConnectForSecurity(const RawAddress& bd_addr) {
281   mock_function_count_map[__func__]++;
282   test::mock::main_shim_l2cap_api::L2CA_ConnectForSecurity(bd_addr);
283 }
L2CA_SetBondingState(const RawAddress & bd_addr,bool is_bonding)284 void bluetooth::shim::L2CA_SetBondingState(const RawAddress& bd_addr,
285                                            bool is_bonding) {
286   mock_function_count_map[__func__]++;
287   test::mock::main_shim_l2cap_api::L2CA_SetBondingState(bd_addr, is_bonding);
288 }
L2CA_DisconnectLink(const RawAddress & remote)289 void bluetooth::shim::L2CA_DisconnectLink(const RawAddress& remote) {
290   mock_function_count_map[__func__]++;
291   test::mock::main_shim_l2cap_api::L2CA_DisconnectLink(remote);
292 }
L2CA_GetNumLinks()293 uint16_t bluetooth::shim::L2CA_GetNumLinks() {
294   mock_function_count_map[__func__]++;
295   return test::mock::main_shim_l2cap_api::L2CA_GetNumLinks();
296 }
L2CA_AllocateLePSM()297 uint16_t bluetooth::shim::L2CA_AllocateLePSM() {
298   mock_function_count_map[__func__]++;
299   return test::mock::main_shim_l2cap_api::L2CA_AllocateLePSM();
300 }
L2CA_FreeLePSM(uint16_t psm)301 void bluetooth::shim::L2CA_FreeLePSM(uint16_t psm) {
302   mock_function_count_map[__func__]++;
303   test::mock::main_shim_l2cap_api::L2CA_FreeLePSM(psm);
304 }
L2CA_RegisterLECoc(uint16_t psm,const tL2CAP_APPL_INFO & callbacks,uint16_t sec_level,tL2CAP_LE_CFG_INFO cfg)305 uint16_t bluetooth::shim::L2CA_RegisterLECoc(uint16_t psm,
306                                              const tL2CAP_APPL_INFO& callbacks,
307                                              uint16_t sec_level,
308                                              tL2CAP_LE_CFG_INFO cfg) {
309   mock_function_count_map[__func__]++;
310   return test::mock::main_shim_l2cap_api::L2CA_RegisterLECoc(psm, callbacks,
311                                                              sec_level, cfg);
312 }
L2CA_DeregisterLECoc(uint16_t psm)313 void bluetooth::shim::L2CA_DeregisterLECoc(uint16_t psm) {
314   mock_function_count_map[__func__]++;
315   test::mock::main_shim_l2cap_api::L2CA_DeregisterLECoc(psm);
316 }
L2CA_ConnectLECocReq(uint16_t psm,const RawAddress & p_bd_addr,tL2CAP_LE_CFG_INFO * p_cfg)317 uint16_t bluetooth::shim::L2CA_ConnectLECocReq(uint16_t psm,
318                                                const RawAddress& p_bd_addr,
319                                                tL2CAP_LE_CFG_INFO* p_cfg) {
320   mock_function_count_map[__func__]++;
321   return test::mock::main_shim_l2cap_api::L2CA_ConnectLECocReq(psm, p_bd_addr,
322                                                                p_cfg);
323 }
L2CA_GetPeerLECocConfig(uint16_t cid,tL2CAP_LE_CFG_INFO * peer_cfg)324 bool bluetooth::shim::L2CA_GetPeerLECocConfig(uint16_t cid,
325                                               tL2CAP_LE_CFG_INFO* peer_cfg) {
326   mock_function_count_map[__func__]++;
327   return test::mock::main_shim_l2cap_api::L2CA_GetPeerLECocConfig(cid,
328                                                                   peer_cfg);
329 }
L2CA_DisconnectLECocReq(uint16_t cid)330 bool bluetooth::shim::L2CA_DisconnectLECocReq(uint16_t cid) {
331   mock_function_count_map[__func__]++;
332   return test::mock::main_shim_l2cap_api::L2CA_DisconnectLECocReq(cid);
333 }
L2CA_LECocDataWrite(uint16_t cid,BT_HDR * p_data)334 uint8_t bluetooth::shim::L2CA_LECocDataWrite(uint16_t cid, BT_HDR* p_data) {
335   mock_function_count_map[__func__]++;
336   return test::mock::main_shim_l2cap_api::L2CA_LECocDataWrite(cid, p_data);
337 }
L2CA_SwitchRoleToCentral(const RawAddress & addr)338 void bluetooth::shim::L2CA_SwitchRoleToCentral(const RawAddress& addr) {
339   mock_function_count_map[__func__]++;
340   test::mock::main_shim_l2cap_api::L2CA_SwitchRoleToCentral(addr);
341 }
342 
343 // END mockcify generation
344