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

Commit 053b4e93 authored by Myles Watson's avatar Myles Watson
Browse files

Use a single IsoManager mock

Bug: 283254594
Test: mma -j32
Flag: EXEMPT, test-only changes
Change-Id: Iebe4ae81d896ff0a2f19ab6d29f4c62309737bfd
parent c7993545
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -429,6 +429,7 @@ cc_test {
        "libbt_shim_ffi",
        "libbtcore",
        "libchrome",
        "libgmock",
        "libosi",
        "libstatslog_bt",
    ],
@@ -849,6 +850,7 @@ cc_test {
        ":TestMockBtaLeAudioHalVerifier",
        ":TestMockMainShim",
        ":TestMockMainShimEntry",
        ":TestMockStackBtmIso",
        ":TestMockStackL2cap",
        ":TestStubOsi",
        "le_audio/audio_hal_client/audio_hal_client_test.cc",
@@ -870,7 +872,6 @@ cc_test {
        "le_audio/metrics_collector_linux.cc",
        "le_audio/mock_codec_interface.cc",
        "le_audio/mock_codec_manager.cc",
        "le_audio/mock_iso_manager.cc",
        "le_audio/state_machine.cc",
        "le_audio/state_machine_test.cc",
        "le_audio/storage_helper.cc",
@@ -912,6 +913,7 @@ cc_test {
        "libevent",
        "libflatbuffers-cpp",
        "libgmock",
        "libgtest",
        "libosi",
    ],
    sanitize: {
@@ -942,6 +944,7 @@ cc_test {
        ":TestMockBtaLeAudioHalVerifier",
        ":TestMockMainShim",
        ":TestMockMainShimEntry",
        ":TestMockStackBtmIso",
        ":TestMockStackL2cap",
        ":TestStubOsi",
        "gatt/database.cc",
@@ -962,7 +965,6 @@ cc_test {
        "le_audio/metrics_collector_test.cc",
        "le_audio/mock_codec_interface.cc",
        "le_audio/mock_codec_manager.cc",
        "le_audio/mock_iso_manager.cc",
        "le_audio/mock_state_machine.cc",
        "le_audio/storage_helper.cc",
        "test/common/bta_gatt_api_mock.cc",
@@ -995,6 +997,7 @@ cc_test {
        "libflagtest",
        "libflatbuffers-cpp",
        "libgmock",
        "libgtest",
        "liblc3",
        "libosi",
    ],
@@ -1056,6 +1059,7 @@ cc_test {
        ":TestCommonMockFunctions",
        ":TestCommonStackConfig",
        ":TestMockMainShim",
        ":TestMockStackBtmIso",
        "le_audio/broadcaster/broadcaster_types.cc",
        "le_audio/broadcaster/state_machine.cc",
        "le_audio/broadcaster/state_machine_test.cc",
@@ -1063,7 +1067,6 @@ cc_test {
        "le_audio/le_audio_utils.cc",
        "le_audio/mock_codec_interface.cc",
        "le_audio/mock_codec_manager.cc",
        "le_audio/mock_iso_manager.cc",
    ],
    shared_libs: [
        "libcrypto",
@@ -1081,6 +1084,7 @@ cc_test {
        "libchrome",
        "libflatbuffers-cpp",
        "libgmock",
        "libgtest",
        "liblc3",
        "libosi",
    ],
@@ -1116,6 +1120,7 @@ cc_test {
    srcs: [
        ":TestCommonMockFunctions",
        ":TestCommonStackConfig",
        ":TestMockStackBtmIso",
        ":TestStubOsi",
        "le_audio/broadcaster/broadcaster.cc",
        "le_audio/broadcaster/broadcaster_test.cc",
@@ -1127,7 +1132,6 @@ cc_test {
        "le_audio/metrics_collector_linux.cc",
        "le_audio/mock_codec_interface.cc",
        "le_audio/mock_codec_manager.cc",
        "le_audio/mock_iso_manager.cc",
        "test/common/mock_controller.cc",
    ],
    shared_libs: [
@@ -1147,6 +1151,7 @@ cc_test {
        "libchrome",
        "libevent",
        "libgmock",
        "libgtest",
        "liblc3",
        "libosi",
    ],
+1 −1
Original line number Diff line number Diff line
@@ -26,11 +26,11 @@
#include "bta/le_audio/broadcaster/mock_state_machine.h"
#include "bta/le_audio/content_control_id_keeper.h"
#include "bta/le_audio/le_audio_types.h"
#include "bta/le_audio/mock_iso_manager.h"
#include "bta/test/common/mock_controller.h"
#include "device/include/controller.h"
#include "stack/include/btm_iso_api.h"
#include "test/common/mock_functions.h"
#include "test/mock/mock_stack_btm_iso.h"

using namespace std::chrono_literals;

+1 −1
Original line number Diff line number Diff line
@@ -22,11 +22,11 @@

#include "../le_audio_types.h"
#include "btm_iso_api.h"
#include "mock_iso_manager.h"
#include "stack/include/btm_ble_api_types.h"
#include "state_machine.h"
#include "test/common/mock_functions.h"
#include "test/mock/mock_main_shim_le_advertising_manager.h"
#include "test/mock/mock_stack_btm_iso.h"

using namespace bluetooth::hci::iso_manager;

+1 −1
Original line number Diff line number Diff line
@@ -43,10 +43,10 @@
#include "mock_controller.h"
#include "mock_csis_client.h"
#include "mock_device_groups.h"
#include "mock_iso_manager.h"
#include "mock_state_machine.h"
#include "os/log.h"
#include "test/common/mock_functions.h"
#include "test/mock/mock_stack_btm_iso.h"

#define TEST_BT com::android::bluetooth::flags

+0 −162
Original line number Diff line number Diff line
/*
 * Copyright 2020 HIMSA II K/S - www.himsa.com.
 * Represented by EHIMA - www.ehima.com
 *
 * 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 "mock_iso_manager.h"

MockIsoManager* mock_pimpl_;
MockIsoManager* MockIsoManager::GetInstance() {
  bluetooth::hci::IsoManager::GetInstance();
  return mock_pimpl_;
}

namespace bluetooth {
namespace hci {

struct IsoManager::impl : public MockIsoManager {
 public:
  impl() = default;
  ~impl() = default;
};

IsoManager::IsoManager() {}

void IsoManager::RegisterCigCallbacks(
    iso_manager::CigCallbacks* callbacks) const {
  if (!pimpl_) return;
  pimpl_->RegisterCigCallbacks(callbacks);
}

void IsoManager::RegisterBigCallbacks(
    iso_manager::BigCallbacks* callbacks) const {
  if (!pimpl_) return;
  pimpl_->RegisterBigCallbacks(callbacks);
}

void IsoManager::RegisterOnIsoTrafficActiveCallback(void callback(bool)) const {
  if (!pimpl_) return;
  pimpl_->RegisterOnIsoTrafficActiveCallbacks(callback);
}

void IsoManager::CreateCig(uint8_t cig_id,
                           struct iso_manager::cig_create_params cig_params) {
  if (!pimpl_) return;
  pimpl_->CreateCig(cig_id, std::move(cig_params));
}

void IsoManager::ReconfigureCig(
    uint8_t cig_id, struct iso_manager::cig_create_params cig_params) {
  if (!pimpl_) return;
  pimpl_->ReconfigureCig(cig_id, std::move(cig_params));
}

void IsoManager::RemoveCig(uint8_t cig_id, bool force) {
  pimpl_->RemoveCig(cig_id, force);
}

void IsoManager::EstablishCis(
    struct iso_manager::cis_establish_params conn_params) {
  if (!pimpl_) return;
  pimpl_->EstablishCis(std::move(conn_params));
}

void IsoManager::DisconnectCis(uint16_t cis_handle, uint8_t reason) {
  if (!pimpl_) return;
  pimpl_->DisconnectCis(cis_handle, reason);
}

void IsoManager::SetupIsoDataPath(
    uint16_t iso_handle, struct iso_manager::iso_data_path_params path_params) {
  if (!pimpl_) return;
  pimpl_->SetupIsoDataPath(iso_handle, std::move(path_params));
}

void IsoManager::RemoveIsoDataPath(uint16_t iso_handle, uint8_t data_path_dir) {
  if (!pimpl_) return;
  pimpl_->RemoveIsoDataPath(iso_handle, data_path_dir);
}

void IsoManager::ReadIsoLinkQuality(uint16_t iso_handle) {
  if (!pimpl_) return;
  pimpl_->ReadIsoLinkQuality(iso_handle);
}

void IsoManager::SendIsoData(uint16_t iso_handle, const uint8_t* data,
                             uint16_t data_len) {
  if (!pimpl_) return;
  pimpl_->SendIsoData(iso_handle, data, data_len);
}

void IsoManager::CreateBig(uint8_t big_id,
                           struct iso_manager::big_create_params big_params) {
  if (!pimpl_) return;
  pimpl_->CreateBig(big_id, std::move(big_params));
}

void IsoManager::TerminateBig(uint8_t big_id, uint8_t reason) {
  if (!pimpl_) return;
  pimpl_->TerminateBig(big_id, reason);
}

void IsoManager::HandleIsoData(void* p_msg) {
  if (!pimpl_) return;
  pimpl_->HandleIsoData(static_cast<BT_HDR*>(p_msg));
}

void IsoManager::HandleDisconnect(uint16_t handle, uint8_t reason) {
  if (!pimpl_) return;
  pimpl_->HandleDisconnect(handle, reason);
}

void IsoManager::HandleNumComplDataPkts(uint16_t handle, uint16_t credits) {
  if (!pimpl_) return;
  pimpl_->HandleNumComplDataPkts(handle, credits);
}

void IsoManager::HandleHciEvent(uint8_t sub_code, uint8_t* params,
                                uint16_t length) {
  if (!pimpl_) return;
  pimpl_->HandleHciEvent(sub_code, params, length);
}

void IsoManager::Start() {
  // It is needed here as IsoManager which is a singleton creates it, but in
  // this mock we want to destroy and recreate the mock on each test case.
  if (!pimpl_) {
    pimpl_ = std::make_unique<testing::NiceMock<impl>>();
  }

  mock_pimpl_ = pimpl_.get();
  pimpl_->Start();
}

void IsoManager::Stop() {
  // It is needed here as IsoManager which is a singleton creates it, but in
  // this mock we want to destroy and recreate the mock on each test case.
  if (pimpl_) {
    pimpl_->Stop();
    pimpl_.reset();
  }

  mock_pimpl_ = nullptr;
}

void IsoManager::Dump(int fd) {}

IsoManager::~IsoManager() = default;

}  // namespace hci
}  // namespace bluetooth
Loading