1 #include <android_bluetooth_sysprop.h>
2 #include <gtest/gtest.h>
3
4 #include "bta_hfp_api.h"
5
6 #undef LOG_TAG
7 #include "btif/src/btif_hf_client.cc"
8
9 static tBTA_HF_CLIENT_FEAT gFeatures;
10
get_default_hfp_version()11 int get_default_hfp_version() {
12 return GET_SYSPROP(Hfp, version, HFP_VERSION_1_7);
13 }
14
get_default_hf_client_features()15 int get_default_hf_client_features() {
16 #define DEFAULT_BTIF_HF_CLIENT_FEATURES \
17 (BTA_HF_CLIENT_FEAT_ECNR | BTA_HF_CLIENT_FEAT_3WAY | \
18 BTA_HF_CLIENT_FEAT_CLI | BTA_HF_CLIENT_FEAT_VREC | BTA_HF_CLIENT_FEAT_VOL | \
19 BTA_HF_CLIENT_FEAT_ECS | BTA_HF_CLIENT_FEAT_ECC | BTA_HF_CLIENT_FEAT_CODEC)
20
21 return GET_SYSPROP(Hfp, hf_client_features, DEFAULT_BTIF_HF_CLIENT_FEATURES);
22 }
23
BTA_HfClientEnable(tBTA_HF_CLIENT_CBACK * p_cback,tBTA_HF_CLIENT_FEAT features,const char * p_service_name)24 tBTA_STATUS BTA_HfClientEnable(tBTA_HF_CLIENT_CBACK* p_cback,
25 tBTA_HF_CLIENT_FEAT features,
26 const char* p_service_name) {
27 gFeatures = features;
28 return BTA_SUCCESS;
29 }
BTA_HfClientDisable(void)30 void BTA_HfClientDisable(void) { }
btif_transfer_context(tBTIF_CBACK * p_cback,uint16_t event,char * p_params,int param_len,tBTIF_COPY_CBACK * p_copy_cback)31 bt_status_t btif_transfer_context(tBTIF_CBACK* p_cback, uint16_t event,
32 char* p_params, int param_len,
33 tBTIF_COPY_CBACK* p_copy_cback) {
34 return BT_STATUS_SUCCESS;
35 }
btif_queue_advance()36 void btif_queue_advance() {}
dump_hf_client_event(uint16_t event)37 std::string dump_hf_client_event(uint16_t event) { return "UNKNOWN MSG ID"; }
38
39 class BtifHfClientTest : public ::testing::Test {
40 protected:
SetUp()41 void SetUp() override { gFeatures = get_default_hf_client_features(); }
42
TearDown()43 void TearDown() override {}
44 };
45
TEST_F(BtifHfClientTest,test_btif_hf_cleint_service)46 TEST_F(BtifHfClientTest, test_btif_hf_cleint_service) {
47 bool enable = true;
48
49 btif_hf_client_execute_service(enable);
50 ASSERT_EQ((gFeatures & BTA_HF_CLIENT_FEAT_ESCO_S4) > 0,
51 get_default_hfp_version() >= HFP_VERSION_1_7);
52
53 ASSERT_EQ((gFeatures & BTA_HF_CLIENT_FEAT_SWB) > 0,
54 get_default_hfp_version() >= HFP_VERSION_1_9);
55 }
56