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

Commit 53afafce authored by Chris Manton's avatar Chris Manton
Browse files

Add testing mocks

Bug: 187825293
Test: gd/cert/run
Tag: #refactor
BYPASS_LONG_LINES_REASON: Bluetooth likes 120 lines

Change-Id: Ie69d4973eccbfb04976377866f3b07cb33e20091
parent 77a4de0d
Loading
Loading
Loading
Loading
+70 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 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:1
 *
 *  mockcify.pl ver 0.5.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_btif_avrcp_service.h"

// Original usings

// Mocked internal structures, if any

bluetooth::avrcp::AvrcpService* bluetooth::avrcp::AvrcpService::Get() {
  mock_function_count_map[__func__]++;
  return nullptr;
}

void bluetooth::avrcp::AvrcpService::ConnectDevice(RawAddress const&) {
  mock_function_count_map[__func__]++;
}

namespace test {
namespace mock {
namespace btif_avrcp_service {

// Function state capture and return values, if needed
struct do_in_avrcp_jni do_in_avrcp_jni;

}  // namespace btif_avrcp_service
}  // namespace mock
}  // namespace test

// Mocked function return values, if any
namespace test {
namespace mock {
namespace btif_avrcp_service {}  // namespace btif_avrcp_service
}  // namespace mock
}  // namespace test

// Mocked functions, if any
void do_in_avrcp_jni(const base::Closure& task) {
  mock_function_count_map[__func__]++;
  test::mock::btif_avrcp_service::do_in_avrcp_jni(task);
}
// Mocked functions complete
// END mockcify generation
+81 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 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

/*
 * Generated mock file from original source file
 *   Functions generated:1
 *
 *  mockcify.pl ver 0.5.0
 */

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

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

// Original included files, if any
// NOTE: Since this is a mock file with mock definitions some number of
//       include files may not be required.  The include-what-you-use
//       still applies, but crafting proper inclusion is out of scope
//       for this effort.  This compilation unit may compile as-is, or
//       may need attention to prune from (or add to ) the inclusion set.
#include <base/bind.h>
#include <base/logging.h>
#include <base/task/cancelable_task_tracker.h>
#include <base/threading/thread.h>

#include <mutex>
#include <sstream>

#include "abstract_message_loop.h"
#include "bta/sys/bta_sys.h"
#include "btif/avrcp/avrcp_service.h"
#include "btif/include/btif_av.h"
#include "btif/include/btif_common.h"
#include "btif/include/btif_dm.h"
#include "profile/avrcp/device.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/btu.h"
#include "types/bluetooth/uuid.h"
#include "types/raw_address.h"

// Original usings

// Mocked compile conditionals, if any

namespace test {
namespace mock {
namespace btif_avrcp_service {

// Shared state between mocked functions and tests
// Name: do_in_avrcp_jni
// Params: const base::Closure& task
// Return: void
struct do_in_avrcp_jni {
  std::function<void(const base::Closure& task)> body{
      [](const base::Closure& task) {}};
  void operator()(const base::Closure& task) { body(task); };
};
extern struct do_in_avrcp_jni do_in_avrcp_jni;

}  // namespace btif_avrcp_service
}  // namespace mock
}  // namespace test

// END mockcify generation
+251 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 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:25
 *
 *  mockcify.pl ver 0.5.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_btif_co_bta_av_co.h"

// Original usings

// Mocked internal structures, if any

namespace test {
namespace mock {
namespace btif_co_bta_av_co {

// Function state capture and return values, if needed
struct bta_av_co_audio_close bta_av_co_audio_close;
struct bta_av_co_audio_delay bta_av_co_audio_delay;
struct bta_av_co_audio_disc_res bta_av_co_audio_disc_res;
struct bta_av_co_audio_drop bta_av_co_audio_drop;
struct bta_av_co_audio_getconfig bta_av_co_audio_getconfig;
struct bta_av_co_audio_init bta_av_co_audio_init;
struct bta_av_co_audio_open bta_av_co_audio_open;
struct bta_av_co_audio_setconfig bta_av_co_audio_setconfig;
struct bta_av_co_audio_source_data_path bta_av_co_audio_source_data_path;
struct bta_av_co_audio_start bta_av_co_audio_start;
struct bta_av_co_audio_stop bta_av_co_audio_stop;
struct bta_av_co_audio_update_mtu bta_av_co_audio_update_mtu;
struct bta_av_co_get_decoder_interface bta_av_co_get_decoder_interface;
struct bta_av_co_get_encoder_effective_frame_size
    bta_av_co_get_encoder_effective_frame_size;
struct bta_av_co_get_encoder_interface bta_av_co_get_encoder_interface;
struct bta_av_co_get_peer_params bta_av_co_get_peer_params;
struct bta_av_co_get_scmst_info bta_av_co_get_scmst_info;
struct bta_av_co_init bta_av_co_init;
struct bta_av_co_is_supported_codec bta_av_co_is_supported_codec;
struct bta_av_co_set_active_peer bta_av_co_set_active_peer;
struct bta_av_co_set_codec_audio_config bta_av_co_set_codec_audio_config;
struct bta_av_co_set_codec_user_config bta_av_co_set_codec_user_config;
struct bta_av_get_a2dp_current_codec bta_av_get_a2dp_current_codec;
struct bta_av_get_a2dp_peer_current_codec bta_av_get_a2dp_peer_current_codec;
struct btif_a2dp_codec_debug_dump btif_a2dp_codec_debug_dump;

}  // namespace btif_co_bta_av_co
}  // namespace mock
}  // namespace test

// Mocked function return values, if any
namespace test {
namespace mock {
namespace btif_co_bta_av_co {

tA2DP_STATUS bta_av_co_audio_getconfig::return_value = 0;
bool bta_av_co_audio_init::return_value = false;
BT_HDR* bta_av_co_audio_source_data_path::return_value = nullptr;
const tA2DP_DECODER_INTERFACE* bta_av_co_get_decoder_interface::return_value =
    nullptr;
int bta_av_co_get_encoder_effective_frame_size::return_value = 0;
const tA2DP_ENCODER_INTERFACE* bta_av_co_get_encoder_interface::return_value =
    nullptr;
btav_a2dp_scmst_info_t bta_av_co_get_scmst_info::return_value = {};
bool bta_av_co_is_supported_codec::return_value = false;
bool bta_av_co_set_active_peer::return_value = false;
bool bta_av_co_set_codec_audio_config::return_value = false;
bool bta_av_co_set_codec_user_config::return_value = false;
A2dpCodecConfig* bta_av_get_a2dp_current_codec::return_value = nullptr;
A2dpCodecConfig* bta_av_get_a2dp_peer_current_codec::return_value = nullptr;

}  // namespace btif_co_bta_av_co
}  // namespace mock
}  // namespace test

// Mocked functions, if any
void bta_av_co_audio_close(tBTA_AV_HNDL bta_av_handle,
                           const RawAddress& peer_address) {
  mock_function_count_map[__func__]++;
  test::mock::btif_co_bta_av_co::bta_av_co_audio_close(bta_av_handle,
                                                       peer_address);
}
void bta_av_co_audio_delay(tBTA_AV_HNDL bta_av_handle,
                           const RawAddress& peer_address, uint16_t delay) {
  mock_function_count_map[__func__]++;
  test::mock::btif_co_bta_av_co::bta_av_co_audio_delay(bta_av_handle,
                                                       peer_address, delay);
}
void bta_av_co_audio_disc_res(tBTA_AV_HNDL bta_av_handle,
                              const RawAddress& peer_address, uint8_t num_seps,
                              uint8_t num_sinks, uint8_t num_sources,
                              uint16_t uuid_local) {
  mock_function_count_map[__func__]++;
  test::mock::btif_co_bta_av_co::bta_av_co_audio_disc_res(
      bta_av_handle, peer_address, num_seps, num_sinks, num_sources,
      uuid_local);
}
void bta_av_co_audio_drop(tBTA_AV_HNDL bta_av_handle,
                          const RawAddress& peer_address) {
  mock_function_count_map[__func__]++;
  test::mock::btif_co_bta_av_co::bta_av_co_audio_drop(bta_av_handle,
                                                      peer_address);
}
tA2DP_STATUS bta_av_co_audio_getconfig(tBTA_AV_HNDL bta_av_handle,
                                       const RawAddress& peer_address,
                                       uint8_t* p_codec_info,
                                       uint8_t* p_sep_info_idx, uint8_t seid,
                                       uint8_t* p_num_protect,
                                       uint8_t* p_protect_info) {
  mock_function_count_map[__func__]++;
  return test::mock::btif_co_bta_av_co::bta_av_co_audio_getconfig(
      bta_av_handle, peer_address, p_codec_info, p_sep_info_idx, seid,
      p_num_protect, p_protect_info);
}
bool bta_av_co_audio_init(btav_a2dp_codec_index_t codec_index,
                          AvdtpSepConfig* p_cfg) {
  mock_function_count_map[__func__]++;
  return test::mock::btif_co_bta_av_co::bta_av_co_audio_init(codec_index,
                                                             p_cfg);
}
void bta_av_co_audio_open(tBTA_AV_HNDL bta_av_handle,
                          const RawAddress& peer_address, uint16_t mtu) {
  mock_function_count_map[__func__]++;
  test::mock::btif_co_bta_av_co::bta_av_co_audio_open(bta_av_handle,
                                                      peer_address, mtu);
}
void bta_av_co_audio_setconfig(tBTA_AV_HNDL bta_av_handle,
                               const RawAddress& peer_address,
                               const uint8_t* p_codec_info, uint8_t seid,
                               uint8_t num_protect,
                               const uint8_t* p_protect_info,
                               uint8_t t_local_sep, uint8_t avdt_handle) {
  mock_function_count_map[__func__]++;
  test::mock::btif_co_bta_av_co::bta_av_co_audio_setconfig(
      bta_av_handle, peer_address, p_codec_info, seid, num_protect,
      p_protect_info, t_local_sep, avdt_handle);
}
BT_HDR* bta_av_co_audio_source_data_path(const uint8_t* p_codec_info,
                                         uint32_t* p_timestamp) {
  mock_function_count_map[__func__]++;
  return test::mock::btif_co_bta_av_co::bta_av_co_audio_source_data_path(
      p_codec_info, p_timestamp);
}
void bta_av_co_audio_start(tBTA_AV_HNDL bta_av_handle,
                           const RawAddress& peer_address,
                           const uint8_t* p_codec_info, bool* p_no_rtp_header) {
  mock_function_count_map[__func__]++;
  test::mock::btif_co_bta_av_co::bta_av_co_audio_start(
      bta_av_handle, peer_address, p_codec_info, p_no_rtp_header);
}
void bta_av_co_audio_stop(tBTA_AV_HNDL bta_av_handle,
                          const RawAddress& peer_address) {
  mock_function_count_map[__func__]++;
  test::mock::btif_co_bta_av_co::bta_av_co_audio_stop(bta_av_handle,
                                                      peer_address);
}
void bta_av_co_audio_update_mtu(tBTA_AV_HNDL bta_av_handle,
                                const RawAddress& peer_address, uint16_t mtu) {
  mock_function_count_map[__func__]++;
  test::mock::btif_co_bta_av_co::bta_av_co_audio_update_mtu(bta_av_handle,
                                                            peer_address, mtu);
}
const tA2DP_DECODER_INTERFACE* bta_av_co_get_decoder_interface(void) {
  mock_function_count_map[__func__]++;
  return test::mock::btif_co_bta_av_co::bta_av_co_get_decoder_interface();
}
int bta_av_co_get_encoder_effective_frame_size() {
  mock_function_count_map[__func__]++;
  return test::mock::btif_co_bta_av_co::
      bta_av_co_get_encoder_effective_frame_size();
}
const tA2DP_ENCODER_INTERFACE* bta_av_co_get_encoder_interface(void) {
  mock_function_count_map[__func__]++;
  return test::mock::btif_co_bta_av_co::bta_av_co_get_encoder_interface();
}
void bta_av_co_get_peer_params(const RawAddress& peer_address,
                               tA2DP_ENCODER_INIT_PEER_PARAMS* p_peer_params) {
  mock_function_count_map[__func__]++;
  test::mock::btif_co_bta_av_co::bta_av_co_get_peer_params(peer_address,
                                                           p_peer_params);
}
btav_a2dp_scmst_info_t bta_av_co_get_scmst_info(
    const RawAddress& peer_address) {
  mock_function_count_map[__func__]++;
  return test::mock::btif_co_bta_av_co::bta_av_co_get_scmst_info(peer_address);
}
void bta_av_co_init(
    const std::vector<btav_a2dp_codec_config_t>& codec_priorities) {
  mock_function_count_map[__func__]++;
  test::mock::btif_co_bta_av_co::bta_av_co_init(codec_priorities);
}
bool bta_av_co_is_supported_codec(btav_a2dp_codec_index_t codec_index) {
  mock_function_count_map[__func__]++;
  return test::mock::btif_co_bta_av_co::bta_av_co_is_supported_codec(
      codec_index);
}
bool bta_av_co_set_active_peer(const RawAddress& peer_address) {
  mock_function_count_map[__func__]++;
  return test::mock::btif_co_bta_av_co::bta_av_co_set_active_peer(peer_address);
}
bool bta_av_co_set_codec_audio_config(
    const btav_a2dp_codec_config_t& codec_audio_config) {
  mock_function_count_map[__func__]++;
  return test::mock::btif_co_bta_av_co::bta_av_co_set_codec_audio_config(
      codec_audio_config);
}
bool bta_av_co_set_codec_user_config(
    const RawAddress& peer_address,
    const btav_a2dp_codec_config_t& codec_user_config, bool* p_restart_output) {
  mock_function_count_map[__func__]++;
  return test::mock::btif_co_bta_av_co::bta_av_co_set_codec_user_config(
      peer_address, codec_user_config, p_restart_output);
}
A2dpCodecConfig* bta_av_get_a2dp_current_codec(void) {
  mock_function_count_map[__func__]++;
  return test::mock::btif_co_bta_av_co::bta_av_get_a2dp_current_codec();
}
A2dpCodecConfig* bta_av_get_a2dp_peer_current_codec(
    const RawAddress& peer_address) {
  mock_function_count_map[__func__]++;
  return test::mock::btif_co_bta_av_co::bta_av_get_a2dp_peer_current_codec(
      peer_address);
}
void btif_a2dp_codec_debug_dump(int fd) {
  mock_function_count_map[__func__]++;
  test::mock::btif_co_bta_av_co::btif_a2dp_codec_debug_dump(fd);
}
// Mocked functions complete
// END mockcify generation
+436 −0

File added.

Preview size limit exceeded, changes collapsed.

+282 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading