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:33
20 *
21 * mockcify.pl ver 0.2
22 */
23
24 #include <map>
25 #include <string>
26
27 extern std::map<std::string, int> mock_function_count_map;
28
29 // Original included files, if any
30 // NOTE: Since this is a mock file with mock definitions some number of
31 // include files may not be required. The include-what-you-use
32 // still applies, but crafting proper inclusion is out of scope
33 // for this effort. This compilation unit may compile as-is, or
34 // may need attention to prune the inclusion set.
35 #include <base/logging.h>
36 #include <base/strings/stringprintf.h>
37 #include <cstdint>
38 #include <string>
39 #include "device/include/controller.h"
40 #include "main/shim/l2c_api.h"
41 #include "main/shim/shim.h"
42 #include "osi/include/log.h"
43 #include "stack/btm/btm_sec.h"
44 #include "stack/include/l2c_api.h"
45 #include "stack/l2cap/l2c_int.h"
46
47 // Mock include file to share data between tests and mock
48 #include "test/mock/mock_stack_l2cap_api.h"
49
50 // Mocked compile conditionals, if any
51 #ifndef UNUSED_ATTR
52 #define UNUSED_ATTR
53 #endif
54
55 // Mocked internal structures, if any
56
57 namespace test {
58 namespace mock {
59 namespace stack_l2cap_api {
60
61 // Function state capture and return values, if needed
62 struct l2c_get_transport_from_fixed_cid l2c_get_transport_from_fixed_cid;
63 struct L2CA_Register2 L2CA_Register2;
64 struct L2CA_Register L2CA_Register;
65 struct L2CA_Deregister L2CA_Deregister;
66 struct L2CA_AllocateLePSM L2CA_AllocateLePSM;
67 struct L2CA_FreeLePSM L2CA_FreeLePSM;
68 struct L2CA_ConnectReq2 L2CA_ConnectReq2;
69 struct L2CA_ConnectReq L2CA_ConnectReq;
70 struct L2CA_RegisterLECoc L2CA_RegisterLECoc;
71 struct L2CA_DeregisterLECoc L2CA_DeregisterLECoc;
72 struct L2CA_ConnectLECocReq L2CA_ConnectLECocReq;
73 struct L2CA_GetPeerLECocConfig L2CA_GetPeerLECocConfig;
74 struct L2CA_ConnectCreditBasedRsp L2CA_ConnectCreditBasedRsp;
75 struct L2CA_ConnectCreditBasedReq L2CA_ConnectCreditBasedReq;
76 struct L2CA_ReconfigCreditBasedConnsReq L2CA_ReconfigCreditBasedConnsReq;
77 struct L2CA_DisconnectReq L2CA_DisconnectReq;
78 struct L2CA_DisconnectLECocReq L2CA_DisconnectLECocReq;
79 struct L2CA_GetRemoteCid L2CA_GetRemoteCid;
80 struct L2CA_SetIdleTimeoutByBdAddr L2CA_SetIdleTimeoutByBdAddr;
81 struct L2CA_SetTraceLevel L2CA_SetTraceLevel;
82 struct L2CA_SetAclPriority L2CA_SetAclPriority;
83 struct L2CA_SetTxPriority L2CA_SetTxPriority;
84 struct L2CA_GetPeerFeatures L2CA_GetPeerFeatures;
85 struct L2CA_RegisterFixedChannel L2CA_RegisterFixedChannel;
86 struct L2CA_ConnectFixedChnl L2CA_ConnectFixedChnl;
87 struct L2CA_SendFixedChnlData L2CA_SendFixedChnlData;
88 struct L2CA_RemoveFixedChnl L2CA_RemoveFixedChnl;
89 struct L2CA_SetLeGattTimeout L2CA_SetLeGattTimeout;
90 struct L2CA_DataWrite L2CA_DataWrite;
91 struct L2CA_LECocDataWrite L2CA_LECocDataWrite;
92 struct L2CA_SetChnlFlushability L2CA_SetChnlFlushability;
93 struct L2CA_FlushChannel L2CA_FlushChannel;
94 struct L2CA_IsLinkEstablished L2CA_IsLinkEstablished;
95
96 } // namespace stack_l2cap_api
97 } // namespace mock
98 } // namespace test
99
100 // Mocked functions, if any
l2c_get_transport_from_fixed_cid(uint16_t fixed_cid)101 tBT_TRANSPORT l2c_get_transport_from_fixed_cid(uint16_t fixed_cid) {
102 mock_function_count_map[__func__]++;
103 return test::mock::stack_l2cap_api::l2c_get_transport_from_fixed_cid(
104 fixed_cid);
105 }
L2CA_Register2(uint16_t psm,const tL2CAP_APPL_INFO & p_cb_info,bool enable_snoop,tL2CAP_ERTM_INFO * p_ertm_info,uint16_t my_mtu,uint16_t required_remote_mtu,uint16_t sec_level)106 uint16_t L2CA_Register2(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info,
107 bool enable_snoop, tL2CAP_ERTM_INFO* p_ertm_info,
108 uint16_t my_mtu, uint16_t required_remote_mtu,
109 uint16_t sec_level) {
110 mock_function_count_map[__func__]++;
111 return test::mock::stack_l2cap_api::L2CA_Register2(
112 psm, p_cb_info, enable_snoop, p_ertm_info, my_mtu, required_remote_mtu,
113 sec_level);
114 }
L2CA_Register(uint16_t psm,const tL2CAP_APPL_INFO & p_cb_info,bool enable_snoop,tL2CAP_ERTM_INFO * p_ertm_info,uint16_t my_mtu,uint16_t required_remote_mtu,uint16_t sec_level)115 uint16_t L2CA_Register(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info,
116 bool enable_snoop, tL2CAP_ERTM_INFO* p_ertm_info,
117 uint16_t my_mtu, uint16_t required_remote_mtu,
118 uint16_t sec_level) {
119 mock_function_count_map[__func__]++;
120 return test::mock::stack_l2cap_api::L2CA_Register(
121 psm, p_cb_info, enable_snoop, p_ertm_info, my_mtu, required_remote_mtu,
122 sec_level);
123 }
L2CA_Deregister(uint16_t psm)124 void L2CA_Deregister(uint16_t psm) {
125 mock_function_count_map[__func__]++;
126 test::mock::stack_l2cap_api::L2CA_Deregister(psm);
127 }
L2CA_AllocateLePSM(void)128 uint16_t L2CA_AllocateLePSM(void) {
129 mock_function_count_map[__func__]++;
130 return test::mock::stack_l2cap_api::L2CA_AllocateLePSM();
131 }
L2CA_FreeLePSM(uint16_t psm)132 void L2CA_FreeLePSM(uint16_t psm) {
133 mock_function_count_map[__func__]++;
134 test::mock::stack_l2cap_api::L2CA_FreeLePSM(psm);
135 }
L2CA_ConnectReq2(uint16_t psm,const RawAddress & p_bd_addr,uint16_t sec_level)136 uint16_t L2CA_ConnectReq2(uint16_t psm, const RawAddress& p_bd_addr,
137 uint16_t sec_level) {
138 mock_function_count_map[__func__]++;
139 return test::mock::stack_l2cap_api::L2CA_ConnectReq2(psm, p_bd_addr,
140 sec_level);
141 }
L2CA_ConnectReq(uint16_t psm,const RawAddress & p_bd_addr)142 uint16_t L2CA_ConnectReq(uint16_t psm, const RawAddress& p_bd_addr) {
143 mock_function_count_map[__func__]++;
144 return test::mock::stack_l2cap_api::L2CA_ConnectReq(psm, p_bd_addr);
145 }
L2CA_RegisterLECoc(uint16_t psm,const tL2CAP_APPL_INFO & p_cb_info,uint16_t sec_level,tL2CAP_LE_CFG_INFO cfg)146 uint16_t L2CA_RegisterLECoc(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info,
147 uint16_t sec_level, tL2CAP_LE_CFG_INFO cfg) {
148 mock_function_count_map[__func__]++;
149 return test::mock::stack_l2cap_api::L2CA_RegisterLECoc(psm, p_cb_info,
150 sec_level, cfg);
151 }
L2CA_DeregisterLECoc(uint16_t psm)152 void L2CA_DeregisterLECoc(uint16_t psm) {
153 mock_function_count_map[__func__]++;
154 test::mock::stack_l2cap_api::L2CA_DeregisterLECoc(psm);
155 }
L2CA_ConnectLECocReq(uint16_t psm,const RawAddress & p_bd_addr,tL2CAP_LE_CFG_INFO * p_cfg,uint16_t sec_level)156 uint16_t L2CA_ConnectLECocReq(uint16_t psm, const RawAddress& p_bd_addr,
157 tL2CAP_LE_CFG_INFO* p_cfg, uint16_t sec_level) {
158 mock_function_count_map[__func__]++;
159 return test::mock::stack_l2cap_api::L2CA_ConnectLECocReq(psm, p_bd_addr,
160 p_cfg, sec_level);
161 }
L2CA_GetPeerLECocConfig(uint16_t lcid,tL2CAP_LE_CFG_INFO * peer_cfg)162 bool L2CA_GetPeerLECocConfig(uint16_t lcid, tL2CAP_LE_CFG_INFO* peer_cfg) {
163 mock_function_count_map[__func__]++;
164 return test::mock::stack_l2cap_api::L2CA_GetPeerLECocConfig(lcid, peer_cfg);
165 }
L2CA_ConnectCreditBasedRsp(const RawAddress & p_bd_addr,uint8_t id,std::vector<uint16_t> & accepted_lcids,uint16_t result,tL2CAP_LE_CFG_INFO * p_cfg)166 bool L2CA_ConnectCreditBasedRsp(const RawAddress& p_bd_addr, uint8_t id,
167 std::vector<uint16_t>& accepted_lcids,
168 uint16_t result, tL2CAP_LE_CFG_INFO* p_cfg) {
169 mock_function_count_map[__func__]++;
170 return test::mock::stack_l2cap_api::L2CA_ConnectCreditBasedRsp(
171 p_bd_addr, id, accepted_lcids, result, p_cfg);
172 }
L2CA_ConnectCreditBasedReq(uint16_t psm,const RawAddress & p_bd_addr,tL2CAP_LE_CFG_INFO * p_cfg)173 std::vector<uint16_t> L2CA_ConnectCreditBasedReq(uint16_t psm,
174 const RawAddress& p_bd_addr,
175 tL2CAP_LE_CFG_INFO* p_cfg) {
176 mock_function_count_map[__func__]++;
177 return test::mock::stack_l2cap_api::L2CA_ConnectCreditBasedReq(psm, p_bd_addr,
178 p_cfg);
179 }
L2CA_ReconfigCreditBasedConnsReq(const RawAddress & bda,std::vector<uint16_t> & lcids,tL2CAP_LE_CFG_INFO * p_cfg)180 bool L2CA_ReconfigCreditBasedConnsReq(const RawAddress& bda,
181 std::vector<uint16_t>& lcids,
182 tL2CAP_LE_CFG_INFO* p_cfg) {
183 mock_function_count_map[__func__]++;
184 return test::mock::stack_l2cap_api::L2CA_ReconfigCreditBasedConnsReq(
185 bda, lcids, p_cfg);
186 }
L2CA_DisconnectReq(uint16_t cid)187 bool L2CA_DisconnectReq(uint16_t cid) {
188 mock_function_count_map[__func__]++;
189 return test::mock::stack_l2cap_api::L2CA_DisconnectReq(cid);
190 }
L2CA_DisconnectLECocReq(uint16_t cid)191 bool L2CA_DisconnectLECocReq(uint16_t cid) {
192 mock_function_count_map[__func__]++;
193 return test::mock::stack_l2cap_api::L2CA_DisconnectLECocReq(cid);
194 }
L2CA_GetRemoteCid(uint16_t lcid,uint16_t * rcid)195 bool L2CA_GetRemoteCid(uint16_t lcid, uint16_t* rcid) {
196 mock_function_count_map[__func__]++;
197 return test::mock::stack_l2cap_api::L2CA_GetRemoteCid(lcid, rcid);
198 }
L2CA_SetIdleTimeoutByBdAddr(const RawAddress & bd_addr,uint16_t timeout,tBT_TRANSPORT transport)199 bool L2CA_SetIdleTimeoutByBdAddr(const RawAddress& bd_addr, uint16_t timeout,
200 tBT_TRANSPORT transport) {
201 mock_function_count_map[__func__]++;
202 return test::mock::stack_l2cap_api::L2CA_SetIdleTimeoutByBdAddr(
203 bd_addr, timeout, transport);
204 }
L2CA_SetTraceLevel(uint8_t new_level)205 uint8_t L2CA_SetTraceLevel(uint8_t new_level) {
206 mock_function_count_map[__func__]++;
207 return test::mock::stack_l2cap_api::L2CA_SetTraceLevel(new_level);
208 }
L2CA_SetAclPriority(const RawAddress & bd_addr,tL2CAP_PRIORITY priority)209 bool L2CA_SetAclPriority(const RawAddress& bd_addr, tL2CAP_PRIORITY priority) {
210 mock_function_count_map[__func__]++;
211 return test::mock::stack_l2cap_api::L2CA_SetAclPriority(bd_addr, priority);
212 }
L2CA_SetTxPriority(uint16_t cid,tL2CAP_CHNL_PRIORITY priority)213 bool L2CA_SetTxPriority(uint16_t cid, tL2CAP_CHNL_PRIORITY priority) {
214 mock_function_count_map[__func__]++;
215 return test::mock::stack_l2cap_api::L2CA_SetTxPriority(cid, priority);
216 }
L2CA_GetPeerFeatures(const RawAddress & bd_addr,uint32_t * p_ext_feat,uint8_t * p_chnl_mask)217 bool L2CA_GetPeerFeatures(const RawAddress& bd_addr, uint32_t* p_ext_feat,
218 uint8_t* p_chnl_mask) {
219 mock_function_count_map[__func__]++;
220 return test::mock::stack_l2cap_api::L2CA_GetPeerFeatures(bd_addr, p_ext_feat,
221 p_chnl_mask);
222 }
L2CA_RegisterFixedChannel(uint16_t fixed_cid,tL2CAP_FIXED_CHNL_REG * p_freg)223 bool L2CA_RegisterFixedChannel(uint16_t fixed_cid,
224 tL2CAP_FIXED_CHNL_REG* p_freg) {
225 mock_function_count_map[__func__]++;
226 return test::mock::stack_l2cap_api::L2CA_RegisterFixedChannel(fixed_cid,
227 p_freg);
228 }
L2CA_ConnectFixedChnl(uint16_t fixed_cid,const RawAddress & rem_bda)229 bool L2CA_ConnectFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda) {
230 mock_function_count_map[__func__]++;
231 return test::mock::stack_l2cap_api::L2CA_ConnectFixedChnl(fixed_cid, rem_bda);
232 }
L2CA_SendFixedChnlData(uint16_t fixed_cid,const RawAddress & rem_bda,BT_HDR * p_buf)233 uint16_t L2CA_SendFixedChnlData(uint16_t fixed_cid, const RawAddress& rem_bda,
234 BT_HDR* p_buf) {
235 mock_function_count_map[__func__]++;
236 return test::mock::stack_l2cap_api::L2CA_SendFixedChnlData(fixed_cid, rem_bda,
237 p_buf);
238 }
L2CA_RemoveFixedChnl(uint16_t fixed_cid,const RawAddress & rem_bda)239 bool L2CA_RemoveFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda) {
240 mock_function_count_map[__func__]++;
241 return test::mock::stack_l2cap_api::L2CA_RemoveFixedChnl(fixed_cid, rem_bda);
242 }
L2CA_SetLeGattTimeout(const RawAddress & rem_bda,uint16_t idle_tout)243 bool L2CA_SetLeGattTimeout(const RawAddress& rem_bda, uint16_t idle_tout) {
244 mock_function_count_map[__func__]++;
245 return test::mock::stack_l2cap_api::L2CA_SetLeGattTimeout(rem_bda, idle_tout);
246 }
L2CA_DataWrite(uint16_t cid,BT_HDR * p_data)247 uint8_t L2CA_DataWrite(uint16_t cid, BT_HDR* p_data) {
248 mock_function_count_map[__func__]++;
249 return test::mock::stack_l2cap_api::L2CA_DataWrite(cid, p_data);
250 }
L2CA_LECocDataWrite(uint16_t cid,BT_HDR * p_data)251 uint8_t L2CA_LECocDataWrite(uint16_t cid, BT_HDR* p_data) {
252 mock_function_count_map[__func__]++;
253 return test::mock::stack_l2cap_api::L2CA_LECocDataWrite(cid, p_data);
254 }
L2CA_SetChnlFlushability(uint16_t cid,bool is_flushable)255 bool L2CA_SetChnlFlushability(uint16_t cid, bool is_flushable) {
256 mock_function_count_map[__func__]++;
257 return test::mock::stack_l2cap_api::L2CA_SetChnlFlushability(cid,
258 is_flushable);
259 }
L2CA_FlushChannel(uint16_t lcid,uint16_t num_to_flush)260 uint16_t L2CA_FlushChannel(uint16_t lcid, uint16_t num_to_flush) {
261 mock_function_count_map[__func__]++;
262 return test::mock::stack_l2cap_api::L2CA_FlushChannel(lcid, num_to_flush);
263 }
L2CA_IsLinkEstablished(const RawAddress & bd_addr,tBT_TRANSPORT transport)264 bool L2CA_IsLinkEstablished(const RawAddress& bd_addr,
265 tBT_TRANSPORT transport) {
266 mock_function_count_map[__func__]++;
267 return test::mock::stack_l2cap_api::L2CA_IsLinkEstablished(bd_addr,
268 transport);
269 }
270
271 // END mockcify generation
272