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

Commit 3dc9ad86 authored by Chris Manton's avatar Chris Manton
Browse files

legacy: Add bta pan unit test

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

Change-Id: I3872c057f5c961a695bea2211491a137b1f860bf
parent 8db40e47
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -216,10 +216,14 @@ cc_test {
        "hh/bta_hh_le.cc",
        "hh/bta_hh_main.cc",
        "hh/bta_hh_utils.cc",
        "pan/bta_pan_act.cc",
        "pan/bta_pan_api.cc",
        "pan/bta_pan_main.cc",
        "sys/bta_sys_conn.cc",
        "sys/bta_sys_main.cc",
        "test/bta_dm_test.cc",
        "test/bta_gatt_test.cc",
        "test/bta_pan_test.cc",
    ],
    shared_libs: [
        "libcrypto",
+37 −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 <gtest/gtest.h>
#include <string.h>

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

#include "bta/pan/bta_pan_int.h"

// TODO put this in common place
extern std::map<std::string, int> mock_function_count_map;

class BtaPanTest : public ::testing::Test {
 protected:
  void SetUp() override {}

  void TearDown() override {}
};

TEST_F(BtaPanTest, nop) {}
+100 −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:7
 *
 *  mockcify.pl ver 0.2.1
 */

#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_bta_pan_co_rx.h"

// Mocked compile conditionals, if any
#ifndef UNUSED_ATTR
#define UNUSED_ATTR
#endif

// Mocked internal structures, if any

namespace test {
namespace mock {
namespace btif_bta_pan_co_rx {

// Function state capture and return values, if needed
struct bta_pan_co_init bta_pan_co_init;
struct bta_pan_co_close bta_pan_co_close;
struct bta_pan_co_mfilt_ind bta_pan_co_mfilt_ind;
struct bta_pan_co_pfilt_ind bta_pan_co_pfilt_ind;
struct bta_pan_co_rx_flow bta_pan_co_rx_flow;
struct bta_pan_co_rx_path bta_pan_co_rx_path;
struct bta_pan_co_tx_path bta_pan_co_tx_path;

}  // namespace btif_bta_pan_co_rx
}  // namespace mock
}  // namespace test

// Mocked functions, if any
uint8_t bta_pan_co_init(uint8_t* q_level) {
  mock_function_count_map[__func__]++;
  return test::mock::btif_bta_pan_co_rx::bta_pan_co_init(q_level);
}
void bta_pan_co_close(uint16_t handle, uint8_t app_id) {
  mock_function_count_map[__func__]++;
  test::mock::btif_bta_pan_co_rx::bta_pan_co_close(handle, app_id);
}
void bta_pan_co_mfilt_ind(UNUSED_ATTR uint16_t handle,
                          UNUSED_ATTR bool indication,
                          UNUSED_ATTR tBTA_PAN_STATUS result,
                          UNUSED_ATTR uint16_t len,
                          UNUSED_ATTR uint8_t* p_filters) {
  mock_function_count_map[__func__]++;
  test::mock::btif_bta_pan_co_rx::bta_pan_co_mfilt_ind(handle, indication,
                                                       result, len, p_filters);
}
void bta_pan_co_pfilt_ind(UNUSED_ATTR uint16_t handle,
                          UNUSED_ATTR bool indication,
                          UNUSED_ATTR tBTA_PAN_STATUS result,
                          UNUSED_ATTR uint16_t len,
                          UNUSED_ATTR uint8_t* p_filters) {
  mock_function_count_map[__func__]++;
  test::mock::btif_bta_pan_co_rx::bta_pan_co_pfilt_ind(handle, indication,
                                                       result, len, p_filters);
}
void bta_pan_co_rx_flow(UNUSED_ATTR uint16_t handle, UNUSED_ATTR uint8_t app_id,
                        UNUSED_ATTR bool enable) {
  mock_function_count_map[__func__]++;
  test::mock::btif_bta_pan_co_rx::bta_pan_co_rx_flow(handle, app_id, enable);
}
void bta_pan_co_rx_path(UNUSED_ATTR uint16_t handle,
                        UNUSED_ATTR uint8_t app_id) {
  mock_function_count_map[__func__]++;
  test::mock::btif_bta_pan_co_rx::bta_pan_co_rx_path(handle, app_id);
}
void bta_pan_co_tx_path(uint16_t handle, uint8_t app_id) {
  mock_function_count_map[__func__]++;
  test::mock::btif_bta_pan_co_rx::bta_pan_co_tx_path(handle, app_id);
}

// END mockcify generation
+147 −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:7
 *
 *  mockcify.pl ver 0.2.1
 */

#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 the inclusion set.
#include <base/logging.h>
#include <hardware/bluetooth.h>
#include <hardware/bt_pan.h>
#include <string.h>

#include "bta/include/bta_pan_api.h"

// Mocked compile conditionals, if any
#ifndef UNUSED_ATTR
#define UNUSED_ATTR
#endif

namespace test {
namespace mock {
namespace btif_bta_pan_co_rx {

// Shared state between mocked functions and tests
// Name: bta_pan_co_init
// Params: uint8_t* q_level
// Returns: uint8_t
struct bta_pan_co_init {
  std::function<uint8_t(uint8_t* q_level)> body{
      [](uint8_t* q_level) { return 0; }};
  uint8_t operator()(uint8_t* q_level) { return body(q_level); };
};
extern struct bta_pan_co_init bta_pan_co_init;
// Name: bta_pan_co_close
// Params: uint16_t handle, uint8_t app_id
// Returns: void
struct bta_pan_co_close {
  std::function<void(uint16_t handle, uint8_t app_id)> body{
      [](uint16_t handle, uint8_t app_id) { ; }};
  void operator()(uint16_t handle, uint8_t app_id) { body(handle, app_id); };
};
extern struct bta_pan_co_close bta_pan_co_close;
// Name: bta_pan_co_mfilt_ind
// Params: UNUSED_ATTR uint16_t handle, UNUSED_ATTR bool indication, UNUSED_ATTR
// tBTA_PAN_STATUS result, UNUSED_ATTR uint16_t len, UNUSED_ATTR uint8_t*
// p_filters Returns: void
struct bta_pan_co_mfilt_ind {
  std::function<void(UNUSED_ATTR uint16_t handle, UNUSED_ATTR bool indication,
                     UNUSED_ATTR tBTA_PAN_STATUS result,
                     UNUSED_ATTR uint16_t len, UNUSED_ATTR uint8_t* p_filters)>
      body{[](UNUSED_ATTR uint16_t handle, UNUSED_ATTR bool indication,
              UNUSED_ATTR tBTA_PAN_STATUS result, UNUSED_ATTR uint16_t len,
              UNUSED_ATTR uint8_t* p_filters) { ; }};
  void operator()(UNUSED_ATTR uint16_t handle, UNUSED_ATTR bool indication,
                  UNUSED_ATTR tBTA_PAN_STATUS result, UNUSED_ATTR uint16_t len,
                  UNUSED_ATTR uint8_t* p_filters) {
    body(handle, indication, result, len, p_filters);
  };
};
extern struct bta_pan_co_mfilt_ind bta_pan_co_mfilt_ind;
// Name: bta_pan_co_pfilt_ind
// Params: UNUSED_ATTR uint16_t handle, UNUSED_ATTR bool indication, UNUSED_ATTR
// tBTA_PAN_STATUS result, UNUSED_ATTR uint16_t len, UNUSED_ATTR uint8_t*
// p_filters Returns: void
struct bta_pan_co_pfilt_ind {
  std::function<void(UNUSED_ATTR uint16_t handle, UNUSED_ATTR bool indication,
                     UNUSED_ATTR tBTA_PAN_STATUS result,
                     UNUSED_ATTR uint16_t len, UNUSED_ATTR uint8_t* p_filters)>
      body{[](UNUSED_ATTR uint16_t handle, UNUSED_ATTR bool indication,
              UNUSED_ATTR tBTA_PAN_STATUS result, UNUSED_ATTR uint16_t len,
              UNUSED_ATTR uint8_t* p_filters) { ; }};
  void operator()(UNUSED_ATTR uint16_t handle, UNUSED_ATTR bool indication,
                  UNUSED_ATTR tBTA_PAN_STATUS result, UNUSED_ATTR uint16_t len,
                  UNUSED_ATTR uint8_t* p_filters) {
    body(handle, indication, result, len, p_filters);
  };
};
extern struct bta_pan_co_pfilt_ind bta_pan_co_pfilt_ind;
// Name: bta_pan_co_rx_flow
// Params: UNUSED_ATTR uint16_t handle, UNUSED_ATTR uint8_t app_id, UNUSED_ATTR
// bool enable Returns: void
struct bta_pan_co_rx_flow {
  std::function<void(UNUSED_ATTR uint16_t handle, UNUSED_ATTR uint8_t app_id,
                     UNUSED_ATTR bool enable)>
      body{[](UNUSED_ATTR uint16_t handle, UNUSED_ATTR uint8_t app_id,
              UNUSED_ATTR bool enable) { ; }};
  void operator()(UNUSED_ATTR uint16_t handle, UNUSED_ATTR uint8_t app_id,
                  UNUSED_ATTR bool enable) {
    body(handle, app_id, enable);
  };
};
extern struct bta_pan_co_rx_flow bta_pan_co_rx_flow;
// Name: bta_pan_co_rx_path
// Params: UNUSED_ATTR uint16_t handle, UNUSED_ATTR uint8_t app_id
// Returns: void
struct bta_pan_co_rx_path {
  std::function<void(UNUSED_ATTR uint16_t handle, UNUSED_ATTR uint8_t app_id)>
      body{[](UNUSED_ATTR uint16_t handle, UNUSED_ATTR uint8_t app_id) { ; }};
  void operator()(UNUSED_ATTR uint16_t handle, UNUSED_ATTR uint8_t app_id) {
    body(handle, app_id);
  };
};
extern struct bta_pan_co_rx_path bta_pan_co_rx_path;
// Name: bta_pan_co_tx_path
// Params: uint16_t handle, uint8_t app_id
// Returns: void
struct bta_pan_co_tx_path {
  std::function<void(uint16_t handle, uint8_t app_id)> body{
      [](uint16_t handle, uint8_t app_id) { ; }};
  void operator()(uint16_t handle, uint8_t app_id) { body(handle, app_id); };
};
extern struct bta_pan_co_tx_path bta_pan_co_tx_path;

}  // namespace btif_bta_pan_co_rx
}  // namespace mock
}  // namespace test

// END mockcify generation