1 /*
2  * Copyright 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <base/functional/bind.h>
18 #include <base/location.h>
19 #include <gtest/gtest.h>
20 
21 #include "bta/av/bta_av_int.h"
22 #include "bta/hf_client/bta_hf_client_int.h"
23 #include "common/init_flags.h"
24 #include "test/common/mock_functions.h"
25 #include "test/mock/mock_osi_alarm.h"
26 #include "test/mock/mock_stack_acl.h"
27 
28 using namespace std::chrono_literals;
29 
btif_av_both_enable(void)30 bool btif_av_both_enable(void) { return true; }
31 
32 namespace {
33 const RawAddress kRawAddress({0x11, 0x22, 0x33, 0x44, 0x55, 0x66});
34 }  // namespace
35 
36 struct alarm_t {
alarm_talarm_t37   alarm_t(const char* name){};
38   int any_value;
39 };
40 
41 class BtaAvTest : public testing::Test {
42  protected:
SetUp()43   void SetUp() override {
44     reset_mock_function_count_map();
45     bluetooth::common::InitFlags::SetAllForTesting();
46   }
TearDown()47   void TearDown() override {
48   }
49 };
50 
TEST_F(BtaAvTest,nop)51 TEST_F(BtaAvTest, nop) {
52   bool status = true;
53   ASSERT_EQ(true, status);
54 }
55 
TEST_F(BtaAvTest,bta_av_rc_opened)56 TEST_F(BtaAvTest, bta_av_rc_opened) {
57   tBTA_AV_CB cb = {
58       .p_cback =
59           [](tBTA_AV_EVT event, tBTA_AV* p_data) {
60             const tBTA_AV_RC_OPEN* rc_open = &p_data->rc_open;
61             ASSERT_EQ(BTA_AV_RC_OPEN_EVT, event);
62             ASSERT_EQ(kRawAddress, rc_open->peer_addr);
63           },
64   };
65   tBTA_AV_DATA data = {
66       .rc_conn_chg =
67           {
68               .hdr = {},
69               .peer_addr = kRawAddress,
70               .handle = 0,
71           },
72   };
73   bta_av_rc_opened(&cb, &data);
74 }
75