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

Commit 4ef8d126 authored by Henri Chataing's avatar Henri Chataing
Browse files

system/bta/test: Migrate to libbluetooth_log

Test: m com.android.btservices
Bug: 305066880
Flag: EXEMPT, mechanical refactor
Change-Id: I784e0e10ff7a4eebce6d8d8f204d06b6a5b85252
parent fdf37e6e
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include <android_bluetooth_flags.h>
#include <base/functional/bind.h>
#include <base/location.h>
#include <bluetooth/log.h>
#include <com_android_bluetooth_flags.h>
#include <flag_macros.h>
#include <gmock/gmock.h>
@@ -51,6 +52,8 @@

#define TEST_BT com::android::bluetooth::flags

using namespace bluetooth;

namespace {

bool bta_ag_hdl_event(const BT_HDR_RIGID* p_msg) { return true; };
@@ -75,7 +78,7 @@ class BtaAgTest : public testing::Test {
    fake_osi_ = std::make_unique<test::fake::FakeOsi>();

    main_thread_start_up();
    post_on_bt_main([]() { LOG_INFO("Main thread started up"); });
    post_on_bt_main([]() { log::info("Main thread started up"); });

    bta_sys_register(BTA_ID_AG, &bta_ag_reg);

@@ -90,7 +93,7 @@ class BtaAgTest : public testing::Test {
  void TearDown() override {
    test::mock::device_esco_parameters::esco_parameters_for_codec = {};
    bta_sys_deregister(BTA_ID_AG);
    post_on_bt_main([]() { LOG_INFO("Main thread shutting down"); });
    post_on_bt_main([]() { log::info("Main thread shutting down"); });
    main_thread_shut_down();
  }

+4 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

#include <base/functional/bind.h>
#include <base/location.h>
#include <bluetooth/log.h>
#include <com_android_bluetooth_flags.h>
#include <flag_macros.h>
#include <gmock/gmock.h>
@@ -45,6 +46,7 @@
#define TEST_BT com::android::bluetooth::flags

using namespace std::chrono_literals;
using namespace bluetooth;

namespace {
constexpr uint8_t kUnusedTimer = BTA_ID_MAX;
@@ -82,7 +84,7 @@ class BtaDmTest : public BtaBaseTest {
  void SetUp() override {
    BtaBaseTest::SetUp();
    main_thread_start_up();
    post_on_bt_main([]() { LOG_INFO("Main thread started up"); });
    post_on_bt_main([]() { log::info("Main thread started up"); });

    bta_sys_register(BTA_ID_DM_SEARCH, &bta_dm_search_reg);
    bluetooth::legacy::testing::bta_dm_init_cb();
@@ -96,7 +98,7 @@ class BtaDmTest : public BtaBaseTest {
  void TearDown() override {
    bta_sys_deregister(BTA_ID_DM_SEARCH);
    bluetooth::legacy::testing::bta_dm_deinit_cb();
    post_on_bt_main([]() { LOG_INFO("Main thread shutting down"); });
    post_on_bt_main([]() { log::info("Main thread shutting down"); });
    main_thread_shut_down();
    BtaBaseTest::TearDown();
  }
+13 −11
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@

#include <base/logging.h>
#include <base/strings/string_number_conversions.h>
#include <bluetooth/log.h>
#include <gtest/gtest.h>

#include "gatt/database_builder.h"
@@ -27,6 +28,7 @@
#include "types/bluetooth/uuid.h"

using bluetooth::Uuid;
using namespace bluetooth;

namespace gatt {

@@ -123,7 +125,7 @@ TEST(GattCacheTest, stored_attribute_to_binary_service_test) {
  // clang-format on

  // useful for debugging:
  // LOG(ERROR) << " " << base::HexEncode(&attr, len);
  // log::error("{}", base::HexEncode(&attr, len));

  // Do not compare last 2 bytes which are padding as
  // x86 can use non-zero padding causing the test to fail
@@ -160,7 +162,7 @@ TEST(GattCacheTest, stored_attribute_to_binary_included_service_test) {
  // clang-format on

  // useful for debugging:
  // LOG(ERROR) << " " << base::HexEncode(&attr, len);
  // log::error("{}", base::HexEncode(&attr, len));
  EXPECT_EQ(memcmp(binary_form, &attr, len), 0);
}

@@ -193,7 +195,7 @@ TEST(GattCacheTest, stored_attribute_to_binary_characteristic_test) {
  // clang-format on

  // useful for debugging:
  // LOG(ERROR) << " " << base::HexEncode(&attr, len);
  // log::error("{}", base::HexEncode(&attr, len));
  EXPECT_EQ(memcmp(binary_form, &attr, len), 0);
}

@@ -219,7 +221,7 @@ TEST(GattCacheTest, stored_attribute_to_binary_descriptor_test) {
  // clang-format on

  // useful for debugging:
  // LOG(ERROR) << " " << base::HexEncode(&attr, len);
  // log::error("{}", base::HexEncode(&attr, len));
  EXPECT_EQ(memcmp(binary_form, &attr, len), 0);
}

@@ -287,7 +289,7 @@ TEST(GattCacheTest,
  // clang-format on

  // useful for debugging:
  // LOG(ERROR) << " " << base::HexEncode(&attr, len);
  // log::error("{}", base::HexEncode(&attr, len));
  EXPECT_EQ(memcmp(binary_form.data(), &attr, len), 0);

  // Don't use memcmp, for better error messages.
@@ -339,7 +341,7 @@ TEST(GattCacheTest, stored_attributes_serialized_to_binary_test) {
  attr = {.handle = 0x0003,
          .type = Uuid::FromString("2900"),
          .value.characteristic_extended_properties = 0x1234};
  LOG(ERROR) << " " << base::HexEncode(&attr, StoredAttribute::kSizeOnDisk);
  log::error("{}", base::HexEncode(&attr, StoredAttribute::kSizeOnDisk));
  */

  memcpy(
@@ -371,7 +373,7 @@ TEST(GattCacheTest, stored_attributes_serialized_to_binary_test) {
              .end_handle = 0x1203,
          },
  };
  LOG(ERROR) << " " << base::HexEncode(&attr, StoredAttribute::kSizeOnDisk);
  log::error("{}", base::HexEncode(&attr, StoredAttribute::kSizeOnDisk));
  */
  memcpy(
      attr_bytes,
@@ -401,7 +403,7 @@ TEST(GattCacheTest, stored_attributes_serialized_to_binary_test) {
          },
  };

  LOG(ERROR) << " " << base::HexEncode(&attr, StoredAttribute::kSizeOnDisk);
  log::error("{}", base::HexEncode(&attr, StoredAttribute::kSizeOnDisk));
  */
  memcpy(
      attr_bytes,
@@ -431,7 +433,7 @@ TEST(GattCacheTest, stored_attributes_serialized_to_binary_test) {
              .uuid = Uuid::FromString("3456"),
          },
  };
  LOG(ERROR) << " " << base::HexEncode(&attr, StoredAttribute::kSizeOnDisk);
  log::error("{}", base::HexEncode(&attr, StoredAttribute::kSizeOnDisk));
  */

  memcpy(
@@ -459,7 +461,7 @@ TEST(GattCacheTest, stored_attributes_serialized_to_binary_test) {
                               .value_handle = 0x302,
                               .uuid = Uuid::FromString("3456")},
  };
  LOG(ERROR) << " " << base::HexEncode(&attr, StoredAttribute::kSizeOnDisk);
  log::error("{}", base::HexEncode(&attr, StoredAttribute::kSizeOnDisk));
  */
  memcpy(
      attr_bytes,
@@ -485,7 +487,7 @@ TEST(GattCacheTest, stored_attributes_serialized_to_binary_test) {
      .type = Uuid::FromString("4444"),
      .value.characteristic = {},
  };
  LOG(ERROR) << " " << base::HexEncode(&attr, StoredAttribute::kSizeOnDisk);
  log::error("{}", base::HexEncode(&attr, StoredAttribute::kSizeOnDisk));
  */
  memcpy(
      attr_bytes,