1 /******************************************************************************
2 *
3 * Copyright 2021 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18
19 #include <base/logging.h>
20 #include <gtest/gtest.h>
21
22 #include "bta/hf_client/bta_hf_client_sdp.cc"
23 #include "bta/include/bta_hf_client_api.h"
24 #include "btif/src/btif_hf_client.cc"
25
26 static uint16_t gVersion;
27
28 // Define appl_trace_level even though LogMsg is trivial. This is required when
29 // coverage is enabled because the compiler is unable to eliminate the `if`
30 // checks against appl_trace_level in APPL_TRACE_* macros.
31 uint8_t appl_trace_level = 0;
LogMsg(uint32_t trace_set_mask,const char * fmt_str,...)32 void LogMsg(uint32_t trace_set_mask, const char* fmt_str, ...) {}
SDP_AddProtocolList(uint32_t handle,uint16_t num_elem,tSDP_PROTOCOL_ELEM * p_elem_list)33 bool SDP_AddProtocolList(uint32_t handle, uint16_t num_elem,
34 tSDP_PROTOCOL_ELEM* p_elem_list) {
35 return false;
36 }
SDP_AddServiceClassIdList(uint32_t handle,uint16_t num_services,uint16_t * p_service_uuids)37 bool SDP_AddServiceClassIdList(uint32_t handle, uint16_t num_services,
38 uint16_t* p_service_uuids) {
39 return false;
40 }
SDP_AddProfileDescriptorList(uint32_t handle,uint16_t profile_uuid,uint16_t version)41 bool SDP_AddProfileDescriptorList(uint32_t handle, uint16_t profile_uuid,
42 uint16_t version) {
43 gVersion = version;
44 return false;
45 }
SDP_AddAttribute(uint32_t handle,uint16_t attr_id,uint8_t attr_type,uint32_t attr_len,uint8_t * p_val)46 bool SDP_AddAttribute(uint32_t handle, uint16_t attr_id, uint8_t attr_type,
47 uint32_t attr_len, uint8_t* p_val) {
48 return false;
49 }
SDP_AddUuidSequence(uint32_t handle,uint16_t attr_id,uint16_t num_uuids,uint16_t * p_uuids)50 bool SDP_AddUuidSequence(uint32_t handle, uint16_t attr_id, uint16_t num_uuids,
51 uint16_t* p_uuids) {
52 return false;
53 }
54
55 class BtaHfClientAddRecordTest : public ::testing::Test {
56 protected:
SetUp()57 void SetUp() override {
58 gVersion = 0;
59 }
60
TearDown()61 void TearDown() override {}
62 };
63
TEST_F(BtaHfClientAddRecordTest,test_hf_client_add_record)64 TEST_F(BtaHfClientAddRecordTest, test_hf_client_add_record) {
65 tBTA_HF_CLIENT_FEAT features = BTIF_HF_CLIENT_FEATURES;
66 uint32_t sdp_handle = 0;
67 uint8_t scn = 0;
68
69 bta_hf_client_add_record("Handsfree", scn, features, sdp_handle);
70 ASSERT_EQ(gVersion, BTA_HFP_VERSION);
71 }
72
73