From 8c476e67f9663e72f843d831532b65e932b55d2a Mon Sep 17 00:00:00 2001 From: Chris Manton Date: Sat, 28 Nov 2020 16:01:10 -0800 Subject: [PATCH] Add various stack/test/common/mock_ Surface area endpoints for btm modules. Mostly generated from corresponding source. Bug: 174401903 Tag: #refactor Test: gd/cert/run --host Change-Id: I322a51d29cc750f8a61c91f620a4dd544b3773ff --- stack/test/common/mock_bta_dm_act.cc | 114 ++++++ stack/test/common/mock_bta_sys_conn.cc | 96 +++++ stack/test/common/mock_btif_dm.cc | 156 ++++++++ stack/test/common/mock_btif_storage.cc | 2 + stack/test/common/mock_btu_hcif.cc | 81 ++++ stack/test/common/mock_gap_gap_ble.cc | 50 +++ stack/test/common/mock_gatt_connection_manager.cc | 59 +++ stack/test/common/mock_gatt_gatt_auth.cc | 66 ++++ stack/test/common/mock_gatt_main.cc | 112 ++++++ stack/test/common/mock_hci_packet_parser.cc | 41 ++ stack/test/common/mock_hcic_hciblecmds.cc | 323 ++++++++++++++++ stack/test/common/mock_hcic_hcicmds.cc | 295 ++++++++++++++ stack/test/common/mock_l2cap_l2c_api.cc | 178 +++++++++ stack/test/common/mock_l2cap_l2c_ble.cc | 156 ++++++++ stack/test/common/mock_l2cap_l2c_link.cc | 96 +++++ stack/test/common/mock_l2cap_l2c_main.cc | 60 +++ stack/test/common/mock_l2cap_l2c_utils.cc | 283 ++++++++++++++ stack/test/common/mock_main_bte_main.cc | 48 +++ stack/test/common/mock_main_shim.cc | 84 ++++ stack/test/common/mock_main_shim_acl_api.cc | 54 +++ stack/test/common/mock_main_shim_btm_api.cc | 447 ++++++++++++++++++++++ stack/test/common/mock_main_shim_controller.cc | 36 ++ stack/test/common/mock_main_shim_l2c_api.cc | 213 +++++++++++ stack/test/common/mock_smp_smp_act.cc | 252 ++++++++++++ stack/test/common/mock_smp_smp_api.cc | 81 ++++ 25 files changed, 3383 insertions(+) create mode 100644 stack/test/common/mock_bta_dm_act.cc create mode 100644 stack/test/common/mock_bta_sys_conn.cc create mode 100644 stack/test/common/mock_btif_dm.cc create mode 100644 stack/test/common/mock_btu_hcif.cc create mode 100644 stack/test/common/mock_gap_gap_ble.cc create mode 100644 stack/test/common/mock_gatt_connection_manager.cc create mode 100644 stack/test/common/mock_gatt_gatt_auth.cc create mode 100644 stack/test/common/mock_gatt_main.cc create mode 100644 stack/test/common/mock_hci_packet_parser.cc create mode 100644 stack/test/common/mock_hcic_hciblecmds.cc create mode 100644 stack/test/common/mock_hcic_hcicmds.cc create mode 100644 stack/test/common/mock_l2cap_l2c_api.cc create mode 100644 stack/test/common/mock_l2cap_l2c_ble.cc create mode 100644 stack/test/common/mock_l2cap_l2c_link.cc create mode 100644 stack/test/common/mock_l2cap_l2c_main.cc create mode 100644 stack/test/common/mock_l2cap_l2c_utils.cc create mode 100644 stack/test/common/mock_main_bte_main.cc create mode 100644 stack/test/common/mock_main_shim.cc create mode 100644 stack/test/common/mock_main_shim_acl_api.cc create mode 100644 stack/test/common/mock_main_shim_btm_api.cc create mode 100644 stack/test/common/mock_main_shim_controller.cc create mode 100644 stack/test/common/mock_main_shim_l2c_api.cc create mode 100644 stack/test/common/mock_smp_smp_act.cc create mode 100644 stack/test/common/mock_smp_smp_api.cc diff --git a/stack/test/common/mock_bta_dm_act.cc b/stack/test/common/mock_bta_dm_act.cc new file mode 100644 index 000000000..ee281a428 --- /dev/null +++ b/stack/test/common/mock_bta_dm_act.cc @@ -0,0 +1,114 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:53 + */ + +#include +#include + +extern std::map mock_function_count_map; + +#include "bta/dm/bta_dm_int.h" +#include "types/raw_address.h" + +#ifndef UNUSED_ATTR +#define UNUSED_ATTR +#endif + +void BTA_dm_acl_down(const RawAddress bd_addr, tBT_TRANSPORT transport) { + mock_function_count_map[__func__]++; +} +void BTA_dm_acl_up(const RawAddress bd_addr, tBT_TRANSPORT transport) { + mock_function_count_map[__func__]++; +} +void BTA_dm_on_hw_off() { mock_function_count_map[__func__]++; } +void BTA_dm_on_hw_on() { mock_function_count_map[__func__]++; } +void BTA_dm_report_role_change(const RawAddress bd_addr, uint8_t new_role, + uint8_t hci_status) { + mock_function_count_map[__func__]++; +} +void bta_dm_add_device(std::unique_ptr msg) { + mock_function_count_map[__func__]++; +} +void bta_dm_bond(const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type, + tBT_TRANSPORT transport, int device_type) { + mock_function_count_map[__func__]++; +} +void bta_dm_bond_cancel(const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; +} +void bta_dm_ci_rmt_oob_act(std::unique_ptr msg) { + mock_function_count_map[__func__]++; +} +void bta_dm_close_acl(const RawAddress& bd_addr, bool remove_dev, + tBT_TRANSPORT transport) { + mock_function_count_map[__func__]++; +} +void bta_dm_confirm(const RawAddress& bd_addr, bool accept) { + mock_function_count_map[__func__]++; +} +void bta_dm_deinit_cb(void) { mock_function_count_map[__func__]++; } +void bta_dm_disable() { mock_function_count_map[__func__]++; } +void bta_dm_disc_result(tBTA_DM_MSG* p_data) { + mock_function_count_map[__func__]++; +} +void bta_dm_disc_rmt_name(tBTA_DM_MSG* p_data) { + mock_function_count_map[__func__]++; +} +void bta_dm_discover(tBTA_DM_MSG* p_data) { + mock_function_count_map[__func__]++; +} +void bta_dm_free_sdp_db() { mock_function_count_map[__func__]++; } +void bta_dm_init_cb(void) { mock_function_count_map[__func__]++; } +void bta_dm_inq_cmpl(uint8_t num) { mock_function_count_map[__func__]++; } +void bta_dm_pin_reply(std::unique_ptr msg) { + mock_function_count_map[__func__]++; +} +void bta_dm_process_remove_device(const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; +} +void bta_dm_queue_disc(tBTA_DM_MSG* p_data) { + mock_function_count_map[__func__]++; +} +void bta_dm_queue_search(tBTA_DM_MSG* p_data) { + mock_function_count_map[__func__]++; +} +void bta_dm_remove_device(const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; +} +void bta_dm_rmt_name(tBTA_DM_MSG* p_data) { + mock_function_count_map[__func__]++; +} +void bta_dm_sdp_result(tBTA_DM_MSG* p_data) { + mock_function_count_map[__func__]++; +} +void bta_dm_search_cancel() { mock_function_count_map[__func__]++; } +void bta_dm_search_cancel_cmpl() { mock_function_count_map[__func__]++; } +void bta_dm_search_cancel_notify() { mock_function_count_map[__func__]++; } +void bta_dm_search_clear_queue() { mock_function_count_map[__func__]++; } +void bta_dm_search_cmpl() { mock_function_count_map[__func__]++; } +void bta_dm_search_result(tBTA_DM_MSG* p_data) { + mock_function_count_map[__func__]++; +} +void bta_dm_search_start(tBTA_DM_MSG* p_data) { + mock_function_count_map[__func__]++; +} +void bta_dm_set_dev_name(const std::vector& name) { + mock_function_count_map[__func__]++; +} diff --git a/stack/test/common/mock_bta_sys_conn.cc b/stack/test/common/mock_bta_sys_conn.cc new file mode 100644 index 000000000..669d67bc6 --- /dev/null +++ b/stack/test/common/mock_bta_sys_conn.cc @@ -0,0 +1,96 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:17 + */ + +#include +#include + +extern std::map mock_function_count_map; + +#include +#include "bt_common.h" +#include "bta/include/bta_api.h" +#include "bta/include/utl.h" +#include "bta/sys/bta_sys.h" +#include "bta/sys/bta_sys_int.h" +#include "osi/include/osi.h" + +#ifndef UNUSED_ATTR +#define UNUSED_ATTR +#endif + +void bta_sys_app_close(uint8_t id, uint8_t app_id, + const RawAddress& peer_addr) { + mock_function_count_map[__func__]++; +} +void bta_sys_app_open(uint8_t id, uint8_t app_id, const RawAddress& peer_addr) { + mock_function_count_map[__func__]++; +} +void bta_sys_busy(uint8_t id, uint8_t app_id, const RawAddress& peer_addr) { + mock_function_count_map[__func__]++; +} +void bta_sys_collision_register(uint8_t bta_id, tBTA_SYS_CONN_CBACK* p_cback) { + mock_function_count_map[__func__]++; +} +void bta_sys_conn_close(uint8_t id, uint8_t app_id, + const RawAddress& peer_addr) { + mock_function_count_map[__func__]++; +} +void bta_sys_conn_open(uint8_t id, uint8_t app_id, + const RawAddress& peer_addr) { + mock_function_count_map[__func__]++; +} +void bta_sys_idle(uint8_t id, uint8_t app_id, const RawAddress& peer_addr) { + mock_function_count_map[__func__]++; +} +void bta_sys_notify_collision(const RawAddress& peer_addr) { + mock_function_count_map[__func__]++; +} +void bta_sys_notify_role_chg(const RawAddress& peer_addr, uint8_t new_role, + uint8_t hci_status) { + mock_function_count_map[__func__]++; +} +void bta_sys_pm_register(tBTA_SYS_CONN_CBACK* p_cback) { + mock_function_count_map[__func__]++; +} +void bta_sys_rm_register(tBTA_SYS_CONN_CBACK* p_cback) { + mock_function_count_map[__func__]++; +} +void bta_sys_role_chg_register(tBTA_SYS_CONN_CBACK* p_cback) { + mock_function_count_map[__func__]++; +} +void bta_sys_sco_close(uint8_t id, uint8_t app_id, + const RawAddress& peer_addr) { + mock_function_count_map[__func__]++; +} +void bta_sys_sco_open(uint8_t id, uint8_t app_id, const RawAddress& peer_addr) { + mock_function_count_map[__func__]++; +} +void bta_sys_sco_register(tBTA_SYS_CONN_CBACK* p_cback) { + mock_function_count_map[__func__]++; +} +void bta_sys_sco_unuse(uint8_t id, uint8_t app_id, + const RawAddress& peer_addr) { + mock_function_count_map[__func__]++; +} +void bta_sys_sco_use(UNUSED_ATTR uint8_t id, uint8_t app_id, + const RawAddress& peer_addr) { + mock_function_count_map[__func__]++; +} diff --git a/stack/test/common/mock_btif_dm.cc b/stack/test/common/mock_btif_dm.cc new file mode 100644 index 000000000..c61cb2a79 --- /dev/null +++ b/stack/test/common/mock_btif_dm.cc @@ -0,0 +1,156 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:51 + */ + +#include +#include + +extern std::map mock_function_count_map; + +#include +#include "bta/include/bta_api.h" +#include "include/hardware/bluetooth.h" +#include "types/raw_address.h" + +struct uid_set_t; + +#ifndef UNUSED_ATTR +#define UNUSED_ATTR +#endif + +bool btif_dm_pairing_is_busy() { + mock_function_count_map[__func__]++; + return false; +} +bool check_cod(const RawAddress* remote_bdaddr, uint32_t cod) { + mock_function_count_map[__func__]++; + return false; +} +bool check_cod_hid(const RawAddress* remote_bdaddr) { + mock_function_count_map[__func__]++; + return false; +} +bool check_sdp_bl(const RawAddress* remote_bdaddr) { + mock_function_count_map[__func__]++; + return false; +} +bt_status_t btif_dm_get_adapter_property(bt_property_t* prop) { + mock_function_count_map[__func__]++; + return BT_STATUS_SUCCESS; +} +bt_status_t btif_in_execute_service_request(tBTA_SERVICE_ID service_id, + bool b_enable) { + mock_function_count_map[__func__]++; + return BT_STATUS_SUCCESS; +} +uint16_t btif_dm_get_connection_state(const RawAddress* bd_addr) { + mock_function_count_map[__func__]++; + return 0; +} +void BTIF_dm_disable() { mock_function_count_map[__func__]++; } +void BTIF_dm_enable() { mock_function_count_map[__func__]++; } +void BTIF_dm_on_hw_error() { mock_function_count_map[__func__]++; } +void BTIF_dm_report_inquiry_status_change(uint8_t status) { + mock_function_count_map[__func__]++; +} +void bte_dm_evt(tBTA_DM_SEC_EVT event, tBTA_DM_SEC* p_data) { + mock_function_count_map[__func__]++; +} +void btif_ble_receiver_test(uint8_t rx_freq) { + mock_function_count_map[__func__]++; +} +void btif_ble_test_end() { mock_function_count_map[__func__]++; } +void btif_ble_transmitter_test(uint8_t tx_freq, uint8_t test_data_len, + uint8_t packet_payload) { + mock_function_count_map[__func__]++; +} +void btif_debug_bond_event_dump(int fd) { mock_function_count_map[__func__]++; } +void btif_dm_ble_sec_req_evt(tBTA_DM_BLE_SEC_REQ* p_ble_req, bool is_consent) { + mock_function_count_map[__func__]++; +} +void btif_dm_cancel_bond(const RawAddress bd_addr) { + mock_function_count_map[__func__]++; +} +void btif_dm_cancel_discovery(void) { mock_function_count_map[__func__]++; } +void btif_dm_cleanup(void) { mock_function_count_map[__func__]++; } +void btif_dm_create_bond(const RawAddress bd_addr, int transport) { + mock_function_count_map[__func__]++; +} +void btif_dm_create_bond_out_of_band(const RawAddress bd_addr, int transport, + const bt_out_of_band_data_t oob_data) { + mock_function_count_map[__func__]++; +} +void btif_dm_enable_service(tBTA_SERVICE_ID service_id, bool enable) { + mock_function_count_map[__func__]++; +} +void btif_dm_get_ble_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK* p_key_mask, + Octet16* p_er, + tBTA_BLE_LOCAL_ID_KEYS* p_id_keys) { + mock_function_count_map[__func__]++; +} +void btif_dm_get_remote_services(RawAddress remote_addr, const int transport) { + mock_function_count_map[__func__]++; +} +void btif_dm_hh_open_failed(RawAddress* bdaddr) { + mock_function_count_map[__func__]++; +} +void btif_dm_init(uid_set_t* set) { mock_function_count_map[__func__]++; } +void btif_dm_load_ble_local_keys(void) { mock_function_count_map[__func__]++; } +void btif_dm_on_disable() { mock_function_count_map[__func__]++; } +void btif_dm_pin_reply(const RawAddress bd_addr, uint8_t accept, + uint8_t pin_len, bt_pin_code_t pin_code) { + mock_function_count_map[__func__]++; +} +void btif_dm_proc_io_req(tBTM_AUTH_REQ* p_auth_req, bool is_orig) { + mock_function_count_map[__func__]++; +} +void btif_dm_proc_io_rsp(UNUSED_ATTR const RawAddress& bd_addr, + tBTM_IO_CAP io_cap, UNUSED_ATTR tBTM_OOB_DATA oob_data, + tBTM_AUTH_REQ auth_req) { + mock_function_count_map[__func__]++; +} +void btif_dm_read_energy_info() { mock_function_count_map[__func__]++; } +void btif_dm_remove_ble_bonding_keys(void) { + mock_function_count_map[__func__]++; +} +void btif_dm_remove_bond(const RawAddress bd_addr) { + mock_function_count_map[__func__]++; +} +void btif_dm_save_ble_bonding_keys(RawAddress& bd_addr) { + mock_function_count_map[__func__]++; +} +void btif_dm_set_oob_for_io_req(tBTM_OOB_DATA* p_has_oob_data) { + mock_function_count_map[__func__]++; +} +void btif_dm_set_oob_for_le_io_req(const RawAddress& bd_addr, + tBTM_OOB_DATA* p_has_oob_data, + tBTM_LE_AUTH_REQ* p_auth_req) { + mock_function_count_map[__func__]++; +} +void btif_dm_ssp_reply(const RawAddress bd_addr, bt_ssp_variant_t variant, + uint8_t accept) { + mock_function_count_map[__func__]++; +} +void btif_dm_start_discovery(void) { mock_function_count_map[__func__]++; } +void btif_dm_update_ble_remote_properties(const RawAddress& bd_addr, + BD_NAME bd_name, + tBT_DEVICE_TYPE dev_type) { + mock_function_count_map[__func__]++; +} diff --git a/stack/test/common/mock_btif_storage.cc b/stack/test/common/mock_btif_storage.cc index d246ba382..b65d89ac2 100644 --- a/stack/test/common/mock_btif_storage.cc +++ b/stack/test/common/mock_btif_storage.cc @@ -29,3 +29,5 @@ void bluetooth::manager::SetMockBtifStorageInterface( void btif_storage_load_bonded_eatt(void) { btif_storage_interface->LoadBondedEatt(); } + +uint8_t btif_storage_get_local_io_caps() { return 0; } diff --git a/stack/test/common/mock_btu_hcif.cc b/stack/test/common/mock_btu_hcif.cc new file mode 100644 index 000000000..cf7b2b63f --- /dev/null +++ b/stack/test/common/mock_btu_hcif.cc @@ -0,0 +1,81 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:9 + */ + +#include +#include + +extern std::map mock_function_count_map; + +#define LOG_TAG "bt_btu_hcif" +#include +#include +#include +#include "btif/include/btif_config.h" +#include "common/metrics.h" +#include "device/include/controller.h" +#include "osi/include/log.h" +#include "stack/btm/btm_int.h" +#include "stack/include/acl_hci_link_interface.h" +#include "stack/include/ble_acl_interface.h" +#include "stack/include/ble_hci_link_interface.h" +#include "stack/include/btm_iso_api.h" +#include "stack/include/btu.h" +#include "stack/include/dev_hci_link_interface.h" +#include "stack/include/gatt_api.h" +#include "stack/include/hci_evt_length.h" +#include "stack/include/hcidefs.h" +#include "stack/include/inq_hci_link_interface.h" +#include "stack/include/l2cap_hci_link_interface.h" +#include "stack/include/sco_hci_link_interface.h" +#include "stack/include/sec_hci_link_interface.h" + +#ifndef UNUSED_ATTR +#define UNUSED_ATTR +#endif + +using hci_cmd_cb = base::OnceCallback; + +struct cmd_with_cb_data { + hci_cmd_cb cb; + base::Location posted_from; +}; + +void btu_hcif_log_event_metrics(uint8_t evt_code, uint8_t* p_event) { + mock_function_count_map[__func__]++; +} +void btu_hcif_process_event(UNUSED_ATTR uint8_t controller_id, BT_HDR* p_msg) { + mock_function_count_map[__func__]++; +} +void btu_hcif_send_cmd(UNUSED_ATTR uint8_t controller_id, BT_HDR* p_buf) { + mock_function_count_map[__func__]++; +} +void btu_hcif_send_cmd_with_cb(const base::Location& posted_from, + uint16_t opcode, uint8_t* params, + uint8_t params_len, hci_cmd_cb cb) { + mock_function_count_map[__func__]++; +} +void cmd_with_cb_data_cleanup(cmd_with_cb_data* cb_wrapper) { + mock_function_count_map[__func__]++; +} +void cmd_with_cb_data_init(cmd_with_cb_data* cb_wrapper) { + mock_function_count_map[__func__]++; +} diff --git a/stack/test/common/mock_gap_gap_ble.cc b/stack/test/common/mock_gap_gap_ble.cc new file mode 100644 index 000000000..4c48167c5 --- /dev/null +++ b/stack/test/common/mock_gap_gap_ble.cc @@ -0,0 +1,50 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:6 + */ + +#include +#include + +extern std::map mock_function_count_map; + +#include "stack/include/gap_api.h" +#include "types/raw_address.h" + +#ifndef UNUSED_ATTR +#define UNUSED_ATTR +#endif + +bool GAP_BleCancelReadPeerDevName(const RawAddress& peer_bda) { + mock_function_count_map[__func__]++; + return false; +} +bool GAP_BleReadPeerDevName(const RawAddress& peer_bda, + tGAP_BLE_CMPL_CBACK* p_cback) { + mock_function_count_map[__func__]++; + return false; +} +bool GAP_BleReadPeerPrefConnParams(const RawAddress& peer_bda) { + mock_function_count_map[__func__]++; + return false; +} +void GAP_BleAttrDBUpdate(uint16_t attr_uuid, tGAP_BLE_ATTR_VALUE* p_value) { + mock_function_count_map[__func__]++; +} +void gap_attr_db_init(void) { mock_function_count_map[__func__]++; } diff --git a/stack/test/common/mock_gatt_connection_manager.cc b/stack/test/common/mock_gatt_connection_manager.cc new file mode 100644 index 000000000..9ce6b8584 --- /dev/null +++ b/stack/test/common/mock_gatt_connection_manager.cc @@ -0,0 +1,59 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:4 + */ + +#include +#include + +extern std::map mock_function_count_map; + +#include +#include +#include +#include +#include +#include +#include +#include "internal_include/bt_trace.h" +#include "main/shim/shim.h" +#include "osi/include/alarm.h" +#include "osi/include/log.h" +#include "stack/btm/btm_ble_bgconn.h" +#include "stack/gatt/connection_manager.h" +#include "stack/include/l2c_api.h" + +#ifndef UNUSED_ATTR +#define UNUSED_ATTR +#endif + +bool connection_manager::direct_connect_add(uint8_t app_id, + const RawAddress& address) { + mock_function_count_map[__func__]++; + return false; +} +bool connection_manager::direct_connect_remove(uint8_t app_id, + const RawAddress& address) { + mock_function_count_map[__func__]++; + return false; +} +void connection_manager::on_connection_complete(const RawAddress& address) { + mock_function_count_map[__func__]++; +} +void connection_manager::reset(bool) { mock_function_count_map[__func__]++; } diff --git a/stack/test/common/mock_gatt_gatt_auth.cc b/stack/test/common/mock_gatt_gatt_auth.cc new file mode 100644 index 000000000..f6fe6294b --- /dev/null +++ b/stack/test/common/mock_gatt_gatt_auth.cc @@ -0,0 +1,66 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:10 + */ + +#include +#include + +extern std::map mock_function_count_map; + +#include +#include "stack/gatt/gatt_int.h" + +#ifndef UNUSED_ATTR +#define UNUSED_ATTR +#endif + +bool gatt_security_check_start(tGATT_CLCB* p_clcb) { + mock_function_count_map[__func__]++; + return false; +} +tGATT_SEC_ACTION gatt_determine_sec_act(tGATT_CLCB* p_clcb) { + mock_function_count_map[__func__]++; + return 0; +} +tGATT_SEC_ACTION gatt_get_sec_act(tGATT_TCB* p_tcb) { + mock_function_count_map[__func__]++; + return 0; +} +tGATT_STATUS gatt_get_link_encrypt_status(tGATT_TCB& tcb) { + mock_function_count_map[__func__]++; + return GATT_SUCCESS; +} +void gatt_enc_cmpl_cback(const RawAddress* bd_addr, tBT_TRANSPORT transport, + UNUSED_ATTR void* p_ref_data, tBTM_STATUS result) { + mock_function_count_map[__func__]++; +} +void gatt_notify_enc_cmpl(const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; +} +void gatt_sec_check_complete(bool sec_check_ok, tGATT_CLCB* p_clcb, + uint8_t sec_act) { + mock_function_count_map[__func__]++; +} +void gatt_set_sec_act(tGATT_TCB* p_tcb, tGATT_SEC_ACTION sec_act) { + mock_function_count_map[__func__]++; +} +void gatt_verify_signature(tGATT_TCB& tcb, uint16_t cid, BT_HDR* p_buf) { + mock_function_count_map[__func__]++; +} diff --git a/stack/test/common/mock_gatt_main.cc b/stack/test/common/mock_gatt_main.cc new file mode 100644 index 000000000..12edff5e9 --- /dev/null +++ b/stack/test/common/mock_gatt_main.cc @@ -0,0 +1,112 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:23 + */ + +#include +#include + +extern std::map mock_function_count_map; + +#include "bt_common.h" +#include "bt_target.h" +#include "btm_ble_int.h" +#include "btm_int.h" +#include "device/include/interop.h" +#include "l2c_api.h" +#include "osi/include/osi.h" +#include "stack/btm/btm_dev.h" +#include "stack/btm/btm_sec.h" +#include "stack/gatt/gatt_int.h" +#include "stack/include/l2cap_acl_interface.h" + +#ifndef UNUSED_ATTR +#define UNUSED_ATTR +#endif + +bool gatt_act_connect(tGATT_REG* p_reg, const RawAddress& bd_addr, + tBT_TRANSPORT transport, int8_t initiating_phys) { + mock_function_count_map[__func__]++; + return false; +} +bool gatt_connect(const RawAddress& rem_bda, tGATT_TCB* p_tcb, + tBT_TRANSPORT transport, uint8_t initiating_phys, + tGATT_IF gatt_if) { + mock_function_count_map[__func__]++; + return false; +} +bool gatt_disconnect(tGATT_TCB* p_tcb) { + mock_function_count_map[__func__]++; + return false; +} +bool gatt_update_app_hold_link_status(tGATT_IF gatt_if, tGATT_TCB* p_tcb, + bool is_add) { + mock_function_count_map[__func__]++; + return false; +} +tGATT_CH_STATE gatt_get_ch_state(tGATT_TCB* p_tcb) { + mock_function_count_map[__func__]++; + return GATT_CH_CLOSE; +} +void gatt_add_a_bonded_dev_for_srv_chg(const RawAddress& bda) { + mock_function_count_map[__func__]++; +} +void gatt_chk_srv_chg(tGATTS_SRV_CHG* p_srv_chg_clt) { + mock_function_count_map[__func__]++; +} +void gatt_data_process(tGATT_TCB& tcb, uint16_t cid, BT_HDR* p_buf) { + mock_function_count_map[__func__]++; +} +void gatt_find_in_device_record(const RawAddress& bd_addr, + tBLE_BD_ADDR* address_with_type) { + mock_function_count_map[__func__]++; +} +void gatt_free(void) { mock_function_count_map[__func__]++; } +void gatt_init(void) { mock_function_count_map[__func__]++; } +void gatt_init_srv_chg(void) { mock_function_count_map[__func__]++; } +void gatt_l2cif_config_cfm_cback(uint16_t lcid, uint16_t initiator, + tL2CAP_CFG_INFO* p_cfg) { + mock_function_count_map[__func__]++; +} +void gatt_l2cif_config_ind_cback(uint16_t lcid, tL2CAP_CFG_INFO* p_cfg) { + mock_function_count_map[__func__]++; +} +void gatt_l2cif_disconnect_ind_cback(uint16_t lcid, bool ack_needed) { + mock_function_count_map[__func__]++; +} +void gatt_notify_conn_update(uint16_t handle, uint16_t interval, + uint16_t latency, uint16_t timeout, + tHCI_STATUS status) { + mock_function_count_map[__func__]++; +} +void gatt_notify_phy_updated(tGATT_STATUS status, uint16_t handle, + uint8_t tx_phy, uint8_t rx_phy) { + mock_function_count_map[__func__]++; +} +void gatt_proc_srv_chg(void) { mock_function_count_map[__func__]++; } +void gatt_send_srv_chg_ind(const RawAddress& peer_bda) { + mock_function_count_map[__func__]++; +} +void gatt_set_ch_state(tGATT_TCB* p_tcb, tGATT_CH_STATE ch_state) { + mock_function_count_map[__func__]++; +} +void gatt_update_app_use_link_flag(tGATT_IF gatt_if, tGATT_TCB* p_tcb, + bool is_add, bool check_acl_link) { + mock_function_count_map[__func__]++; +} diff --git a/stack/test/common/mock_hci_packet_parser.cc b/stack/test/common/mock_hci_packet_parser.cc new file mode 100644 index 000000000..8d5d1652a --- /dev/null +++ b/stack/test/common/mock_hci_packet_parser.cc @@ -0,0 +1,41 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:3 + */ + +#include +#include + +extern std::map mock_function_count_map; + +#include "hci/include/hci_packet_parser.h" + +#ifndef UNUSED_ATTR +#define UNUSED_ATTR +#endif + +const hci_packet_parser_t* hci_packet_parser_get_interface() { + mock_function_count_map[__func__]++; + return nullptr; +} +const hci_packet_parser_t* hci_packet_parser_get_test_interface( + allocator_t* buffer_allocator_interface) { + mock_function_count_map[__func__]++; + return nullptr; +} diff --git a/stack/test/common/mock_hcic_hciblecmds.cc b/stack/test/common/mock_hcic_hciblecmds.cc new file mode 100644 index 000000000..f7474aa4d --- /dev/null +++ b/stack/test/common/mock_hcic_hciblecmds.cc @@ -0,0 +1,323 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + */ + +#include +#include + +extern std::map mock_function_count_map; +#define UNUSED_ATTR + +#include +#include +#include +#include "bt_common.h" +#include "bt_target.h" +#include "btu.h" +#include "hcidefs.h" +#include "hcimsgs.h" +void btsnd_hci_ble_add_device_to_periodic_advertiser_list( + uint8_t adv_addr_type, const RawAddress& adv_addr, uint8_t adv_sid, + base::OnceCallback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hci_ble_clear_periodic_advertiser_list( + base::OnceCallback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hci_ble_read_periodic_advertiser_list_size( + base::OnceCallback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hci_ble_remove_device_from_periodic_advertiser_list( + uint8_t adv_addr_type, const RawAddress& adv_addr, uint8_t adv_sid, + base::OnceCallback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_accept_cis_req(uint16_t conn_handle) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_big_create_sync(uint8_t big_handle, uint16_t sync_handle, + uint8_t enc, std::array bcst_code, + uint8_t mse, uint16_t big_sync_timeout, + std::vector bis) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_big_term_sync(uint8_t big_handle, + base::OnceCallback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_add_acceptlist( + uint8_t addr_type, const RawAddress& bda, + base::OnceCallback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_add_device_resolving_list(uint8_t addr_type_peer, + const RawAddress& bda_peer, + const Octet16& irk_peer, + const Octet16& irk_local) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_clear_acceptlist( + base::OnceCallback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_clear_resolving_list(void) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_create_conn_cancel(void) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_create_ll_conn( + uint16_t scan_int, uint16_t scan_win, uint8_t init_filter_policy, + uint8_t addr_type_peer, const RawAddress& bda_peer, uint8_t addr_type_own, + uint16_t conn_int_min, uint16_t conn_int_max, uint16_t conn_latency, + uint16_t conn_timeout, uint16_t min_ce_len, uint16_t max_ce_len) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_encrypt(uint8_t* key, uint8_t key_len, uint8_t* plain_text, + uint8_t pt_len, void* p_cmd_cplt_cback) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_enh_rx_test(uint8_t rx_chan, uint8_t phy, + uint8_t mod_index) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_enh_tx_test(uint8_t tx_chan, uint8_t data_len, + uint8_t payload, uint8_t phy) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_ext_create_conn(uint8_t init_filter_policy, + uint8_t addr_type_own, + uint8_t addr_type_peer, + const RawAddress& bda_peer, + uint8_t initiating_phys, + EXT_CONN_PHY_CFG* phy_cfg) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_ltk_req_neg_reply(uint16_t handle) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_ltk_req_reply(uint16_t handle, const Octet16& ltk) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_periodic_advertising_create_sync( + uint8_t options, uint8_t adv_sid, uint8_t adv_addr_type, + const RawAddress& adv_addr, uint16_t skip_num, uint16_t sync_timeout, + uint8_t sync_cte_type) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_periodic_advertising_create_sync_cancel( + base::OnceCallback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_periodic_advertising_set_info_transfer( + uint16_t conn_handle, uint16_t service_data, uint8_t adv_handle, + base::OnceCallback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_periodic_advertising_sync_transfer( + uint16_t conn_handle, uint16_t service_data, uint16_t sync_handle, + base::OnceCallback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_periodic_advertising_terminate_sync( + uint16_t sync_handle, base::OnceCallback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_rand(base::Callback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_read_adv_chnl_tx_power(void) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_read_chnl_map(uint16_t handle) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_read_host_supported(void) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_read_remote_feat(uint16_t handle) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_read_resolvable_addr_local(uint8_t addr_type_peer, + const RawAddress& bda_peer) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_read_resolvable_addr_peer(uint8_t addr_type_peer, + const RawAddress& bda_peer) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_receiver_test(uint8_t rx_freq) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_remove_from_acceptlist( + uint8_t addr_type, const RawAddress& bda, + base::OnceCallback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_rm_device_resolving_list(uint8_t addr_type_peer, + const RawAddress& bda_peer) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_set_addr_resolution_enable(uint8_t addr_resolution_enable) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_set_adv_data(uint8_t data_len, uint8_t* p_data) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_set_adv_enable(uint8_t adv_enable) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_set_data_length(uint16_t conn_handle, uint16_t tx_octets, + uint16_t tx_time) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_set_default_periodic_advertising_sync_transfer_params( + uint16_t conn_handle, uint8_t mode, uint16_t skip, uint16_t sync_timeout, + uint8_t cte_type, base::OnceCallback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_set_extended_scan_enable(uint8_t enable, + uint8_t filter_duplicates, + uint16_t duration, + uint16_t period) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_set_extended_scan_params(uint8_t own_address_type, + uint8_t scanning_filter_policy, + uint8_t scanning_phys, + scanning_phy_cfg* phy_cfg) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_set_host_chnl_class( + uint8_t chnl_map[HCIC_BLE_CHNL_MAP_SIZE]) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_set_local_used_feat(uint8_t feat_set[8]) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_set_periodic_advertising_receive_enable( + uint16_t sync_handle, bool enable, + base::OnceCallback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_set_periodic_advertising_sync_transfer_params( + uint16_t conn_handle, uint8_t mode, uint16_t skip, uint16_t sync_timeout, + uint8_t cte_type, base::OnceCallback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_set_privacy_mode(uint8_t addr_type_peer, + const RawAddress& bda_peer, + uint8_t privacy_type) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_set_rand_priv_addr_timeout(uint16_t rpa_timout) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_set_random_addr(const RawAddress& random_bda) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_set_scan_enable(uint8_t scan_enable, uint8_t duplicate) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_set_scan_params(uint8_t scan_type, uint16_t scan_int, + uint16_t scan_win, uint8_t addr_type_own, + uint8_t scan_filter_policy) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_set_scan_rsp_data(uint8_t data_len, uint8_t* p_scan_rsp) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_start_enc(uint16_t handle, + uint8_t rand[HCIC_BLE_RAND_DI_SIZE], + uint16_t ediv, const Octet16& ltk) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_test_end(void) { mock_function_count_map[__func__]++; } +void btsnd_hcic_ble_transmitter_test(uint8_t tx_freq, uint8_t test_data_len, + uint8_t payload) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_upd_ll_conn_params(uint16_t handle, uint16_t conn_int_min, + uint16_t conn_int_max, + uint16_t conn_latency, + uint16_t conn_timeout, + uint16_t min_ce_len, + uint16_t max_ce_len) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_ble_write_adv_params(uint16_t adv_int_min, uint16_t adv_int_max, + uint8_t adv_type, uint8_t addr_type_own, + uint8_t addr_type_dir, + const RawAddress& direct_bda, + uint8_t channel_map, + uint8_t adv_filter_policy) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_create_big(uint8_t big_handle, uint8_t adv_handle, + uint8_t num_bis, uint32_t sdu_itv, + uint16_t max_sdu_size, uint16_t transport_latency, + uint8_t rtn, uint8_t phy, uint8_t packing, + uint8_t framing, uint8_t enc, + std::array bcst_code) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_create_cis(uint8_t num_cis, const EXT_CIS_CREATE_CFG* cis_cfg, + base::OnceCallback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_read_iso_tx_sync( + uint16_t iso_handle, base::OnceCallback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_rej_cis_req(uint16_t conn_handle, uint8_t reason, + base::OnceCallback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_remove_cig(uint8_t cig_id, + base::OnceCallback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_remove_iso_data_path( + uint16_t iso_handle, uint8_t data_path_dir, + base::OnceCallback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_req_peer_sca(uint16_t conn_handle) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_set_cig_params( + uint8_t cig_id, uint32_t sdu_itv_mtos, uint32_t sdu_itv_stom, uint8_t sca, + uint8_t packing, uint8_t framing, uint16_t max_trans_lat_stom, + uint16_t max_trans_lat_mtos, uint8_t cis_cnt, const EXT_CIS_CFG* cis_cfg, + base::OnceCallback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_setup_iso_data_path( + uint16_t iso_handle, uint8_t data_path_dir, uint8_t data_path_id, + uint8_t codec_id_format, uint16_t codec_id_company, + uint16_t codec_id_vendor, uint32_t controller_delay, + std::vector codec_conf, + base::OnceCallback cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_term_big(uint8_t big_handle, uint8_t reason) { + mock_function_count_map[__func__]++; +} diff --git a/stack/test/common/mock_hcic_hcicmds.cc b/stack/test/common/mock_hcic_hcicmds.cc new file mode 100644 index 000000000..3be3a9e7c --- /dev/null +++ b/stack/test/common/mock_hcic_hcicmds.cc @@ -0,0 +1,295 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:77 + */ + +#include +#include + +extern std::map mock_function_count_map; +#define UNUSED_ATTR + +#include +#include +#include "bt_common.h" +#include "bt_target.h" +#include "btm_int.h" +#include "btu.h" +#include "hcidefs.h" +#include "hcimsgs.h" +#include "stack/include/acl_hci_link_interface.h" +void btsnd_hcic_accept_conn(const RawAddress& dest, uint8_t role) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_accept_esco_conn(const RawAddress& bd_addr, + uint32_t transmit_bandwidth, + uint32_t receive_bandwidth, + uint16_t max_latency, uint16_t content_fmt, + uint8_t retrans_effort, + uint16_t packet_types) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_add_SCO_conn(uint16_t handle, uint16_t packet_types) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_auth_request(uint16_t handle) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_change_conn_type(uint16_t handle, uint16_t packet_types) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_change_name(BD_NAME name) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_create_conn(const RawAddress& dest, uint16_t packet_types, + uint8_t page_scan_rep_mode, uint8_t page_scan_mode, + uint16_t clock_offset, uint8_t allow_switch) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_create_conn_cancel(const RawAddress& dest) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_delete_stored_key(const RawAddress& bd_addr, + bool delete_all_flag) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_disconnect(uint16_t handle, uint8_t reason) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_enable_test_mode(void) { mock_function_count_map[__func__]++; } +void btsnd_hcic_enhanced_accept_synchronous_connection( + const RawAddress& bd_addr, enh_esco_params_t* p_params) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_enhanced_flush(uint16_t handle, uint8_t packet_type) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_enhanced_set_up_synchronous_connection( + uint16_t conn_handle, enh_esco_params_t* p_params) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_exit_park_mode(uint16_t handle) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_exit_per_inq(void) { mock_function_count_map[__func__]++; } +void btsnd_hcic_exit_sniff_mode(uint16_t handle) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_get_link_quality(uint16_t handle) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_hold_mode(uint16_t handle, uint16_t max_hold_period, + uint16_t min_hold_period) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_host_num_xmitted_pkts(uint8_t num_handles, uint16_t* handle, + uint16_t* num_pkts) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_inq_cancel(void) { mock_function_count_map[__func__]++; } +void btsnd_hcic_inquiry(const LAP inq_lap, uint8_t duration, + uint8_t response_cnt) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_io_cap_req_neg_reply(const RawAddress& bd_addr, + uint8_t err_code) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_io_cap_req_reply(const RawAddress& bd_addr, uint8_t capability, + uint8_t oob_present, uint8_t auth_req) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_link_key_neg_reply(const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_link_key_req_reply(const RawAddress& bd_addr, + const LinkKey& link_key) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_park_mode(uint16_t handle, uint16_t beacon_max_interval, + uint16_t beacon_min_interval) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_per_inq_mode(uint16_t max_period, uint16_t min_period, + const LAP inq_lap, uint8_t duration, + uint8_t response_cnt) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_pin_code_neg_reply(const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_pin_code_req_reply(const RawAddress& bd_addr, + uint8_t pin_code_len, PIN_CODE pin_code) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_qos_setup(uint16_t handle, uint8_t flags, uint8_t service_type, + uint32_t token_rate, uint32_t peak, uint32_t latency, + uint32_t delay_var) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_read_automatic_flush_timeout(uint16_t handle) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_read_encryption_key_size(uint16_t handle, ReadEncKeySizeCb cb) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_read_failed_contact_counter(uint16_t handle) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_read_inq_tx_power(void) { mock_function_count_map[__func__]++; } +void btsnd_hcic_read_lmp_handle(uint16_t handle) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_read_local_oob_data(void) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_read_name(void) { mock_function_count_map[__func__]++; } +void btsnd_hcic_read_rmt_clk_offset(uint16_t handle) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_read_rssi(uint16_t handle) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_read_tx_power(uint16_t handle, uint8_t type) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_reject_conn(const RawAddress& dest, uint8_t reason) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_reject_esco_conn(const RawAddress& bd_addr, uint8_t reason) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_rem_oob_neg_reply(const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_rem_oob_reply(const RawAddress& bd_addr, const Octet16& c, + const Octet16& r) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_rmt_ext_features(uint16_t handle, uint8_t page_num) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_rmt_features_req(uint16_t handle) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_rmt_name_req(const RawAddress& bd_addr, + uint8_t page_scan_rep_mode, uint8_t page_scan_mode, + uint16_t clock_offset) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_rmt_name_req_cancel(const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_rmt_ver_req(uint16_t handle) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_send_keypress_notif(const RawAddress& bd_addr, uint8_t notif) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_set_conn_encrypt(uint16_t handle, bool enable) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_set_event_filter(uint8_t filt_type, uint8_t filt_cond_type, + uint8_t* filt_cond, uint8_t filt_cond_len) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_setup_esco_conn(uint16_t handle, uint32_t transmit_bandwidth, + uint32_t receive_bandwidth, + uint16_t max_latency, uint16_t voice, + uint8_t retrans_effort, uint16_t packet_types) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_sniff_mode(uint16_t handle, uint16_t max_sniff_period, + uint16_t min_sniff_period, uint16_t sniff_attempt, + uint16_t sniff_timeout) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_sniff_sub_rate(uint16_t handle, uint16_t max_lat, + uint16_t min_remote_lat, + uint16_t min_local_lat) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_switch_role(const RawAddress& bd_addr, uint8_t role) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_user_conf_reply(const RawAddress& bd_addr, bool is_yes) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_user_passkey_neg_reply(const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_user_passkey_reply(const RawAddress& bd_addr, uint32_t value) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_vendor_spec_cmd(void* buffer, uint16_t opcode, uint8_t len, + uint8_t* p_data, void* p_cmd_cplt_cback) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_write_auth_enable(uint8_t flag) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_write_auto_flush_tout(uint16_t handle, uint16_t tout) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_write_cur_iac_lap(uint8_t num_cur_iac, LAP* const iac_lap) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_write_def_policy_set(uint16_t settings) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_write_dev_class(DEV_CLASS dev_class) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_write_ext_inquiry_response(void* buffer, uint8_t fec_req) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_write_inqscan_cfg(uint16_t interval, uint16_t window) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_write_inqscan_type(uint8_t type) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_write_inquiry_mode(uint8_t mode) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_write_link_super_tout(uint8_t local_controller_id, + uint16_t handle, uint16_t timeout) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_write_page_tout(uint16_t timeout) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_write_pagescan_cfg(uint16_t interval, uint16_t window) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_write_pagescan_type(uint8_t type) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_write_pin_type(uint8_t type) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_write_policy_set(uint16_t handle, uint16_t settings) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_write_scan_enable(uint8_t flag) { + mock_function_count_map[__func__]++; +} +void btsnd_hcic_write_voice_settings(uint16_t flags) { + mock_function_count_map[__func__]++; +} diff --git a/stack/test/common/mock_l2cap_l2c_api.cc b/stack/test/common/mock_l2cap_l2c_api.cc new file mode 100644 index 000000000..5d0cae533 --- /dev/null +++ b/stack/test/common/mock_l2cap_l2c_api.cc @@ -0,0 +1,178 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:33 + */ + +#include +#include + +extern std::map mock_function_count_map; + +#include +#include "stack/include/l2c_api.h" +#include "types/raw_address.h" + +#ifndef UNUSED_ATTR +#define UNUSED_ATTR +#endif + +bool L2CA_ConnectCreditBasedRsp(const RawAddress& p_bd_addr, uint8_t id, + std::vector& accepted_lcids, + uint16_t result, tL2CAP_LE_CFG_INFO* p_cfg) { + mock_function_count_map[__func__]++; + return false; +} +bool L2CA_ConnectFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda) { + mock_function_count_map[__func__]++; + return false; +} +bool L2CA_DisconnectLECocReq(uint16_t cid) { + mock_function_count_map[__func__]++; + return false; +} +bool L2CA_DisconnectReq(uint16_t cid) { + mock_function_count_map[__func__]++; + return false; +} +bool L2CA_GetPeerFeatures(const RawAddress& bd_addr, uint32_t* p_ext_feat, + uint8_t* p_chnl_mask) { + mock_function_count_map[__func__]++; + return false; +} +bool L2CA_GetPeerLECocConfig(uint16_t lcid, tL2CAP_LE_CFG_INFO* peer_cfg) { + mock_function_count_map[__func__]++; + return false; +} +bool L2CA_GetRemoteCid(uint16_t lcid, uint16_t* rcid) { + mock_function_count_map[__func__]++; + return false; +} +bool L2CA_IsLinkEstablished(const RawAddress& bd_addr, + tBT_TRANSPORT transport) { + mock_function_count_map[__func__]++; + return false; +} +bool L2CA_ReconfigCreditBasedConnsReq(const RawAddress& bda, + std::vector& lcids, + tL2CAP_LE_CFG_INFO* p_cfg) { + mock_function_count_map[__func__]++; + return false; +} +bool L2CA_RegisterFixedChannel(uint16_t fixed_cid, + tL2CAP_FIXED_CHNL_REG* p_freg) { + mock_function_count_map[__func__]++; + return false; +} +bool L2CA_RemoveFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda) { + mock_function_count_map[__func__]++; + return false; +} +bool L2CA_SetAclPriority(const RawAddress& bd_addr, tL2CAP_PRIORITY priority) { + mock_function_count_map[__func__]++; + return false; +} +bool L2CA_SetChnlFlushability(uint16_t cid, bool is_flushable) { + mock_function_count_map[__func__]++; + return false; +} +bool L2CA_SetFixedChannelTout(const RawAddress& rem_bda, uint16_t fixed_cid, + uint16_t idle_tout) { + mock_function_count_map[__func__]++; + return false; +} +bool L2CA_SetIdleTimeoutByBdAddr(const RawAddress& bd_addr, uint16_t timeout, + tBT_TRANSPORT transport) { + mock_function_count_map[__func__]++; + return false; +} +bool L2CA_SetTxPriority(uint16_t cid, tL2CAP_CHNL_PRIORITY priority) { + mock_function_count_map[__func__]++; + return false; +} +std::vector L2CA_ConnectCreditBasedReq(uint16_t psm, + const RawAddress& p_bd_addr, + tL2CAP_LE_CFG_INFO* p_cfg) { + mock_function_count_map[__func__]++; + std::vector v; + return v; +} +tBT_TRANSPORT l2c_get_transport_from_fixed_cid(uint16_t fixed_cid) { + mock_function_count_map[__func__]++; + return 0; +} +uint16_t L2CA_AllocateLePSM(void) { + mock_function_count_map[__func__]++; + return 0; +} +uint16_t L2CA_ConnectLECocReq(uint16_t psm, const RawAddress& p_bd_addr, + tL2CAP_LE_CFG_INFO* p_cfg, uint16_t sec_level) { + mock_function_count_map[__func__]++; + return 0; +} +uint16_t L2CA_ConnectReq(uint16_t psm, const RawAddress& p_bd_addr) { + mock_function_count_map[__func__]++; + return 0; +} +uint16_t L2CA_ConnectReq2(uint16_t psm, const RawAddress& p_bd_addr, + uint16_t sec_level) { + mock_function_count_map[__func__]++; + return 0; +} +uint16_t L2CA_FlushChannel(uint16_t lcid, uint16_t num_to_flush) { + mock_function_count_map[__func__]++; + return 0; +} +uint16_t 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) { + mock_function_count_map[__func__]++; + return 0; +} +uint16_t 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) { + mock_function_count_map[__func__]++; + return 0; +} +uint16_t L2CA_RegisterLECoc(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info, + uint16_t sec_level, tL2CAP_LE_CFG_INFO cfg) { + mock_function_count_map[__func__]++; + return 0; +} +uint16_t L2CA_SendFixedChnlData(uint16_t fixed_cid, const RawAddress& rem_bda, + BT_HDR* p_buf) { + mock_function_count_map[__func__]++; + return 0; +} +uint8_t L2CA_DataWrite(uint16_t cid, BT_HDR* p_data) { + mock_function_count_map[__func__]++; + return 0; +} +uint8_t L2CA_LECocDataWrite(uint16_t cid, BT_HDR* p_data) { + mock_function_count_map[__func__]++; + return 0; +} +uint8_t L2CA_SetTraceLevel(uint8_t new_level) { + mock_function_count_map[__func__]++; + return 0; +} +void L2CA_Deregister(uint16_t psm) { mock_function_count_map[__func__]++; } +void L2CA_DeregisterLECoc(uint16_t psm) { mock_function_count_map[__func__]++; } +void L2CA_FreeLePSM(uint16_t psm) { mock_function_count_map[__func__]++; } diff --git a/stack/test/common/mock_l2cap_l2c_ble.cc b/stack/test/common/mock_l2cap_l2c_ble.cc new file mode 100644 index 000000000..e06e11b94 --- /dev/null +++ b/stack/test/common/mock_l2cap_l2c_ble.cc @@ -0,0 +1,156 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:26 + */ + +#include +#include + +extern std::map mock_function_count_map; + +#include +#include "bt_target.h" +#include "device/include/controller.h" +#include "hcimsgs.h" +#include "main/shim/shim.h" +#include "osi/include/log.h" +#include "osi/include/osi.h" +#include "stack/btm/btm_dev.h" +#include "stack/btm/btm_sec.h" +#include "stack/include/acl_api.h" +#include "stack/include/l2c_api.h" +#include "stack/include/l2cdefs.h" +#include "stack/l2cap/l2c_int.h" +#include "stack_config.h" + +#ifndef UNUSED_ATTR +#define UNUSED_ATTR +#endif + +bool L2CA_CancelBleConnectReq(const RawAddress& rem_bda) { + mock_function_count_map[__func__]++; + return false; +} +bool L2CA_EnableUpdateBleConnParams(const RawAddress& rem_bda, bool enable) { + mock_function_count_map[__func__]++; + return false; +} +bool L2CA_UpdateBleConnParams(const RawAddress& rem_bda, uint16_t min_int, + uint16_t max_int, uint16_t latency, + uint16_t timeout) { + mock_function_count_map[__func__]++; + return false; +} +bool L2CA_UpdateBleConnParams(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) { + mock_function_count_map[__func__]++; + return false; +} +bool l2cble_conn_comp(uint16_t handle, uint8_t role, const RawAddress& bda, + tBLE_ADDR_TYPE type, uint16_t conn_interval, + uint16_t conn_latency, uint16_t conn_timeout) { + mock_function_count_map[__func__]++; + return false; +} +bool l2cble_conn_comp_from_address_with_type( + uint16_t handle, uint8_t role, const tBLE_BD_ADDR& address_with_type, + uint16_t conn_interval, uint16_t conn_latency, uint16_t conn_timeout) { + mock_function_count_map[__func__]++; + return false; +} +bool l2cble_create_conn(tL2C_LCB* p_lcb) { + mock_function_count_map[__func__]++; + return false; +} +hci_role_t L2CA_GetBleConnRole(const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; + return 0; +} +tL2CAP_LE_RESULT_CODE l2ble_sec_access_req(const RawAddress& bd_addr, + uint16_t psm, bool is_originator, + tL2CAP_SEC_CBACK* p_callback, + void* p_ref_data) { + mock_function_count_map[__func__]++; + return L2CAP_LE_RESULT_CONN_OK; +} +uint16_t L2CA_GetDisconnectReason(const RawAddress& remote_bda, + tBT_TRANSPORT transport) { + mock_function_count_map[__func__]++; + return 0; +} +void L2CA_AdjustConnectionIntervals(uint16_t* min_interval, + uint16_t* max_interval, + uint16_t floor_interval) { + mock_function_count_map[__func__]++; +} +void L2CA_SetLeFixedChannelTxDataLength(const RawAddress& remote_bda, + uint16_t fix_cid, uint16_t tx_mtu) { + mock_function_count_map[__func__]++; +} +void l2c_ble_link_adjust_allocation(void) { + mock_function_count_map[__func__]++; +} +void l2c_link_processs_ble_num_bufs(uint16_t num_lm_ble_bufs) { + mock_function_count_map[__func__]++; +} +void l2cble_credit_based_conn_req(tL2C_CCB* p_ccb) { + mock_function_count_map[__func__]++; +} +void l2cble_credit_based_conn_res(tL2C_CCB* p_ccb, uint16_t result) { + mock_function_count_map[__func__]++; +} +void l2cble_notify_le_connection(const RawAddress& bda) { + mock_function_count_map[__func__]++; +} +void l2cble_process_conn_update_evt(uint16_t handle, uint8_t status, + uint16_t interval, uint16_t latency, + uint16_t timeout) { + mock_function_count_map[__func__]++; +} +void l2cble_process_data_length_change_event(uint16_t handle, + uint16_t tx_data_len, + uint16_t rx_data_len) { + mock_function_count_map[__func__]++; +} +void l2cble_process_sig_cmd(tL2C_LCB* p_lcb, uint8_t* p, uint16_t pkt_len) { + mock_function_count_map[__func__]++; +} +void l2cble_sec_comp(const RawAddress* bda, tBT_TRANSPORT transport, + void* p_ref_data, uint8_t status) { + mock_function_count_map[__func__]++; +} +void l2cble_send_flow_control_credit(tL2C_CCB* p_ccb, uint16_t credit_value) { + mock_function_count_map[__func__]++; +} +void l2cble_send_peer_disc_req(tL2C_CCB* p_ccb) { + mock_function_count_map[__func__]++; +} +void l2cble_set_fixed_channel_tx_data_length(const RawAddress& remote_bda, + uint16_t fix_cid, + uint16_t tx_mtu) { + mock_function_count_map[__func__]++; +} +void l2cble_update_data_length(tL2C_LCB* p_lcb) { + mock_function_count_map[__func__]++; +} +void l2cble_use_preferred_conn_params(const RawAddress& bda) { + mock_function_count_map[__func__]++; +} diff --git a/stack/test/common/mock_l2cap_l2c_link.cc b/stack/test/common/mock_l2cap_l2c_link.cc new file mode 100644 index 000000000..f7ae8c785 --- /dev/null +++ b/stack/test/common/mock_l2cap_l2c_link.cc @@ -0,0 +1,96 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + */ + +#include +#include + +extern std::map mock_function_count_map; +#define UNUSED_ATTR + +#include +#include "stack/l2cap/l2c_int.h" +BT_HDR* l2cu_get_next_buffer_to_send(tL2C_LCB* p_lcb) { + mock_function_count_map[__func__]++; + return nullptr; +} +bool l2c_link_hci_disc_comp(uint16_t handle, uint8_t reason) { + mock_function_count_map[__func__]++; + return false; +} +tBTM_STATUS l2cu_ConnectAclForSecurity(const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; + return 0; +} +tL2C_CCB* l2cu_get_next_channel_in_rr(tL2C_LCB* p_lcb) { + mock_function_count_map[__func__]++; + return nullptr; +} +void l2c_OnHciModeChangeSendPendingPackets(RawAddress remote) { + mock_function_count_map[__func__]++; +} +void l2c_info_resp_timer_timeout(void* data) { + mock_function_count_map[__func__]++; +} +void l2c_link_adjust_allocation(void) { mock_function_count_map[__func__]++; } +void l2c_link_adjust_chnl_allocation(void) { + mock_function_count_map[__func__]++; +} +void l2c_link_check_send_pkts(tL2C_LCB* p_lcb, uint16_t local_cid, + BT_HDR* p_buf) { + mock_function_count_map[__func__]++; +} +void l2c_link_hci_conn_comp(uint8_t status, uint16_t handle, + const RawAddress& p_bda) { + mock_function_count_map[__func__]++; +} +void l2c_link_hci_conn_req(const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; +} +void l2c_link_init() { mock_function_count_map[__func__]++; } +void l2c_link_process_num_completed_pkts(uint8_t* p, uint8_t evt_len) { + mock_function_count_map[__func__]++; +} +void l2c_link_role_changed(const RawAddress* bd_addr, uint8_t new_role, + uint8_t hci_status) { + mock_function_count_map[__func__]++; +} +void l2c_link_sec_comp(const RawAddress* p_bda, + UNUSED_ATTR tBT_TRANSPORT transport, void* p_ref_data, + uint8_t status) { + mock_function_count_map[__func__]++; +} +void l2c_link_sec_comp2(const RawAddress& p_bda, + UNUSED_ATTR tBT_TRANSPORT transport, void* p_ref_data, + uint8_t status) { + mock_function_count_map[__func__]++; +} +void l2c_link_segments_xmitted(BT_HDR* p_msg) { + mock_function_count_map[__func__]++; +} +void l2c_link_timeout(tL2C_LCB* p_lcb) { mock_function_count_map[__func__]++; } +void l2c_packets_completed(uint16_t handle, uint16_t num_sent) { + mock_function_count_map[__func__]++; +} +void l2c_pin_code_request(const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; +} +void l2cble_update_sec_act(const RawAddress& bd_addr, uint16_t sec_act) { + mock_function_count_map[__func__]++; +} diff --git a/stack/test/common/mock_l2cap_l2c_main.cc b/stack/test/common/mock_l2cap_l2c_main.cc new file mode 100644 index 000000000..6b11dcb4f --- /dev/null +++ b/stack/test/common/mock_l2cap_l2c_main.cc @@ -0,0 +1,60 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:9 + */ + +#include +#include + +extern std::map mock_function_count_map; + +#include +#include "bt_common.h" +#include "bt_target.h" +#include "hci/include/btsnoop.h" +#include "hcimsgs.h" +#include "main/shim/shim.h" +#include "osi/include/log.h" +#include "osi/include/osi.h" +#include "stack/include/l2c_api.h" +#include "stack/include/l2cdefs.h" +#include "stack/l2cap/l2c_int.h" + +#ifndef UNUSED_ATTR +#define UNUSED_ATTR +#endif + +uint8_t l2c_data_write(uint16_t cid, BT_HDR* p_data, uint16_t flags) { + mock_function_count_map[__func__]++; + return 0; +} +void l2c_ccb_timer_timeout(void* data) { mock_function_count_map[__func__]++; } +void l2c_fcrb_ack_timer_timeout(void* data) { + mock_function_count_map[__func__]++; +} +void l2c_free(void) { mock_function_count_map[__func__]++; } +void l2c_init(void) { mock_function_count_map[__func__]++; } +void l2c_lcb_timer_timeout(void* data) { mock_function_count_map[__func__]++; } +void l2c_process_held_packets(bool timed_out) { + mock_function_count_map[__func__]++; +} +void l2c_rcv_acl_data(BT_HDR* p_msg) { mock_function_count_map[__func__]++; } +void l2c_receive_hold_timer_timeout(UNUSED_ATTR void* data) { + mock_function_count_map[__func__]++; +} diff --git a/stack/test/common/mock_l2cap_l2c_utils.cc b/stack/test/common/mock_l2cap_l2c_utils.cc new file mode 100644 index 000000000..304c7596b --- /dev/null +++ b/stack/test/common/mock_l2cap_l2c_utils.cc @@ -0,0 +1,283 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:72 + */ + +#include +#include + +extern std::map mock_function_count_map; + +#include +#include "stack/include/bt_types.h" +#include "stack/l2cap/l2c_int.h" +#include "types/raw_address.h" + +#ifndef UNUSED_ATTR +#define UNUSED_ATTR +#endif + +BT_HDR* l2cu_build_header(tL2C_LCB* p_lcb, uint16_t len, uint8_t cmd, + uint8_t signal_id) { + mock_function_count_map[__func__]++; + return nullptr; +} +bool l2c_is_cmd_rejected(uint8_t cmd_code, uint8_t signal_id, tL2C_LCB* p_lcb) { + mock_function_count_map[__func__]++; + return false; +} +bool l2cu_create_conn_le(tL2C_LCB* p_lcb) { + mock_function_count_map[__func__]++; + return false; +} +bool l2cu_create_conn_le(tL2C_LCB* p_lcb, uint8_t initiating_phys) { + mock_function_count_map[__func__]++; + return false; +} +bool l2cu_initialize_fixed_ccb(tL2C_LCB* p_lcb, uint16_t fixed_cid) { + mock_function_count_map[__func__]++; + return false; +} +bool l2cu_is_ccb_active(tL2C_CCB* p_ccb) { + mock_function_count_map[__func__]++; + return false; +} +bool l2cu_lcb_disconnecting(void) { + mock_function_count_map[__func__]++; + return false; +} +bool l2cu_set_acl_priority(const RawAddress& bd_addr, tL2CAP_PRIORITY priority, + bool reset_after_rs) { + mock_function_count_map[__func__]++; + return false; +} +bool l2cu_start_post_bond_timer(uint16_t handle) { + mock_function_count_map[__func__]++; + return false; +} +tL2C_CCB* l2cu_allocate_ccb(tL2C_LCB* p_lcb, uint16_t cid) { + mock_function_count_map[__func__]++; + return nullptr; +} +tL2C_CCB* l2cu_find_ccb_by_cid(tL2C_LCB* p_lcb, uint16_t local_cid) { + mock_function_count_map[__func__]++; + return nullptr; +} +tL2C_CCB* l2cu_find_ccb_by_remote_cid(tL2C_LCB* p_lcb, uint16_t remote_cid) { + mock_function_count_map[__func__]++; + return nullptr; +} +tL2C_LCB* l2cu_allocate_lcb(const RawAddress& p_bd_addr, bool is_bonding, + tBT_TRANSPORT transport) { + mock_function_count_map[__func__]++; + return nullptr; +} +tL2C_LCB* l2cu_find_lcb_by_bd_addr(const RawAddress& p_bd_addr, + tBT_TRANSPORT transport) { + mock_function_count_map[__func__]++; + return nullptr; +} +tL2C_LCB* l2cu_find_lcb_by_handle(uint16_t handle) { + mock_function_count_map[__func__]++; + return nullptr; +} +tL2C_LCB* l2cu_find_lcb_by_state(tL2C_LINK_STATE state) { + mock_function_count_map[__func__]++; + return nullptr; +} +tL2C_RCB* l2cu_allocate_ble_rcb(uint16_t psm) { + mock_function_count_map[__func__]++; + return nullptr; +} +tL2C_RCB* l2cu_allocate_rcb(uint16_t psm) { + mock_function_count_map[__func__]++; + return nullptr; +} +tL2C_RCB* l2cu_find_ble_rcb_by_psm(uint16_t psm) { + mock_function_count_map[__func__]++; + return nullptr; +} +tL2C_RCB* l2cu_find_rcb_by_psm(uint16_t psm) { + mock_function_count_map[__func__]++; + return nullptr; +} +uint8_t l2cu_get_num_hi_priority(void) { + mock_function_count_map[__func__]++; + return 0; +} +uint8_t l2cu_process_peer_cfg_req(tL2C_CCB* p_ccb, tL2CAP_CFG_INFO* p_cfg) { + mock_function_count_map[__func__]++; + return 0; +} +void l2cu_adj_id(tL2C_LCB* p_lcb) { mock_function_count_map[__func__]++; } +void l2cu_adjust_out_mps(tL2C_CCB* p_ccb) { + mock_function_count_map[__func__]++; +} +void l2cu_change_pri_ccb(tL2C_CCB* p_ccb, tL2CAP_CHNL_PRIORITY priority) { + mock_function_count_map[__func__]++; +} +void l2cu_check_channel_congestion(tL2C_CCB* p_ccb) { + mock_function_count_map[__func__]++; +} +void l2cu_create_conn_after_switch(tL2C_LCB* p_lcb) { + mock_function_count_map[__func__]++; +} +void l2cu_create_conn_br_edr(tL2C_LCB* p_lcb) { + mock_function_count_map[__func__]++; +} +void l2cu_dequeue_ccb(tL2C_CCB* p_ccb) { mock_function_count_map[__func__]++; } +void l2cu_device_reset(void) { mock_function_count_map[__func__]++; } +void l2cu_disconnect_chnl(tL2C_CCB* p_ccb) { + mock_function_count_map[__func__]++; +} +void l2cu_enqueue_ccb(tL2C_CCB* p_ccb) { mock_function_count_map[__func__]++; } +void l2cu_no_dynamic_ccbs(tL2C_LCB* p_lcb) { + mock_function_count_map[__func__]++; +} +void l2cu_process_fixed_chnl_resp(tL2C_LCB* p_lcb) { + mock_function_count_map[__func__]++; +} +void l2cu_process_fixed_disc_cback(tL2C_LCB* p_lcb) { + mock_function_count_map[__func__]++; +} +void l2cu_process_our_cfg_req(tL2C_CCB* p_ccb, tL2CAP_CFG_INFO* p_cfg) { + mock_function_count_map[__func__]++; +} +void l2cu_process_our_cfg_rsp(tL2C_CCB* p_ccb, tL2CAP_CFG_INFO* p_cfg) { + mock_function_count_map[__func__]++; +} +void l2cu_process_peer_cfg_rsp(tL2C_CCB* p_ccb, tL2CAP_CFG_INFO* p_cfg) { + mock_function_count_map[__func__]++; +} +void l2cu_reject_ble_coc_connection(tL2C_LCB* p_lcb, uint8_t rem_id, + uint16_t result) { + mock_function_count_map[__func__]++; +} +void l2cu_reject_ble_connection(tL2C_CCB* p_ccb, uint8_t rem_id, + uint16_t result) { + mock_function_count_map[__func__]++; +} +void l2cu_reject_connection(tL2C_LCB* p_lcb, uint16_t remote_cid, + uint8_t rem_id, uint16_t result) { + mock_function_count_map[__func__]++; +} +void l2cu_reject_credit_based_conn_req(tL2C_LCB* p_lcb, uint8_t rem_id, + uint8_t num_of_channels, + uint16_t result) { + mock_function_count_map[__func__]++; +} +void l2cu_release_ble_rcb(tL2C_RCB* p_rcb) { + mock_function_count_map[__func__]++; +} +void l2cu_release_ccb(tL2C_CCB* p_ccb) { mock_function_count_map[__func__]++; } +void l2cu_release_lcb(tL2C_LCB* p_lcb) { mock_function_count_map[__func__]++; } +void l2cu_release_rcb(tL2C_RCB* p_rcb) { mock_function_count_map[__func__]++; } +void l2cu_resubmit_pending_sec_req(const RawAddress* p_bda) { + mock_function_count_map[__func__]++; +} +void l2cu_send_ble_reconfig_rsp(tL2C_LCB* p_lcb, uint8_t rem_id, + uint16_t result) { + mock_function_count_map[__func__]++; +} +void l2cu_send_credit_based_reconfig_req(tL2C_CCB* p_ccb, + tL2CAP_LE_CFG_INFO* p_cfg) { + mock_function_count_map[__func__]++; +} +void l2cu_send_peer_ble_credit_based_conn_req(tL2C_CCB* p_ccb) { + mock_function_count_map[__func__]++; +} +void l2cu_send_peer_ble_credit_based_conn_res(tL2C_CCB* p_ccb, + uint16_t result) { + mock_function_count_map[__func__]++; +} +void l2cu_send_peer_ble_credit_based_disconn_req(tL2C_CCB* p_ccb) { + mock_function_count_map[__func__]++; +} +void l2cu_send_peer_ble_flow_control_credit(tL2C_CCB* p_ccb, + uint16_t credit_value) { + mock_function_count_map[__func__]++; +} +void l2cu_send_peer_ble_par_req(tL2C_LCB* p_lcb, uint16_t min_int, + uint16_t max_int, uint16_t latency, + uint16_t timeout) { + mock_function_count_map[__func__]++; +} +void l2cu_send_peer_ble_par_rsp(tL2C_LCB* p_lcb, uint16_t reason, + uint8_t rem_id) { + mock_function_count_map[__func__]++; +} +void l2cu_send_peer_cmd_reject(tL2C_LCB* p_lcb, uint16_t reason, uint8_t rem_id, + uint16_t p1, uint16_t p2) { + mock_function_count_map[__func__]++; +} +void l2cu_send_peer_config_rej(tL2C_CCB* p_ccb, uint8_t* p_data, + uint16_t data_len, uint16_t rej_len) { + mock_function_count_map[__func__]++; +} +void l2cu_send_peer_config_req(tL2C_CCB* p_ccb, tL2CAP_CFG_INFO* p_cfg) { + mock_function_count_map[__func__]++; +} +void l2cu_send_peer_config_rsp(tL2C_CCB* p_ccb, tL2CAP_CFG_INFO* p_cfg) { + mock_function_count_map[__func__]++; +} +void l2cu_send_peer_connect_req(tL2C_CCB* p_ccb) { + mock_function_count_map[__func__]++; +} +void l2cu_send_peer_connect_rsp(tL2C_CCB* p_ccb, uint16_t result, + uint16_t status) { + mock_function_count_map[__func__]++; +} +void l2cu_send_peer_credit_based_conn_req(tL2C_CCB* p_ccb) { + mock_function_count_map[__func__]++; +} +void l2cu_send_peer_credit_based_conn_res(tL2C_CCB* p_ccb, + std::vector& accepted_cids, + uint16_t result) { + mock_function_count_map[__func__]++; +} +void l2cu_send_peer_disc_req(tL2C_CCB* p_ccb) { + mock_function_count_map[__func__]++; +} +void l2cu_send_peer_disc_rsp(tL2C_LCB* p_lcb, uint8_t remote_id, + uint16_t local_cid, uint16_t remote_cid) { + mock_function_count_map[__func__]++; +} +void l2cu_send_peer_echo_rsp(tL2C_LCB* p_lcb, uint8_t signal_id, + uint8_t* p_data, uint16_t data_len) { + mock_function_count_map[__func__]++; +} +void l2cu_send_peer_info_req(tL2C_LCB* p_lcb, uint16_t info_type) { + mock_function_count_map[__func__]++; +} +void l2cu_send_peer_info_rsp(tL2C_LCB* p_lcb, uint8_t remote_id, + uint16_t info_type) { + mock_function_count_map[__func__]++; +} +void l2cu_set_acl_hci_header(BT_HDR* p_buf, tL2C_CCB* p_ccb) { + mock_function_count_map[__func__]++; +} +void l2cu_set_lcb_handle(struct t_l2c_linkcb& p_lcb, uint16_t handle) { + mock_function_count_map[__func__]++; +} +void l2cu_set_non_flushable_pbf(bool is_supported) { + mock_function_count_map[__func__]++; +} +void l2cu_update_lcb_4_bonding(const RawAddress& p_bd_addr, bool is_bonding) { + mock_function_count_map[__func__]++; +} diff --git a/stack/test/common/mock_main_bte_main.cc b/stack/test/common/mock_main_bte_main.cc new file mode 100644 index 000000000..581782ef2 --- /dev/null +++ b/stack/test/common/mock_main_bte_main.cc @@ -0,0 +1,48 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:3 + */ + +#include +#include + +extern std::map mock_function_count_map; + +#include +#include +#include "bt_common.h" +#include "btcore/include/module.h" +#include "bte.h" +#include "btif/include/btif_config.h" +#include "btu.h" +#include "device/include/interop.h" +#include "osi/include/log.h" +#include "osi/include/osi.h" + +#ifndef UNUSED_ATTR +#define UNUSED_ATTR +#endif + +void bte_main_hci_send(BT_HDR* p_msg, uint16_t event) { + mock_function_count_map[__func__]++; +} +void bte_main_init(void) { mock_function_count_map[__func__]++; } +void post_to_main_message_loop(const base::Location& from_here, BT_HDR* p_msg) { + mock_function_count_map[__func__]++; +} diff --git a/stack/test/common/mock_main_shim.cc b/stack/test/common/mock_main_shim.cc new file mode 100644 index 000000000..b59ce657e --- /dev/null +++ b/stack/test/common/mock_main_shim.cc @@ -0,0 +1,84 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:14 + */ + +#include +#include + +extern std::map mock_function_count_map; + +#define LOG_TAG "bt_shim" +#include "gd/common/init_flags.h" +#include "gd/os/log.h" +#include "main/shim/entry.h" +#include "main/shim/shim.h" + +#ifndef UNUSED_ATTR +#define UNUSED_ATTR +#endif + +bool bluetooth::shim::is_any_gd_enabled() { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::is_gd_acl_enabled() { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::is_gd_advertising_enabled() { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::is_gd_controller_enabled() { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::is_gd_hci_enabled() { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::is_gd_l2cap_enabled() { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::is_gd_security_enabled() { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::is_gd_shim_enabled() { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::is_gd_stack_started_up() { + mock_function_count_map[__func__]++; + return false; +} +future_t* GeneralShutDown() { + mock_function_count_map[__func__]++; + return nullptr; +} +future_t* IdleModuleStartUp() { + mock_function_count_map[__func__]++; + return nullptr; +} +future_t* ShimModuleStartUp() { + mock_function_count_map[__func__]++; + return nullptr; +} diff --git a/stack/test/common/mock_main_shim_acl_api.cc b/stack/test/common/mock_main_shim_acl_api.cc new file mode 100644 index 000000000..91230c094 --- /dev/null +++ b/stack/test/common/mock_main_shim_acl_api.cc @@ -0,0 +1,54 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:5 + */ + +#include +#include + +extern std::map mock_function_count_map; + +#include +#include +#include "main/shim/acl_api.h" +#include "types/ble_address_with_type.h" +#include "types/raw_address.h" + +#ifndef UNUSED_ATTR +#define UNUSED_ATTR +#endif + +void bluetooth::shim::ACL_CancelLeConnection( + const tBLE_BD_ADDR& legacy_address_with_type) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::ACL_ConfigureLePrivacy(bool is_le_privacy_enabled) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::ACL_CreateClassicConnection( + const RawAddress& raw_address) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::ACL_CreateLeConnection( + const tBLE_BD_ADDR& legacy_address_with_type) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::ACL_WriteData(uint16_t handle, const BT_HDR* p_buf) { + mock_function_count_map[__func__]++; +} diff --git a/stack/test/common/mock_main_shim_btm_api.cc b/stack/test/common/mock_main_shim_btm_api.cc new file mode 100644 index 000000000..44a8731dc --- /dev/null +++ b/stack/test/common/mock_main_shim_btm_api.cc @@ -0,0 +1,447 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:85 + */ + +#include +#include + +extern std::map mock_function_count_map; + +#include +#include +#include "common/metric_id_allocator.h" +#include "common/time_util.h" +#include "device/include/controller.h" +#include "main/shim/btm_api.h" +#include "main/shim/controller.h" +#include "main/shim/shim.h" +#include "stack/btm/btm_int_types.h" +#include "types/raw_address.h" + +#ifndef UNUSED_ATTR +#define UNUSED_ATTR +#endif + +Octet16 octet16; + +bool bluetooth::shim::BTM_BleDataSignature(const RawAddress& bd_addr, + uint8_t* p_text, uint16_t len, + BLE_SIGNATURE signature) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::BTM_BleLocalPrivacyEnabled(void) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::BTM_BleSecurityProcedureIsRunning( + const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::BTM_BleVerifySignature(const RawAddress& bd_addr, + uint8_t* p_orig, uint16_t len, + uint32_t counter, + uint8_t* p_comp) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::BTM_GetLeSecurityState(const RawAddress& bd_addr, + uint8_t* p_le_dev_sec_flags, + uint8_t* p_le_key_size) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::BTM_HasEirService(const uint32_t* p_eir_uuid, + uint16_t uuid16) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::BTM_ReadConnectedTransportAddress( + RawAddress* remote_bda, tBT_TRANSPORT transport) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::BTM_ReadRemoteConnectionAddr( + const RawAddress& pseudo_addr, RawAddress& conn_addr, + tBLE_ADDR_TYPE* p_addr_type) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::BTM_SecAddDevice(const RawAddress& bd_addr, + DEV_CLASS dev_class, BD_NAME bd_name, + uint8_t* features, LinkKey* link_key, + uint8_t key_type, uint8_t pin_length) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::BTM_SecAddRmtNameNotifyCallback( + tBTM_RMT_NAME_CALLBACK* p_callback) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::BTM_SecDeleteDevice(const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::BTM_SecDeleteRmtNameNotifyCallback( + tBTM_RMT_NAME_CALLBACK* p_callback) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::BTM_SecRegister(const tBTM_APPL_INFO* bta_callbacks) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::BTM_UseLeLink(const RawAddress& raw_address) { + mock_function_count_map[__func__]++; + return false; +} +char* bluetooth::shim::BTM_SecReadDevName(const RawAddress& address) { + mock_function_count_map[__func__]++; + return nullptr; +} +const Octet16& bluetooth::shim::BTM_GetDeviceEncRoot() { + mock_function_count_map[__func__]++; + return octet16; +} +const Octet16& bluetooth::shim::BTM_GetDeviceDHK() { + mock_function_count_map[__func__]++; + return octet16; +} +const Octet16& bluetooth::shim::BTM_GetDeviceIDRoot() { + mock_function_count_map[__func__]++; + return octet16; +} +tBTM_EIR_SEARCH_RESULT bluetooth::shim::BTM_HasInquiryEirService( + tBTM_INQ_RESULTS* p_results, uint16_t uuid16) { + mock_function_count_map[__func__]++; + return 0; +} +tBTM_INQ_INFO* bluetooth::shim::BTM_InqDbFirst(void) { + mock_function_count_map[__func__]++; + return nullptr; +} +tBTM_INQ_INFO* bluetooth::shim::BTM_InqDbNext(tBTM_INQ_INFO* p_cur) { + mock_function_count_map[__func__]++; + return nullptr; +} +tBTM_INQ_INFO* bluetooth::shim::BTM_InqDbRead(const RawAddress& p_bda) { + mock_function_count_map[__func__]++; + return nullptr; +} +tBTM_STATUS bluetooth::shim::BTM_BleObserve(bool start, uint8_t duration_sec, + tBTM_INQ_RESULTS_CB* p_results_cb, + tBTM_CMPL_CB* p_cmpl_cb) { + mock_function_count_map[__func__]++; + return 0; +} +tBTM_STATUS bluetooth::shim::BTM_CancelRemoteDeviceName(void) { + mock_function_count_map[__func__]++; + return 0; +} +tBTM_STATUS bluetooth::shim::BTM_ClearInqDb(const RawAddress* p_bda) { + mock_function_count_map[__func__]++; + return 0; +} +tBTM_STATUS bluetooth::shim::BTM_ReadRemoteDeviceName( + const RawAddress& raw_address, tBTM_CMPL_CB* callback, + tBT_TRANSPORT transport) { + mock_function_count_map[__func__]++; + return 0; +} +tBTM_STATUS bluetooth::shim::BTM_SecBond(const RawAddress& bd_addr, + tBLE_ADDR_TYPE addr_type, + tBT_TRANSPORT transport, + int device_type) { + mock_function_count_map[__func__]++; + return 0; +} +tBTM_STATUS bluetooth::shim::BTM_SecBondCancel(const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; + return 0; +} +tBTM_STATUS bluetooth::shim::BTM_SetBleDataLength(const RawAddress& bd_addr, + uint16_t tx_pdu_length) { + mock_function_count_map[__func__]++; + return 0; +} +tBTM_STATUS bluetooth::shim::BTM_SetConnectability(uint16_t page_mode, + uint16_t window, + uint16_t interval) { + mock_function_count_map[__func__]++; + return 0; +} +tBTM_STATUS bluetooth::shim::BTM_SetDeviceClass(DEV_CLASS dev_class) { + mock_function_count_map[__func__]++; + return 0; +} +tBTM_STATUS bluetooth::shim::BTM_SetDiscoverability(uint16_t discoverable_mode, + uint16_t window, + uint16_t interval) { + mock_function_count_map[__func__]++; + return 0; +} +tBTM_STATUS bluetooth::shim::BTM_SetEncryption(const RawAddress& bd_addr, + tBT_TRANSPORT transport, + tBTM_SEC_CALLBACK* p_callback, + void* p_ref_data, + tBTM_BLE_SEC_ACT sec_act) { + mock_function_count_map[__func__]++; + return 0; +} +tBTM_STATUS bluetooth::shim::BTM_SetInquiryMode(uint8_t inquiry_mode) { + mock_function_count_map[__func__]++; + return 0; +} +tBTM_STATUS bluetooth::shim::BTM_StartInquiry(tBTM_INQ_RESULTS_CB* p_results_cb, + tBTM_CMPL_CB* p_cmpl_cb) { + mock_function_count_map[__func__]++; + return 0; +} +tBTM_STATUS bluetooth::shim::BTM_WriteEIR(BT_HDR* p_buff) { + mock_function_count_map[__func__]++; + return 0; +} +tBTM_STATUS bluetooth::shim::btm_sec_mx_access_request( + const RawAddress& bd_addr, bool is_originator, + uint16_t security_requirement, tBTM_SEC_CALLBACK* p_callback, + void* p_ref_data) { + mock_function_count_map[__func__]++; + return 0; +} +uint16_t bluetooth::shim::BTM_GetHCIConnHandle(const RawAddress& remote_bda, + tBT_TRANSPORT transport) { + mock_function_count_map[__func__]++; + return 0; +} +uint16_t bluetooth::shim::BTM_IsInquiryActive(void) { + mock_function_count_map[__func__]++; + return 0; +} +uint8_t bluetooth::shim::BTM_BleGetSupportedKeySize(const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; + return 0; +} +uint8_t bluetooth::shim::BTM_BleMaxMultiAdvInstanceCount() { + mock_function_count_map[__func__]++; + return 0; +} +uint8_t bluetooth::shim::BTM_GetEirSupportedServices(uint32_t* p_eir_uuid, + uint8_t** p, + uint8_t max_num_uuid16, + uint8_t* p_num_uuid16) { + mock_function_count_map[__func__]++; + return 0; +} +uint8_t bluetooth::shim::BTM_GetEirUuidList(uint8_t* p_eir, size_t eir_len, + uint8_t uuid_size, + uint8_t* p_num_uuid, + uint8_t* p_uuid_list, + uint8_t max_num_uuid) { + mock_function_count_map[__func__]++; + return 0; +} +void bluetooth::shim::BTM_AddEirService(uint32_t* p_eir_uuid, uint16_t uuid16) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_BleAdvFilterParamSetup( + int action, tBTM_BLE_PF_FILT_INDEX filt_index, + std::unique_ptr p_filt_params, + tBTM_BLE_PF_PARAM_CB cb) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_BleEnableDisableFilterFeature( + uint8_t enable, tBTM_BLE_PF_STATUS_CBACK p_stat_cback) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_BleLoadLocalKeys(uint8_t key_type, + tBTM_BLE_LOCAL_KEYS* p_key) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_BleOobDataReply(const RawAddress& bd_addr, + uint8_t res, uint8_t len, + uint8_t* p_data) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_BleReadPhy( + const RawAddress& bd_addr, + base::Callback cb) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_BleReceiverTest(uint8_t rx_freq, + tBTM_CMPL_CB* p_cmd_cmpl_cback) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_BleSecureConnectionOobDataReply( + const RawAddress& bd_addr, uint8_t* p_c, uint8_t* p_r) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_BleSetConnScanParams(uint32_t scan_interval, + uint32_t scan_window) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_BleSetPhy(const RawAddress& bd_addr, uint8_t tx_phys, + uint8_t rx_phys, uint16_t phy_options) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_BleSetPrefConnParams(const RawAddress& bd_addr, + uint16_t min_conn_int, + uint16_t max_conn_int, + uint16_t peripheral_latency, + uint16_t supervision_tout) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_BleTestEnd(tBTM_CMPL_CB* p_cmd_cmpl_cback) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_BleTransmitterTest(uint8_t tx_freq, + uint8_t test_data_len, + uint8_t packet_payload, + tBTM_CMPL_CB* p_cmd_cmpl_cback) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_CancelInquiry(void) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_ConfirmReqReply(tBTM_STATUS res, + const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_EnableInterlacedInquiryScan() { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_EnableInterlacedPageScan() { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_LE_PF_addr_filter(tBTM_BLE_SCAN_COND_OP action, + tBTM_BLE_PF_FILT_INDEX filt_index, + tBLE_BD_ADDR addr, + tBTM_BLE_PF_CFG_CBACK cb) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_LE_PF_clear(tBTM_BLE_PF_FILT_INDEX filt_index, + tBTM_BLE_PF_CFG_CBACK cb) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_LE_PF_local_name(tBTM_BLE_SCAN_COND_OP action, + tBTM_BLE_PF_FILT_INDEX filt_index, + std::vector name, + tBTM_BLE_PF_CFG_CBACK cb) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_LE_PF_manu_data( + tBTM_BLE_SCAN_COND_OP action, tBTM_BLE_PF_FILT_INDEX filt_index, + uint16_t company_id, uint16_t company_id_mask, std::vector data, + std::vector data_mask, tBTM_BLE_PF_CFG_CBACK cb) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_LE_PF_set(tBTM_BLE_PF_FILT_INDEX filt_index, + std::vector commands, + tBTM_BLE_PF_CFG_CBACK cb) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_LE_PF_srvc_data(tBTM_BLE_SCAN_COND_OP action, + tBTM_BLE_PF_FILT_INDEX filt_index) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_LE_PF_srvc_data_pattern( + tBTM_BLE_SCAN_COND_OP action, tBTM_BLE_PF_FILT_INDEX filt_index, + std::vector data, std::vector data_mask, + tBTM_BLE_PF_CFG_CBACK cb) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_LE_PF_uuid_filter(tBTM_BLE_SCAN_COND_OP action, + tBTM_BLE_PF_FILT_INDEX filt_index, + tBTM_BLE_PF_COND_TYPE filter_type, + const bluetooth::Uuid& uuid, + tBTM_BLE_PF_LOGIC_TYPE cond_logic, + const bluetooth::Uuid& uuid_mask, + tBTM_BLE_PF_CFG_CBACK cb) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_PINCodeReply(const RawAddress& bd_addr, uint8_t res, + uint8_t pin_len, uint8_t* p_pin) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_ReadConnectionAddr(const RawAddress& remote_bda, + RawAddress& local_conn_addr, + tBLE_ADDR_TYPE* p_addr_type) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_ReadDevInfo(const RawAddress& remote_bda, + tBT_DEVICE_TYPE* p_dev_type, + tBLE_ADDR_TYPE* p_addr_type) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_RemoteOobDataReply(tBTM_STATUS res, + const RawAddress& bd_addr, + const Octet16& c, + const Octet16& r) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_RemoveEirService(uint32_t* p_eir_uuid, + uint16_t uuid16) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_SecAddBleDevice(const RawAddress& bd_addr, + tBT_DEVICE_TYPE dev_type, + tBLE_ADDR_TYPE addr_type) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_SecAddBleKey(const RawAddress& bd_addr, + tBTM_LE_KEY_VALUE* p_le_key, + tBTM_LE_KEY_TYPE key_type) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_SecClearSecurityFlags(const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::BTM_SecurityGrant(const RawAddress& bd_addr, + uint8_t res) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::SendRemoteNameRequest(const RawAddress& raw_address) { + mock_function_count_map[__func__]++; +} +void btm_api_process_extended_inquiry_result(RawAddress raw_address, + uint8_t page_scan_rep_mode, + DEV_CLASS device_class, + uint16_t clock_offset, int8_t rssi, + const uint8_t* eir_data, + size_t eir_len) { + mock_function_count_map[__func__]++; +} +void btm_api_process_inquiry_result(const RawAddress& raw_address, + uint8_t page_scan_rep_mode, + DEV_CLASS device_class, + uint16_t clock_offset) { + mock_function_count_map[__func__]++; +} +void btm_api_process_inquiry_result_with_rssi(RawAddress raw_address, + uint8_t page_scan_rep_mode, + DEV_CLASS device_class, + uint16_t clock_offset, + int8_t rssi) { + mock_function_count_map[__func__]++; +} diff --git a/stack/test/common/mock_main_shim_controller.cc b/stack/test/common/mock_main_shim_controller.cc new file mode 100644 index 000000000..8e4c9f5c2 --- /dev/null +++ b/stack/test/common/mock_main_shim_controller.cc @@ -0,0 +1,36 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:5 + */ + +#include +#include + +extern std::map mock_function_count_map; + +#include "main/shim/controller.h" + +#ifndef UNUSED_ATTR +#define UNUSED_ATTR +#endif + +const controller_t* bluetooth::shim::controller_get_interface() { + mock_function_count_map[__func__]++; + return nullptr; +} diff --git a/stack/test/common/mock_main_shim_l2c_api.cc b/stack/test/common/mock_main_shim_l2c_api.cc new file mode 100644 index 000000000..d191acbbd --- /dev/null +++ b/stack/test/common/mock_main_shim_l2c_api.cc @@ -0,0 +1,213 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:54 + */ + +#include +#include + +extern std::map mock_function_count_map; + +#include "main/shim/l2c_api.h" + +#ifndef UNUSED_ATTR +#define UNUSED_ATTR +#endif + +bool bluetooth::shim::L2CA_RegisterFixedChannel(uint16_t cid, + tL2CAP_FIXED_CHNL_REG* p_freg) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::L2CA_ConnectCreditBasedRsp( + const RawAddress& bd_addr, uint8_t id, + std::vector& accepted_lcids, uint16_t result, + tL2CAP_LE_CFG_INFO* p_cfg) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::L2CA_ConnectFixedChnl(uint16_t cid, + const RawAddress& rem_bda) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::L2CA_ConnectFixedChnl(uint16_t cid, + const RawAddress& rem_bda, + uint8_t initiating_phys) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::L2CA_DisconnectLECocReq(uint16_t cid) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::L2CA_DisconnectReq(uint16_t cid) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::L2CA_GetPeerFeatures(const RawAddress& bd_addr, + uint32_t* p_ext_feat, + uint8_t* p_chnl_mask) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::L2CA_GetPeerLECocConfig(uint16_t cid, + tL2CAP_LE_CFG_INFO* peer_cfg) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::L2CA_GetRemoteCid(uint16_t lcid, uint16_t* rcid) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::L2CA_IsLinkEstablished(const RawAddress& bd_addr, + tBT_TRANSPORT transport) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::L2CA_ReconfigCreditBasedConnsReq( + const RawAddress& bd_addr, std::vector& lcids, + tL2CAP_LE_CFG_INFO* p_cfg) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::L2CA_RemoveFixedChnl(uint16_t cid, + const RawAddress& rem_bda) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::L2CA_SetAclPriority(const RawAddress& bd_addr, + tL2CAP_PRIORITY priority) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::L2CA_SetChnlFlushability(uint16_t cid, + bool is_flushable) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::L2CA_SetFixedChannelTout(const RawAddress& rem_bda, + uint16_t fixed_cid, + uint16_t idle_tout) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::L2CA_SetIdleTimeoutByBdAddr(const RawAddress& bd_addr, + uint16_t timeout, + tBT_TRANSPORT transport) { + mock_function_count_map[__func__]++; + return false; +} +bool bluetooth::shim::L2CA_SetTxPriority(uint16_t cid, + tL2CAP_CHNL_PRIORITY priority) { + mock_function_count_map[__func__]++; + return false; +} +uint16_t bluetooth::shim::L2CA_AllocateLePSM(void) { + mock_function_count_map[__func__]++; + return 0; +} +uint16_t bluetooth::shim::L2CA_ConnectLECocReq(uint16_t psm, + const RawAddress& p_bd_addr, + tL2CAP_LE_CFG_INFO* p_cfg) { + mock_function_count_map[__func__]++; + return 0; +} +uint16_t bluetooth::shim::L2CA_ConnectReq(uint16_t psm, + const RawAddress& raw_address) { + mock_function_count_map[__func__]++; + return 0; +} +uint16_t bluetooth::shim::L2CA_FlushChannel(uint16_t lcid, + uint16_t num_to_flush) { + mock_function_count_map[__func__]++; + return 0; +} +uint16_t bluetooth::shim::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) { + mock_function_count_map[__func__]++; + return 0; +} +uint16_t bluetooth::shim::L2CA_SendFixedChnlData(uint16_t cid, + const RawAddress& rem_bda, + BT_HDR* p_buf) { + mock_function_count_map[__func__]++; + return 0; +} +uint16_t find_classic_cid_token_by_psm_address(uint16_t psm, + RawAddress remote) { + mock_function_count_map[__func__]++; + return 0; +} +uint16_t find_le_cid_token_by_psm_address(uint16_t psm, RawAddress remote) { + mock_function_count_map[__func__]++; + return 0; +} +uint8_t bluetooth::shim::L2CA_DataWrite(uint16_t cid, BT_HDR* p_data) { + mock_function_count_map[__func__]++; + return 0; +} +uint8_t bluetooth::shim::L2CA_LECocDataWrite(uint16_t cid, BT_HDR* p_data) { + mock_function_count_map[__func__]++; + return 0; +} +void bluetooth::shim::L2CA_ConnectForSecurity(const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::L2CA_Deregister(uint16_t client_psm) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::L2CA_DeregisterLECoc(uint16_t psm) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::L2CA_FreeLePSM(uint16_t psm) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::L2CA_SetBondingState(const RawAddress& bd_addr, + bool is_bonding) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::L2CA_SwitchRoleToCentral(const RawAddress& addr) { + mock_function_count_map[__func__]++; +} +void bluetooth::shim::L2CA_UseLegacySecurityModule() { + mock_function_count_map[__func__]++; +} +void remove_classic_cid_token_entry(uint16_t cid_token) { + mock_function_count_map[__func__]++; +} +void remove_le_cid_token_entry(uint16_t cid_token) { + mock_function_count_map[__func__]++; +} +bool bluetooth::shim::L2CA_ReadRemoteVersion(const RawAddress& addr, + uint8_t* lmp_version, + uint16_t* manufacturer, + uint16_t* lmp_sub_version) { + mock_function_count_map[__func__]++; + return false; +} +void bluetooth::shim::L2CA_DisconnectLink(const RawAddress& remote) { + mock_function_count_map[__func__]++; +} +uint16_t bluetooth::shim::L2CA_GetNumLinks() { + mock_function_count_map[__func__]++; + return 0; +} diff --git a/stack/test/common/mock_smp_smp_act.cc b/stack/test/common/mock_smp_smp_act.cc new file mode 100644 index 000000000..b3e2390f1 --- /dev/null +++ b/stack/test/common/mock_smp_smp_act.cc @@ -0,0 +1,252 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:73 + */ + +#include +#include + +extern std::map mock_function_count_map; + +#include "stack/smp/smp_int.h" +#include "types/raw_address.h" + +#ifndef UNUSED_ATTR +#define UNUSED_ATTR +#endif + +bool smp_proc_ltk_request(const RawAddress& bda) { + mock_function_count_map[__func__]++; + return false; +} +void smp_both_have_public_keys(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_br_check_authorization_request(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_br_pairing_complete(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_br_process_link_key(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_br_process_pairing_command(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_br_process_peripheral_keys_response(tSMP_CB* p_cb, + tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_br_process_security_grant(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_br_select_next_key(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_br_send_pair_response(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_cancel_start_encryption_attempt() { + mock_function_count_map[__func__]++; +} +void smp_check_auth_req(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_decide_association_model(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_derive_link_key_from_long_term_key(tSMP_CB* p_cb, + tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_enc_cmpl(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_idle_terminate(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_key_distribution(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_key_distribution_by_transport(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_key_pick_key(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_link_encrypted(const RawAddress& bda, uint8_t encr_enable) { + mock_function_count_map[__func__]++; +} +void smp_match_dhkey_checks(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_move_to_secure_connections_phase2(tSMP_CB* p_cb, + tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_pair_terminate(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_pairing_cmpl(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_phase_2_dhkey_checks_are_present(tSMP_CB* p_cb, + tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_proc_central_id(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_proc_compare(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_proc_confirm(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_proc_discard(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_proc_enc_info(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_proc_id_addr(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_proc_id_info(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_proc_init(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_proc_pair_cmd(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_proc_pair_fail(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_proc_rand(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_proc_sec_grant(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_proc_sec_req(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_proc_sl_key(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_proc_srk_info(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_process_dhkey_check(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_process_io_response(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_process_keypress_notification(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_process_local_nonce(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_process_pairing_commitment(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_process_pairing_public_key(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_process_peer_nonce(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_process_secure_connection_long_term_key(void) { + mock_function_count_map[__func__]++; +} +void smp_process_secure_connection_oob_data(tSMP_CB* p_cb, + tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_send_app_cback(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_send_commitment(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_send_confirm(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_send_csrk_info(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_send_dhkey_check(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_send_enc_info(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_send_id_info(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_send_init(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_send_keypress_notification(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_send_ltk_reply(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_send_pair_fail(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_send_pair_public_key(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_send_pair_req(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_send_pair_rsp(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_send_rand(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_set_derive_link_key(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_set_local_oob_keys(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_set_local_oob_random_commitment(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_start_enc(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_start_passkey_verification(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_start_secure_connection_phase1(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} +void smp_wait_for_both_public_keys(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { + mock_function_count_map[__func__]++; +} diff --git a/stack/test/common/mock_smp_smp_api.cc b/stack/test/common/mock_smp_smp_api.cc new file mode 100644 index 000000000..df96f7397 --- /dev/null +++ b/stack/test/common/mock_smp_smp_api.cc @@ -0,0 +1,81 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:11 + */ + +#include +#include + +extern std::map mock_function_count_map; + +#include +#include "bt_target.h" +#include "btm_int.h" +#include "hcimsgs.h" +#include "main/shim/shim.h" +#include "stack/btm/btm_dev.h" +#include "stack/include/l2c_api.h" +#include "stack/include/l2cdefs.h" +#include "stack/include/smp_api.h" +#include "stack/smp/smp_int.h" +#include "stack_config.h" +#include "utils/include/bt_utils.h" + +#ifndef UNUSED_ATTR +#define UNUSED_ATTR +#endif + +bool SMP_PairCancel(const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; + return false; +} +bool SMP_Register(tSMP_CALLBACK* p_cback) { + mock_function_count_map[__func__]++; + return false; +} +tSMP_STATUS SMP_BR_PairWith(const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; + return 0; +} +tSMP_STATUS SMP_Pair(const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; + return 0; +} +uint8_t SMP_SetTraceLevel(uint8_t new_level) { + mock_function_count_map[__func__]++; + return 0; +} +void SMP_ConfirmReply(const RawAddress& bd_addr, uint8_t res) { + mock_function_count_map[__func__]++; +} +void SMP_Init(void) { mock_function_count_map[__func__]++; } +void SMP_OobDataReply(const RawAddress& bd_addr, tSMP_STATUS res, uint8_t len, + uint8_t* p_data) { + mock_function_count_map[__func__]++; +} +void SMP_PasskeyReply(const RawAddress& bd_addr, uint8_t res, + uint32_t passkey) { + mock_function_count_map[__func__]++; +} +void SMP_SecureConnectionOobDataReply(uint8_t* p_data) { + mock_function_count_map[__func__]++; +} +void SMP_SecurityGrant(const RawAddress& bd_addr, uint8_t res) { + mock_function_count_map[__func__]++; +} -- 2.11.0