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

Commit 8f47f483 authored by Chris Manton's avatar Chris Manton
Browse files

legacy: update select mocks to v3.0

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

Change-Id: Iff97cac25252bb4c928319d753af7b82cf6b8ce6
parent 04ce740f
Loading
Loading
Loading
Loading
+35 −0
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.
 */

#include <map>

#include "osi/include/log.h"
#include "test/common/mock_functions.h"

// tLEGACY_TRACE_LEVEL
// uint8_t btu_trace_level = 6;
uint8_t appl_trace_level = 6;
uint8_t btif_trace_level = 6;

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

void dump_mock_function_count_map() {
  LOG_INFO("Mock function count map size:%zu", mock_function_count_map.size());

  for (auto it : mock_function_count_map) {
    LOG_INFO("function:%s: call_count:%d", it.first.c_str(), it.second);
  }
}
+22 −0
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.
 */

#pragma once

#include <map>

extern std::map<std::string, int> mock_function_count_map;
void dump_mock_function_count_map();
+133 −37
Original line number Diff line number Diff line
@@ -16,136 +16,232 @@

/*
 * Generated mock file from original source file
 *   Functions generated:33
 *   Functions generated:34
 *
 *  mockcify.pl ver 0.3.0
 */

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

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

#include <base/bind.h>
#include <vector>
#include "bt_target.h"
#include "bta/dm/bta_dm_int.h"
#include "osi/include/allocator.h"
#include "stack/btm/btm_sec.h"
#include "stack/include/btm_api.h"
#include "stack/include/btu.h"
#include "types/bluetooth/uuid.h"
#include "types/raw_address.h"
// Mock include file to share data between tests and mock
#include "test/mock/mock_bta_dm_api.h"

#ifndef UNUSED_ATTR
#define UNUSED_ATTR
#endif
// Mocked internal structures, if any

void BTA_dm_init() { mock_function_count_map[__func__]++; }
bool BTA_DmGetConnectionState(const RawAddress& bd_addr) {
  mock_function_count_map[__func__]++;
  return false;
}
tBTA_STATUS BTA_DmRemoveDevice(const RawAddress& bd_addr) {
  mock_function_count_map[__func__]++;
  return BTA_SUCCESS;
}
tBTA_STATUS BTA_DmSetLocalDiRecord(tSDP_DI_RECORD* p_device_info,
                                   uint32_t* p_handle) {
namespace test {
namespace mock {
namespace bta_dm_api {

// Function state capture and return values, if needed
struct BTA_AddEirUuid BTA_AddEirUuid;
struct BTA_DmAddBleDevice BTA_DmAddBleDevice;
struct BTA_DmAddBleKey BTA_DmAddBleKey;
struct BTA_DmAddDevice BTA_DmAddDevice;
struct BTA_DmBleConfigLocalPrivacy BTA_DmBleConfigLocalPrivacy;
struct BTA_DmBleConfirmReply BTA_DmBleConfirmReply;
struct BTA_DmBleCsisObserve BTA_DmBleCsisObserve;
struct BTA_DmBleGetEnergyInfo BTA_DmBleGetEnergyInfo;
struct BTA_DmBleObserve BTA_DmBleObserve;
struct BTA_DmBlePasskeyReply BTA_DmBlePasskeyReply;
struct BTA_DmBleRequestMaxTxDataLength BTA_DmBleRequestMaxTxDataLength;
struct BTA_DmBleScan BTA_DmBleScan;
struct BTA_DmBleSecurityGrant BTA_DmBleSecurityGrant;
struct BTA_DmBleUpdateConnectionParams BTA_DmBleUpdateConnectionParams;
struct BTA_DmBond BTA_DmBond;
struct BTA_DmBondCancel BTA_DmBondCancel;
struct BTA_DmCloseACL BTA_DmCloseACL;
struct BTA_DmConfirm BTA_DmConfirm;
struct BTA_DmDiscover BTA_DmDiscover;
struct BTA_DmGetConnectionState BTA_DmGetConnectionState;
struct BTA_DmLocalOob BTA_DmLocalOob;
struct BTA_DmPinReply BTA_DmPinReply;
struct BTA_DmRemoveDevice BTA_DmRemoveDevice;
struct BTA_DmSearch BTA_DmSearch;
struct BTA_DmSearchCancel BTA_DmSearchCancel;
struct BTA_DmSetBlePrefConnParams BTA_DmSetBlePrefConnParams;
struct BTA_DmSetDeviceName BTA_DmSetDeviceName;
struct BTA_DmSetEncryption BTA_DmSetEncryption;
struct BTA_DmSetLocalDiRecord BTA_DmSetLocalDiRecord;
struct BTA_EnableTestMode BTA_EnableTestMode;
struct BTA_GetEirService BTA_GetEirService;
struct BTA_RemoveEirUuid BTA_RemoveEirUuid;
struct BTA_VendorInit BTA_VendorInit;
struct BTA_dm_init BTA_dm_init;

}  // namespace bta_dm_api
}  // namespace mock
}  // namespace test

// Mocked functions, if any
void BTA_AddEirUuid(uint16_t uuid16) {
  mock_function_count_map[__func__]++;
  return BTA_SUCCESS;
  test::mock::bta_dm_api::BTA_AddEirUuid(uuid16);
}
void BTA_AddEirUuid(uint16_t uuid16) { mock_function_count_map[__func__]++; }
void BTA_DmAddBleDevice(const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type,
                        tBT_DEVICE_TYPE dev_type) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmAddBleDevice(bd_addr, addr_type, dev_type);
}
void BTA_DmAddBleKey(const RawAddress& bd_addr, tBTA_LE_KEY_VALUE* p_le_key,
                     tBTM_LE_KEY_TYPE key_type) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmAddBleKey(bd_addr, p_le_key, key_type);
}
void BTA_DmAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class,
                     const LinkKey& link_key, uint8_t key_type,
                     uint8_t pin_length) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmAddDevice(bd_addr, dev_class, link_key,
                                          key_type, pin_length);
}
void BTA_DmBleConfigLocalPrivacy(bool privacy_enable) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmBleConfigLocalPrivacy(privacy_enable);
}
void BTA_DmBleConfirmReply(const RawAddress& bd_addr, bool accept) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmBleConfirmReply(bd_addr, accept);
}
void BTA_DmBleCsisObserve(bool observe, tBTA_DM_SEARCH_CBACK* p_results_cb) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmBleCsisObserve(observe, p_results_cb);
}
void BTA_DmBleGetEnergyInfo(tBTA_BLE_ENERGY_INFO_CBACK* p_cmpl_cback) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmBleGetEnergyInfo(p_cmpl_cback);
}
void BTA_DmBleObserve(bool start, uint8_t duration,
                      tBTA_DM_SEARCH_CBACK* p_results_cb) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmBleObserve(start, duration, p_results_cb);
}
void BTA_DmBlePasskeyReply(const RawAddress& bd_addr, bool accept,
                           uint32_t passkey) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmBlePasskeyReply(bd_addr, accept, passkey);
}
void BTA_DmBleRequestMaxTxDataLength(const RawAddress& remote_device) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmBleRequestMaxTxDataLength(remote_device);
}
void BTA_DmBleScan(bool start, uint8_t duration) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmBleScan(start, duration);
}
void BTA_DmBleSecurityGrant(const RawAddress& bd_addr,
                            tBTA_DM_BLE_SEC_GRANT res) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmBleSecurityGrant(bd_addr, res);
}
void BTA_DmBleUpdateConnectionParams(const RawAddress& bd_addr,
                                     uint16_t min_int, uint16_t max_int,
                                     uint16_t latency, uint16_t timeout,
                                     uint16_t min_ce_len, uint16_t max_ce_len) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmBleUpdateConnectionParams(
      bd_addr, min_int, max_int, latency, timeout, min_ce_len, max_ce_len);
}
void BTA_DmBond(const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type,
                tBT_TRANSPORT transport, tBT_DEVICE_TYPE device_type) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmBond(bd_addr, addr_type, transport,
                                     device_type);
}
void BTA_DmBondCancel(const RawAddress& bd_addr) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmBondCancel(bd_addr);
}
void BTA_DmCloseACL(const RawAddress& bd_addr, bool remove_dev,
                    tBT_TRANSPORT transport) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmCloseACL(bd_addr, remove_dev, transport);
}
void BTA_DmConfirm(const RawAddress& bd_addr, bool accept) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmConfirm(bd_addr, accept);
}
void BTA_DmDiscover(const RawAddress& bd_addr, tBTA_DM_SEARCH_CBACK* p_cback,
                    tBT_TRANSPORT transport, bool is_bonding_or_sd) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmDiscover(bd_addr, p_cback, transport,
                                         is_bonding_or_sd);
}
bool BTA_DmGetConnectionState(const RawAddress& bd_addr) {
  mock_function_count_map[__func__]++;
  return test::mock::bta_dm_api::BTA_DmGetConnectionState(bd_addr);
}
void BTA_DmLocalOob(void) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmLocalOob();
}
void BTA_DmLocalOob(void) { mock_function_count_map[__func__]++; }
void BTA_DmPinReply(const RawAddress& bd_addr, bool accept, uint8_t pin_len,
                    uint8_t* p_pin) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmPinReply(bd_addr, accept, pin_len, p_pin);
}
tBTA_STATUS BTA_DmRemoveDevice(const RawAddress& bd_addr) {
  mock_function_count_map[__func__]++;
  return test::mock::bta_dm_api::BTA_DmRemoveDevice(bd_addr);
}
void BTA_DmSearch(tBTA_DM_SEARCH_CBACK* p_cback, bool is_bonding_or_sdp) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmSearch(p_cback, is_bonding_or_sdp);
}
void BTA_DmSearchCancel(void) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmSearchCancel();
}
void BTA_DmSearchCancel(void) { mock_function_count_map[__func__]++; }
void BTA_DmSetBlePrefConnParams(const RawAddress& bd_addr,
                                uint16_t min_conn_int, uint16_t max_conn_int,
                                uint16_t peripheral_latency,
                                uint16_t supervision_tout) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmSetBlePrefConnParams(
      bd_addr, min_conn_int, max_conn_int, peripheral_latency,
      supervision_tout);
}
void BTA_DmSetDeviceName(char* p_name) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmSetDeviceName(p_name);
}
void BTA_DmSetDeviceName(char* p_name) { mock_function_count_map[__func__]++; }
void BTA_DmSetEncryption(const RawAddress& bd_addr, tBT_TRANSPORT transport,
                         tBTA_DM_ENCRYPT_CBACK* p_callback,
                         tBTM_BLE_SEC_ACT sec_act) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_DmSetEncryption(bd_addr, transport, p_callback,
                                              sec_act);
}
tBTA_STATUS BTA_DmSetLocalDiRecord(tSDP_DI_RECORD* p_device_info,
                                   uint32_t* p_handle) {
  mock_function_count_map[__func__]++;
  return test::mock::bta_dm_api::BTA_DmSetLocalDiRecord(p_device_info,
                                                        p_handle);
}
void BTA_EnableTestMode(void) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_EnableTestMode();
}
void BTA_EnableTestMode(void) { mock_function_count_map[__func__]++; }
void BTA_GetEirService(uint8_t* p_eir, size_t eir_len,
                       tBTA_SERVICE_MASK* p_services) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_GetEirService(p_eir, eir_len, p_services);
}
void BTA_RemoveEirUuid(uint16_t uuid16) { mock_function_count_map[__func__]++; }
void BTA_DmBleObserve(bool start, uint8_t duration,
                      tBTA_DM_SEARCH_CBACK* p_results_cb) {
void BTA_RemoveEirUuid(uint16_t uuid16) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_RemoveEirUuid(uuid16);
}
void BTA_DmBleScan(bool start, uint8_t duration) {
void BTA_VendorInit(void) {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_VendorInit();
}
void BTA_DmBleCsisObserve(bool observe, tBTA_DM_SEARCH_CBACK* p_results_cb) {
void BTA_dm_init() {
  mock_function_count_map[__func__]++;
  test::mock::bta_dm_api::BTA_dm_init();
}
void BTA_VendorInit(void) { mock_function_count_map[__func__]++; }

// END mockcify generation
+488 −0

File added.

Preview size limit exceeded, changes collapsed.

+110 −0
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:10
 *
 *  mockcify.pl ver 0.3.0
 */

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

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

// Mock include file to share data between tests and mock
#include "test/mock/mock_bta_hh_utils.h"

// Mocked internal structures, if any

namespace test {
namespace mock {
namespace bta_hh_utils {

// Function state capture and return values, if needed
struct bta_hh_add_device_to_list bta_hh_add_device_to_list;
struct bta_hh_clean_up_kdev bta_hh_clean_up_kdev;
struct bta_hh_cleanup_disable bta_hh_cleanup_disable;
struct bta_hh_dev_handle_to_cb_idx bta_hh_dev_handle_to_cb_idx;
struct bta_hh_find_cb bta_hh_find_cb;
struct bta_hh_get_cb bta_hh_get_cb;
struct bta_hh_read_ssr_param bta_hh_read_ssr_param;
struct bta_hh_tod_spt bta_hh_tod_spt;
struct bta_hh_trace_dev_db bta_hh_trace_dev_db;
struct bta_hh_update_di_info bta_hh_update_di_info;

}  // namespace bta_hh_utils
}  // namespace mock
}  // namespace test

// Mocked functions, if any
void bta_hh_add_device_to_list(tBTA_HH_DEV_CB* p_cb, uint8_t handle,
                               uint16_t attr_mask,
                               const tHID_DEV_DSCP_INFO* p_dscp_info,
                               uint8_t sub_class, uint16_t ssr_max_latency,
                               uint16_t ssr_min_tout, uint8_t app_id) {
  mock_function_count_map[__func__]++;
  test::mock::bta_hh_utils::bta_hh_add_device_to_list(
      p_cb, handle, attr_mask, p_dscp_info, sub_class, ssr_max_latency,
      ssr_min_tout, app_id);
}
void bta_hh_clean_up_kdev(tBTA_HH_DEV_CB* p_cb) {
  mock_function_count_map[__func__]++;
  test::mock::bta_hh_utils::bta_hh_clean_up_kdev(p_cb);
}
void bta_hh_cleanup_disable(tBTA_HH_STATUS status) {
  mock_function_count_map[__func__]++;
  test::mock::bta_hh_utils::bta_hh_cleanup_disable(status);
}
uint8_t bta_hh_dev_handle_to_cb_idx(uint8_t dev_handle) {
  mock_function_count_map[__func__]++;
  return test::mock::bta_hh_utils::bta_hh_dev_handle_to_cb_idx(dev_handle);
}
uint8_t bta_hh_find_cb(const RawAddress& bda) {
  mock_function_count_map[__func__]++;
  return test::mock::bta_hh_utils::bta_hh_find_cb(bda);
}
tBTA_HH_DEV_CB* bta_hh_get_cb(const RawAddress& bda) {
  mock_function_count_map[__func__]++;
  return test::mock::bta_hh_utils::bta_hh_get_cb(bda);
}
tBTA_HH_STATUS bta_hh_read_ssr_param(const RawAddress& bd_addr,
                                     uint16_t* p_max_ssr_lat,
                                     uint16_t* p_min_ssr_tout) {
  mock_function_count_map[__func__]++;
  return test::mock::bta_hh_utils::bta_hh_read_ssr_param(bd_addr, p_max_ssr_lat,
                                                         p_min_ssr_tout);
}
bool bta_hh_tod_spt(tBTA_HH_DEV_CB* p_cb, uint8_t sub_class) {
  mock_function_count_map[__func__]++;
  return test::mock::bta_hh_utils::bta_hh_tod_spt(p_cb, sub_class);
}
void bta_hh_trace_dev_db(void) {
  mock_function_count_map[__func__]++;
  test::mock::bta_hh_utils::bta_hh_trace_dev_db();
}
void bta_hh_update_di_info(tBTA_HH_DEV_CB* p_cb, uint16_t vendor_id,
                           uint16_t product_id, uint16_t version,
                           uint8_t flag) {
  mock_function_count_map[__func__]++;
  test::mock::bta_hh_utils::bta_hh_update_di_info(p_cb, vendor_id, product_id,
                                                  version, flag);
}
// Mocked functions complete
// END mockcify generation
Loading