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

Commit 6aa6c0df authored by Chris Manton's avatar Chris Manton
Browse files

Re-point bta:: tests to common test/mock

Bug: 163134718
Test: gd/cert/run
Tag: #refactor

Change-Id: I8dbfc4754a754011a0c06c5f8d21abce15931cd3
parent a7ae816d
Loading
Loading
Loading
Loading
+12 −30
Original line number Diff line number Diff line
@@ -160,8 +160,19 @@ cc_test {
    host_supported: true,
    include_dirs: [
        "packages/modules/Bluetooth/system",
        "packages/modules/Bluetooth/system/gd",
    ],
    generated_headers: [
        "BluetoothGeneratedBundlerSchema_h_bfbs",
        "BluetoothGeneratedDumpsysDataSchema_h",
        "BluetoothGeneratedPackets_h",
    ],
    srcs: [
        ":TestMockBtif",
        ":TestMockDevice",
        ":TestMockMainShim",
        ":TestMockStack",
        ":TestStubOsi",
        "dm/bta_dm_act.cc",
        "dm/bta_dm_cfg.cc",
        "dm/bta_dm_ci.cc",
@@ -183,39 +194,10 @@ cc_test {
        "sys/bta_sys_conn.cc",
        "sys/bta_sys_main.cc",
        "test/bta_dm_test.cc",
        "test/common/fake_osi.cc",
        "test/common/mock_btif_co_bta_dm_co.cc",
        "test/common/mock_btif_co_bta_hh_co.cc",
        "test/common/mock_btif_debug_conn.cc",
        "test/common/mock_btif_dm.cc",
        "test/common/mock_btif_stack_manager.cc",
        "test/common/mock_btif_storage.cc",
        "test/common/mock_device_controller.cc",
        "test/common/mock_device_interop.cc",
        "test/common/mock_main_shim_acl.cc",
        "test/common/mock_main_shim_btm_api.cc",
        "test/common/mock_shim.cc",
        "test/common/mock_stack_acl.cc",
        "test/common/mock_stack_btm.cc",
        "test/common/mock_stack_btm_ble.cc",
        "test/common/mock_stack_btm_dev.cc",
        "test/common/mock_stack_btm_pm.cc",
        "test/common/mock_stack_btm_sco.cc",
        "test/common/mock_stack_btm_sec.cc",
        "test/common/mock_stack_crypto_toolbox_aes_cmac.cc",
        "test/common/mock_stack_gap_ble.cc",
        "test/common/mock_stack_btm_main.cc",
        "test/common/mock_stack_gatt.cc",
        "test/common/mock_stack_gatt_attr.cc",
        "test/common/mock_stack_gatt_connection_manager.cc",
        "test/common/mock_stack_hidh.cc",
        "test/common/mock_stack_l2cap.cc",
        "test/common/mock_stack_l2cap_ble.cc",
        "test/common/mock_stack_sdp.cc",
        "test/common/mock_stack_srvc_dis.cc",
    ],
    shared_libs: [
        "libcrypto",
        "libflatbuffers-cpp",
        "liblog",
        "libprotobuf-cpp-lite",
    ],
+0 −12
Original line number Diff line number Diff line
@@ -26,23 +26,11 @@

std::map<std::string, int> mock_function_count_map;

bt_status_t do_in_main_thread_delayed(const base::Location& from_here,
                                      base::OnceClosure task,
                                      const base::TimeDelta& delay) {
  return BT_STATUS_SUCCESS;
}

bt_status_t do_in_main_thread(const base::Location& from_here,
                              base::OnceClosure task) {
  return BT_STATUS_SUCCESS;
}

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

namespace base {
class MessageLoop;
}  // namespace base
bluetooth::common::MessageLoopThread* get_main_thread() { return nullptr; }

namespace {
constexpr uint8_t kUnusedTimer = BTA_ID_MAX;
+0 −175
Original line number Diff line number Diff line
/*
 * Copyright 2021 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.
 */

/*
 * Generated mock file from original source file
 *   Functions generated:51
 */

#include <cstdint>
#include <map>
#include <string>

extern std::map<std::string, int> mock_function_count_map;

#include "bta/include/bta_api.h"
#include "include/hardware/bluetooth.h"
#include "internal_include/bte_appl.h"
#include "types/bt_transport.h"
#include "types/raw_address.h"

struct uid_set_t;

#ifndef UNUSED_ATTR
#define UNUSED_ATTR
#endif

bool btif_dm_pairing_is_busy() {
  mock_function_count_map[__func__]++;
  return false;
}
bool check_cod(const RawAddress* remote_bdaddr, uint32_t cod) {
  mock_function_count_map[__func__]++;
  return false;
}
bool check_cod_hid(const RawAddress* remote_bdaddr) {
  mock_function_count_map[__func__]++;
  return false;
}
bool check_sdp_bl(const RawAddress* remote_bdaddr) {
  mock_function_count_map[__func__]++;
  return false;
}
bt_status_t btif_dm_get_adapter_property(bt_property_t* prop) {
  mock_function_count_map[__func__]++;
  return BT_STATUS_SUCCESS;
}
bt_status_t btif_in_execute_service_request(tBTA_SERVICE_ID service_id,
                                            bool b_enable) {
  mock_function_count_map[__func__]++;
  return BT_STATUS_SUCCESS;
}
uint16_t btif_dm_get_connection_state(const RawAddress* bd_addr) {
  mock_function_count_map[__func__]++;
  return 0;
}
void BTIF_dm_disable() { mock_function_count_map[__func__]++; }
void BTIF_dm_enable() { mock_function_count_map[__func__]++; }
void BTIF_dm_on_hw_error() { mock_function_count_map[__func__]++; }
void BTIF_dm_report_inquiry_status_change(uint8_t status) {
  mock_function_count_map[__func__]++;
}
void bte_dm_evt(tBTA_DM_SEC_EVT event, tBTA_DM_SEC* p_data) {
  mock_function_count_map[__func__]++;
}
void btif_ble_receiver_test(uint8_t rx_freq) {
  mock_function_count_map[__func__]++;
}
void btif_ble_test_end() { mock_function_count_map[__func__]++; }
void btif_ble_transmitter_test(uint8_t tx_freq, uint8_t test_data_len,
                               uint8_t packet_payload) {
  mock_function_count_map[__func__]++;
}
void btif_debug_bond_event_dump(int fd) { mock_function_count_map[__func__]++; }
void btif_dm_ble_sec_req_evt(tBTA_DM_BLE_SEC_REQ* p_ble_req, bool is_consent) {
  mock_function_count_map[__func__]++;
}
void btif_dm_cancel_bond(const RawAddress bd_addr) {
  mock_function_count_map[__func__]++;
}
void btif_dm_cancel_discovery(void) { mock_function_count_map[__func__]++; }
void btif_dm_cleanup(void) { mock_function_count_map[__func__]++; }
void btif_dm_create_bond(const RawAddress bd_addr, int transport) {
  mock_function_count_map[__func__]++;
}
void btif_dm_create_bond_out_of_band(const RawAddress bd_addr, int transport,
                                     const bt_oob_data_t p192_data,
                                     const bt_oob_data_t p256_data) {
  mock_function_count_map[__func__]++;
}
void btif_dm_enable_service(tBTA_SERVICE_ID service_id, bool enable) {
  mock_function_count_map[__func__]++;
}
void btif_dm_get_ble_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK* p_key_mask,
                                Octet16* p_er,
                                tBTA_BLE_LOCAL_ID_KEYS* p_id_keys) {
  mock_function_count_map[__func__]++;
}
void btif_dm_get_remote_services(RawAddress remote_addr, const int transport) {
  mock_function_count_map[__func__]++;
}
void btif_dm_hh_open_failed(RawAddress* bdaddr) {
  mock_function_count_map[__func__]++;
}
void btif_dm_init(uid_set_t* set) { mock_function_count_map[__func__]++; }
void btif_dm_load_ble_local_keys(void) { mock_function_count_map[__func__]++; }
void btif_dm_on_disable() { mock_function_count_map[__func__]++; }
void btif_dm_pin_reply(const RawAddress bd_addr, uint8_t accept,
                       uint8_t pin_len, bt_pin_code_t pin_code) {
  mock_function_count_map[__func__]++;
}
void btif_dm_proc_io_req(tBTM_AUTH_REQ* p_auth_req, bool is_orig) {
  mock_function_count_map[__func__]++;
}
void btif_dm_proc_io_rsp(UNUSED_ATTR const RawAddress& bd_addr,
                         tBTM_IO_CAP io_cap, UNUSED_ATTR tBTM_OOB_DATA oob_data,
                         tBTM_AUTH_REQ auth_req) {
  mock_function_count_map[__func__]++;
}
void btif_dm_read_energy_info() { mock_function_count_map[__func__]++; }
void btif_dm_remove_ble_bonding_keys(void) {
  mock_function_count_map[__func__]++;
}
void btif_dm_remove_bond(const RawAddress bd_addr) {
  mock_function_count_map[__func__]++;
}
void btif_dm_save_ble_bonding_keys(RawAddress& bd_addr) {
  mock_function_count_map[__func__]++;
}
void btif_dm_set_oob_for_io_req(tBTM_OOB_DATA* p_has_oob_data) {
  mock_function_count_map[__func__]++;
}
void btif_dm_set_oob_for_le_io_req(const RawAddress& bd_addr,
                                   tBTM_OOB_DATA* p_has_oob_data,
                                   tBTM_LE_AUTH_REQ* p_auth_req) {
  mock_function_count_map[__func__]++;
}
void btif_dm_ssp_reply(const RawAddress bd_addr, bt_ssp_variant_t variant,
                       uint8_t accept) {
  mock_function_count_map[__func__]++;
}
void btif_dm_start_discovery(void) { mock_function_count_map[__func__]++; }
void btif_dm_update_ble_remote_properties(const RawAddress& bd_addr,
                                          BD_NAME bd_name,
                                          tBT_DEVICE_TYPE dev_type) {
  mock_function_count_map[__func__]++;
}

bool btif_dm_get_smp_config(tBTE_APPL_CFG* p_cfg) {
  mock_function_count_map[__func__]++;
  return true;
}

bool btif_dm_proc_rmt_oob(const RawAddress& bd_addr, Octet16* p_c,
                          Octet16* p_r) {
  mock_function_count_map[__func__]++;
  return false;
}

void btif_dm_proc_loc_oob(tBT_TRANSPORT transport, bool is_valid,
                          const Octet16& c, const Octet16& r) {
  mock_function_count_map[__func__]++;
}
+0 −45
Original line number Diff line number Diff line
/*
 * Copyright 2021 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.
 */

/*
 * Generated mock file from original source file
 *   Functions generated:8
 */

#include <map>
#include <string>

extern std::map<std::string, int> mock_function_count_map;

#include "device/include/controller.h"
#include "hci/include/hci_layer.h"
#include "hci/include/hci_packet_factory.h"

#ifndef UNUSED_ATTR
#define UNUSED_ATTR
#endif

const controller_t* controller_get_interface() {
  mock_function_count_map[__func__]++;
  return nullptr;
}
const controller_t* controller_get_test_interface(
    const hci_t* hci_interface,
    const hci_packet_factory_t* packet_factory_interface,
    const hci_packet_parser_t* packet_parser_interface) {
  mock_function_count_map[__func__]++;
  return nullptr;
}
+0 −50
Original line number Diff line number Diff line
/*
 * Copyright 2021 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.
 */

#define LOG_TAG "bt_shim"

#include "gd/common/init_flags.h"
#include "main/shim/shim.h"

future_t* IdleModuleStartUp() { return kReturnImmediate; }

future_t* ShimModuleStartUp() { return kReturnImmediate; }

future_t* GeneralShutDown() { return kReturnImmediate; }

bool bluetooth::shim::is_gd_advertising_enabled() { return false; }

bool bluetooth::shim::is_gd_scanning_enabled() { return false; }

bool bluetooth::shim::is_gd_security_enabled() { return false; }

bool bluetooth::shim::is_gd_acl_enabled() { return false; }

bool bluetooth::shim::is_gd_link_policy_enabled() { return false; }

bool bluetooth::shim::is_gd_hci_enabled() { return false; }

bool bluetooth::shim::is_gd_controller_enabled() { return false; }

bool bluetooth::shim::is_gd_l2cap_enabled() { return false; }

bool bluetooth::shim::is_gd_shim_enabled() {
  return bluetooth::common::init_flags::gd_core_is_enabled();
}

bool bluetooth::shim::is_any_gd_enabled() { return false; }

bool bluetooth::shim::is_gd_stack_started_up() { return false; }
Loading