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

Commit 93a8d4d5 authored by Chris Manton's avatar Chris Manton Committed by Automerger Merge Worker
Browse files

Introduce bta/test mocks and fakes am: 445082d4 am: 5bcc5e24

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1580482

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I669fab7ccd5d759fb6d0b384f03138f62c021e9e
parents 6f63c1a2 5bcc5e24
Loading
Loading
Loading
Loading
+74 −0
Original line number Original line Diff line number Diff line
@@ -153,6 +153,80 @@ cc_test {
    ],
    ],
}
}


cc_test {
    name: "bt_host_test_bta",
    defaults: ["fluoride_bta_defaults"],
    test_suites: ["device-tests"],
    host_supported: true,
    include_dirs: [
        "packages/modules/Bluetooth/system",
    ],
    srcs: [
        "dm/bta_dm_act.cc",
        "dm/bta_dm_cfg.cc",
        "dm/bta_dm_ci.cc",
        "dm/bta_dm_main.cc",
        "dm/bta_dm_pm.cc",
        "gatt/bta_gattc_act.cc",
        "gatt/bta_gattc_api.cc",
        "gatt/bta_gattc_cache.cc",
        "gatt/bta_gattc_main.cc",
        "gatt/bta_gattc_queue.cc",
        "gatt/bta_gattc_utils.cc",
        "gatt/database.cc",
        "gatt/database_builder.cc",
        "hh/bta_hh_act.cc",
        "hh/bta_hh_cfg.cc",
        "hh/bta_hh_le.cc",
        "hh/bta_hh_main.cc",
        "hh/bta_hh_utils.cc",
        "sys/bta_sys_conn.cc",
        "sys/bta_sys_main.cc",
        "test/bta_dm_test.cc",
        "test/common/fake_osi.cc",
        "test/common/mock_btif_co_bta_dm_co.cc",
        "test/common/mock_btif_co_bta_hh_co.cc",
        "test/common/mock_btif_debug_conn.cc",
        "test/common/mock_btif_dm.cc",
        "test/common/mock_btif_stack_manager.cc",
        "test/common/mock_btif_storage.cc",
        "test/common/mock_device_controller.cc",
        "test/common/mock_device_interop.cc",
        "test/common/mock_main_shim_acl.cc",
        "test/common/mock_main_shim_btm_api.cc",
        "test/common/mock_shim.cc",
        "test/common/mock_stack_acl.cc",
        "test/common/mock_stack_btm.cc",
        "test/common/mock_stack_btm_ble.cc",
        "test/common/mock_stack_btm_dev.cc",
        "test/common/mock_stack_btm_pm.cc",
        "test/common/mock_stack_btm_sco.cc",
        "test/common/mock_stack_btm_sec.cc",
        "test/common/mock_stack_crypto_toolbox_aes_cmac.cc",
        "test/common/mock_stack_gap_ble.cc",
        "test/common/mock_stack_gatt.cc",
        "test/common/mock_stack_gatt_attr.cc",
        "test/common/mock_stack_gatt_connection_manager.cc",
        "test/common/mock_stack_hidh.cc",
        "test/common/mock_stack_l2cap.cc",
        "test/common/mock_stack_l2cap_ble.cc",
        "test/common/mock_stack_sdp.cc",
        "test/common/mock_stack_srvc_dis.cc",
    ],
    shared_libs: [
        "libcrypto",
        "liblog",
        "libprotobuf-cpp-lite",
    ],
    static_libs: [
        "libbluetooth-types",
        "libbt-common",
        "libbt-protos-lite",
        "libbtcore",
        "libgmock",
    ],
}

// bta hf client add record tests for target
// bta hf client add record tests for target
// ========================================================
// ========================================================
cc_test {
cc_test {
+69 −0
Original line number Original line 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 <base/bind.h>
#include <base/location.h>
#include <gtest/gtest.h>

#include "bta/dm/bta_dm_int.h"
#include "bta/hf_client/bta_hf_client_int.h"
#include "bta/include/bta_hf_client_api.h"
#include "common/message_loop_thread.h"

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

bt_status_t do_in_main_thread_delayed(const base::Location& from_here,
                                      base::OnceClosure task,
                                      const base::TimeDelta& delay) {
  return BT_STATUS_SUCCESS;
}

bt_status_t do_in_main_thread(const base::Location& from_here,
                              base::OnceClosure task) {
  return BT_STATUS_SUCCESS;
}

void LogMsg(uint32_t trace_set_mask, const char* fmt_str, ...) {}

namespace base {
class MessageLoop;
}  // namespace base
bluetooth::common::MessageLoopThread* get_main_thread() { return nullptr; }

namespace {
constexpr uint8_t kUnusedTimer = BTA_ID_MAX;
}  // namespace

class BtaDmTest : public testing::Test {
 protected:
  void SetUp() override {
    mock_function_count_map.clear();

    bta_dm_init_cb();

    for (int i = 0; i < BTA_DM_NUM_PM_TIMER; i++) {
      for (int j = 0; j < BTA_DM_PM_MODE_TIMER_MAX; j++) {
        bta_dm_cb.pm_timer[i].srvc_id[j] = kUnusedTimer;
      }
    }
  }
  void TearDown() override { bta_dm_deinit_cb(); }
};

TEST_F(BtaDmTest, nop) {
  bool status = true;
  ASSERT_EQ(true, status);
}
+645 −0

File added.

Preview size limit exceeded, changes collapsed.

+26 −0
Original line number Original line 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 <cstdint>
#include "osi/include/alarm.h"

struct fake_osi_alarm_set_on_mloop {
  uint64_t interval_ms{0};
  alarm_callback_t cb{};
  void* data{nullptr};
};
+38 −0
Original line number Original line 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
 */

#include <cstdint>

#include "bta/include/bta_api.h"
#include "bta/sys/bta_sys.h"
#include "internal_include/bte_appl.h"
#include "osi/include/osi.h"  // UNUSED_ATTR
#include "stack/include/btm_api_types.h"

tBTE_APPL_CFG bte_appl_cfg = {
    BTA_LE_AUTH_REQ_SC_MITM_BOND,  // Authentication requirements
    BTM_IO_CAP_UNKNOWN, BTM_BLE_INITIATOR_KEY_SIZE, BTM_BLE_RESPONDER_KEY_SIZE,
    BTM_BLE_MAX_KEY_SIZE};

bool bta_dm_co_get_compress_memory(UNUSED_ATTR tBTA_SYS_ID id,
                                   UNUSED_ATTR uint8_t** memory_p,
                                   UNUSED_ATTR uint32_t* memory_size) {
  return true;
}
Loading