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

Commit 47ee7b32 authored by Chris Manton's avatar Chris Manton
Browse files

Re-point main/test/ to use common test/mock

Toward testable code

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

Change-Id: I6f2d7a4a26858c416750bf35c47f70ec13f2f0f4
parent 9e45a01c
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -317,7 +317,6 @@ cc_test {
        "packages/modules/Bluetooth/system/bta/dm",
        "packages/modules/Bluetooth/system/bta/include",
        "packages/modules/Bluetooth/system/bta/sys",
        "packages/modules/Bluetooth/system/btcore/include",
        "packages/modules/Bluetooth/system/btif/avrcp",
        "packages/modules/Bluetooth/system/btif/co",
        "packages/modules/Bluetooth/system/btif/include",
@@ -353,6 +352,12 @@ cc_test {
          ":TestMockUdrv",
          "test/btif_stack_test.cc",
      ],
      generated_headers: [
        "BluetoothGeneratedBundlerSchema_h_bfbs",
        "BluetoothGeneratedDumpsysDataSchema_h",
        "BluetoothGeneratedDumpsysTestData_h",
        "BluetoothGeneratedPackets_h",
      ],
      header_libs: ["libbluetooth_headers"],
      shared_libs: [
          "android.hardware.bluetooth.a2dp@1.0",
@@ -360,6 +365,7 @@ cc_test {
          "android.hardware.bluetooth.audio@2.1",
          "libcrypto",
          "libcutils",
          "libflatbuffers-cpp",
          "libhidlbase",
          "liblog",
          "libtinyxml2",
+5 −19
Original line number Diff line number Diff line
@@ -216,6 +216,11 @@ cc_test {
        "packages/modules/Bluetooth/system/stack/include",
    ],
    srcs: [
        ":TestMockBta",
        ":TestMockBtif",
        ":TestMockLegacyHciCommands",
        ":TestMockMainShimEntry",
        ":TestMockStack",
        "shim/acl_api.cc",
        "shim/acl.cc",
        "shim/acl_legacy_interface.cc",
@@ -233,25 +238,6 @@ cc_test {
        "shim/metrics_api.cc",
        "shim/shim.cc",
        "shim/stack.cc",
        "test/common/main_handler.cc",
        "test/common/mock_acl_ble.cc",
        "test/common/mock_acl_btm_pm.cc",
        "test/common/mock_bta_dm_act.cc",
        "test/common/mock_btif_core.cc",
        "test/common/mock_btif_dm.cc",
        "test/common/mock_btm_ble_gap.cc",
        "test/common/mock_btm_dev.cc",
        "test/common/mock_btm_inq.cc",
        "test/common/mock_btm_main.cc",
        "test/common/mock_btm_sec.cc",
        "test/common/mock_entry.cc",
        "test/common/mock_gatt_main.cc",
        "test/common/mock_hcic_hcicmds.cc",
        "test/common/mock_l2cap_l2c_ble.cc",
        "test/common/mock_l2cap_l2c_link.cc",
        "test/common/mock_stack_acl.cc",
        "test/common/mock_stack_btm_ble.cc",
        "test/common/mock_stack_btm_sco.cc",
        "test/main_shim_test.cc",
    ],
    static_libs: [
+0 −35
Original line number Diff line number Diff line
/*
 * Copyright 2020 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 "module.h"

#include "btif/include/btif_activity_attribution.h"
#include "main/shim/activity_attribution.h"
#include "main/shim/shim.h"

ActivityAttributionInterface*
bluetooth::activity_attribution::get_activity_attribution_instance() {
  return nullptr;
}

ActivityAttributionInterface*
bluetooth::shim::get_activity_attribution_instance() {
  return nullptr;
}

const bluetooth::ModuleFactory
    bluetooth::activity_attribution::ActivityAttribution::Factory =
        bluetooth::ModuleFactory([]() { return nullptr; });
+0 −118
Original line number Diff line number Diff line
/*
 * Copyright 2020 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:53
 */

#include <map>
#include <string>

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

#include "bta/dm/bta_dm_int.h"
#include "types/raw_address.h"

#ifndef UNUSED_ATTR
#define UNUSED_ATTR
#endif

void BTA_dm_acl_down(const RawAddress bd_addr, tBT_TRANSPORT transport) {
  mock_function_count_map[__func__]++;
}
void BTA_dm_acl_up(const RawAddress bd_addr, tBT_TRANSPORT transport) {
  mock_function_count_map[__func__]++;
}
void BTA_dm_notify_remote_features_complete(const RawAddress bd_addr) {
  mock_function_count_map[__func__]++;
}

void BTA_dm_on_hw_off() { mock_function_count_map[__func__]++; }
void BTA_dm_on_hw_on() { mock_function_count_map[__func__]++; }
void BTA_dm_report_role_change(const RawAddress bd_addr, uint8_t new_role,
                               tHCI_STATUS hci_status) {
  mock_function_count_map[__func__]++;
}
void bta_dm_add_device(std::unique_ptr<tBTA_DM_API_ADD_DEVICE> msg) {
  mock_function_count_map[__func__]++;
}
void bta_dm_bond(const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type,
                 tBT_TRANSPORT transport, int device_type) {
  mock_function_count_map[__func__]++;
}
void bta_dm_bond_cancel(const RawAddress& bd_addr) {
  mock_function_count_map[__func__]++;
}
void bta_dm_ci_rmt_oob_act(std::unique_ptr<tBTA_DM_CI_RMT_OOB> msg) {
  mock_function_count_map[__func__]++;
}
void bta_dm_close_acl(const RawAddress& bd_addr, bool remove_dev,
                      tBT_TRANSPORT transport) {
  mock_function_count_map[__func__]++;
}
void bta_dm_confirm(const RawAddress& bd_addr, bool accept) {
  mock_function_count_map[__func__]++;
}
void bta_dm_deinit_cb(void) { mock_function_count_map[__func__]++; }
void bta_dm_disable() { mock_function_count_map[__func__]++; }
void bta_dm_disc_result(tBTA_DM_MSG* p_data) {
  mock_function_count_map[__func__]++;
}
void bta_dm_disc_rmt_name(tBTA_DM_MSG* p_data) {
  mock_function_count_map[__func__]++;
}
void bta_dm_discover(tBTA_DM_MSG* p_data) {
  mock_function_count_map[__func__]++;
}
void bta_dm_free_sdp_db() { mock_function_count_map[__func__]++; }
void bta_dm_init_cb(void) { mock_function_count_map[__func__]++; }
void bta_dm_inq_cmpl(uint8_t num) { mock_function_count_map[__func__]++; }
void bta_dm_pin_reply(std::unique_ptr<tBTA_DM_API_PIN_REPLY> msg) {
  mock_function_count_map[__func__]++;
}
void bta_dm_process_remove_device(const RawAddress& bd_addr) {
  mock_function_count_map[__func__]++;
}
void bta_dm_queue_disc(tBTA_DM_MSG* p_data) {
  mock_function_count_map[__func__]++;
}
void bta_dm_queue_search(tBTA_DM_MSG* p_data) {
  mock_function_count_map[__func__]++;
}
void bta_dm_remove_device(const RawAddress& bd_addr) {
  mock_function_count_map[__func__]++;
}
void bta_dm_rmt_name(tBTA_DM_MSG* p_data) {
  mock_function_count_map[__func__]++;
}
void bta_dm_sdp_result(tBTA_DM_MSG* p_data) {
  mock_function_count_map[__func__]++;
}
void bta_dm_search_cancel() { mock_function_count_map[__func__]++; }
void bta_dm_search_cancel_cmpl() { mock_function_count_map[__func__]++; }
void bta_dm_search_cancel_notify() { mock_function_count_map[__func__]++; }
void bta_dm_search_clear_queue() { mock_function_count_map[__func__]++; }
void bta_dm_search_cmpl() { mock_function_count_map[__func__]++; }
void bta_dm_search_result(tBTA_DM_MSG* p_data) {
  mock_function_count_map[__func__]++;
}
void bta_dm_search_start(tBTA_DM_MSG* p_data) {
  mock_function_count_map[__func__]++;
}
void bta_dm_set_dev_name(const std::vector<uint8_t>& name) {
  mock_function_count_map[__func__]++;
}
+0 −213
Original line number Diff line number Diff line
/*
 * Copyright 2020 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:47
 */

#include <map>
#include <string>

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

#include <base/bind.h>
#include <base/strings/string_number_conversions.h>
#include <cstdint>
#include <list>
#include <memory>
#include <vector>
#include "common/time_util.h"
#include "device/include/controller.h"
#include "main/shim/acl_api.h"
#include "main/shim/btm_api.h"
#include "main/shim/shim.h"
#include "osi/include/log.h"
#include "stack/btm/btm_ble_int.h"
#include "stack/btm/btm_ble_int_types.h"
#include "stack/btm/btm_dev.h"
#include "stack/btm/btm_int_types.h"
#include "stack/gatt/gatt_int.h"
#include "stack/include/acl_api.h"
#include "stack/include/advertise_data_parser.h"
#include "stack/include/bt_types.h"
#include "stack/include/btm_api_types.h"
#include "stack/include/gap_api.h"
#include "stack/include/hci_error_code.h"
#include "stack/include/hcimsgs.h"
#include "stack/include/inq_hci_link_interface.h"
#include "types/raw_address.h"

#ifndef UNUSED_ATTR
#define UNUSED_ATTR
#endif

bool BTM_BleConfigPrivacy(bool privacy_mode) {
  mock_function_count_map[__func__]++;
  return false;
}
bool BTM_BleLocalPrivacyEnabled(void) {
  mock_function_count_map[__func__]++;
  return false;
}
bool btm_ble_cancel_remote_name(const RawAddress& remote_bda) {
  mock_function_count_map[__func__]++;
  return false;
}
bool btm_ble_clear_topology_mask(tBTM_BLE_STATE_MASK request_state_mask) {
  mock_function_count_map[__func__]++;
  return false;
}
bool btm_ble_set_topology_mask(tBTM_BLE_STATE_MASK request_state_mask) {
  mock_function_count_map[__func__]++;
  return false;
}
bool btm_ble_topology_check(tBTM_BLE_STATE_MASK request_state_mask) {
  mock_function_count_map[__func__]++;
  return false;
}
tBTM_STATUS BTM_BleObserve(bool start, uint8_t duration,
                           tBTM_INQ_RESULTS_CB* p_results_cb,
                           tBTM_CMPL_CB* p_cmpl_cb) {
  mock_function_count_map[__func__]++;
  return BTM_SUCCESS;
}
tBTM_STATUS btm_ble_read_remote_name(const RawAddress& remote_bda,
                                     tBTM_CMPL_CB* p_cb) {
  mock_function_count_map[__func__]++;
  return BTM_SUCCESS;
}
tBTM_STATUS btm_ble_set_connectability(uint16_t combined_mode) {
  mock_function_count_map[__func__]++;
  return BTM_SUCCESS;
}
tBTM_STATUS btm_ble_set_discoverability(uint16_t combined_mode) {
  mock_function_count_map[__func__]++;
  return BTM_SUCCESS;
}
tBTM_STATUS btm_ble_start_adv(void) {
  mock_function_count_map[__func__]++;
  return BTM_SUCCESS;
}
tBTM_STATUS btm_ble_start_inquiry(uint8_t duration) {
  mock_function_count_map[__func__]++;
  return BTM_SUCCESS;
}
tBTM_STATUS btm_ble_stop_adv(void) {
  mock_function_count_map[__func__]++;
  return BTM_SUCCESS;
}
uint16_t BTM_BleReadConnectability() {
  mock_function_count_map[__func__]++;
  return 0;
}
uint16_t BTM_BleReadDiscoverability() {
  mock_function_count_map[__func__]++;
  return 0;
}
uint8_t BTM_BleMaxMultiAdvInstanceCount(void) {
  mock_function_count_map[__func__]++;
  return 0;
}
void BTM_BleGetDynamicAudioBuffer(
    tBTM_BT_DYNAMIC_AUDIO_BUFFER_CB p_dynamic_audio_buffer_cb[]) {
  mock_function_count_map[__func__]++;
}
void BTM_BleGetVendorCapabilities(tBTM_BLE_VSC_CB* p_cmn_vsc_cb) {
  mock_function_count_map[__func__]++;
}
void BTM_BleSetScanParams(uint32_t scan_interval, uint32_t scan_window,
                          tBLE_SCAN_MODE scan_mode,
                          base::Callback<void(uint8_t)> cb) {
  mock_function_count_map[__func__]++;
}
void btm_ble_decrement_link_topology_mask(uint8_t link_role) {
  mock_function_count_map[__func__]++;
}
void btm_ble_dir_adv_tout(void) { mock_function_count_map[__func__]++; }
void btm_ble_free() { mock_function_count_map[__func__]++; }
void btm_ble_increment_link_topology_mask(uint8_t link_role) {
  mock_function_count_map[__func__]++;
}
void btm_ble_init(void) { mock_function_count_map[__func__]++; }
void btm_ble_process_adv_addr(RawAddress& bda, uint8_t* addr_type) {
  mock_function_count_map[__func__]++;
}
void btm_ble_process_adv_pkt(uint8_t data_len, uint8_t* data) {
  mock_function_count_map[__func__]++;
}
void btm_ble_process_adv_pkt_cont(uint16_t evt_type, uint8_t addr_type,
                                  const RawAddress& bda, uint8_t primary_phy,
                                  uint8_t secondary_phy,
                                  uint8_t advertising_sid, int8_t tx_power,
                                  int8_t rssi, uint16_t periodic_adv_int,
                                  uint8_t data_len, uint8_t* data) {
  mock_function_count_map[__func__]++;
}
void btm_ble_process_adv_pkt_cont_for_inquiry(
    uint16_t evt_type, uint8_t addr_type, const RawAddress& bda,
    uint8_t primary_phy, uint8_t secondary_phy, uint8_t advertising_sid,
    int8_t tx_power, int8_t rssi, uint16_t periodic_adv_int,
    std::vector<uint8_t> advertising_data) {
  mock_function_count_map[__func__]++;
}
void btm_ble_process_ext_adv_pkt(uint8_t data_len, uint8_t* data) {
  mock_function_count_map[__func__]++;
}
void btm_ble_process_phy_update_pkt(uint8_t len, uint8_t* data) {
  mock_function_count_map[__func__]++;
}
void btm_ble_read_remote_features_complete(uint8_t* p) {
  mock_function_count_map[__func__]++;
}
void btm_ble_read_remote_name_cmpl(bool status, const RawAddress& bda,
                                   uint16_t length, char* p_name) {
  mock_function_count_map[__func__]++;
}
void btm_ble_set_adv_flag(uint16_t connect_mode, uint16_t disc_mode) {
  mock_function_count_map[__func__]++;
}
void btm_ble_start_scan() { mock_function_count_map[__func__]++; }
void btm_ble_stop_inquiry(void) { mock_function_count_map[__func__]++; }
void btm_ble_stop_scan(void) { mock_function_count_map[__func__]++; }
void btm_ble_update_dmt_flag_bits(uint8_t* adv_flag_value,
                                  const uint16_t connect_mode,
                                  const uint16_t disc_mode) {
  mock_function_count_map[__func__]++;
}
void btm_ble_update_inq_result(tINQ_DB_ENT* p_i, uint8_t addr_type,
                               const RawAddress& bda, uint16_t evt_type,
                               uint8_t primary_phy, uint8_t secondary_phy,
                               uint8_t advertising_sid, int8_t tx_power,
                               int8_t rssi, uint16_t periodic_adv_int,
                               std::vector<uint8_t> const& data) {
  mock_function_count_map[__func__]++;
}
void btm_ble_update_mode_operation(uint8_t link_role, const RawAddress* bd_addr,
                                   tHCI_STATUS status) {
  mock_function_count_map[__func__]++;
}
void btm_ble_write_adv_enable_complete(uint8_t* p) {
  mock_function_count_map[__func__]++;
}
void btm_clear_all_pending_le_entry(void) {
  mock_function_count_map[__func__]++;
}
void btm_send_hci_set_scan_params(uint8_t scan_type, uint16_t scan_int,
                                  uint16_t scan_win, uint8_t addr_type_own,
                                  uint8_t scan_filter_policy) {
  mock_function_count_map[__func__]++;
}
Loading