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 #pragma once 17 18 /* 19 * Generated mock file from original source file 20 * Functions generated:26 21 * 22 * mockcify.pl ver 0.5.0 23 */ 24 25 #include <cstdint> 26 #include <functional> 27 #include <map> 28 #include <string> 29 30 // Original included files, if any 31 // NOTE: Since this is a mock file with mock definitions some number of 32 // include files may not be required. The include-what-you-use 33 // still applies, but crafting proper inclusion is out of scope 34 // for this effort. This compilation unit may compile as-is, or 35 // may need attention to prune from (or add to ) the inclusion set. 36 #include <base/logging.h> 37 #include <base/strings/string_number_conversions.h> 38 #include <stdio.h> 39 40 #include <string> 41 42 #include "bt_target.h" 43 #include "device/include/controller.h" 44 #include "l2c_api.h" 45 #include "main/shim/dumpsys.h" 46 #include "osi/include/allocator.h" 47 #include "osi/include/log.h" 48 #include "stack/gatt/connection_manager.h" 49 #include "stack/gatt/gatt_int.h" 50 #include "stack/include/bt_hdr.h" 51 #include "stack/include/gatt_api.h" 52 #include "test/common/mock_functions.h" 53 #include "types/bluetooth/uuid.h" 54 #include "types/bt_transport.h" 55 #include "types/raw_address.h" 56 57 // Original usings 58 using bluetooth::Uuid; 59 60 // Mocked compile conditionals, if any 61 62 namespace test { 63 namespace mock { 64 namespace stack_gatt_api { 65 66 // Shared state between mocked functions and tests 67 // Name: GATTC_GetAndRemoveListOfConnIdsWaitingForMtuRequest 68 // Params: RawAddress& remote_bda 69 // Return: std::list<uint16_t> 70 struct GATTC_GetAndRemoveListOfConnIdsWaitingForMtuRequest { 71 static std::list<uint16_t> return_value; 72 std::function<std::list<uint16_t>(const RawAddress& remote_bda)> body{ 73 [](const RawAddress& remote_bda) { return return_value; }}; operatorGATTC_GetAndRemoveListOfConnIdsWaitingForMtuRequest74 std::list<uint16_t> operator()(const RawAddress& remote_bda) { 75 return body(remote_bda); 76 }; 77 }; 78 extern struct GATTC_GetAndRemoveListOfConnIdsWaitingForMtuRequest 79 GATTC_GetAndRemoveListOfConnIdsWaitingForMtuRequest; 80 81 // Shared state between mocked functions and tests 82 // Name: GATTC_ConfigureMTU 83 // Params: RawAddress& remote_bda, tBT_TRANSPORT transport, uint16_t conn_id, 84 // uint16_t *current_mtu 85 // Return: tGATTC_TryMtuRequestResult 86 struct GATTC_TryMtuRequest { 87 static tGATTC_TryMtuRequestResult return_value; 88 std::function<tGATTC_TryMtuRequestResult( 89 const RawAddress& remote_bda, tBT_TRANSPORT transport, uint16_t conn_id, 90 uint16_t* current_mtu)> 91 body{[](const RawAddress& remote_bda, tBT_TRANSPORT transport, 92 uint16_t conn_id, 93 uint16_t* current_mtu) { return return_value; }}; operatorGATTC_TryMtuRequest94 tGATTC_TryMtuRequestResult operator()(const RawAddress& remote_bda, 95 tBT_TRANSPORT transport, 96 uint16_t conn_id, 97 uint16_t* current_mtu) { 98 return body(remote_bda, transport, conn_id, current_mtu); 99 }; 100 }; 101 extern struct GATTC_TryMtuRequest GATTC_TryMtuRequest; 102 103 // Shared state between mocked functions and tests 104 // Name: GATTC_ConfigureMTU 105 // Params: RawAddress& remote_bda, tBT_TRANSPORT transport, 106 // uint16_t user_mtu 107 // Return: void 108 struct GATTC_UpdateUserAttMtuIfNeeded { 109 std::function<void(const RawAddress& remote_bda, tBT_TRANSPORT transport, 110 uint16_t user_mtu)> 111 body{[](const RawAddress& remote_bda, tBT_TRANSPORT transport, 112 uint16_t user_mtu) {}}; operatorGATTC_UpdateUserAttMtuIfNeeded113 void operator()(const RawAddress& remote_bda, tBT_TRANSPORT transport, 114 uint16_t user_mtu) { 115 body(remote_bda, transport, user_mtu); 116 }; 117 }; 118 extern struct GATTC_UpdateUserAttMtuIfNeeded GATTC_UpdateUserAttMtuIfNeeded; 119 120 // Shared state between mocked functions and tests 121 // Name: GATTC_ConfigureMTU 122 // Params: uint16_t conn_id, uint16_t mtu 123 // Return: tGATT_STATUS 124 struct GATTC_ConfigureMTU { 125 static tGATT_STATUS return_value; 126 std::function<tGATT_STATUS(uint16_t conn_id, uint16_t mtu)> body{ 127 [](uint16_t conn_id, uint16_t mtu) { return return_value; }}; operatorGATTC_ConfigureMTU128 tGATT_STATUS operator()(uint16_t conn_id, uint16_t mtu) { 129 return body(conn_id, mtu); 130 }; 131 }; 132 extern struct GATTC_ConfigureMTU GATTC_ConfigureMTU; 133 134 // Name: GATTC_Discover 135 // Params: uint16_t conn_id, tGATT_DISC_TYPE disc_type, uint16_t start_handle, 136 // uint16_t end_handle Return: tGATT_STATUS 137 struct GATTC_Discover { 138 static tGATT_STATUS return_value; 139 std::function<tGATT_STATUS(uint16_t conn_id, tGATT_DISC_TYPE disc_type, 140 uint16_t start_handle, uint16_t end_handle)> 141 body{[](uint16_t conn_id, tGATT_DISC_TYPE disc_type, 142 uint16_t start_handle, 143 uint16_t end_handle) { return return_value; }}; operatorGATTC_Discover144 tGATT_STATUS operator()(uint16_t conn_id, tGATT_DISC_TYPE disc_type, 145 uint16_t start_handle, uint16_t end_handle) { 146 return body(conn_id, disc_type, start_handle, end_handle); 147 }; 148 }; 149 extern struct GATTC_Discover GATTC_Discover; 150 151 // Name: GATTC_ExecuteWrite 152 // Params: uint16_t conn_id, bool is_execute 153 // Return: tGATT_STATUS 154 struct GATTC_ExecuteWrite { 155 static tGATT_STATUS return_value; 156 std::function<tGATT_STATUS(uint16_t conn_id, bool is_execute)> body{ 157 [](uint16_t conn_id, bool is_execute) { return return_value; }}; operatorGATTC_ExecuteWrite158 tGATT_STATUS operator()(uint16_t conn_id, bool is_execute) { 159 return body(conn_id, is_execute); 160 }; 161 }; 162 extern struct GATTC_ExecuteWrite GATTC_ExecuteWrite; 163 164 // Name: GATTC_Read 165 // Params: uint16_t conn_id, tGATT_READ_TYPE type, tGATT_READ_PARAM* p_read 166 // Return: tGATT_STATUS 167 struct GATTC_Read { 168 static tGATT_STATUS return_value; 169 std::function<tGATT_STATUS(uint16_t conn_id, tGATT_READ_TYPE type, 170 tGATT_READ_PARAM* p_read)> 171 body{[](uint16_t conn_id, tGATT_READ_TYPE type, 172 tGATT_READ_PARAM* p_read) { return return_value; }}; operatorGATTC_Read173 tGATT_STATUS operator()(uint16_t conn_id, tGATT_READ_TYPE type, 174 tGATT_READ_PARAM* p_read) { 175 return body(conn_id, type, p_read); 176 }; 177 }; 178 extern struct GATTC_Read GATTC_Read; 179 180 // Name: GATTC_SendHandleValueConfirm 181 // Params: uint16_t conn_id, uint16_t cid 182 // Return: tGATT_STATUS 183 struct GATTC_SendHandleValueConfirm { 184 static tGATT_STATUS return_value; 185 std::function<tGATT_STATUS(uint16_t conn_id, uint16_t cid)> body{ 186 [](uint16_t conn_id, uint16_t cid) { return return_value; }}; operatorGATTC_SendHandleValueConfirm187 tGATT_STATUS operator()(uint16_t conn_id, uint16_t cid) { 188 return body(conn_id, cid); 189 }; 190 }; 191 extern struct GATTC_SendHandleValueConfirm GATTC_SendHandleValueConfirm; 192 193 // Name: GATTC_Write 194 // Params: uint16_t conn_id, tGATT_WRITE_TYPE type, tGATT_VALUE* p_write 195 // Return: tGATT_STATUS 196 struct GATTC_Write { 197 static tGATT_STATUS return_value; 198 std::function<tGATT_STATUS(uint16_t conn_id, tGATT_WRITE_TYPE type, 199 tGATT_VALUE* p_write)> 200 body{[](uint16_t conn_id, tGATT_WRITE_TYPE type, tGATT_VALUE* p_write) { 201 return return_value; 202 }}; operatorGATTC_Write203 tGATT_STATUS operator()(uint16_t conn_id, tGATT_WRITE_TYPE type, 204 tGATT_VALUE* p_write) { 205 return body(conn_id, type, p_write); 206 }; 207 }; 208 extern struct GATTC_Write GATTC_Write; 209 210 // Name: GATTS_AddService 211 // Params: tGATT_IF gatt_if, btgatt_db_element_t* service, int count 212 // Return: tGATT_STATUS 213 struct GATTS_AddService { 214 static tGATT_STATUS return_value; 215 std::function<tGATT_STATUS(tGATT_IF gatt_if, btgatt_db_element_t* service, 216 int count)> 217 body{[](tGATT_IF gatt_if, btgatt_db_element_t* service, int count) { 218 return return_value; 219 }}; operatorGATTS_AddService220 tGATT_STATUS operator()(tGATT_IF gatt_if, btgatt_db_element_t* service, 221 int count) { 222 return body(gatt_if, service, count); 223 }; 224 }; 225 extern struct GATTS_AddService GATTS_AddService; 226 227 // Name: GATTS_DeleteService 228 // Params: tGATT_IF gatt_if, Uuid* p_svc_uuid, uint16_t svc_inst 229 // Return: bool 230 struct GATTS_DeleteService { 231 static bool return_value; 232 std::function<bool(tGATT_IF gatt_if, Uuid* p_svc_uuid, uint16_t svc_inst)> 233 body{[](tGATT_IF gatt_if, Uuid* p_svc_uuid, uint16_t svc_inst) { 234 return return_value; 235 }}; operatorGATTS_DeleteService236 bool operator()(tGATT_IF gatt_if, Uuid* p_svc_uuid, uint16_t svc_inst) { 237 return body(gatt_if, p_svc_uuid, svc_inst); 238 }; 239 }; 240 extern struct GATTS_DeleteService GATTS_DeleteService; 241 242 // Name: GATTS_HandleValueIndication 243 // Params: uint16_t conn_id, uint16_t attr_handle, uint16_t val_len, uint8_t* 244 // p_val Return: tGATT_STATUS 245 struct GATTS_HandleValueIndication { 246 static tGATT_STATUS return_value; 247 std::function<tGATT_STATUS(uint16_t conn_id, uint16_t attr_handle, 248 uint16_t val_len, uint8_t* p_val)> 249 body{[](uint16_t conn_id, uint16_t attr_handle, uint16_t val_len, 250 uint8_t* p_val) { return return_value; }}; operatorGATTS_HandleValueIndication251 tGATT_STATUS operator()(uint16_t conn_id, uint16_t attr_handle, 252 uint16_t val_len, uint8_t* p_val) { 253 return body(conn_id, attr_handle, val_len, p_val); 254 }; 255 }; 256 extern struct GATTS_HandleValueIndication GATTS_HandleValueIndication; 257 258 // Name: GATTS_HandleValueNotification 259 // Params: uint16_t conn_id, uint16_t attr_handle, uint16_t val_len, uint8_t* 260 // p_val Return: tGATT_STATUS 261 struct GATTS_HandleValueNotification { 262 static tGATT_STATUS return_value; 263 std::function<tGATT_STATUS(uint16_t conn_id, uint16_t attr_handle, 264 uint16_t val_len, uint8_t* p_val)> 265 body{[](uint16_t conn_id, uint16_t attr_handle, uint16_t val_len, 266 uint8_t* p_val) { return return_value; }}; operatorGATTS_HandleValueNotification267 tGATT_STATUS operator()(uint16_t conn_id, uint16_t attr_handle, 268 uint16_t val_len, uint8_t* p_val) { 269 return body(conn_id, attr_handle, val_len, p_val); 270 }; 271 }; 272 extern struct GATTS_HandleValueNotification GATTS_HandleValueNotification; 273 274 // Name: GATTS_NVRegister 275 // Params: tGATT_APPL_INFO* p_cb_info 276 // Return: bool 277 struct GATTS_NVRegister { 278 static bool return_value; 279 std::function<bool(tGATT_APPL_INFO* p_cb_info)> body{ 280 [](tGATT_APPL_INFO* p_cb_info) { return return_value; }}; operatorGATTS_NVRegister281 bool operator()(tGATT_APPL_INFO* p_cb_info) { return body(p_cb_info); }; 282 }; 283 extern struct GATTS_NVRegister GATTS_NVRegister; 284 285 // Name: GATTS_SendRsp 286 // Params: uint16_t conn_id, uint32_t trans_id, tGATT_STATUS status, tGATTS_RSP* 287 // p_msg Return: tGATT_STATUS 288 struct GATTS_SendRsp { 289 static tGATT_STATUS return_value; 290 std::function<tGATT_STATUS(uint16_t conn_id, uint32_t trans_id, 291 tGATT_STATUS status, tGATTS_RSP* p_msg)> 292 body{[](uint16_t conn_id, uint32_t trans_id, tGATT_STATUS status, 293 tGATTS_RSP* p_msg) { return return_value; }}; operatorGATTS_SendRsp294 tGATT_STATUS operator()(uint16_t conn_id, uint32_t trans_id, 295 tGATT_STATUS status, tGATTS_RSP* p_msg) { 296 return body(conn_id, trans_id, status, p_msg); 297 }; 298 }; 299 extern struct GATTS_SendRsp GATTS_SendRsp; 300 301 // Name: GATTS_StopService 302 // Params: uint16_t service_handle 303 // Return: void 304 struct GATTS_StopService { 305 std::function<void(uint16_t service_handle)> body{ 306 [](uint16_t service_handle) {}}; operatorGATTS_StopService307 void operator()(uint16_t service_handle) { body(service_handle); }; 308 }; 309 extern struct GATTS_StopService GATTS_StopService; 310 311 // Name: GATT_CancelConnect 312 // Params: tGATT_IF gatt_if, const RawAddress& bd_addr, bool is_direct 313 // Return: bool 314 struct GATT_CancelConnect { 315 static bool return_value; 316 std::function<bool(tGATT_IF gatt_if, const RawAddress& bd_addr, 317 bool is_direct)> 318 body{[](tGATT_IF gatt_if, const RawAddress& bd_addr, bool is_direct) { 319 return return_value; 320 }}; operatorGATT_CancelConnect321 bool operator()(tGATT_IF gatt_if, const RawAddress& bd_addr, bool is_direct) { 322 return body(gatt_if, bd_addr, is_direct); 323 }; 324 }; 325 extern struct GATT_CancelConnect GATT_CancelConnect; 326 327 // Name: GATT_Connect 328 // Params: tGATT_IF gatt_if, const RawAddress& bd_addr, bool is_direct, 329 // tBT_TRANSPORT transport, bool opportunistic, uint8_t initiating_phys Return: 330 // bool 331 struct GATT_Connect { 332 static bool return_value; 333 std::function<bool(tGATT_IF gatt_if, const RawAddress& bd_addr, 334 tBLE_ADDR_TYPE addr_type, bool is_direct, 335 tBT_TRANSPORT transport, bool opportunistic, 336 uint8_t initiating_phys)> 337 body{[](tGATT_IF gatt_if, const RawAddress& bd_addr, 338 tBLE_ADDR_TYPE addr_type, bool is_direct, tBT_TRANSPORT transport, 339 bool opportunistic, 340 uint8_t initiating_phys) { return return_value; }}; operatorGATT_Connect341 bool operator()(tGATT_IF gatt_if, const RawAddress& bd_addr, 342 tBLE_ADDR_TYPE addr_type, bool is_direct, 343 tBT_TRANSPORT transport, bool opportunistic, 344 uint8_t initiating_phys) { 345 return body(gatt_if, bd_addr, addr_type, is_direct, transport, 346 opportunistic, initiating_phys); 347 }; 348 }; 349 extern struct GATT_Connect GATT_Connect; 350 351 // Name: GATT_Deregister 352 // Params: tGATT_IF gatt_if 353 // Return: void 354 struct GATT_Deregister { 355 std::function<void(tGATT_IF gatt_if)> body{[](tGATT_IF gatt_if) {}}; operatorGATT_Deregister356 void operator()(tGATT_IF gatt_if) { body(gatt_if); }; 357 }; 358 extern struct GATT_Deregister GATT_Deregister; 359 360 // Name: GATT_Disconnect 361 // Params: uint16_t conn_id 362 // Return: tGATT_STATUS 363 struct GATT_Disconnect { 364 static tGATT_STATUS return_value; 365 std::function<tGATT_STATUS(uint16_t conn_id)> body{ 366 [](uint16_t conn_id) { return return_value; }}; operatorGATT_Disconnect367 tGATT_STATUS operator()(uint16_t conn_id) { return body(conn_id); }; 368 }; 369 extern struct GATT_Disconnect GATT_Disconnect; 370 371 // Name: GATT_GetConnIdIfConnected 372 // Params: tGATT_IF gatt_if, const RawAddress& bd_addr, uint16_t* p_conn_id, 373 // tBT_TRANSPORT transport Return: bool 374 struct GATT_GetConnIdIfConnected { 375 static bool return_value; 376 std::function<bool(tGATT_IF gatt_if, const RawAddress& bd_addr, 377 uint16_t* p_conn_id, tBT_TRANSPORT transport)> 378 body{[](tGATT_IF gatt_if, const RawAddress& bd_addr, uint16_t* p_conn_id, 379 tBT_TRANSPORT transport) { return return_value; }}; operatorGATT_GetConnIdIfConnected380 bool operator()(tGATT_IF gatt_if, const RawAddress& bd_addr, 381 uint16_t* p_conn_id, tBT_TRANSPORT transport) { 382 return body(gatt_if, bd_addr, p_conn_id, transport); 383 }; 384 }; 385 extern struct GATT_GetConnIdIfConnected GATT_GetConnIdIfConnected; 386 387 // Name: GATT_GetConnectionInfor 388 // Params: uint16_t conn_id, tGATT_IF* p_gatt_if, RawAddress& bd_addr, 389 // tBT_TRANSPORT* p_transport Return: bool 390 struct GATT_GetConnectionInfor { 391 static bool return_value; 392 std::function<bool(uint16_t conn_id, tGATT_IF* p_gatt_if, RawAddress& bd_addr, 393 tBT_TRANSPORT* p_transport)> 394 body{[](uint16_t conn_id, tGATT_IF* p_gatt_if, RawAddress& bd_addr, 395 tBT_TRANSPORT* p_transport) { return return_value; }}; operatorGATT_GetConnectionInfor396 bool operator()(uint16_t conn_id, tGATT_IF* p_gatt_if, RawAddress& bd_addr, 397 tBT_TRANSPORT* p_transport) { 398 return body(conn_id, p_gatt_if, bd_addr, p_transport); 399 }; 400 }; 401 extern struct GATT_GetConnectionInfor GATT_GetConnectionInfor; 402 403 // Name: GATT_Register 404 // Params: const Uuid& app_uuid128, std::string name, tGATT_CBACK* p_cb_info, 405 // bool eatt_support Return: tGATT_IF 406 struct GATT_Register { 407 static tGATT_IF return_value; 408 std::function<tGATT_IF(const Uuid& app_uuid128, const std::string& name, 409 tGATT_CBACK* p_cb_info, bool eatt_support)> 410 body{[](const Uuid& app_uuid128, const std::string& name, 411 tGATT_CBACK* p_cb_info, 412 bool eatt_support) { return return_value; }}; operatorGATT_Register413 tGATT_IF operator()(const Uuid& app_uuid128, const std::string& name, 414 tGATT_CBACK* p_cb_info, bool eatt_support) { 415 return body(app_uuid128, name, p_cb_info, eatt_support); 416 }; 417 }; 418 extern struct GATT_Register GATT_Register; 419 420 // Name: GATT_SetIdleTimeout 421 // Params: const RawAddress& bd_addr, uint16_t idle_tout, tBT_TRANSPORT 422 // transport Return: void 423 struct GATT_SetIdleTimeout { 424 std::function<void(const RawAddress& bd_addr, uint16_t idle_tout, 425 tBT_TRANSPORT transport, bool is_active)> 426 body{[](const RawAddress& bd_addr, uint16_t idle_tout, 427 tBT_TRANSPORT transport, bool is_active) {}}; operatorGATT_SetIdleTimeout428 void operator()(const RawAddress& bd_addr, uint16_t idle_tout, 429 tBT_TRANSPORT transport, bool is_active) { 430 body(bd_addr, idle_tout, transport, is_active); 431 }; 432 }; 433 extern struct GATT_SetIdleTimeout GATT_SetIdleTimeout; 434 435 // Name: GATT_StartIf 436 // Params: tGATT_IF gatt_if 437 // Return: void 438 struct GATT_StartIf { 439 std::function<void(tGATT_IF gatt_if)> body{[](tGATT_IF gatt_if) {}}; operatorGATT_StartIf440 void operator()(tGATT_IF gatt_if) { body(gatt_if); }; 441 }; 442 extern struct GATT_StartIf GATT_StartIf; 443 444 // // Name: gatt_add_an_item_to_list 445 // // Params: uint16_t s_handle 446 // // Return: tGATT_HDL_LIST_ELEM& 447 // struct gatt_add_an_item_to_list { 448 // static tGATT_HDL_LIST_ELEM return_value; 449 // std::function<tGATT_HDL_LIST_ELEM&(uint16_t s_handle)> body{ 450 // [](uint16_t s_handle) { return return_value; }}; 451 // tGATT_HDL_LIST_ELEM& operator()(uint16_t s_handle) { return body(s_handle); 452 // }; 453 // }; 454 // extern struct gatt_add_an_item_to_list gatt_add_an_item_to_list; 455 456 // Name: is_active_service 457 // Params: const Uuid& app_uuid128, Uuid* p_svc_uuid, uint16_t start_handle 458 // Return: bool 459 struct is_active_service { 460 static bool return_value; 461 std::function<bool(const Uuid& app_uuid128, Uuid* p_svc_uuid, 462 uint16_t start_handle)> 463 body{[](const Uuid& app_uuid128, Uuid* p_svc_uuid, 464 uint16_t start_handle) { return return_value; }}; operatoris_active_service465 bool operator()(const Uuid& app_uuid128, Uuid* p_svc_uuid, 466 uint16_t start_handle) { 467 return body(app_uuid128, p_svc_uuid, start_handle); 468 }; 469 }; 470 extern struct is_active_service is_active_service; 471 472 } // namespace stack_gatt_api 473 } // namespace mock 474 } // namespace test 475 476 // END mockcify generation 477