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 "test/common/mock_functions.h"
24 #include "test/mock/mock_osi_alarm.h"
25 #include "test/mock/mock_stack_acl.h"
26
27 // TODO(b/369381361) Enfore -Wmissing-prototypes
28 #pragma GCC diagnostic ignored "-Wmissing-prototypes"
29
30 using namespace std::chrono_literals;
31
btif_av_both_enable(void)32 bool btif_av_both_enable(void) { return true; }
33
34 namespace {
35 const RawAddress kRawAddress({0x11, 0x22, 0x33, 0x44, 0x55, 0x66});
36 } // namespace
37
38 struct alarm_t {
alarm_talarm_t39 alarm_t(const char* /*name*/) {}
40 int any_value;
41 };
42
43 class BtaAvTest : public testing::Test {
44 protected:
SetUp()45 void SetUp() override { reset_mock_function_count_map(); }
TearDown()46 void TearDown() override {}
47 };
48
TEST_F(BtaAvTest,nop)49 TEST_F(BtaAvTest, nop) {
50 bool status = true;
51 ASSERT_EQ(true, status);
52 }
53
TEST_F(BtaAvTest,bta_av_rc_opened)54 TEST_F(BtaAvTest, bta_av_rc_opened) {
55 tBTA_AV_CB cb = {
56 .p_cback =
57 [](tBTA_AV_EVT event, tBTA_AV* p_data) {
58 const tBTA_AV_RC_OPEN* rc_open = &p_data->rc_open;
59 ASSERT_EQ(BTA_AV_RC_OPEN_EVT, event);
60 ASSERT_EQ(kRawAddress, rc_open->peer_addr);
61 },
62 };
63 tBTA_AV_DATA data = {
64 .rc_conn_chg =
65 {
66 .hdr = {},
67 .peer_addr = kRawAddress,
68 .handle = 0,
69 },
70 };
71 bta_av_rc_opened(&cb, &data);
72 }
73