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

Commit b8012eb9 authored by Yuexi Ma's avatar Yuexi Ma
Browse files

Updates bluetooth hal test to use VtsHalHidlTargetTestBase v3

Test: pass
Change-Id: Ia5237a27800010174f2b23a3a4b1157f1c48781f
parent 3b9e2351
Loading
Loading
Loading
Loading
+54 −53
Original line number Diff line number Diff line
@@ -158,7 +158,7 @@ class BluetoothHidlTest : public ::testing::VtsHalHidlTargetTestBase {

    EXPECT_TRUE(
        bluetooth_cb->WaitForCallback(kCallbackNameInitializationComplete)
            .first);
            .no_timeout);

    ASSERT_EQ(initialized, true);
  }
@@ -260,8 +260,8 @@ void BluetoothHidlTest::wait_for_command_complete_event(hidl_vec<uint8_t> cmd) {
  int status_event_count = 0;
  hidl_vec<uint8_t> event;
  do {
    EXPECT_TRUE(
        bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).first);
      EXPECT_TRUE(bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived)
                      .no_timeout);
      EXPECT_LT(static_cast<size_t>(0), event_queue.size());
      if (event_queue.size() == 0) {
          event.resize(0);
@@ -294,7 +294,7 @@ void BluetoothHidlTest::setBufferSizes() {
  bluetooth->sendHciCommand(cmd);

  EXPECT_TRUE(
      bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).first);
      bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).no_timeout);

  EXPECT_LT(static_cast<size_t>(0), event_queue.size());
  if (event_queue.size() == 0) return;
@@ -348,8 +348,8 @@ void BluetoothHidlTest::sendAndCheckHCI(int num_packets) {
    bluetooth->sendHciCommand(cmd);

    // Check the loopback of the HCI packet
    EXPECT_TRUE(
        bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).first);
    EXPECT_TRUE(bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived)
                    .no_timeout);
    hidl_vec<uint8_t> event = event_queue.front();
    event_queue.pop();
    size_t compare_length =
@@ -385,8 +385,8 @@ void BluetoothHidlTest::sendAndCheckSCO(int num_packets, size_t size,
    bluetooth->sendScoData(sco_vector);

    // Check the loopback of the SCO packet
    EXPECT_TRUE(
        bluetooth_cb->WaitForCallback(kCallbackNameScoEventReceived).first);
    EXPECT_TRUE(bluetooth_cb->WaitForCallback(kCallbackNameScoEventReceived)
                    .no_timeout);
    hidl_vec<uint8_t> sco_loopback = sco_queue.front();
    sco_queue.pop();

@@ -431,8 +431,8 @@ void BluetoothHidlTest::sendAndCheckACL(int num_packets, size_t size,
    bluetooth->sendAclData(acl_vector);

    // Check the loopback of the ACL packet
    EXPECT_TRUE(
        bluetooth_cb->WaitForCallback(kCallbackNameAclEventReceived).first);
    EXPECT_TRUE(bluetooth_cb->WaitForCallback(kCallbackNameAclEventReceived)
                    .no_timeout);
    hidl_vec<uint8_t> acl_loopback = acl_queue.front();
    acl_queue.pop();

@@ -458,8 +458,8 @@ void BluetoothHidlTest::sendAndCheckACL(int num_packets, size_t size,

// Return the number of completed packets reported by the controller.
int BluetoothHidlTest::wait_for_completed_packets_event(uint16_t handle) {
  EXPECT_TRUE(
      bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).first);
    EXPECT_TRUE(bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived)
                    .no_timeout);
    int packets_processed = 0;
    while (event_queue.size() > 0) {
        hidl_vec<uint8_t> event = event_queue.front();
@@ -486,8 +486,8 @@ void BluetoothHidlTest::enterLoopbackMode(std::vector<uint16_t>& sco_handles,
  int connection_event_count = 0;
  hidl_vec<uint8_t> event;
  do {
    EXPECT_TRUE(
        bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).first);
      EXPECT_TRUE(bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived)
                      .no_timeout);
      event = event_queue.front();
      event_queue.pop();
      EXPECT_GT(event.size(),
@@ -504,7 +504,8 @@ void BluetoothHidlTest::enterLoopbackMode(std::vector<uint16_t>& sco_handles,

          // Save handles
          uint16_t handle = event[EVENT_CONNECTION_COMPLETE_HANDLE_LSBYTE] |
                        event[EVENT_CONNECTION_COMPLETE_HANDLE_LSBYTE + 1] << 8;
                            event[EVENT_CONNECTION_COMPLETE_HANDLE_LSBYTE + 1]
                                << 8;
          if (connection_type == EVENT_CONNECTION_COMPLETE_TYPE_SCO)
              sco_handles.push_back(handle);
          else
@@ -541,7 +542,7 @@ TEST_F(BluetoothHidlTest, HciVersionTest) {
  bluetooth->sendHciCommand(cmd);

  EXPECT_TRUE(
      bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).first);
      bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).no_timeout);

  hidl_vec<uint8_t> event = event_queue.front();
  event_queue.pop();
@@ -562,7 +563,7 @@ TEST_F(BluetoothHidlTest, HciUnknownCommand) {
  bluetooth->sendHciCommand(cmd);

  EXPECT_TRUE(
      bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).first);
      bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).no_timeout);

  hidl_vec<uint8_t> event = event_queue.front();
  event_queue.pop();