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

Commit 1b53f822 authored by Myles Watson's avatar Myles Watson
Browse files

Use a single mock LE Advertising Manager

Bug: 301661850
Test: mma -j32
Flag: EXEMPT, no logical change
Change-Id: Ibba43c807d766f1a7d51d89c2b8d9dd5fa2bc980
parent 780e89f6
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -1053,8 +1053,8 @@ cc_test {
    srcs: [
    srcs: [
        ":TestCommonMockFunctions",
        ":TestCommonMockFunctions",
        ":TestCommonStackConfig",
        ":TestCommonStackConfig",
        ":TestMockMainShim",
        "le_audio/broadcaster/broadcaster_types.cc",
        "le_audio/broadcaster/broadcaster_types.cc",
        "le_audio/broadcaster/mock_ble_advertising_manager.cc",
        "le_audio/broadcaster/state_machine.cc",
        "le_audio/broadcaster/state_machine.cc",
        "le_audio/broadcaster/state_machine_test.cc",
        "le_audio/broadcaster/state_machine_test.cc",
        "le_audio/le_audio_types.cc",
        "le_audio/le_audio_types.cc",
@@ -1072,11 +1072,14 @@ cc_test {
        "libbluetooth_gd",
        "libbluetooth_gd",
        "libbluetooth_log",
        "libbluetooth_log",
        "libbt-common",
        "libbt-common",
        "libbt-platform-protos-lite",
        "libbt_shim_bridge",
        "libbt_shim_bridge",
        "libbt_shim_ffi",
        "libbt_shim_ffi",
        "libchrome",
        "libchrome",
        "libflatbuffers-cpp",
        "libgmock",
        "libgmock",
        "liblc3",
        "liblc3",
        "libosi",
    ],
    ],
    sanitize: {
    sanitize: {
        cfi: true,
        cfi: true,
@@ -1114,7 +1117,6 @@ cc_test {
        "le_audio/broadcaster/broadcaster.cc",
        "le_audio/broadcaster/broadcaster.cc",
        "le_audio/broadcaster/broadcaster_test.cc",
        "le_audio/broadcaster/broadcaster_test.cc",
        "le_audio/broadcaster/broadcaster_types.cc",
        "le_audio/broadcaster/broadcaster_types.cc",
        "le_audio/broadcaster/mock_ble_advertising_manager.cc",
        "le_audio/broadcaster/mock_state_machine.cc",
        "le_audio/broadcaster/mock_state_machine.cc",
        "le_audio/content_control_id_keeper.cc",
        "le_audio/content_control_id_keeper.cc",
        "le_audio/le_audio_types.cc",
        "le_audio/le_audio_types.cc",
+0 −45
Original line number Original line Diff line number Diff line
/*
 * Copyright 2021 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_ble_advertising_manager.h"

#include <base/memory/weak_ptr.h>

#include "main/shim/le_advertising_manager.h"

namespace {
MockBleAdvertisingManager* bt_le_advertiser_instance;
}  // namespace

void MockBleAdvertisingManager::Initialize() {
  if (bt_le_advertiser_instance == nullptr) {
    bt_le_advertiser_instance = new MockBleAdvertisingManager();
  }
}

void MockBleAdvertisingManager::CleanUp() {
  delete bt_le_advertiser_instance;
  bt_le_advertiser_instance = nullptr;
}

MockBleAdvertisingManager* MockBleAdvertisingManager::Get() {
  return bt_le_advertiser_instance;
}

BleAdvertiserInterface* bluetooth::shim::get_ble_advertiser_instance() {
  return static_cast<BleAdvertiserInterface*>(bt_le_advertiser_instance);
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -22,11 +22,11 @@


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


using namespace bluetooth::hci::iso_manager;
using namespace bluetooth::hci::iso_manager;


+2 −5
Original line number Original line Diff line number Diff line
@@ -336,6 +336,8 @@ cc_defaults {
    ],
    ],
    static_libs: [
    static_libs: [
        "libchrome",
        "libchrome",
        "libgmock",
        "libgtest",
    ],
    ],
    shared_libs: [
    shared_libs: [
        "libbase",
        "libbase",
@@ -465,7 +467,6 @@ cc_fuzz {
        "libbt-platform-protos-lite",
        "libbt-platform-protos-lite",
        "libbt_shim_bridge",
        "libbt_shim_bridge",
        "libbt_shim_ffi",
        "libbt_shim_ffi",
        "libgmock",
    ],
    ],
}
}


@@ -515,7 +516,6 @@ cc_fuzz {
        "libbt-platform-protos-lite",
        "libbt-platform-protos-lite",
        "libbt_shim_bridge",
        "libbt_shim_bridge",
        "libbt_shim_ffi",
        "libbt_shim_ffi",
        "libgmock",
    ],
    ],
}
}


@@ -560,7 +560,6 @@ cc_fuzz {
        "libbt-platform-protos-lite",
        "libbt-platform-protos-lite",
        "libbt_shim_bridge",
        "libbt_shim_bridge",
        "libbt_shim_ffi",
        "libbt_shim_ffi",
        "libgmock",
    ],
    ],
}
}


@@ -609,7 +608,6 @@ cc_fuzz {
        "libbt_shim_bridge",
        "libbt_shim_bridge",
        "libbt_shim_ffi",
        "libbt_shim_ffi",
        "libcom.android.sysprop.bluetooth.wrapped",
        "libcom.android.sysprop.bluetooth.wrapped",
        "libgmock",
    ],
    ],
}
}


@@ -653,7 +651,6 @@ cc_fuzz {
        "libbt-platform-protos-lite",
        "libbt-platform-protos-lite",
        "libbt_shim_bridge",
        "libbt_shim_bridge",
        "libbt_shim_ffi",
        "libbt_shim_ffi",
        "libgmock",
    ],
    ],
    target: {
    target: {
        android: {
        android: {
+25 −12
Original line number Original line Diff line number Diff line
/*
/*
 * Copyright 2021 The Android Open Source Project
 * Copyright 2021 HIMSA II K/S - www.himsa.com.
 * Represented by EHIMA - www.ehima.com
 *
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * you may not use this file except in compliance with the License.
@@ -14,19 +15,31 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


/*
#include "mock_main_shim_le_advertising_manager.h"
 * Generated mock file from original source file

 *   Functions generated:3
#include <base/memory/weak_ptr.h>
 */


#include "include/hardware/ble_advertiser.h"
#include "main/shim/le_advertising_manager.h"
#include "main/shim/le_advertising_manager.h"
#include "test/common/mock_functions.h"


BleAdvertiserInterface* bluetooth::shim::get_ble_advertiser_instance() {
namespace {
  inc_func_call_count(__func__);
MockBleAdvertisingManager* bt_le_advertiser_instance;
  return nullptr;
}  // namespace

void MockBleAdvertisingManager::Initialize() {
  if (bt_le_advertiser_instance == nullptr) {
    bt_le_advertiser_instance = new MockBleAdvertisingManager();
  }
}
}
void bluetooth::shim::init_advertising_manager() {

  inc_func_call_count(__func__);
void MockBleAdvertisingManager::CleanUp() {
  delete bt_le_advertiser_instance;
  bt_le_advertiser_instance = nullptr;
}

MockBleAdvertisingManager* MockBleAdvertisingManager::Get() {
  return bt_le_advertiser_instance;
}

BleAdvertiserInterface* bluetooth::shim::get_ble_advertiser_instance() {
  return static_cast<BleAdvertiserInterface*>(bt_le_advertiser_instance);
}
}
Loading