Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 43b23f04 authored by Chris Manton's avatar Chris Manton Committed by Automerger Merge Worker
Browse files

Merge "Add bt_host_test_bta::bta_av_test" am: d1852456

parents 558b8e40 d1852456
Loading
Loading
Loading
Loading
+9 −1
Original line number Original line Diff line number Diff line
@@ -216,6 +216,7 @@ cc_test {
    ],
    ],
    srcs: [
    srcs: [
        ":OsiCompatSources",
        ":OsiCompatSources",
        ":TestCommonLogMsg",
        ":TestCommonMainHandler",
        ":TestCommonMainHandler",
        ":TestMockBtif",
        ":TestMockBtif",
        ":TestMockDevice",
        ":TestMockDevice",
@@ -223,8 +224,13 @@ cc_test {
        ":TestMockOsi",
        ":TestMockOsi",
        ":TestMockStack",
        ":TestMockStack",
        "ar/bta_ar.cc",
        "ar/bta_ar.cc",
        "dm/bta_dm_api.cc",
        "av/bta_av_aact.cc",
        "av/bta_av_act.cc",
        "av/bta_av_cfg.cc",
        "av/bta_av_main.cc",
        "av/bta_av_ssm.cc",
        "dm/bta_dm_act.cc",
        "dm/bta_dm_act.cc",
        "dm/bta_dm_api.cc",
        "dm/bta_dm_cfg.cc",
        "dm/bta_dm_cfg.cc",
        "dm/bta_dm_ci.cc",
        "dm/bta_dm_ci.cc",
        "dm/bta_dm_main.cc",
        "dm/bta_dm_main.cc",
@@ -249,6 +255,8 @@ cc_test {
        "pan/bta_pan_main.cc",
        "pan/bta_pan_main.cc",
        "sys/bta_sys_conn.cc",
        "sys/bta_sys_conn.cc",
        "sys/bta_sys_main.cc",
        "sys/bta_sys_main.cc",
        "sys/utl.cc",
        "test/bta_av_test.cc",
        "test/bta_dm_test.cc",
        "test/bta_dm_test.cc",
        "test/bta_gatt_test.cc",
        "test/bta_gatt_test.cc",
        "test/bta_pan_test.cc",
        "test/bta_pan_test.cc",
+88 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <base/bind.h>
#include <base/location.h>
#include <gtest/gtest.h>

#include <chrono>

#include "bta/av/bta_av_int.h"
#include "bta/dm/bta_dm_int.h"
#include "bta/hf_client/bta_hf_client_int.h"
#include "bta/include/bta_api.h"
#include "bta/include/bta_dm_api.h"
#include "bta/include/bta_hf_client_api.h"
#include "btif/include/stack_manager.h"
#include "common/message_loop_thread.h"
#include "osi/include/log.h"
#include "stack/include/btm_status.h"
#include "test/mock/mock_osi_alarm.h"
#include "test/mock/mock_stack_acl.h"
#include "test/mock/mock_stack_btm_sec.h"

using namespace std::chrono_literals;

namespace {
const RawAddress kRawAddress({0x11, 0x22, 0x33, 0x44, 0x55, 0x66});
}  // namespace

// TODO move into mock
void BTM_block_role_switch_and_sniff_mode_for(const RawAddress& peer_addr) {}

struct alarm_t {
  alarm_t(const char* name){};
  int any_value;
};

extern uint8_t appl_trace_level;

class BtaAvTest : public testing::Test {
 protected:
  void SetUp() override {
    mock_function_count_map.clear();
    bluetooth::common::InitFlags::SetAllForTesting();
    appl_trace_level = BT_TRACE_LEVEL_VERBOSE;
  }
  void TearDown() override {
    LOG_INFO("appl_trace_level:%hhu", appl_trace_level);
  }
};

TEST_F(BtaAvTest, nop) {
  bool status = true;
  ASSERT_EQ(true, status);
}

TEST_F(BtaAvTest, bta_av_rc_opened) {
  tBTA_AV_CB cb = {
      .p_cback =
          [](tBTA_AV_EVT event, tBTA_AV* p_data) {
            const tBTA_AV_RC_OPEN* rc_open = &p_data->rc_open;
            ASSERT_EQ(BTA_AV_RC_OPEN_EVT, event);
            ASSERT_EQ(kRawAddress, rc_open->peer_addr);
          },
  };
  tBTA_AV_DATA data = {
      .rc_conn_chg =
          {
              .hdr = {},
              .peer_addr = kRawAddress,
              .handle = 0,
          },
  };
  bta_av_rc_opened(&cb, &data);
}
+0 −2
Original line number Original line Diff line number Diff line
@@ -38,8 +38,6 @@ std::map<std::string, int> mock_function_count_map;


extern struct btm_client_interface_t btm_client_interface;
extern struct btm_client_interface_t btm_client_interface;


void LogMsg(uint32_t trace_set_mask, const char* fmt_str, ...) {}

namespace base {
namespace base {
class MessageLoop;
class MessageLoop;
}  // namespace base
}  // namespace base