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

Commit 80eb995e authored by Chris Manton's avatar Chris Manton
Browse files

testing: Add additional btif mocks

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

Change-Id: I232ef98b8d98b5f9a15900f288b8f9b3c5532f44
parent e6a2920b
Loading
Loading
Loading
Loading
+86 −0
Original line number Diff line number Diff line
/*
 * Copyright 2023 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:5
 *
 *  mockcify.pl ver 0.6.0
 */

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

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

// Original usings

// Mocked internal structures, if any

namespace test {
namespace mock {
namespace btif_profile_queue {

// Function state capture and return values, if needed
struct btif_queue_advance btif_queue_advance;
struct btif_queue_cleanup btif_queue_cleanup;
struct btif_queue_connect btif_queue_connect;
struct btif_queue_connect_next btif_queue_connect_next;
struct btif_queue_release btif_queue_release;

}  // namespace btif_profile_queue
}  // namespace mock
}  // namespace test

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

bt_status_t btif_queue_connect::return_value = BT_STATUS_SUCCESS;
bt_status_t btif_queue_connect_next::return_value = BT_STATUS_SUCCESS;

}  // namespace btif_profile_queue
}  // namespace mock
}  // namespace test

// Mocked functions, if any
void btif_queue_advance() {
  inc_func_call_count(__func__);
  test::mock::btif_profile_queue::btif_queue_advance();
}
void btif_queue_cleanup(uint16_t uuid) {
  inc_func_call_count(__func__);
  test::mock::btif_profile_queue::btif_queue_cleanup(uuid);
}
bt_status_t btif_queue_connect(uint16_t uuid, const RawAddress* bda,
                               btif_connect_cb_t connect_cb) {
  inc_func_call_count(__func__);
  return test::mock::btif_profile_queue::btif_queue_connect(uuid, bda,
                                                            connect_cb);
}
bt_status_t btif_queue_connect_next(void) {
  inc_func_call_count(__func__);
  return test::mock::btif_profile_queue::btif_queue_connect_next();
}
void btif_queue_release() {
  inc_func_call_count(__func__);
  test::mock::btif_profile_queue::btif_queue_release();
}
// Mocked functions complete
// END mockcify generation
+118 −0
Original line number Diff line number Diff line
/*
 * Copyright 2023 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:5
 *
 *  mockcify.pl ver 0.6.0
 */

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

#include "test/common/mock_functions.h"

// 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/callback.h>
#include <base/logging.h>
#include <base/strings/stringprintf.h>
#include <string.h>

#include <list>

#include "btif/include/btif_common.h"
#include "btif/include/btif_profile_queue.h"
#include "btif/include/stack_manager.h"
#include "main/shim/dumpsys.h"
#include "types/raw_address.h"

// Original usings

// Mocked compile conditionals, if any

namespace test {
namespace mock {
namespace btif_profile_queue {

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

// Name: btif_queue_cleanup
// Params: uint16_t uuid
// Return: void
struct btif_queue_cleanup {
  std::function<void(uint16_t uuid)> body{[](uint16_t uuid) {}};
  void operator()(uint16_t uuid) { body(uuid); };
};
extern struct btif_queue_cleanup btif_queue_cleanup;

// Name: btif_queue_connect
// Params: uint16_t uuid, const RawAddress* bda, btif_connect_cb_t connect_cb
// Return: bt_status_t
struct btif_queue_connect {
  static bt_status_t return_value;
  std::function<bt_status_t(uint16_t uuid, const RawAddress* bda,
                            btif_connect_cb_t connect_cb)>
      body{[](uint16_t uuid, const RawAddress* bda,
              btif_connect_cb_t connect_cb) { return return_value; }};
  bt_status_t operator()(uint16_t uuid, const RawAddress* bda,
                         btif_connect_cb_t connect_cb) {
    return body(uuid, bda, connect_cb);
  };
};
extern struct btif_queue_connect btif_queue_connect;

// Name: btif_queue_connect_next
// Params: void
// Return: bt_status_t
struct btif_queue_connect_next {
  static bt_status_t return_value;
  std::function<bt_status_t(void)> body{[](void) { return return_value; }};
  bt_status_t operator()(void) { return body(); };
};
extern struct btif_queue_connect_next btif_queue_connect_next;

// Name: btif_queue_release
// Params:
// Return: void
struct btif_queue_release {
  std::function<void()> body{[]() {}};
  void operator()() { body(); };
};
extern struct btif_queue_release btif_queue_release;

}  // namespace btif_profile_queue
}  // namespace mock
}  // namespace test

// END mockcify generation
+164 −0
Original line number Diff line number Diff line
/*
 * Copyright 2023 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:18
 *
 *  mockcify.pl ver 0.6.0
 */

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

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

// Original usings

// Mocked internal structures, if any

namespace test {
namespace mock {
namespace btif_util {

// Function state capture and return values, if needed
struct ascii_2_hex ascii_2_hex;
struct devclass2uint devclass2uint;
struct dump_adapter_scan_mode dump_adapter_scan_mode;
struct dump_av_audio_state dump_av_audio_state;
struct dump_av_conn_state dump_av_conn_state;
struct dump_bt_status dump_bt_status;
struct dump_dm_event dump_dm_event;
struct dump_dm_search_event dump_dm_search_event;
struct dump_hd_event dump_hd_event;
struct dump_hf_client_event dump_hf_client_event;
struct dump_hf_event dump_hf_event;
struct dump_hh_event dump_hh_event;
struct dump_property_type dump_property_type;
struct dump_rc_event dump_rc_event;
struct dump_rc_notification_event_id dump_rc_notification_event_id;
struct dump_rc_pdu dump_rc_pdu;
struct dump_thread_evt dump_thread_evt;
struct uint2devclass uint2devclass;

}  // namespace btif_util
}  // namespace mock
}  // namespace test

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

int ascii_2_hex::return_value = 0;
uint32_t devclass2uint::return_value = 0;
const char* dump_adapter_scan_mode::return_value = nullptr;
const char* dump_av_audio_state::return_value = nullptr;
const char* dump_av_conn_state::return_value = nullptr;
const char* dump_bt_status::return_value = nullptr;
const char* dump_dm_event::return_value = nullptr;
const char* dump_dm_search_event::return_value = nullptr;
const char* dump_hd_event::return_value = nullptr;
const char* dump_hf_client_event::return_value = nullptr;
const char* dump_hf_event::return_value = nullptr;
const char* dump_hh_event::return_value = nullptr;
const char* dump_property_type::return_value = nullptr;
const char* dump_rc_event::return_value = nullptr;
const char* dump_rc_notification_event_id::return_value = nullptr;
const char* dump_rc_pdu::return_value = nullptr;
const char* dump_thread_evt::return_value = nullptr;

}  // namespace btif_util
}  // namespace mock
}  // namespace test

// Mocked functions, if any
int ascii_2_hex(const char* p_ascii, int len, uint8_t* p_hex) {
  inc_func_call_count(__func__);
  return test::mock::btif_util::ascii_2_hex(p_ascii, len, p_hex);
}
uint32_t devclass2uint(DEV_CLASS dev_class) {
  inc_func_call_count(__func__);
  return test::mock::btif_util::devclass2uint(dev_class);
}
const char* dump_adapter_scan_mode(bt_scan_mode_t mode) {
  inc_func_call_count(__func__);
  return test::mock::btif_util::dump_adapter_scan_mode(mode);
}
const char* dump_av_audio_state(uint16_t event) {
  inc_func_call_count(__func__);
  return test::mock::btif_util::dump_av_audio_state(event);
}
const char* dump_av_conn_state(uint16_t event) {
  inc_func_call_count(__func__);
  return test::mock::btif_util::dump_av_conn_state(event);
}
const char* dump_bt_status(bt_status_t status) {
  inc_func_call_count(__func__);
  return test::mock::btif_util::dump_bt_status(status);
}
const char* dump_dm_event(uint16_t event) {
  inc_func_call_count(__func__);
  return test::mock::btif_util::dump_dm_event(event);
}
const char* dump_dm_search_event(uint16_t event) {
  inc_func_call_count(__func__);
  return test::mock::btif_util::dump_dm_search_event(event);
}
const char* dump_hd_event(uint16_t event) {
  inc_func_call_count(__func__);
  return test::mock::btif_util::dump_hd_event(event);
}
const char* dump_hf_client_event(uint16_t event) {
  inc_func_call_count(__func__);
  return test::mock::btif_util::dump_hf_client_event(event);
}
const char* dump_hf_event(uint16_t event) {
  inc_func_call_count(__func__);
  return test::mock::btif_util::dump_hf_event(event);
}
const char* dump_hh_event(uint16_t event) {
  inc_func_call_count(__func__);
  return test::mock::btif_util::dump_hh_event(event);
}
const char* dump_property_type(bt_property_type_t type) {
  inc_func_call_count(__func__);
  return test::mock::btif_util::dump_property_type(type);
}
const char* dump_rc_event(uint8_t event) {
  inc_func_call_count(__func__);
  return test::mock::btif_util::dump_rc_event(event);
}
const char* dump_rc_notification_event_id(uint8_t event_id) {
  inc_func_call_count(__func__);
  return test::mock::btif_util::dump_rc_notification_event_id(event_id);
}
const char* dump_rc_pdu(uint8_t pdu) {
  inc_func_call_count(__func__);
  return test::mock::btif_util::dump_rc_pdu(pdu);
}
const char* dump_thread_evt(bt_cb_thread_evt evt) {
  inc_func_call_count(__func__);
  return test::mock::btif_util::dump_thread_evt(evt);
}
void uint2devclass(uint32_t cod, DEV_CLASS dev_class) {
  inc_func_call_count(__func__);
  test::mock::btif_util::uint2devclass(cod, dev_class);
}
// Mocked functions complete
// END mockcify generation
+260 −0
Original line number Diff line number Diff line
/*
 * Copyright 2023 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:18
 *
 *  mockcify.pl ver 0.6.0
 */

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

// 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 <cstdint>
#include <functional>
#include <map>
#include <string>

#include "include/hardware/bluetooth.h"
#include "stack/include/bt_dev_class.h"
#include "test/common/mock_functions.h"
#include "test/mock/mock_btif_util.h"

// Original usings

// Mocked compile conditionals, if any

namespace test {
namespace mock {
namespace btif_util {

// Shared state between mocked functions and tests
// Name: ascii_2_hex
// Params: const char* p_ascii, int len, uint8_t* p_hex
// Return: int
struct ascii_2_hex {
  static int return_value;
  std::function<int(const char* p_ascii, int len, uint8_t* p_hex)> body{
      [](const char* p_ascii, int len, uint8_t* p_hex) {
        return return_value;
      }};
  int operator()(const char* p_ascii, int len, uint8_t* p_hex) {
    return body(p_ascii, len, p_hex);
  };
};
extern struct ascii_2_hex ascii_2_hex;

// Name: devclass2uint
// Params: DEV_CLASS dev_class
// Return: uint32_t
struct devclass2uint {
  static uint32_t return_value;
  std::function<uint32_t(DEV_CLASS dev_class)> body{
      [](DEV_CLASS dev_class) { return return_value; }};
  uint32_t operator()(DEV_CLASS dev_class) { return body(dev_class); };
};
extern struct devclass2uint devclass2uint;

// Name: dump_adapter_scan_mode
// Params: bt_scan_mode_t mode
// Return: const char*
struct dump_adapter_scan_mode {
  static const char* return_value;
  std::function<const char*(bt_scan_mode_t mode)> body{
      [](bt_scan_mode_t mode) { return return_value; }};
  const char* operator()(bt_scan_mode_t mode) { return body(mode); };
};
extern struct dump_adapter_scan_mode dump_adapter_scan_mode;

// Name: dump_av_audio_state
// Params: uint16_t event
// Return: const char*
struct dump_av_audio_state {
  static const char* return_value;
  std::function<const char*(uint16_t event)> body{
      [](uint16_t event) { return return_value; }};
  const char* operator()(uint16_t event) { return body(event); };
};
extern struct dump_av_audio_state dump_av_audio_state;

// Name: dump_av_conn_state
// Params: uint16_t event
// Return: const char*
struct dump_av_conn_state {
  static const char* return_value;
  std::function<const char*(uint16_t event)> body{
      [](uint16_t event) { return return_value; }};
  const char* operator()(uint16_t event) { return body(event); };
};
extern struct dump_av_conn_state dump_av_conn_state;

// Name: dump_bt_status
// Params: bt_status_t status
// Return: const char*
struct dump_bt_status {
  static const char* return_value;
  std::function<const char*(bt_status_t status)> body{
      [](bt_status_t status) { return return_value; }};
  const char* operator()(bt_status_t status) { return body(status); };
};
extern struct dump_bt_status dump_bt_status;

// Name: dump_dm_event
// Params: uint16_t event
// Return: const char*
struct dump_dm_event {
  static const char* return_value;
  std::function<const char*(uint16_t event)> body{
      [](uint16_t event) { return return_value; }};
  const char* operator()(uint16_t event) { return body(event); };
};
extern struct dump_dm_event dump_dm_event;

// Name: dump_dm_search_event
// Params: uint16_t event
// Return: const char*
struct dump_dm_search_event {
  static const char* return_value;
  std::function<const char*(uint16_t event)> body{
      [](uint16_t event) { return return_value; }};
  const char* operator()(uint16_t event) { return body(event); };
};
extern struct dump_dm_search_event dump_dm_search_event;

// Name: dump_hd_event
// Params: uint16_t event
// Return: const char*
struct dump_hd_event {
  static const char* return_value;
  std::function<const char*(uint16_t event)> body{
      [](uint16_t event) { return return_value; }};
  const char* operator()(uint16_t event) { return body(event); };
};
extern struct dump_hd_event dump_hd_event;

// Name: dump_hf_client_event
// Params: uint16_t event
// Return: const char*
struct dump_hf_client_event {
  static const char* return_value;
  std::function<const char*(uint16_t event)> body{
      [](uint16_t event) { return return_value; }};
  const char* operator()(uint16_t event) { return body(event); };
};
extern struct dump_hf_client_event dump_hf_client_event;

// Name: dump_hf_event
// Params: uint16_t event
// Return: const char*
struct dump_hf_event {
  static const char* return_value;
  std::function<const char*(uint16_t event)> body{
      [](uint16_t event) { return return_value; }};
  const char* operator()(uint16_t event) { return body(event); };
};
extern struct dump_hf_event dump_hf_event;

// Name: dump_hh_event
// Params: uint16_t event
// Return: const char*
struct dump_hh_event {
  static const char* return_value;
  std::function<const char*(uint16_t event)> body{
      [](uint16_t event) { return return_value; }};
  const char* operator()(uint16_t event) { return body(event); };
};
extern struct dump_hh_event dump_hh_event;

// Name: dump_property_type
// Params: bt_property_type_t type
// Return: const char*
struct dump_property_type {
  static const char* return_value;
  std::function<const char*(bt_property_type_t type)> body{
      [](bt_property_type_t type) { return return_value; }};
  const char* operator()(bt_property_type_t type) { return body(type); };
};
extern struct dump_property_type dump_property_type;

// Name: dump_rc_event
// Params: uint8_t event
// Return: const char*
struct dump_rc_event {
  static const char* return_value;
  std::function<const char*(uint8_t event)> body{
      [](uint8_t event) { return return_value; }};
  const char* operator()(uint8_t event) { return body(event); };
};
extern struct dump_rc_event dump_rc_event;

// Name: dump_rc_notification_event_id
// Params: uint8_t event_id
// Return: const char*
struct dump_rc_notification_event_id {
  static const char* return_value;
  std::function<const char*(uint8_t event_id)> body{
      [](uint8_t event_id) { return return_value; }};
  const char* operator()(uint8_t event_id) { return body(event_id); };
};
extern struct dump_rc_notification_event_id dump_rc_notification_event_id;

// Name: dump_rc_pdu
// Params: uint8_t pdu
// Return: const char*
struct dump_rc_pdu {
  static const char* return_value;
  std::function<const char*(uint8_t pdu)> body{
      [](uint8_t pdu) { return return_value; }};
  const char* operator()(uint8_t pdu) { return body(pdu); };
};
extern struct dump_rc_pdu dump_rc_pdu;

// Name: dump_thread_evt
// Params: bt_cb_thread_evt evt
// Return: const char*
struct dump_thread_evt {
  static const char* return_value;
  std::function<const char*(bt_cb_thread_evt evt)> body{
      [](bt_cb_thread_evt evt) { return return_value; }};
  const char* operator()(bt_cb_thread_evt evt) { return body(evt); };
};
extern struct dump_thread_evt dump_thread_evt;

// Name: uint2devclass
// Params: uint32_t cod, DEV_CLASS dev_class
// Return: void
struct uint2devclass {
  std::function<void(uint32_t cod, DEV_CLASS dev_class)> body{
      [](uint32_t cod, DEV_CLASS dev_class) {}};
  void operator()(uint32_t cod, DEV_CLASS dev_class) { body(cod, dev_class); };
};
extern struct uint2devclass uint2devclass;

}  // namespace btif_util
}  // namespace mock
}  // namespace test

// END mockcify generation