Loading system/bta/dm/bta_dm_act.cc +6 −0 Original line number Diff line number Diff line Loading @@ -4781,6 +4781,12 @@ tBT_TRANSPORT bta_dm_determine_discovery_transport(const RawAddress& bd_addr) { return ::bta_dm_determine_discovery_transport(bd_addr); } tBTM_STATUS bta_dm_sp_cback(tBTM_SP_EVT event, tBTM_SP_EVT_DATA* p_data) { return ::bta_dm_sp_cback(event, p_data); } void btm_set_local_io_caps(uint8_t io_caps) { ::btm_local_io_caps = io_caps; } } // namespace testing } // namespace legacy } // namespace bluetooth system/bta/test/bta_dm_test.cc +188 −6 Original line number Diff line number Diff line Loading @@ -16,10 +16,13 @@ #include <base/functional/bind.h> #include <base/location.h> #include <gmock/gmock.h> #include <gtest/gtest.h> #include <chrono> #include <iostream> #include <memory> #include <string> #include "bta/dm/bta_dm_int.h" #include "bta/hf_client/bta_hf_client_int.h" Loading @@ -29,6 +32,8 @@ #include "btif/include/stack_manager.h" #include "common/message_loop_thread.h" #include "osi/include/compat.h" #include "stack/include/bt_dev_class.h" #include "stack/include/bt_name.h" #include "stack/include/btm_status.h" #include "test/common/main_handler.h" #include "test/common/mock_functions.h" Loading @@ -36,9 +41,11 @@ #include "test/mock/mock_osi_alarm.h" #include "test/mock/mock_osi_allocator.h" #include "test/mock/mock_stack_acl.h" #include "test/mock/mock_stack_btm_inq.h" #include "test/mock/mock_stack_btm_sec.h" using namespace std::chrono_literals; using ::testing::ElementsAre; extern struct btm_client_interface_t btm_client_interface; Loading @@ -50,12 +57,9 @@ namespace { constexpr uint8_t kUnusedTimer = BTA_ID_MAX; const RawAddress kRawAddress({0x11, 0x22, 0x33, 0x44, 0x55, 0x66}); const RawAddress kRawAddress2({0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc}); constexpr char kRemoteName[] = "TheRemoteName"; const DEV_CLASS kDeviceClass = {0x11, 0x22, 0x33}; const char* test_flags[] = { "INIT_logging_debug_enabled_for_all=true", nullptr, }; constexpr char kRemoteName[] = "TheRemoteName"; bool bta_dm_search_sm_execute(BT_HDR_RIGID* p_msg) { return true; } void bta_dm_search_sm_disable() { bta_sys_deregister(BTA_ID_DM_SEARCH); } Loading @@ -69,7 +73,6 @@ class BtaDmTest : public testing::Test { protected: void SetUp() override { reset_mock_function_count_map(); bluetooth::common::InitFlags::Load(test_flags); fake_osi_ = std::make_unique<test::fake::FakeOsi>(); main_thread_start_up(); Loading Loading @@ -226,6 +229,10 @@ void bta_dm_remname_cback(const tBTM_REMOTE_DEV_NAME* p); tBT_TRANSPORT bta_dm_determine_discovery_transport( const RawAddress& remote_bd_addr); void btm_set_local_io_caps(uint8_t io_caps); tBTM_STATUS bta_dm_sp_cback(tBTM_SP_EVT event, tBTM_SP_EVT_DATA* p_data); } // namespace testing } // namespace legacy } // namespace bluetooth Loading Loading @@ -516,3 +523,178 @@ TEST_F(BtaDmTest, bta_dm_remote_name_cmpl) { bta_dm_remote_name_cmpl(&msg); ASSERT_EQ(1, get_func_call_count("BTM_InqDbRead")); } TEST_F(BtaDmTest, bta_dm_sp_cback__BTM_SP_CFM_REQ_EVT_WithName) { constexpr uint32_t kNumVal = 1234; static bool callback_sent = false; static tBTA_DM_SP_CFM_REQ cfm_req{}; bta_dm_enable([](tBTA_DM_SEC_EVT event, tBTA_DM_SEC* p_data) { callback_sent = true; cfm_req = p_data->cfm_req; }); bluetooth::legacy::testing::btm_set_local_io_caps(0xff); tBTM_SP_EVT_DATA data = { .cfm_req = { // tBTM_SP_CFM_REQ .bd_addr = kRawAddress, .dev_class = {}, .bd_name = {}, .num_val = kNumVal, .just_works = false, .loc_auth_req = BTM_AUTH_SP_YES, .rmt_auth_req = BTM_AUTH_SP_YES, .loc_io_caps = BTM_IO_CAP_NONE, .rmt_io_caps = BTM_IO_CAP_NONE, }, }; dev_class_copy(data.cfm_req.dev_class, kDeviceClass); bd_name_copy(data.cfm_req.bd_name, kRemoteName); ASSERT_EQ(btm_status_text(BTM_CMD_STARTED), btm_status_text(bluetooth::legacy::testing::bta_dm_sp_cback( BTM_SP_CFM_REQ_EVT, &data))); ASSERT_EQ(kNumVal, bta_dm_cb.num_val); ASSERT_TRUE(callback_sent); ASSERT_EQ(kRawAddress, cfm_req.bd_addr); ASSERT_THAT(cfm_req.dev_class, ElementsAre(kDeviceClass[0], kDeviceClass[1], kDeviceClass[2])); ASSERT_STREQ(kRemoteName, reinterpret_cast<const char*>(cfm_req.bd_name)); ASSERT_EQ(kNumVal, cfm_req.num_val); ASSERT_EQ(false, cfm_req.just_works); ASSERT_EQ(BTM_AUTH_SP_YES, cfm_req.loc_auth_req); ASSERT_EQ(BTM_AUTH_SP_YES, cfm_req.rmt_auth_req); ASSERT_EQ(BTM_IO_CAP_NONE, cfm_req.loc_io_caps); ASSERT_EQ(BTM_IO_CAP_NONE, cfm_req.rmt_io_caps); } TEST_F(BtaDmTest, bta_dm_sp_cback__BTM_SP_CFM_REQ_EVT_WithoutName_RNRSuccess) { constexpr uint32_t kNumVal = 1234; static bool callback_sent = false; test::mock::stack_btm_inq::BTM_ReadRemoteDeviceName.body = [](const RawAddress& remote_bda, tBTM_NAME_CMPL_CB* p_cb, tBT_TRANSPORT transport) { return BTM_CMD_STARTED; }; static tBTA_DM_SP_CFM_REQ cfm_req{}; bta_dm_enable([](tBTA_DM_SEC_EVT event, tBTA_DM_SEC* p_data) { callback_sent = true; cfm_req = p_data->cfm_req; }); bluetooth::legacy::testing::btm_set_local_io_caps(0xff); tBTM_SP_EVT_DATA data = { .cfm_req = { // tBTM_SP_CFM_REQ .bd_addr = kRawAddress, .dev_class = {}, .bd_name = {0}, .num_val = kNumVal, .just_works = false, .loc_auth_req = BTM_AUTH_SP_YES, .rmt_auth_req = BTM_AUTH_SP_YES, .loc_io_caps = BTM_IO_CAP_NONE, .rmt_io_caps = BTM_IO_CAP_NONE, }, }; dev_class_copy(data.cfm_req.dev_class, kDeviceClass); ASSERT_EQ(btm_status_text(BTM_CMD_STARTED), btm_status_text(bluetooth::legacy::testing::bta_dm_sp_cback( BTM_SP_CFM_REQ_EVT, &data))); ASSERT_EQ(kNumVal, bta_dm_cb.num_val); ASSERT_FALSE(callback_sent); test::mock::stack_btm_inq::BTM_ReadRemoteDeviceName = {}; } TEST_F(BtaDmTest, bta_dm_sp_cback__BTM_SP_CFM_REQ_EVT_WithoutName_RNRFail) { constexpr uint32_t kNumVal = 1234; static bool callback_sent = false; test::mock::stack_btm_inq::BTM_ReadRemoteDeviceName.body = [](const RawAddress& remote_bda, tBTM_NAME_CMPL_CB* p_cb, tBT_TRANSPORT transport) { return BTM_SUCCESS; }; static tBTA_DM_SP_CFM_REQ cfm_req{}; bta_dm_enable([](tBTA_DM_SEC_EVT event, tBTA_DM_SEC* p_data) { callback_sent = true; cfm_req = p_data->cfm_req; }); bluetooth::legacy::testing::btm_set_local_io_caps(0xff); tBTM_SP_EVT_DATA data = { .cfm_req = { // tBTM_SP_CFM_REQ .bd_addr = kRawAddress, .dev_class = {}, .bd_name = {0}, .num_val = kNumVal, .just_works = false, .loc_auth_req = BTM_AUTH_SP_YES, .rmt_auth_req = BTM_AUTH_SP_YES, .loc_io_caps = BTM_IO_CAP_NONE, .rmt_io_caps = BTM_IO_CAP_NONE, }, }; dev_class_copy(data.cfm_req.dev_class, kDeviceClass); ASSERT_EQ(btm_status_text(BTM_CMD_STARTED), btm_status_text(bluetooth::legacy::testing::bta_dm_sp_cback( BTM_SP_CFM_REQ_EVT, &data))); ASSERT_EQ(kNumVal, bta_dm_cb.num_val); ASSERT_TRUE(callback_sent); ASSERT_EQ(kRawAddress, cfm_req.bd_addr); ASSERT_THAT(cfm_req.dev_class, ElementsAre(kDeviceClass[0], kDeviceClass[1], kDeviceClass[2])); ASSERT_EQ(kNumVal, cfm_req.num_val); ASSERT_EQ(false, cfm_req.just_works); ASSERT_EQ(BTM_AUTH_SP_YES, cfm_req.loc_auth_req); ASSERT_EQ(BTM_AUTH_SP_YES, cfm_req.rmt_auth_req); ASSERT_EQ(BTM_IO_CAP_NONE, cfm_req.loc_io_caps); ASSERT_EQ(BTM_IO_CAP_NONE, cfm_req.rmt_io_caps); test::mock::stack_btm_inq::BTM_ReadRemoteDeviceName = {}; } TEST_F(BtaDmTest, bta_dm_sp_cback__BTM_SP_KEY_NOTIF_EVT) { constexpr uint32_t kPassKey = 1234; static bool callback_sent = false; static tBTA_DM_SP_KEY_NOTIF key_notif{}; bta_dm_enable([](tBTA_DM_SEC_EVT event, tBTA_DM_SEC* p_data) { callback_sent = true; key_notif = p_data->key_notif; }); bluetooth::legacy::testing::btm_set_local_io_caps(0xff); tBTM_SP_EVT_DATA data = { .key_notif = { // tBTM_SP_KEY_NOTIF .bd_addr = kRawAddress, .dev_class = {}, .bd_name = {}, .passkey = kPassKey, }, }; dev_class_copy(data.key_notif.dev_class, kDeviceClass); bd_name_copy(data.key_notif.bd_name, kRemoteName); ASSERT_EQ(btm_status_text(BTM_CMD_STARTED), btm_status_text(bluetooth::legacy::testing::bta_dm_sp_cback( BTM_SP_KEY_NOTIF_EVT, &data))); ASSERT_EQ(kPassKey, bta_dm_cb.num_val); ASSERT_TRUE(callback_sent); ASSERT_EQ(kRawAddress, key_notif.bd_addr); ASSERT_THAT(key_notif.dev_class, ElementsAre(kDeviceClass[0], kDeviceClass[1], kDeviceClass[2])); ASSERT_STREQ(kRemoteName, reinterpret_cast<const char*>(key_notif.bd_name)); ASSERT_EQ(kPassKey, key_notif.passkey); } system/stack/include/bt_dev_class.h +6 −0 Original line number Diff line number Diff line Loading @@ -123,6 +123,12 @@ inline constexpr DEV_CLASS kDevClassEmpty = {}; } #ifdef __cplusplus inline void dev_class_copy(DEV_CLASS& dst, const DEV_CLASS& src) { dst[0] = src[0]; dst[1] = src[1]; dst[2] = src[2]; } #include <sstream> inline std::string dev_class_text(const DEV_CLASS& dev_class) { std::ostringstream oss; Loading system/stack/include/bt_name.h +4 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,10 @@ typedef uint8_t tBTM_LOC_BD_NAME[BTM_MAX_LOC_BD_NAME_LEN + 1]; inline constexpr tBTM_BD_NAME kBtmBdNameEmpty = {}; constexpr size_t kBdNameLength = static_cast<size_t>(BD_NAME_LEN); inline size_t bd_name_copy(BD_NAME bd_name_dest, const char* src) { return strlcpy(reinterpret_cast<char*>(bd_name_dest), const_cast<char*>(src), kBdNameLength + 1); } inline size_t bd_name_copy(BD_NAME bd_name_dest, const BD_NAME bd_name_src) { return strlcpy(reinterpret_cast<char*>(bd_name_dest), reinterpret_cast<const char*>(bd_name_src), kBdNameLength + 1); Loading system/test/mock/mock_stack_btm_inq.cc +207 −78 Original line number Diff line number Diff line /* * Copyright 2020 The Android Open Source Project * Copyright 2023 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. Loading @@ -13,170 +13,299 @@ * See the License for the specific language governing permissions and * limitations under the License. */ /* * Generated mock file from original source file * Functions generated:44 * Functions generated:43 * * mockcify.pl ver 0.6.0 */ #include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <cstdint> #include <functional> #include <map> #include <string> #include "advertise_data_parser.h" #include "btm_api.h" #include "common/time_util.h" #include "device/include/controller.h" #include "main/shim/btm_api.h" #include "main/shim/shim.h" #include "osi/include/log.h" #include "osi/include/osi.h" #include "stack/btm/btm_ble_int.h" #include "stack/btm/btm_int_types.h" #include "stack/include/acl_api.h" #include "stack/include/bt_hdr.h" #include "stack/include/btm_ble_api.h" #include "stack/include/inq_hci_link_interface.h" #include "test/common/mock_functions.h" #include "types/bluetooth/uuid.h" #include "types/raw_address.h" // Mock include file to share data between tests and mock #include "test/mock/mock_stack_btm_inq.h" #ifndef UNUSED_ATTR #define UNUSED_ATTR #endif // Original usings void SendRemoteNameRequest(const RawAddress& raw_address) { // Mocked internal structures, if any namespace test { namespace mock { namespace stack_btm_inq { // Function state capture and return values, if needed struct BTM_AddEirService BTM_AddEirService; struct BTM_CancelInquiry BTM_CancelInquiry; struct BTM_CancelRemoteDeviceName BTM_CancelRemoteDeviceName; struct BTM_ClearInqDb BTM_ClearInqDb; struct BTM_EnableInterlacedInquiryScan BTM_EnableInterlacedInquiryScan; struct BTM_EnableInterlacedPageScan BTM_EnableInterlacedPageScan; struct BTM_GetEirSupportedServices BTM_GetEirSupportedServices; struct BTM_GetEirUuidList BTM_GetEirUuidList; struct BTM_HasEirService BTM_HasEirService; struct BTM_HasInquiryEirService BTM_HasInquiryEirService; struct BTM_InqDbFirst BTM_InqDbFirst; struct BTM_InqDbNext BTM_InqDbNext; struct BTM_InqDbRead BTM_InqDbRead; struct BTM_IsInquiryActive BTM_IsInquiryActive; struct BTM_IsRemoteNameKnown BTM_IsRemoteNameKnown; struct BTM_ReadRemoteDeviceName BTM_ReadRemoteDeviceName; struct BTM_RemoveEirService BTM_RemoveEirService; struct BTM_SetConnectability BTM_SetConnectability; struct BTM_SetDiscoverability BTM_SetDiscoverability; struct BTM_SetInquiryMode BTM_SetInquiryMode; struct BTM_StartInquiry BTM_StartInquiry; struct BTM_WriteEIR BTM_WriteEIR; struct SendRemoteNameRequest SendRemoteNameRequest; struct btm_clear_all_pending_le_entry btm_clear_all_pending_le_entry; struct btm_clr_inq_db btm_clr_inq_db; struct btm_clr_inq_result_flt btm_clr_inq_result_flt; struct btm_initiate_rem_name btm_initiate_rem_name; struct btm_inq_clear_ssp btm_inq_clear_ssp; struct btm_inq_db_find btm_inq_db_find; struct btm_inq_db_free btm_inq_db_free; struct btm_inq_db_init btm_inq_db_init; struct btm_inq_db_new btm_inq_db_new; struct btm_inq_db_reset btm_inq_db_reset; struct btm_inq_find_bdaddr btm_inq_find_bdaddr; struct btm_inq_remote_name_timer_timeout btm_inq_remote_name_timer_timeout; struct btm_inq_rmt_name_failed_cancelled btm_inq_rmt_name_failed_cancelled; struct btm_inq_stop_on_ssp btm_inq_stop_on_ssp; struct btm_process_cancel_complete btm_process_cancel_complete; struct btm_process_inq_complete btm_process_inq_complete; struct btm_process_inq_results btm_process_inq_results; struct btm_process_remote_name btm_process_remote_name; struct btm_set_eir_uuid btm_set_eir_uuid; struct btm_sort_inq_result btm_sort_inq_result; } // namespace stack_btm_inq } // namespace mock } // namespace test // Mocked function return values, if any namespace test { namespace mock { namespace stack_btm_inq { tBTM_STATUS BTM_CancelRemoteDeviceName::return_value = 0; tBTM_STATUS BTM_ClearInqDb::return_value = 0; uint8_t BTM_GetEirSupportedServices::return_value = 0; uint8_t BTM_GetEirUuidList::return_value = 0; bool BTM_HasEirService::return_value = false; tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService::return_value = 0; tBTM_INQ_INFO* BTM_InqDbFirst::return_value = nullptr; tBTM_INQ_INFO* BTM_InqDbNext::return_value = nullptr; tBTM_INQ_INFO* BTM_InqDbRead::return_value = nullptr; uint16_t BTM_IsInquiryActive::return_value = 0; bool BTM_IsRemoteNameKnown::return_value = false; tBTM_STATUS BTM_ReadRemoteDeviceName::return_value = 0; tBTM_STATUS BTM_SetConnectability::return_value = 0; tBTM_STATUS BTM_SetDiscoverability::return_value = 0; tBTM_STATUS BTM_SetInquiryMode::return_value = 0; tBTM_STATUS BTM_StartInquiry::return_value = 0; tBTM_STATUS BTM_WriteEIR::return_value = 0; tBTM_STATUS btm_initiate_rem_name::return_value = 0; tINQ_DB_ENT* btm_inq_db_find::return_value = nullptr; tINQ_DB_ENT* btm_inq_db_new::return_value = nullptr; bool btm_inq_find_bdaddr::return_value = false; } // namespace stack_btm_inq } // namespace mock } // namespace test // Mocked functions, if any void BTM_AddEirService(uint32_t* p_eir_uuid, uint16_t uuid16) { inc_func_call_count(__func__); test::mock::stack_btm_inq::BTM_AddEirService(p_eir_uuid, uuid16); } bool BTM_HasEirService(const uint32_t* p_eir_uuid, uint16_t uuid16) { void BTM_CancelInquiry(void) { inc_func_call_count(__func__); return false; test::mock::stack_btm_inq::BTM_CancelInquiry(); } bool btm_inq_find_bdaddr(const RawAddress& p_bda) { tBTM_STATUS BTM_CancelRemoteDeviceName(void) { inc_func_call_count(__func__); return test::mock::stack_btm_inq::BTM_CancelRemoteDeviceName(); } tBTM_STATUS BTM_ClearInqDb(const RawAddress* p_bda) { inc_func_call_count(__func__); return test::mock::stack_btm_inq::BTM_ClearInqDb(p_bda); } void BTM_EnableInterlacedInquiryScan() { inc_func_call_count(__func__); test::mock::stack_btm_inq::BTM_EnableInterlacedInquiryScan(); } void BTM_EnableInterlacedPageScan() { inc_func_call_count(__func__); test::mock::stack_btm_inq::BTM_EnableInterlacedPageScan(); } uint8_t BTM_GetEirSupportedServices(uint32_t* p_eir_uuid, uint8_t** p, uint8_t max_num_uuid16, uint8_t* p_num_uuid16) { inc_func_call_count(__func__); return test::mock::stack_btm_inq::BTM_GetEirSupportedServices( p_eir_uuid, p, max_num_uuid16, p_num_uuid16); } uint8_t BTM_GetEirUuidList(const 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) { inc_func_call_count(__func__); return test::mock::stack_btm_inq::BTM_GetEirUuidList( p_eir, eir_len, uuid_size, p_num_uuid, p_uuid_list, max_num_uuid); } bool BTM_HasEirService(const uint32_t* p_eir_uuid, uint16_t uuid16) { inc_func_call_count(__func__); return false; return test::mock::stack_btm_inq::BTM_HasEirService(p_eir_uuid, uuid16); } tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService(tBTM_INQ_RESULTS* p_results, uint16_t uuid16) { inc_func_call_count(__func__); return 0; return test::mock::stack_btm_inq::BTM_HasInquiryEirService(p_results, uuid16); } tBTM_INQ_INFO* BTM_InqDbFirst(void) { inc_func_call_count(__func__); return nullptr; return test::mock::stack_btm_inq::BTM_InqDbFirst(); } tBTM_INQ_INFO* BTM_InqDbNext(tBTM_INQ_INFO* p_cur) { inc_func_call_count(__func__); return nullptr; return test::mock::stack_btm_inq::BTM_InqDbNext(p_cur); } tBTM_INQ_INFO* BTM_InqDbRead(const RawAddress& p_bda) { inc_func_call_count(__func__); return nullptr; return test::mock::stack_btm_inq::BTM_InqDbRead(p_bda); } tBTM_STATUS BTM_CancelRemoteDeviceName(void) { uint16_t BTM_IsInquiryActive(void) { inc_func_call_count(__func__); return BTM_SUCCESS; return test::mock::stack_btm_inq::BTM_IsInquiryActive(); } tBTM_STATUS BTM_ClearInqDb(const RawAddress* p_bda) { bool BTM_IsRemoteNameKnown(const RawAddress& bd_addr, tBT_TRANSPORT transport) { inc_func_call_count(__func__); return BTM_SUCCESS; return test::mock::stack_btm_inq::BTM_IsRemoteNameKnown(bd_addr, transport); } tBTM_STATUS BTM_ReadRemoteDeviceName(const RawAddress& remote_bda, tBTM_NAME_CMPL_CB* p_cb, tBT_TRANSPORT transport) { inc_func_call_count(__func__); return BTM_SUCCESS; return test::mock::stack_btm_inq::BTM_ReadRemoteDeviceName(remote_bda, p_cb, transport); } void BTM_RemoveEirService(uint32_t* p_eir_uuid, uint16_t uuid16) { inc_func_call_count(__func__); test::mock::stack_btm_inq::BTM_RemoveEirService(p_eir_uuid, uuid16); } tBTM_STATUS BTM_SetConnectability(uint16_t page_mode) { inc_func_call_count(__func__); return BTM_SUCCESS; return test::mock::stack_btm_inq::BTM_SetConnectability(page_mode); } tBTM_STATUS BTM_SetDiscoverability(uint16_t inq_mode) { inc_func_call_count(__func__); return BTM_SUCCESS; return test::mock::stack_btm_inq::BTM_SetDiscoverability(inq_mode); } tBTM_STATUS BTM_SetInquiryMode(uint8_t mode) { inc_func_call_count(__func__); return BTM_SUCCESS; return test::mock::stack_btm_inq::BTM_SetInquiryMode(mode); } tBTM_STATUS BTM_StartInquiry(tBTM_INQ_RESULTS_CB* p_results_cb, tBTM_CMPL_CB* p_cmpl_cb) { inc_func_call_count(__func__); return BTM_SUCCESS; return test::mock::stack_btm_inq::BTM_StartInquiry(p_results_cb, p_cmpl_cb); } tBTM_STATUS BTM_WriteEIR(BT_HDR* p_buff) { inc_func_call_count(__func__); return test::mock::stack_btm_inq::BTM_WriteEIR(p_buff); } void SendRemoteNameRequest(const RawAddress& raw_address) { inc_func_call_count(__func__); test::mock::stack_btm_inq::SendRemoteNameRequest(raw_address); } void btm_clear_all_pending_le_entry(void) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_clear_all_pending_le_entry(); } void btm_clr_inq_db(const RawAddress* p_bda) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_clr_inq_db(p_bda); } void btm_clr_inq_result_flt(void) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_clr_inq_result_flt(); } tBTM_STATUS btm_initiate_rem_name(const RawAddress& remote_bda, uint8_t origin, uint64_t timeout_ms, tBTM_CMPL_CB* p_cb) { uint64_t timeout_ms, tBTM_NAME_CMPL_CB* p_cb) { inc_func_call_count(__func__); return BTM_SUCCESS; return test::mock::stack_btm_inq::btm_initiate_rem_name(remote_bda, origin, timeout_ms, p_cb); } void btm_inq_clear_ssp(void) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_inq_clear_ssp(); } tINQ_DB_ENT* btm_inq_db_find(const RawAddress& p_bda) { inc_func_call_count(__func__); return nullptr; return test::mock::stack_btm_inq::btm_inq_db_find(p_bda); } void btm_inq_db_free(void) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_inq_db_free(); } void btm_inq_db_init(void) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_inq_db_init(); } tINQ_DB_ENT* btm_inq_db_new(const RawAddress& p_bda) { inc_func_call_count(__func__); return nullptr; return test::mock::stack_btm_inq::btm_inq_db_new(p_bda); } uint16_t BTM_IsInquiryActive(void) { void btm_inq_db_reset(void) { inc_func_call_count(__func__); return 0; test::mock::stack_btm_inq::btm_inq_db_reset(); } uint8_t BTM_GetEirSupportedServices(uint32_t* p_eir_uuid, uint8_t** p, uint8_t max_num_uuid16, uint8_t* p_num_uuid16) { bool btm_inq_find_bdaddr(const RawAddress& p_bda) { inc_func_call_count(__func__); return 0; return test::mock::stack_btm_inq::btm_inq_find_bdaddr(p_bda); } uint8_t BTM_GetEirUuidList(const 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) { void btm_inq_remote_name_timer_timeout(void* data) { inc_func_call_count(__func__); return 0; test::mock::stack_btm_inq::btm_inq_remote_name_timer_timeout(data); } void BTM_AddEirService(uint32_t* p_eir_uuid, uint16_t uuid16) { void btm_inq_rmt_name_failed_cancelled(void) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_inq_rmt_name_failed_cancelled(); } void BTM_CancelInquiry(void) { inc_func_call_count(__func__); } void BTM_EnableInterlacedInquiryScan() { inc_func_call_count(__func__); } void BTM_EnableInterlacedPageScan() { inc_func_call_count(__func__); } void btm_clr_inq_db(const RawAddress* p_bda) { inc_func_call_count(__func__); } void btm_clr_inq_result_flt(void) { inc_func_call_count(__func__); } void btm_inq_clear_ssp(void) { inc_func_call_count(__func__); } void btm_inq_db_free(void) { inc_func_call_count(__func__); } void btm_inq_db_init(void) { inc_func_call_count(__func__); } void btm_inq_db_reset(void) { inc_func_call_count(__func__); } void btm_inq_remote_name_timer_timeout(UNUSED_ATTR void* data) { void btm_inq_stop_on_ssp(void) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_inq_stop_on_ssp(); } void btm_inq_rmt_name_failed_cancelled(void) { inc_func_call_count(__func__); } void btm_inq_stop_on_ssp(void) { inc_func_call_count(__func__); } void btm_process_cancel_complete(tHCI_STATUS status, uint8_t mode) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_process_cancel_complete(status, mode); } void btm_process_inq_complete(tHCI_STATUS status, uint8_t mode) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_process_inq_complete(status, mode); } void btm_process_inq_results(const uint8_t* p, uint8_t hci_evt_len, uint8_t inq_res_mode) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_process_inq_results(p, hci_evt_len, inq_res_mode); } void btm_process_remote_name(const RawAddress* bda, const BD_NAME bdn, uint16_t evt_len, tHCI_STATUS hci_status) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_process_remote_name(bda, bdn, evt_len, hci_status); } void btm_set_eir_uuid(const uint8_t* p_eir, tBTM_INQ_RESULTS* p_results) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_set_eir_uuid(p_eir, p_results); } void btm_sort_inq_result(void) { inc_func_call_count(__func__); } bool BTM_IsRemoteNameKnown(const RawAddress& bd_addr, tBT_TRANSPORT transport) { void btm_sort_inq_result(void) { inc_func_call_count(__func__); return false; test::mock::stack_btm_inq::btm_sort_inq_result(); } void btm_clear_all_pending_le_entry(void) { inc_func_call_count(__func__); } // Mocked functions complete // END mockcify generation Loading
system/bta/dm/bta_dm_act.cc +6 −0 Original line number Diff line number Diff line Loading @@ -4781,6 +4781,12 @@ tBT_TRANSPORT bta_dm_determine_discovery_transport(const RawAddress& bd_addr) { return ::bta_dm_determine_discovery_transport(bd_addr); } tBTM_STATUS bta_dm_sp_cback(tBTM_SP_EVT event, tBTM_SP_EVT_DATA* p_data) { return ::bta_dm_sp_cback(event, p_data); } void btm_set_local_io_caps(uint8_t io_caps) { ::btm_local_io_caps = io_caps; } } // namespace testing } // namespace legacy } // namespace bluetooth
system/bta/test/bta_dm_test.cc +188 −6 Original line number Diff line number Diff line Loading @@ -16,10 +16,13 @@ #include <base/functional/bind.h> #include <base/location.h> #include <gmock/gmock.h> #include <gtest/gtest.h> #include <chrono> #include <iostream> #include <memory> #include <string> #include "bta/dm/bta_dm_int.h" #include "bta/hf_client/bta_hf_client_int.h" Loading @@ -29,6 +32,8 @@ #include "btif/include/stack_manager.h" #include "common/message_loop_thread.h" #include "osi/include/compat.h" #include "stack/include/bt_dev_class.h" #include "stack/include/bt_name.h" #include "stack/include/btm_status.h" #include "test/common/main_handler.h" #include "test/common/mock_functions.h" Loading @@ -36,9 +41,11 @@ #include "test/mock/mock_osi_alarm.h" #include "test/mock/mock_osi_allocator.h" #include "test/mock/mock_stack_acl.h" #include "test/mock/mock_stack_btm_inq.h" #include "test/mock/mock_stack_btm_sec.h" using namespace std::chrono_literals; using ::testing::ElementsAre; extern struct btm_client_interface_t btm_client_interface; Loading @@ -50,12 +57,9 @@ namespace { constexpr uint8_t kUnusedTimer = BTA_ID_MAX; const RawAddress kRawAddress({0x11, 0x22, 0x33, 0x44, 0x55, 0x66}); const RawAddress kRawAddress2({0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc}); constexpr char kRemoteName[] = "TheRemoteName"; const DEV_CLASS kDeviceClass = {0x11, 0x22, 0x33}; const char* test_flags[] = { "INIT_logging_debug_enabled_for_all=true", nullptr, }; constexpr char kRemoteName[] = "TheRemoteName"; bool bta_dm_search_sm_execute(BT_HDR_RIGID* p_msg) { return true; } void bta_dm_search_sm_disable() { bta_sys_deregister(BTA_ID_DM_SEARCH); } Loading @@ -69,7 +73,6 @@ class BtaDmTest : public testing::Test { protected: void SetUp() override { reset_mock_function_count_map(); bluetooth::common::InitFlags::Load(test_flags); fake_osi_ = std::make_unique<test::fake::FakeOsi>(); main_thread_start_up(); Loading Loading @@ -226,6 +229,10 @@ void bta_dm_remname_cback(const tBTM_REMOTE_DEV_NAME* p); tBT_TRANSPORT bta_dm_determine_discovery_transport( const RawAddress& remote_bd_addr); void btm_set_local_io_caps(uint8_t io_caps); tBTM_STATUS bta_dm_sp_cback(tBTM_SP_EVT event, tBTM_SP_EVT_DATA* p_data); } // namespace testing } // namespace legacy } // namespace bluetooth Loading Loading @@ -516,3 +523,178 @@ TEST_F(BtaDmTest, bta_dm_remote_name_cmpl) { bta_dm_remote_name_cmpl(&msg); ASSERT_EQ(1, get_func_call_count("BTM_InqDbRead")); } TEST_F(BtaDmTest, bta_dm_sp_cback__BTM_SP_CFM_REQ_EVT_WithName) { constexpr uint32_t kNumVal = 1234; static bool callback_sent = false; static tBTA_DM_SP_CFM_REQ cfm_req{}; bta_dm_enable([](tBTA_DM_SEC_EVT event, tBTA_DM_SEC* p_data) { callback_sent = true; cfm_req = p_data->cfm_req; }); bluetooth::legacy::testing::btm_set_local_io_caps(0xff); tBTM_SP_EVT_DATA data = { .cfm_req = { // tBTM_SP_CFM_REQ .bd_addr = kRawAddress, .dev_class = {}, .bd_name = {}, .num_val = kNumVal, .just_works = false, .loc_auth_req = BTM_AUTH_SP_YES, .rmt_auth_req = BTM_AUTH_SP_YES, .loc_io_caps = BTM_IO_CAP_NONE, .rmt_io_caps = BTM_IO_CAP_NONE, }, }; dev_class_copy(data.cfm_req.dev_class, kDeviceClass); bd_name_copy(data.cfm_req.bd_name, kRemoteName); ASSERT_EQ(btm_status_text(BTM_CMD_STARTED), btm_status_text(bluetooth::legacy::testing::bta_dm_sp_cback( BTM_SP_CFM_REQ_EVT, &data))); ASSERT_EQ(kNumVal, bta_dm_cb.num_val); ASSERT_TRUE(callback_sent); ASSERT_EQ(kRawAddress, cfm_req.bd_addr); ASSERT_THAT(cfm_req.dev_class, ElementsAre(kDeviceClass[0], kDeviceClass[1], kDeviceClass[2])); ASSERT_STREQ(kRemoteName, reinterpret_cast<const char*>(cfm_req.bd_name)); ASSERT_EQ(kNumVal, cfm_req.num_val); ASSERT_EQ(false, cfm_req.just_works); ASSERT_EQ(BTM_AUTH_SP_YES, cfm_req.loc_auth_req); ASSERT_EQ(BTM_AUTH_SP_YES, cfm_req.rmt_auth_req); ASSERT_EQ(BTM_IO_CAP_NONE, cfm_req.loc_io_caps); ASSERT_EQ(BTM_IO_CAP_NONE, cfm_req.rmt_io_caps); } TEST_F(BtaDmTest, bta_dm_sp_cback__BTM_SP_CFM_REQ_EVT_WithoutName_RNRSuccess) { constexpr uint32_t kNumVal = 1234; static bool callback_sent = false; test::mock::stack_btm_inq::BTM_ReadRemoteDeviceName.body = [](const RawAddress& remote_bda, tBTM_NAME_CMPL_CB* p_cb, tBT_TRANSPORT transport) { return BTM_CMD_STARTED; }; static tBTA_DM_SP_CFM_REQ cfm_req{}; bta_dm_enable([](tBTA_DM_SEC_EVT event, tBTA_DM_SEC* p_data) { callback_sent = true; cfm_req = p_data->cfm_req; }); bluetooth::legacy::testing::btm_set_local_io_caps(0xff); tBTM_SP_EVT_DATA data = { .cfm_req = { // tBTM_SP_CFM_REQ .bd_addr = kRawAddress, .dev_class = {}, .bd_name = {0}, .num_val = kNumVal, .just_works = false, .loc_auth_req = BTM_AUTH_SP_YES, .rmt_auth_req = BTM_AUTH_SP_YES, .loc_io_caps = BTM_IO_CAP_NONE, .rmt_io_caps = BTM_IO_CAP_NONE, }, }; dev_class_copy(data.cfm_req.dev_class, kDeviceClass); ASSERT_EQ(btm_status_text(BTM_CMD_STARTED), btm_status_text(bluetooth::legacy::testing::bta_dm_sp_cback( BTM_SP_CFM_REQ_EVT, &data))); ASSERT_EQ(kNumVal, bta_dm_cb.num_val); ASSERT_FALSE(callback_sent); test::mock::stack_btm_inq::BTM_ReadRemoteDeviceName = {}; } TEST_F(BtaDmTest, bta_dm_sp_cback__BTM_SP_CFM_REQ_EVT_WithoutName_RNRFail) { constexpr uint32_t kNumVal = 1234; static bool callback_sent = false; test::mock::stack_btm_inq::BTM_ReadRemoteDeviceName.body = [](const RawAddress& remote_bda, tBTM_NAME_CMPL_CB* p_cb, tBT_TRANSPORT transport) { return BTM_SUCCESS; }; static tBTA_DM_SP_CFM_REQ cfm_req{}; bta_dm_enable([](tBTA_DM_SEC_EVT event, tBTA_DM_SEC* p_data) { callback_sent = true; cfm_req = p_data->cfm_req; }); bluetooth::legacy::testing::btm_set_local_io_caps(0xff); tBTM_SP_EVT_DATA data = { .cfm_req = { // tBTM_SP_CFM_REQ .bd_addr = kRawAddress, .dev_class = {}, .bd_name = {0}, .num_val = kNumVal, .just_works = false, .loc_auth_req = BTM_AUTH_SP_YES, .rmt_auth_req = BTM_AUTH_SP_YES, .loc_io_caps = BTM_IO_CAP_NONE, .rmt_io_caps = BTM_IO_CAP_NONE, }, }; dev_class_copy(data.cfm_req.dev_class, kDeviceClass); ASSERT_EQ(btm_status_text(BTM_CMD_STARTED), btm_status_text(bluetooth::legacy::testing::bta_dm_sp_cback( BTM_SP_CFM_REQ_EVT, &data))); ASSERT_EQ(kNumVal, bta_dm_cb.num_val); ASSERT_TRUE(callback_sent); ASSERT_EQ(kRawAddress, cfm_req.bd_addr); ASSERT_THAT(cfm_req.dev_class, ElementsAre(kDeviceClass[0], kDeviceClass[1], kDeviceClass[2])); ASSERT_EQ(kNumVal, cfm_req.num_val); ASSERT_EQ(false, cfm_req.just_works); ASSERT_EQ(BTM_AUTH_SP_YES, cfm_req.loc_auth_req); ASSERT_EQ(BTM_AUTH_SP_YES, cfm_req.rmt_auth_req); ASSERT_EQ(BTM_IO_CAP_NONE, cfm_req.loc_io_caps); ASSERT_EQ(BTM_IO_CAP_NONE, cfm_req.rmt_io_caps); test::mock::stack_btm_inq::BTM_ReadRemoteDeviceName = {}; } TEST_F(BtaDmTest, bta_dm_sp_cback__BTM_SP_KEY_NOTIF_EVT) { constexpr uint32_t kPassKey = 1234; static bool callback_sent = false; static tBTA_DM_SP_KEY_NOTIF key_notif{}; bta_dm_enable([](tBTA_DM_SEC_EVT event, tBTA_DM_SEC* p_data) { callback_sent = true; key_notif = p_data->key_notif; }); bluetooth::legacy::testing::btm_set_local_io_caps(0xff); tBTM_SP_EVT_DATA data = { .key_notif = { // tBTM_SP_KEY_NOTIF .bd_addr = kRawAddress, .dev_class = {}, .bd_name = {}, .passkey = kPassKey, }, }; dev_class_copy(data.key_notif.dev_class, kDeviceClass); bd_name_copy(data.key_notif.bd_name, kRemoteName); ASSERT_EQ(btm_status_text(BTM_CMD_STARTED), btm_status_text(bluetooth::legacy::testing::bta_dm_sp_cback( BTM_SP_KEY_NOTIF_EVT, &data))); ASSERT_EQ(kPassKey, bta_dm_cb.num_val); ASSERT_TRUE(callback_sent); ASSERT_EQ(kRawAddress, key_notif.bd_addr); ASSERT_THAT(key_notif.dev_class, ElementsAre(kDeviceClass[0], kDeviceClass[1], kDeviceClass[2])); ASSERT_STREQ(kRemoteName, reinterpret_cast<const char*>(key_notif.bd_name)); ASSERT_EQ(kPassKey, key_notif.passkey); }
system/stack/include/bt_dev_class.h +6 −0 Original line number Diff line number Diff line Loading @@ -123,6 +123,12 @@ inline constexpr DEV_CLASS kDevClassEmpty = {}; } #ifdef __cplusplus inline void dev_class_copy(DEV_CLASS& dst, const DEV_CLASS& src) { dst[0] = src[0]; dst[1] = src[1]; dst[2] = src[2]; } #include <sstream> inline std::string dev_class_text(const DEV_CLASS& dev_class) { std::ostringstream oss; Loading
system/stack/include/bt_name.h +4 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,10 @@ typedef uint8_t tBTM_LOC_BD_NAME[BTM_MAX_LOC_BD_NAME_LEN + 1]; inline constexpr tBTM_BD_NAME kBtmBdNameEmpty = {}; constexpr size_t kBdNameLength = static_cast<size_t>(BD_NAME_LEN); inline size_t bd_name_copy(BD_NAME bd_name_dest, const char* src) { return strlcpy(reinterpret_cast<char*>(bd_name_dest), const_cast<char*>(src), kBdNameLength + 1); } inline size_t bd_name_copy(BD_NAME bd_name_dest, const BD_NAME bd_name_src) { return strlcpy(reinterpret_cast<char*>(bd_name_dest), reinterpret_cast<const char*>(bd_name_src), kBdNameLength + 1); Loading
system/test/mock/mock_stack_btm_inq.cc +207 −78 Original line number Diff line number Diff line /* * Copyright 2020 The Android Open Source Project * Copyright 2023 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. Loading @@ -13,170 +13,299 @@ * See the License for the specific language governing permissions and * limitations under the License. */ /* * Generated mock file from original source file * Functions generated:44 * Functions generated:43 * * mockcify.pl ver 0.6.0 */ #include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <cstdint> #include <functional> #include <map> #include <string> #include "advertise_data_parser.h" #include "btm_api.h" #include "common/time_util.h" #include "device/include/controller.h" #include "main/shim/btm_api.h" #include "main/shim/shim.h" #include "osi/include/log.h" #include "osi/include/osi.h" #include "stack/btm/btm_ble_int.h" #include "stack/btm/btm_int_types.h" #include "stack/include/acl_api.h" #include "stack/include/bt_hdr.h" #include "stack/include/btm_ble_api.h" #include "stack/include/inq_hci_link_interface.h" #include "test/common/mock_functions.h" #include "types/bluetooth/uuid.h" #include "types/raw_address.h" // Mock include file to share data between tests and mock #include "test/mock/mock_stack_btm_inq.h" #ifndef UNUSED_ATTR #define UNUSED_ATTR #endif // Original usings void SendRemoteNameRequest(const RawAddress& raw_address) { // Mocked internal structures, if any namespace test { namespace mock { namespace stack_btm_inq { // Function state capture and return values, if needed struct BTM_AddEirService BTM_AddEirService; struct BTM_CancelInquiry BTM_CancelInquiry; struct BTM_CancelRemoteDeviceName BTM_CancelRemoteDeviceName; struct BTM_ClearInqDb BTM_ClearInqDb; struct BTM_EnableInterlacedInquiryScan BTM_EnableInterlacedInquiryScan; struct BTM_EnableInterlacedPageScan BTM_EnableInterlacedPageScan; struct BTM_GetEirSupportedServices BTM_GetEirSupportedServices; struct BTM_GetEirUuidList BTM_GetEirUuidList; struct BTM_HasEirService BTM_HasEirService; struct BTM_HasInquiryEirService BTM_HasInquiryEirService; struct BTM_InqDbFirst BTM_InqDbFirst; struct BTM_InqDbNext BTM_InqDbNext; struct BTM_InqDbRead BTM_InqDbRead; struct BTM_IsInquiryActive BTM_IsInquiryActive; struct BTM_IsRemoteNameKnown BTM_IsRemoteNameKnown; struct BTM_ReadRemoteDeviceName BTM_ReadRemoteDeviceName; struct BTM_RemoveEirService BTM_RemoveEirService; struct BTM_SetConnectability BTM_SetConnectability; struct BTM_SetDiscoverability BTM_SetDiscoverability; struct BTM_SetInquiryMode BTM_SetInquiryMode; struct BTM_StartInquiry BTM_StartInquiry; struct BTM_WriteEIR BTM_WriteEIR; struct SendRemoteNameRequest SendRemoteNameRequest; struct btm_clear_all_pending_le_entry btm_clear_all_pending_le_entry; struct btm_clr_inq_db btm_clr_inq_db; struct btm_clr_inq_result_flt btm_clr_inq_result_flt; struct btm_initiate_rem_name btm_initiate_rem_name; struct btm_inq_clear_ssp btm_inq_clear_ssp; struct btm_inq_db_find btm_inq_db_find; struct btm_inq_db_free btm_inq_db_free; struct btm_inq_db_init btm_inq_db_init; struct btm_inq_db_new btm_inq_db_new; struct btm_inq_db_reset btm_inq_db_reset; struct btm_inq_find_bdaddr btm_inq_find_bdaddr; struct btm_inq_remote_name_timer_timeout btm_inq_remote_name_timer_timeout; struct btm_inq_rmt_name_failed_cancelled btm_inq_rmt_name_failed_cancelled; struct btm_inq_stop_on_ssp btm_inq_stop_on_ssp; struct btm_process_cancel_complete btm_process_cancel_complete; struct btm_process_inq_complete btm_process_inq_complete; struct btm_process_inq_results btm_process_inq_results; struct btm_process_remote_name btm_process_remote_name; struct btm_set_eir_uuid btm_set_eir_uuid; struct btm_sort_inq_result btm_sort_inq_result; } // namespace stack_btm_inq } // namespace mock } // namespace test // Mocked function return values, if any namespace test { namespace mock { namespace stack_btm_inq { tBTM_STATUS BTM_CancelRemoteDeviceName::return_value = 0; tBTM_STATUS BTM_ClearInqDb::return_value = 0; uint8_t BTM_GetEirSupportedServices::return_value = 0; uint8_t BTM_GetEirUuidList::return_value = 0; bool BTM_HasEirService::return_value = false; tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService::return_value = 0; tBTM_INQ_INFO* BTM_InqDbFirst::return_value = nullptr; tBTM_INQ_INFO* BTM_InqDbNext::return_value = nullptr; tBTM_INQ_INFO* BTM_InqDbRead::return_value = nullptr; uint16_t BTM_IsInquiryActive::return_value = 0; bool BTM_IsRemoteNameKnown::return_value = false; tBTM_STATUS BTM_ReadRemoteDeviceName::return_value = 0; tBTM_STATUS BTM_SetConnectability::return_value = 0; tBTM_STATUS BTM_SetDiscoverability::return_value = 0; tBTM_STATUS BTM_SetInquiryMode::return_value = 0; tBTM_STATUS BTM_StartInquiry::return_value = 0; tBTM_STATUS BTM_WriteEIR::return_value = 0; tBTM_STATUS btm_initiate_rem_name::return_value = 0; tINQ_DB_ENT* btm_inq_db_find::return_value = nullptr; tINQ_DB_ENT* btm_inq_db_new::return_value = nullptr; bool btm_inq_find_bdaddr::return_value = false; } // namespace stack_btm_inq } // namespace mock } // namespace test // Mocked functions, if any void BTM_AddEirService(uint32_t* p_eir_uuid, uint16_t uuid16) { inc_func_call_count(__func__); test::mock::stack_btm_inq::BTM_AddEirService(p_eir_uuid, uuid16); } bool BTM_HasEirService(const uint32_t* p_eir_uuid, uint16_t uuid16) { void BTM_CancelInquiry(void) { inc_func_call_count(__func__); return false; test::mock::stack_btm_inq::BTM_CancelInquiry(); } bool btm_inq_find_bdaddr(const RawAddress& p_bda) { tBTM_STATUS BTM_CancelRemoteDeviceName(void) { inc_func_call_count(__func__); return test::mock::stack_btm_inq::BTM_CancelRemoteDeviceName(); } tBTM_STATUS BTM_ClearInqDb(const RawAddress* p_bda) { inc_func_call_count(__func__); return test::mock::stack_btm_inq::BTM_ClearInqDb(p_bda); } void BTM_EnableInterlacedInquiryScan() { inc_func_call_count(__func__); test::mock::stack_btm_inq::BTM_EnableInterlacedInquiryScan(); } void BTM_EnableInterlacedPageScan() { inc_func_call_count(__func__); test::mock::stack_btm_inq::BTM_EnableInterlacedPageScan(); } uint8_t BTM_GetEirSupportedServices(uint32_t* p_eir_uuid, uint8_t** p, uint8_t max_num_uuid16, uint8_t* p_num_uuid16) { inc_func_call_count(__func__); return test::mock::stack_btm_inq::BTM_GetEirSupportedServices( p_eir_uuid, p, max_num_uuid16, p_num_uuid16); } uint8_t BTM_GetEirUuidList(const 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) { inc_func_call_count(__func__); return test::mock::stack_btm_inq::BTM_GetEirUuidList( p_eir, eir_len, uuid_size, p_num_uuid, p_uuid_list, max_num_uuid); } bool BTM_HasEirService(const uint32_t* p_eir_uuid, uint16_t uuid16) { inc_func_call_count(__func__); return false; return test::mock::stack_btm_inq::BTM_HasEirService(p_eir_uuid, uuid16); } tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService(tBTM_INQ_RESULTS* p_results, uint16_t uuid16) { inc_func_call_count(__func__); return 0; return test::mock::stack_btm_inq::BTM_HasInquiryEirService(p_results, uuid16); } tBTM_INQ_INFO* BTM_InqDbFirst(void) { inc_func_call_count(__func__); return nullptr; return test::mock::stack_btm_inq::BTM_InqDbFirst(); } tBTM_INQ_INFO* BTM_InqDbNext(tBTM_INQ_INFO* p_cur) { inc_func_call_count(__func__); return nullptr; return test::mock::stack_btm_inq::BTM_InqDbNext(p_cur); } tBTM_INQ_INFO* BTM_InqDbRead(const RawAddress& p_bda) { inc_func_call_count(__func__); return nullptr; return test::mock::stack_btm_inq::BTM_InqDbRead(p_bda); } tBTM_STATUS BTM_CancelRemoteDeviceName(void) { uint16_t BTM_IsInquiryActive(void) { inc_func_call_count(__func__); return BTM_SUCCESS; return test::mock::stack_btm_inq::BTM_IsInquiryActive(); } tBTM_STATUS BTM_ClearInqDb(const RawAddress* p_bda) { bool BTM_IsRemoteNameKnown(const RawAddress& bd_addr, tBT_TRANSPORT transport) { inc_func_call_count(__func__); return BTM_SUCCESS; return test::mock::stack_btm_inq::BTM_IsRemoteNameKnown(bd_addr, transport); } tBTM_STATUS BTM_ReadRemoteDeviceName(const RawAddress& remote_bda, tBTM_NAME_CMPL_CB* p_cb, tBT_TRANSPORT transport) { inc_func_call_count(__func__); return BTM_SUCCESS; return test::mock::stack_btm_inq::BTM_ReadRemoteDeviceName(remote_bda, p_cb, transport); } void BTM_RemoveEirService(uint32_t* p_eir_uuid, uint16_t uuid16) { inc_func_call_count(__func__); test::mock::stack_btm_inq::BTM_RemoveEirService(p_eir_uuid, uuid16); } tBTM_STATUS BTM_SetConnectability(uint16_t page_mode) { inc_func_call_count(__func__); return BTM_SUCCESS; return test::mock::stack_btm_inq::BTM_SetConnectability(page_mode); } tBTM_STATUS BTM_SetDiscoverability(uint16_t inq_mode) { inc_func_call_count(__func__); return BTM_SUCCESS; return test::mock::stack_btm_inq::BTM_SetDiscoverability(inq_mode); } tBTM_STATUS BTM_SetInquiryMode(uint8_t mode) { inc_func_call_count(__func__); return BTM_SUCCESS; return test::mock::stack_btm_inq::BTM_SetInquiryMode(mode); } tBTM_STATUS BTM_StartInquiry(tBTM_INQ_RESULTS_CB* p_results_cb, tBTM_CMPL_CB* p_cmpl_cb) { inc_func_call_count(__func__); return BTM_SUCCESS; return test::mock::stack_btm_inq::BTM_StartInquiry(p_results_cb, p_cmpl_cb); } tBTM_STATUS BTM_WriteEIR(BT_HDR* p_buff) { inc_func_call_count(__func__); return test::mock::stack_btm_inq::BTM_WriteEIR(p_buff); } void SendRemoteNameRequest(const RawAddress& raw_address) { inc_func_call_count(__func__); test::mock::stack_btm_inq::SendRemoteNameRequest(raw_address); } void btm_clear_all_pending_le_entry(void) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_clear_all_pending_le_entry(); } void btm_clr_inq_db(const RawAddress* p_bda) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_clr_inq_db(p_bda); } void btm_clr_inq_result_flt(void) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_clr_inq_result_flt(); } tBTM_STATUS btm_initiate_rem_name(const RawAddress& remote_bda, uint8_t origin, uint64_t timeout_ms, tBTM_CMPL_CB* p_cb) { uint64_t timeout_ms, tBTM_NAME_CMPL_CB* p_cb) { inc_func_call_count(__func__); return BTM_SUCCESS; return test::mock::stack_btm_inq::btm_initiate_rem_name(remote_bda, origin, timeout_ms, p_cb); } void btm_inq_clear_ssp(void) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_inq_clear_ssp(); } tINQ_DB_ENT* btm_inq_db_find(const RawAddress& p_bda) { inc_func_call_count(__func__); return nullptr; return test::mock::stack_btm_inq::btm_inq_db_find(p_bda); } void btm_inq_db_free(void) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_inq_db_free(); } void btm_inq_db_init(void) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_inq_db_init(); } tINQ_DB_ENT* btm_inq_db_new(const RawAddress& p_bda) { inc_func_call_count(__func__); return nullptr; return test::mock::stack_btm_inq::btm_inq_db_new(p_bda); } uint16_t BTM_IsInquiryActive(void) { void btm_inq_db_reset(void) { inc_func_call_count(__func__); return 0; test::mock::stack_btm_inq::btm_inq_db_reset(); } uint8_t BTM_GetEirSupportedServices(uint32_t* p_eir_uuid, uint8_t** p, uint8_t max_num_uuid16, uint8_t* p_num_uuid16) { bool btm_inq_find_bdaddr(const RawAddress& p_bda) { inc_func_call_count(__func__); return 0; return test::mock::stack_btm_inq::btm_inq_find_bdaddr(p_bda); } uint8_t BTM_GetEirUuidList(const 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) { void btm_inq_remote_name_timer_timeout(void* data) { inc_func_call_count(__func__); return 0; test::mock::stack_btm_inq::btm_inq_remote_name_timer_timeout(data); } void BTM_AddEirService(uint32_t* p_eir_uuid, uint16_t uuid16) { void btm_inq_rmt_name_failed_cancelled(void) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_inq_rmt_name_failed_cancelled(); } void BTM_CancelInquiry(void) { inc_func_call_count(__func__); } void BTM_EnableInterlacedInquiryScan() { inc_func_call_count(__func__); } void BTM_EnableInterlacedPageScan() { inc_func_call_count(__func__); } void btm_clr_inq_db(const RawAddress* p_bda) { inc_func_call_count(__func__); } void btm_clr_inq_result_flt(void) { inc_func_call_count(__func__); } void btm_inq_clear_ssp(void) { inc_func_call_count(__func__); } void btm_inq_db_free(void) { inc_func_call_count(__func__); } void btm_inq_db_init(void) { inc_func_call_count(__func__); } void btm_inq_db_reset(void) { inc_func_call_count(__func__); } void btm_inq_remote_name_timer_timeout(UNUSED_ATTR void* data) { void btm_inq_stop_on_ssp(void) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_inq_stop_on_ssp(); } void btm_inq_rmt_name_failed_cancelled(void) { inc_func_call_count(__func__); } void btm_inq_stop_on_ssp(void) { inc_func_call_count(__func__); } void btm_process_cancel_complete(tHCI_STATUS status, uint8_t mode) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_process_cancel_complete(status, mode); } void btm_process_inq_complete(tHCI_STATUS status, uint8_t mode) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_process_inq_complete(status, mode); } void btm_process_inq_results(const uint8_t* p, uint8_t hci_evt_len, uint8_t inq_res_mode) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_process_inq_results(p, hci_evt_len, inq_res_mode); } void btm_process_remote_name(const RawAddress* bda, const BD_NAME bdn, uint16_t evt_len, tHCI_STATUS hci_status) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_process_remote_name(bda, bdn, evt_len, hci_status); } void btm_set_eir_uuid(const uint8_t* p_eir, tBTM_INQ_RESULTS* p_results) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_set_eir_uuid(p_eir, p_results); } void btm_sort_inq_result(void) { inc_func_call_count(__func__); } bool BTM_IsRemoteNameKnown(const RawAddress& bd_addr, tBT_TRANSPORT transport) { void btm_sort_inq_result(void) { inc_func_call_count(__func__); return false; test::mock::stack_btm_inq::btm_sort_inq_result(); } void btm_clear_all_pending_le_entry(void) { inc_func_call_count(__func__); } // Mocked functions complete // END mockcify generation