1 /*
2 * Copyright 2022 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 * Generated mock file from original source file
18 * Functions generated:26
19 *
20 * mockcify.pl ver 0.5.0
21 */
22
23 #include <cstdint>
24 #include <functional>
25 #include <map>
26 #include <string>
27
28 // Mock include file to share data between tests and mock
29 #include "test/mock/mock_stack_gatt_api.h"
30
31 // Original usings
32 using bluetooth::Uuid;
33
34 // Mocked internal structures, if any
35
36 namespace test {
37 namespace mock {
38 namespace stack_gatt_api {
39
40 // Function state capture and return values, if needed
41 struct GATTC_GetAndRemoveListOfConnIdsWaitingForMtuRequest
42 GATTC_GetAndRemoveListOfConnIdsWaitingForMtuRequest;
43 struct GATTC_TryMtuRequest GATTC_TryMtuRequest;
44 struct GATTC_UpdateUserAttMtuIfNeeded GATTC_UpdateUserAttMtuIfNeeded;
45 struct GATTC_ConfigureMTU GATTC_ConfigureMTU;
46 struct GATTC_Discover GATTC_Discover;
47 struct GATTC_ExecuteWrite GATTC_ExecuteWrite;
48 struct GATTC_Read GATTC_Read;
49 struct GATTC_SendHandleValueConfirm GATTC_SendHandleValueConfirm;
50 struct GATTC_Write GATTC_Write;
51 struct GATTS_AddService GATTS_AddService;
52 struct GATTS_DeleteService GATTS_DeleteService;
53 struct GATTS_HandleValueIndication GATTS_HandleValueIndication;
54 struct GATTS_HandleValueNotification GATTS_HandleValueNotification;
55 struct GATTS_NVRegister GATTS_NVRegister;
56 struct GATTS_SendRsp GATTS_SendRsp;
57 struct GATTS_StopService GATTS_StopService;
58 struct GATT_CancelConnect GATT_CancelConnect;
59 struct GATT_Connect GATT_Connect;
60 struct GATT_Deregister GATT_Deregister;
61 struct GATT_Disconnect GATT_Disconnect;
62 struct GATT_GetConnIdIfConnected GATT_GetConnIdIfConnected;
63 struct GATT_GetConnectionInfor GATT_GetConnectionInfor;
64 struct GATT_Register GATT_Register;
65 struct GATT_SetIdleTimeout GATT_SetIdleTimeout;
66 struct GATT_StartIf GATT_StartIf;
67 // struct gatt_add_an_item_to_list gatt_add_an_item_to_list;
68 struct is_active_service is_active_service;
69
70 } // namespace stack_gatt_api
71 } // namespace mock
72 } // namespace test
73
74 // Mocked function return values, if any
75 namespace test {
76 namespace mock {
77 namespace stack_gatt_api {
78
79 std::list<uint16_t>
80 GATTC_GetAndRemoveListOfConnIdsWaitingForMtuRequest::return_value =
81 std::list<uint16_t>();
82 tGATTC_TryMtuRequestResult GATTC_TryMtuRequest::return_value =
83 MTU_EXCHANGE_NOT_DONE_YET;
84 tGATT_STATUS GATTC_ConfigureMTU::return_value = GATT_SUCCESS;
85 tGATT_STATUS GATTC_Discover::return_value = GATT_SUCCESS;
86 tGATT_STATUS GATTC_ExecuteWrite::return_value = GATT_SUCCESS;
87 tGATT_STATUS GATTC_Read::return_value = GATT_SUCCESS;
88 tGATT_STATUS GATTC_SendHandleValueConfirm::return_value = GATT_SUCCESS;
89 tGATT_STATUS GATTC_Write::return_value = GATT_SUCCESS;
90 tGATT_STATUS GATTS_AddService::return_value = GATT_SUCCESS;
91 bool GATTS_DeleteService::return_value = false;
92 tGATT_STATUS GATTS_HandleValueIndication::return_value = GATT_SUCCESS;
93 tGATT_STATUS GATTS_HandleValueNotification::return_value = GATT_SUCCESS;
94 bool GATTS_NVRegister::return_value = false;
95 tGATT_STATUS GATTS_SendRsp::return_value = GATT_SUCCESS;
96 bool GATT_CancelConnect::return_value = false;
97 bool GATT_Connect::return_value = false;
98 tGATT_STATUS GATT_Disconnect::return_value = GATT_SUCCESS;
99 bool GATT_GetConnIdIfConnected::return_value = false;
100 bool GATT_GetConnectionInfor::return_value = false;
101 tGATT_IF GATT_Register::return_value = 0;
102 // tGATT_HDL_LIST_ELEM gatt_add_an_item_to_list::return_value = { .svc_db = {},
103 // .asgn_range = {}};
104 bool is_active_service::return_value = false;
105
106 } // namespace stack_gatt_api
107 } // namespace mock
108 } // namespace test
109
110 // Mocked functions, if any
GATTC_GetAndRemoveListOfConnIdsWaitingForMtuRequest(const RawAddress & remote_bda)111 std::list<uint16_t> GATTC_GetAndRemoveListOfConnIdsWaitingForMtuRequest(
112 const RawAddress& remote_bda) {
113 inc_func_call_count(__func__);
114 return test::mock::stack_gatt_api::
115 GATTC_GetAndRemoveListOfConnIdsWaitingForMtuRequest(remote_bda);
116 }
GATTC_TryMtuRequest(const RawAddress & remote_bda,tBT_TRANSPORT transport,uint16_t conn_id,uint16_t * current_mtu)117 tGATTC_TryMtuRequestResult GATTC_TryMtuRequest(const RawAddress& remote_bda,
118 tBT_TRANSPORT transport,
119 uint16_t conn_id,
120 uint16_t* current_mtu) {
121 inc_func_call_count(__func__);
122 return test::mock::stack_gatt_api::GATTC_TryMtuRequest(remote_bda, transport,
123 conn_id, current_mtu);
124 }
GATTC_UpdateUserAttMtuIfNeeded(const RawAddress & remote_bda,tBT_TRANSPORT transport,uint16_t user_mtu)125 void GATTC_UpdateUserAttMtuIfNeeded(const RawAddress& remote_bda,
126 tBT_TRANSPORT transport,
127 uint16_t user_mtu) {
128 inc_func_call_count(__func__);
129 test::mock::stack_gatt_api::GATTC_UpdateUserAttMtuIfNeeded(
130 remote_bda, transport, user_mtu);
131 }
GATTC_ConfigureMTU(uint16_t conn_id,uint16_t mtu)132 tGATT_STATUS GATTC_ConfigureMTU(uint16_t conn_id, uint16_t mtu) {
133 inc_func_call_count(__func__);
134 return test::mock::stack_gatt_api::GATTC_ConfigureMTU(conn_id, mtu);
135 }
GATTC_Discover(uint16_t conn_id,tGATT_DISC_TYPE disc_type,uint16_t start_handle,uint16_t end_handle)136 tGATT_STATUS GATTC_Discover(uint16_t conn_id, tGATT_DISC_TYPE disc_type,
137 uint16_t start_handle, uint16_t end_handle) {
138 inc_func_call_count(__func__);
139 return test::mock::stack_gatt_api::GATTC_Discover(conn_id, disc_type,
140 start_handle, end_handle);
141 }
GATTC_ExecuteWrite(uint16_t conn_id,bool is_execute)142 tGATT_STATUS GATTC_ExecuteWrite(uint16_t conn_id, bool is_execute) {
143 inc_func_call_count(__func__);
144 return test::mock::stack_gatt_api::GATTC_ExecuteWrite(conn_id, is_execute);
145 }
GATTC_Read(uint16_t conn_id,tGATT_READ_TYPE type,tGATT_READ_PARAM * p_read)146 tGATT_STATUS GATTC_Read(uint16_t conn_id, tGATT_READ_TYPE type,
147 tGATT_READ_PARAM* p_read) {
148 inc_func_call_count(__func__);
149 return test::mock::stack_gatt_api::GATTC_Read(conn_id, type, p_read);
150 }
GATTC_SendHandleValueConfirm(uint16_t conn_id,uint16_t cid)151 tGATT_STATUS GATTC_SendHandleValueConfirm(uint16_t conn_id, uint16_t cid) {
152 inc_func_call_count(__func__);
153 return test::mock::stack_gatt_api::GATTC_SendHandleValueConfirm(conn_id, cid);
154 }
GATTC_Write(uint16_t conn_id,tGATT_WRITE_TYPE type,tGATT_VALUE * p_write)155 tGATT_STATUS GATTC_Write(uint16_t conn_id, tGATT_WRITE_TYPE type,
156 tGATT_VALUE* p_write) {
157 inc_func_call_count(__func__);
158 return test::mock::stack_gatt_api::GATTC_Write(conn_id, type, p_write);
159 }
GATTS_AddService(tGATT_IF gatt_if,btgatt_db_element_t * service,int count)160 tGATT_STATUS GATTS_AddService(tGATT_IF gatt_if, btgatt_db_element_t* service,
161 int count) {
162 inc_func_call_count(__func__);
163 return test::mock::stack_gatt_api::GATTS_AddService(gatt_if, service, count);
164 }
GATTS_DeleteService(tGATT_IF gatt_if,Uuid * p_svc_uuid,uint16_t svc_inst)165 bool GATTS_DeleteService(tGATT_IF gatt_if, Uuid* p_svc_uuid,
166 uint16_t svc_inst) {
167 inc_func_call_count(__func__);
168 return test::mock::stack_gatt_api::GATTS_DeleteService(gatt_if, p_svc_uuid,
169 svc_inst);
170 }
GATTS_HandleValueIndication(uint16_t conn_id,uint16_t attr_handle,uint16_t val_len,uint8_t * p_val)171 tGATT_STATUS GATTS_HandleValueIndication(uint16_t conn_id, uint16_t attr_handle,
172 uint16_t val_len, uint8_t* p_val) {
173 inc_func_call_count(__func__);
174 return test::mock::stack_gatt_api::GATTS_HandleValueIndication(
175 conn_id, attr_handle, val_len, p_val);
176 }
GATTS_HandleValueNotification(uint16_t conn_id,uint16_t attr_handle,uint16_t val_len,uint8_t * p_val)177 tGATT_STATUS GATTS_HandleValueNotification(uint16_t conn_id,
178 uint16_t attr_handle,
179 uint16_t val_len, uint8_t* p_val) {
180 inc_func_call_count(__func__);
181 return test::mock::stack_gatt_api::GATTS_HandleValueNotification(
182 conn_id, attr_handle, val_len, p_val);
183 }
GATTS_NVRegister(tGATT_APPL_INFO * p_cb_info)184 bool GATTS_NVRegister(tGATT_APPL_INFO* p_cb_info) {
185 inc_func_call_count(__func__);
186 return test::mock::stack_gatt_api::GATTS_NVRegister(p_cb_info);
187 }
GATTS_SendRsp(uint16_t conn_id,uint32_t trans_id,tGATT_STATUS status,tGATTS_RSP * p_msg)188 tGATT_STATUS GATTS_SendRsp(uint16_t conn_id, uint32_t trans_id,
189 tGATT_STATUS status, tGATTS_RSP* p_msg) {
190 inc_func_call_count(__func__);
191 return test::mock::stack_gatt_api::GATTS_SendRsp(conn_id, trans_id, status,
192 p_msg);
193 }
GATTS_StopService(uint16_t service_handle)194 void GATTS_StopService(uint16_t service_handle) {
195 inc_func_call_count(__func__);
196 test::mock::stack_gatt_api::GATTS_StopService(service_handle);
197 }
GATT_CancelConnect(tGATT_IF gatt_if,const RawAddress & bd_addr,bool is_direct)198 bool GATT_CancelConnect(tGATT_IF gatt_if, const RawAddress& bd_addr,
199 bool is_direct) {
200 inc_func_call_count(__func__);
201 return test::mock::stack_gatt_api::GATT_CancelConnect(gatt_if, bd_addr,
202 is_direct);
203 }
GATT_Connect(tGATT_IF gatt_if,const RawAddress & bd_addr,tBLE_ADDR_TYPE addr_type,tBTM_BLE_CONN_TYPE connection_type,tBT_TRANSPORT transport,bool opportunistic,uint8_t initiating_phys)204 bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type,
205 tBTM_BLE_CONN_TYPE connection_type, tBT_TRANSPORT transport,
206 bool opportunistic, uint8_t initiating_phys) {
207 inc_func_call_count(__func__);
208 return test::mock::stack_gatt_api::GATT_Connect(
209 gatt_if, bd_addr, addr_type, connection_type, transport, opportunistic,
210 initiating_phys);
211 }
GATT_Deregister(tGATT_IF gatt_if)212 void GATT_Deregister(tGATT_IF gatt_if) {
213 inc_func_call_count(__func__);
214 test::mock::stack_gatt_api::GATT_Deregister(gatt_if);
215 }
GATT_Disconnect(uint16_t conn_id)216 tGATT_STATUS GATT_Disconnect(uint16_t conn_id) {
217 inc_func_call_count(__func__);
218 return test::mock::stack_gatt_api::GATT_Disconnect(conn_id);
219 }
GATT_GetConnIdIfConnected(tGATT_IF gatt_if,const RawAddress & bd_addr,uint16_t * p_conn_id,tBT_TRANSPORT transport)220 bool GATT_GetConnIdIfConnected(tGATT_IF gatt_if, const RawAddress& bd_addr,
221 uint16_t* p_conn_id, tBT_TRANSPORT transport) {
222 inc_func_call_count(__func__);
223 return test::mock::stack_gatt_api::GATT_GetConnIdIfConnected(
224 gatt_if, bd_addr, p_conn_id, transport);
225 }
GATT_GetConnectionInfor(uint16_t conn_id,tGATT_IF * p_gatt_if,RawAddress & bd_addr,tBT_TRANSPORT * p_transport)226 bool GATT_GetConnectionInfor(uint16_t conn_id, tGATT_IF* p_gatt_if,
227 RawAddress& bd_addr, tBT_TRANSPORT* p_transport) {
228 inc_func_call_count(__func__);
229 return test::mock::stack_gatt_api::GATT_GetConnectionInfor(
230 conn_id, p_gatt_if, bd_addr, p_transport);
231 }
GATT_Register(const Uuid & app_uuid128,const std::string & name,tGATT_CBACK * p_cb_info,bool eatt_support)232 tGATT_IF GATT_Register(const Uuid& app_uuid128, const std::string& name,
233 tGATT_CBACK* p_cb_info, bool eatt_support) {
234 inc_func_call_count(__func__);
235 return test::mock::stack_gatt_api::GATT_Register(app_uuid128, name, p_cb_info,
236 eatt_support);
237 }
GATT_SetIdleTimeout(const RawAddress & bd_addr,uint16_t idle_tout,tBT_TRANSPORT transport,bool is_active)238 void GATT_SetIdleTimeout(const RawAddress& bd_addr, uint16_t idle_tout,
239 tBT_TRANSPORT transport, bool is_active) {
240 inc_func_call_count(__func__);
241 test::mock::stack_gatt_api::GATT_SetIdleTimeout(bd_addr, idle_tout, transport,
242 is_active);
243 }
GATT_StartIf(tGATT_IF gatt_if)244 void GATT_StartIf(tGATT_IF gatt_if) {
245 inc_func_call_count(__func__);
246 test::mock::stack_gatt_api::GATT_StartIf(gatt_if);
247 }
248 // tGATT_HDL_LIST_ELEM& gatt_add_an_item_to_list(uint16_t s_handle) {
249 // inc_func_call_count(__func__);
250 // return test::mock::stack_gatt_api::gatt_add_an_item_to_list(s_handle);
251 // }
is_active_service(const Uuid & app_uuid128,Uuid * p_svc_uuid,uint16_t start_handle)252 bool is_active_service(const Uuid& app_uuid128, Uuid* p_svc_uuid,
253 uint16_t start_handle) {
254 inc_func_call_count(__func__);
255 return test::mock::stack_gatt_api::is_active_service(app_uuid128, p_svc_uuid,
256 start_handle);
257 }
258 // Mocked functions complete
259 //
GATT_Connect(tGATT_IF gatt_if,const RawAddress & bd_addr,tBTM_BLE_CONN_TYPE connection_type,tBT_TRANSPORT transport,bool opportunistic)260 bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr,
261 tBTM_BLE_CONN_TYPE connection_type, tBT_TRANSPORT transport,
262 bool opportunistic) {
263 inc_func_call_count(__func__);
264 return test::mock::stack_gatt_api::GATT_Connect(
265 gatt_if, bd_addr, 0, connection_type, transport, opportunistic, 0);
266 }
267
268 // END mockcify generation
269