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

Commit 683a833f authored by Myles Watson's avatar Myles Watson Committed by Gerrit Code Review
Browse files

Merge "Use a single mock LE Advertising Manager" into main

parents 5c03a6e6 1b53f822
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1053,8 +1053,8 @@ cc_test {
    srcs: [
        ":TestCommonMockFunctions",
        ":TestCommonStackConfig",
        ":TestMockMainShim",
        "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_test.cc",
        "le_audio/le_audio_types.cc",
@@ -1072,11 +1072,14 @@ cc_test {
        "libbluetooth_gd",
        "libbluetooth_log",
        "libbt-common",
        "libbt-platform-protos-lite",
        "libbt_shim_bridge",
        "libbt_shim_ffi",
        "libchrome",
        "libflatbuffers-cpp",
        "libgmock",
        "liblc3",
        "libosi",
    ],
    sanitize: {
        cfi: true,
@@ -1114,7 +1117,6 @@ cc_test {
        "le_audio/broadcaster/broadcaster.cc",
        "le_audio/broadcaster/broadcaster_test.cc",
        "le_audio/broadcaster/broadcaster_types.cc",
        "le_audio/broadcaster/mock_ble_advertising_manager.cc",
        "le_audio/broadcaster/mock_state_machine.cc",
        "le_audio/content_control_id_keeper.cc",
        "le_audio/le_audio_types.cc",
+0 −45
Original line number 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 Diff line number Diff line
@@ -22,11 +22,11 @@

#include "../le_audio_types.h"
#include "btm_iso_api.h"
#include "mock_ble_advertising_manager.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"

using namespace bluetooth::hci::iso_manager;

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

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

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

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

@@ -653,7 +651,6 @@ cc_fuzz {
        "libbt-platform-protos-lite",
        "libbt_shim_bridge",
        "libbt_shim_ffi",
        "libgmock",
    ],
    target: {
        android: {
+25 −12
Original line number 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");
 * you may not use this file except in compliance with the License.
@@ -14,19 +15,31 @@
 * limitations under the License.
 */

/*
 * Generated mock file from original source file
 *   Functions generated:3
 */
#include "mock_main_shim_le_advertising_manager.h"

#include <base/memory/weak_ptr.h>

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

BleAdvertiserInterface* bluetooth::shim::get_ble_advertiser_instance() {
  inc_func_call_count(__func__);
  return nullptr;
namespace {
MockBleAdvertisingManager* bt_le_advertiser_instance;
}  // 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