Loading system/bta/Android.bp +17 −0 Original line number Diff line number Diff line Loading @@ -199,9 +199,11 @@ cc_test { ], test_suites: ["device-tests"], srcs: [ ":LegacyStackSdp", ":TestCommonLogMsg", ":TestCommonMockFunctions", ":TestMockBtif", ":TestMockMainShim", ":TestMockStackBtm", "test/bta_dip_test.cc", "test/bta_dm_cust_uuid_test.cc", Loading @@ -211,6 +213,10 @@ cc_test { "test/gatt/database_builder_test.cc", "test/gatt/database_test.cc", ], generated_headers: [ "BluetoothGeneratedDumpsysDataSchema_h", "BluetoothGeneratedPackets_h", ], shared_libs: [ "android.hardware.bluetooth.audio@2.0", "android.hardware.bluetooth.audio@2.1", Loading @@ -228,6 +234,7 @@ cc_test { "libbtcore", "libchrome", "libcom.android.sysprop.bluetooth", "libgmock", "libosi", ], data: [ Loading Loading @@ -324,6 +331,14 @@ cc_test { "gatt/bta_gattc_utils.cc", "gatt/database.cc", "gatt/database_builder.cc", "hf_client/bta_hf_client_act.cc", "hf_client/bta_hf_client_api.cc", "hf_client/bta_hf_client_at.cc", "hf_client/bta_hf_client_main.cc", "hf_client/bta_hf_client_rfc.cc", "hf_client/bta_hf_client_sco.cc", "hf_client/bta_hf_client_sdp.cc", "hfp/bta_hfp_api.cc", "hh/bta_hh_act.cc", "hh/bta_hh_api.cc", "hh/bta_hh_cfg.cc", Loading @@ -333,9 +348,11 @@ cc_test { "pan/bta_pan_act.cc", "pan/bta_pan_api.cc", "pan/bta_pan_main.cc", "sdp/bta_sdp_cfg.cc", "sys/bta_sys_conn.cc", "sys/bta_sys_main.cc", "sys/utl.cc", "test/bta_hf_client_add_record_test.cc", "test/bta_api_test.cc", "test/bta_av_test.cc", "test/bta_dm_test.cc", Loading system/bta/sdp/bta_sdp_act.cc +15 −0 Original line number Diff line number Diff line Loading @@ -569,3 +569,18 @@ void bta_sdp_remove_record(void* user_data) { if (bta_sdp_cb.p_dm_cback) bta_sdp_cb.p_dm_cback(BTA_SDP_REMOVE_RECORD_USER_EVT, NULL, user_data); } namespace bluetooth { namespace testing { void bta_create_dip_sdp_record(bluetooth_sdp_record* record, tSDP_DISC_REC* p_rec) { ::bta_create_dip_sdp_record(record, p_rec); } void bta_sdp_search_cback(tSDP_RESULT result, const void* user_data) { ::bta_sdp_search_cback(result, user_data); } } // namespace testing } // namespace bluetooth system/bta/test/bta_dip_test.cc +16 −15 Original line number Diff line number Diff line Loading @@ -18,9 +18,10 @@ #include <gtest/gtest.h> #include "bta/sdp/bta_sdp_act.cc" #include "bta/sdp/bta_sdp_int.h" #include "btif/include/btif_sock_sdp.h" #include "main/shim/metrics_api.h" #include "stack/sdp/sdp_api.cc" #include "test/mock/mock_stack_sdp_api.h" #include "types/bluetooth/uuid.h" #include "types/raw_address.h" Loading @@ -28,8 +29,7 @@ namespace { const RawAddress bdaddr({0x11, 0x22, 0x33, 0x44, 0x55, 0x66}); } // namespace extern tBTA_SDP_CB bta_sdp_cb; extern tBTA_SDP_CFG* p_bta_sdp_cfg; tBTA_SDP_CB bta_sdp_cb; static tSDP_DISC_ATTR g_attr_service_class_id_list; static tSDP_DISC_ATTR g_sub_attr; Loading @@ -41,19 +41,11 @@ static tSDP_DISC_ATTR g_attr_vendor_product_version; static tSDP_DISC_ATTR g_attr_vendor_product_primary_record; static tSDP_DISC_REC g_rec; bool sdpu_compare_uuid_with_attr(const Uuid& uuid, tSDP_DISC_ATTR* p_attr) { return true; } static void sdp_dm_cback(tBTA_SDP_EVT event, tBTA_SDP* p_data, void* user_data) { return; } bool bluetooth::shim::CountCounterMetrics(int32_t key, int64_t count) { return true; } class BtaDipTest : public ::testing::Test { protected: void SetUp() override { Loading Loading @@ -109,11 +101,21 @@ class BtaDipTest : public ::testing::Test { void TearDown() override {} }; namespace bluetooth { namespace testing { void bta_create_dip_sdp_record(bluetooth_sdp_record* record, tSDP_DISC_REC* p_rec); void bta_sdp_search_cback(tSDP_RESULT result, const void* user_data); } // namespace testing } // namespace bluetooth // Test that bta_create_dip_sdp_record can parse sdp record to bluetooth_sdp_record correctly TEST_F(BtaDipTest, test_bta_create_dip_sdp_record) { bluetooth_sdp_record record; bta_create_dip_sdp_record(&record, &g_rec); bluetooth::testing::bta_create_dip_sdp_record(&record, &g_rec); ASSERT_EQ(record.dip.spec_id, 0x0103); ASSERT_EQ(record.dip.vendor, 0x18d1); Loading @@ -127,6 +129,5 @@ TEST_F(BtaDipTest, test_bta_sdp_search_cback) { Uuid* userdata = (Uuid*)malloc(sizeof(Uuid)); memcpy(userdata, &UUID_DIP, sizeof(UUID_DIP)); bta_sdp_search_cback(SDP_SUCCESS, userdata); bluetooth::testing::bta_sdp_search_cback(SDP_SUCCESS, userdata); } system/bta/test/bta_hf_client_add_record_test.cc +2 −25 Original line number Diff line number Diff line Loading @@ -19,35 +19,12 @@ #include <base/logging.h> #include <gtest/gtest.h> #include "bta/hf_client/bta_hf_client_sdp.cc" #include "bta/hf_client/bta_hf_client_int.h" #include "bta/include/bta_hf_client_api.h" #include "btif/src/btif_hf_client.cc" #include "types/bluetooth/uuid.h" static uint16_t gVersion; bool SDP_AddProtocolList(uint32_t handle, uint16_t num_elem, tSDP_PROTOCOL_ELEM* p_elem_list) { return false; } bool SDP_AddServiceClassIdList(uint32_t handle, uint16_t num_services, uint16_t* p_service_uuids) { return false; } bool SDP_AddProfileDescriptorList(uint32_t handle, uint16_t profile_uuid, uint16_t version) { gVersion = version; return false; } bool SDP_AddAttribute(uint32_t handle, uint16_t attr_id, uint8_t attr_type, uint32_t attr_len, uint8_t* p_val) { return false; } bool SDP_AddUuidSequence(uint32_t handle, uint16_t attr_id, uint16_t num_uuids, uint16_t* p_uuids) { return false; } class BtaHfClientAddRecordTest : public ::testing::Test { protected: void SetUp() override { Loading @@ -63,6 +40,6 @@ TEST_F(BtaHfClientAddRecordTest, test_hf_client_add_record) { uint8_t scn = 0; bta_hf_client_add_record("Handsfree", scn, features, sdp_handle); ASSERT_EQ(gVersion, get_default_hfp_version()); ASSERT_EQ(HFP_VERSION_1_7, get_default_hfp_version()); } Loading
system/bta/Android.bp +17 −0 Original line number Diff line number Diff line Loading @@ -199,9 +199,11 @@ cc_test { ], test_suites: ["device-tests"], srcs: [ ":LegacyStackSdp", ":TestCommonLogMsg", ":TestCommonMockFunctions", ":TestMockBtif", ":TestMockMainShim", ":TestMockStackBtm", "test/bta_dip_test.cc", "test/bta_dm_cust_uuid_test.cc", Loading @@ -211,6 +213,10 @@ cc_test { "test/gatt/database_builder_test.cc", "test/gatt/database_test.cc", ], generated_headers: [ "BluetoothGeneratedDumpsysDataSchema_h", "BluetoothGeneratedPackets_h", ], shared_libs: [ "android.hardware.bluetooth.audio@2.0", "android.hardware.bluetooth.audio@2.1", Loading @@ -228,6 +234,7 @@ cc_test { "libbtcore", "libchrome", "libcom.android.sysprop.bluetooth", "libgmock", "libosi", ], data: [ Loading Loading @@ -324,6 +331,14 @@ cc_test { "gatt/bta_gattc_utils.cc", "gatt/database.cc", "gatt/database_builder.cc", "hf_client/bta_hf_client_act.cc", "hf_client/bta_hf_client_api.cc", "hf_client/bta_hf_client_at.cc", "hf_client/bta_hf_client_main.cc", "hf_client/bta_hf_client_rfc.cc", "hf_client/bta_hf_client_sco.cc", "hf_client/bta_hf_client_sdp.cc", "hfp/bta_hfp_api.cc", "hh/bta_hh_act.cc", "hh/bta_hh_api.cc", "hh/bta_hh_cfg.cc", Loading @@ -333,9 +348,11 @@ cc_test { "pan/bta_pan_act.cc", "pan/bta_pan_api.cc", "pan/bta_pan_main.cc", "sdp/bta_sdp_cfg.cc", "sys/bta_sys_conn.cc", "sys/bta_sys_main.cc", "sys/utl.cc", "test/bta_hf_client_add_record_test.cc", "test/bta_api_test.cc", "test/bta_av_test.cc", "test/bta_dm_test.cc", Loading
system/bta/sdp/bta_sdp_act.cc +15 −0 Original line number Diff line number Diff line Loading @@ -569,3 +569,18 @@ void bta_sdp_remove_record(void* user_data) { if (bta_sdp_cb.p_dm_cback) bta_sdp_cb.p_dm_cback(BTA_SDP_REMOVE_RECORD_USER_EVT, NULL, user_data); } namespace bluetooth { namespace testing { void bta_create_dip_sdp_record(bluetooth_sdp_record* record, tSDP_DISC_REC* p_rec) { ::bta_create_dip_sdp_record(record, p_rec); } void bta_sdp_search_cback(tSDP_RESULT result, const void* user_data) { ::bta_sdp_search_cback(result, user_data); } } // namespace testing } // namespace bluetooth
system/bta/test/bta_dip_test.cc +16 −15 Original line number Diff line number Diff line Loading @@ -18,9 +18,10 @@ #include <gtest/gtest.h> #include "bta/sdp/bta_sdp_act.cc" #include "bta/sdp/bta_sdp_int.h" #include "btif/include/btif_sock_sdp.h" #include "main/shim/metrics_api.h" #include "stack/sdp/sdp_api.cc" #include "test/mock/mock_stack_sdp_api.h" #include "types/bluetooth/uuid.h" #include "types/raw_address.h" Loading @@ -28,8 +29,7 @@ namespace { const RawAddress bdaddr({0x11, 0x22, 0x33, 0x44, 0x55, 0x66}); } // namespace extern tBTA_SDP_CB bta_sdp_cb; extern tBTA_SDP_CFG* p_bta_sdp_cfg; tBTA_SDP_CB bta_sdp_cb; static tSDP_DISC_ATTR g_attr_service_class_id_list; static tSDP_DISC_ATTR g_sub_attr; Loading @@ -41,19 +41,11 @@ static tSDP_DISC_ATTR g_attr_vendor_product_version; static tSDP_DISC_ATTR g_attr_vendor_product_primary_record; static tSDP_DISC_REC g_rec; bool sdpu_compare_uuid_with_attr(const Uuid& uuid, tSDP_DISC_ATTR* p_attr) { return true; } static void sdp_dm_cback(tBTA_SDP_EVT event, tBTA_SDP* p_data, void* user_data) { return; } bool bluetooth::shim::CountCounterMetrics(int32_t key, int64_t count) { return true; } class BtaDipTest : public ::testing::Test { protected: void SetUp() override { Loading Loading @@ -109,11 +101,21 @@ class BtaDipTest : public ::testing::Test { void TearDown() override {} }; namespace bluetooth { namespace testing { void bta_create_dip_sdp_record(bluetooth_sdp_record* record, tSDP_DISC_REC* p_rec); void bta_sdp_search_cback(tSDP_RESULT result, const void* user_data); } // namespace testing } // namespace bluetooth // Test that bta_create_dip_sdp_record can parse sdp record to bluetooth_sdp_record correctly TEST_F(BtaDipTest, test_bta_create_dip_sdp_record) { bluetooth_sdp_record record; bta_create_dip_sdp_record(&record, &g_rec); bluetooth::testing::bta_create_dip_sdp_record(&record, &g_rec); ASSERT_EQ(record.dip.spec_id, 0x0103); ASSERT_EQ(record.dip.vendor, 0x18d1); Loading @@ -127,6 +129,5 @@ TEST_F(BtaDipTest, test_bta_sdp_search_cback) { Uuid* userdata = (Uuid*)malloc(sizeof(Uuid)); memcpy(userdata, &UUID_DIP, sizeof(UUID_DIP)); bta_sdp_search_cback(SDP_SUCCESS, userdata); bluetooth::testing::bta_sdp_search_cback(SDP_SUCCESS, userdata); }
system/bta/test/bta_hf_client_add_record_test.cc +2 −25 Original line number Diff line number Diff line Loading @@ -19,35 +19,12 @@ #include <base/logging.h> #include <gtest/gtest.h> #include "bta/hf_client/bta_hf_client_sdp.cc" #include "bta/hf_client/bta_hf_client_int.h" #include "bta/include/bta_hf_client_api.h" #include "btif/src/btif_hf_client.cc" #include "types/bluetooth/uuid.h" static uint16_t gVersion; bool SDP_AddProtocolList(uint32_t handle, uint16_t num_elem, tSDP_PROTOCOL_ELEM* p_elem_list) { return false; } bool SDP_AddServiceClassIdList(uint32_t handle, uint16_t num_services, uint16_t* p_service_uuids) { return false; } bool SDP_AddProfileDescriptorList(uint32_t handle, uint16_t profile_uuid, uint16_t version) { gVersion = version; return false; } bool SDP_AddAttribute(uint32_t handle, uint16_t attr_id, uint8_t attr_type, uint32_t attr_len, uint8_t* p_val) { return false; } bool SDP_AddUuidSequence(uint32_t handle, uint16_t attr_id, uint16_t num_uuids, uint16_t* p_uuids) { return false; } class BtaHfClientAddRecordTest : public ::testing::Test { protected: void SetUp() override { Loading @@ -63,6 +40,6 @@ TEST_F(BtaHfClientAddRecordTest, test_hf_client_add_record) { uint8_t scn = 0; bta_hf_client_add_record("Handsfree", scn, features, sdp_handle); ASSERT_EQ(gVersion, get_default_hfp_version()); ASSERT_EQ(HFP_VERSION_1_7, get_default_hfp_version()); }