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

Commit 64e88d3d authored by Chris Manton's avatar Chris Manton Committed by Automerger Merge Worker
Browse files

Merge "[16/25] stack::eatt Use stack::l2cap::get_interface()" into main am: 5623e6cc

parents 7ed554bd 5623e6cc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1567,6 +1567,7 @@ cc_test {
        ":TestCommonStackConfig",
        ":TestMockMainShim",
        ":TestMockMainShimEntry",
        ":TestMockStackL2capInterface",
        ":TestStubOsi",
        "eatt/eatt.cc",
        "test/common/mock_btif_storage.cc",
+12 −5
Original line number Diff line number Diff line
@@ -15,12 +15,18 @@
 * limitations under the License.
 */

#include "stack/eatt/eatt.h"

#include <bluetooth/log.h>

#include "eatt_impl.h"
#include "l2cdefs.h"
#include <memory>
#include <vector>

#include "stack/eatt/eatt_impl.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_psm_types.h"
#include "stack/include/l2cap_interface.h"
#include "stack/include/l2cdefs.h"
#include "types/raw_address.h"

using bluetooth::eatt::eatt_impl;
@@ -36,7 +42,7 @@ struct EattExtension::impl {
    if (eatt_impl_) {
      log::error("Eatt already started");
      return;
    };
    }

    /* Register server for Eatt */
    memset(&reg_info_, 0, sizeof(reg_info_));
@@ -48,7 +54,8 @@ struct EattExtension::impl {
    reg_info_.pL2CA_DataInd_Cb = eatt_data_ind;
    reg_info_.pL2CA_CreditBasedCollisionInd_Cb = eatt_collision_ind;

    if (L2CA_RegisterLECoc(BT_PSM_EATT, reg_info_, BTM_SEC_NONE, {}) == 0) {
    if (stack::l2cap::get_interface().L2CA_RegisterLECoc(BT_PSM_EATT, reg_info_, BTM_SEC_NONE,
                                                         {}) == 0) {
      log::error("cannot register EATT");
    } else {
      eatt_impl_ = std::make_unique<eatt_impl>();
@@ -61,7 +68,7 @@ struct EattExtension::impl {
      return;
    }
    eatt_impl_.reset(nullptr);
    L2CA_DeregisterLECoc(BT_PSM_EATT);
    stack::l2cap::get_interface().L2CA_DeregisterLECoc(BT_PSM_EATT);
  }

  bool IsRunning() { return eatt_impl_ ? true : false; }
+21 −15
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 * limitations under the License.
 */

#pragma once

#include <bluetooth/log.h>
#include <com_android_bluetooth_flags.h>

@@ -23,19 +25,19 @@
#include <utility>
#include <vector>

#include "bind_helpers.h"
#include "eatt.h"
#include "hci/controller_interface.h"
#include "include/bind_helpers.h"
#include "internal_include/stack_config.h"
#include "l2c_api.h"
#include "main/shim/entry.h"
#include "osi/include/alarm.h"
#include "osi/include/allocator.h"
#include "stack/btm/btm_sec.h"
#include "stack/eatt/eatt.h"
#include "stack/gatt/gatt_int.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_psm_types.h"
#include "stack/include/btm_sec_api.h"
#include "stack/include/l2cap_interface.h"
#include "stack/include/l2cdefs.h"
#include "stack/include/main_thread.h"

@@ -165,8 +167,8 @@ struct eatt_impl {
            .credits = L2CA_LeCreditDefault(),
    };

    if (!L2CA_ConnectCreditBasedRsp(bda, identifier, lcids,
                                    tL2CAP_LE_RESULT_CODE::L2CAP_LE_RESULT_CONN_OK,
    if (!stack::l2cap::get_interface().L2CA_ConnectCreditBasedRsp(
                bda, identifier, lcids, tL2CAP_LE_RESULT_CODE::L2CAP_LE_RESULT_CONN_OK,
                &local_coc_cfg)) {
      log::warn("Unable to respond L2CAP le_coc credit indication peer:{}", bda);
      return false;
@@ -228,7 +230,7 @@ struct eatt_impl {
      p_buf->offset = L2CAP_MIN_OFFSET;
      p_buf->len = mtu;

      auto status = L2CA_DataWrite(cid, p_buf);
      auto status = stack::l2cap::get_interface().L2CA_DataWrite(cid, p_buf);
      log::info("Data num: {} sent with status {}", i, static_cast<int>(status));
    }
  }
@@ -263,7 +265,7 @@ struct eatt_impl {
      if (key_size < min_key_size) {
        std::vector<uint16_t> empty;
        log::error("Insufficient key size ({}<{}) for device {}", key_size, min_key_size, bda);
        if (!L2CA_ConnectCreditBasedRsp(
        if (!stack::l2cap::get_interface().L2CA_ConnectCreditBasedRsp(
                    bda, identifier, empty,
                    tL2CAP_LE_RESULT_CODE::L2CAP_LE_RESULT_INSUFFICIENT_ENCRYP_KEY_SIZE, nullptr)) {
          log::warn("Unable to respond L2CAP le_coc credit indication peer:{}", bda);
@@ -310,7 +312,8 @@ struct eatt_impl {
        result = tL2CAP_LE_RESULT_CODE::L2CAP_LE_RESULT_INSUFFICIENT_ENCRYP;
      }
      log::error("ACL to device {} is unencrypted.", bda);
      if (!L2CA_ConnectCreditBasedRsp(bda, identifier, empty, result, nullptr)) {
      if (!stack::l2cap::get_interface().L2CA_ConnectCreditBasedRsp(bda, identifier, empty, result,
                                                                    nullptr)) {
        log::warn("Unable to respond L2CAP le_coc credit indication peer:{}", bda);
      }
      return;
@@ -336,7 +339,7 @@ struct eatt_impl {
    log::info("EATT collision detected. If we are Central we will retry right away");

    eatt_dev->collision = false;
    uint8_t role = L2CA_GetBleConnRole(eatt_dev->bda_);
    uint8_t role = stack::l2cap::get_interface().L2CA_GetBleConnRole(eatt_dev->bda_);
    if (role == HCI_ROLE_CENTRAL) {
      log::info("Retrying EATT setup due to previous collision for device {}", eatt_dev->bda_);
      connect_eatt_wrap(eatt_dev);
@@ -559,7 +562,8 @@ struct eatt_impl {

    /* Warning! CIDs in Android are unique across the ACL connections */
    std::vector<uint16_t> connecting_cids =
            L2CA_ConnectCreditBasedReq(psm_, eatt_dev->bda_, &local_coc_cfg);
            stack::l2cap::get_interface().L2CA_ConnectCreditBasedReq(psm_, eatt_dev->bda_,
                                                                     &local_coc_cfg);

    if (connecting_cids.size() == 0) {
      log::error("Unable to get cid");
@@ -794,7 +798,8 @@ struct eatt_impl {
            .mps = eatt_dev->rx_mps_,
    };

    if (!L2CA_ReconfigCreditBasedConnsReq(eatt_dev->bda_, cids, &cfg)) {
    if (!stack::l2cap::get_interface().L2CA_ReconfigCreditBasedConnsReq(eatt_dev->bda_, cids,
                                                                        &cfg)) {
      log::error("Could not start reconfig cid: 0x{:x} or device {}", cid, bd_addr);
      return;
    }
@@ -833,7 +838,8 @@ struct eatt_impl {
    tL2CAP_LE_CFG_INFO cfg = {
            .result = tL2CAP_CFG_RESULT::L2CAP_CFG_OK, .mtu = new_mtu, .mps = eatt_dev->rx_mps_};

    if (!L2CA_ReconfigCreditBasedConnsReq(eatt_dev->bda_, cids, &cfg)) {
    if (!stack::l2cap::get_interface().L2CA_ReconfigCreditBasedConnsReq(eatt_dev->bda_, cids,
                                                                        &cfg)) {
      log::error("Could not start reconfig for device {}", bd_addr);
      return;
    }
@@ -868,7 +874,7 @@ struct eatt_impl {
  }

  void disconnect_channel(uint16_t cid) {
    if (!L2CA_DisconnectReq(cid)) {
    if (!stack::l2cap::get_interface().L2CA_DisconnectReq(cid)) {
      log::warn("Unable to request L2CAP disconnect cid:{}", cid);
    }
  }
@@ -952,7 +958,7 @@ struct eatt_impl {
  void connect(const RawAddress& bd_addr) {
    eatt_device* eatt_dev = find_device_by_address(bd_addr);

    uint8_t role = L2CA_GetBleConnRole(bd_addr);
    uint8_t role = stack::l2cap::get_interface().L2CA_GetBleConnRole(bd_addr);
    if (role == HCI_ROLE_UNKNOWN) {
      log::error("Could not get device role{}", bd_addr);
      return;
+63 −43
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@

#include "bta/test/common/fake_osi.h"
#include "hci/controller_interface_mock.h"
#include "include/bind_helpers.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_psm_types.h"
#include "stack/include/l2cdefs.h"
@@ -34,6 +33,7 @@
#include "stack/test/common/mock_gatt_layer.h"
#include "stack/test/common/mock_l2cap_layer.h"
#include "test/mock/mock_main_shim_entry.h"
#include "test/mock/mock_stack_l2cap_interface.h"
#include "types/raw_address.h"

using testing::_;
@@ -68,7 +68,7 @@ namespace {
const RawAddress test_address({0x11, 0x11, 0x11, 0x11, 0x11, 0x11});
std::vector<uint16_t> test_local_cids{61, 62, 63, 64, 65};

class EattTest : public testing::Test {
class EattTest : public ::testing::Test {
protected:
  void ConnectDeviceEattSupported(int num_of_accepted_connections, bool collision = false) {
    ON_CALL(gatt_interface_, ClientReadSupportedFeatures)
@@ -77,12 +77,15 @@ protected:
              std::move(cb).Run(addr, BLE_GATT_SVR_SUP_FEAT_EATT_BITMASK);
              return true;
            });
    ON_CALL(gatt_interface_, GetEattSupport).WillByDefault([](const RawAddress& addr) {
    EXPECT_CALL(gatt_interface_, GetEattSupport).WillRepeatedly([](const RawAddress& addr) {
      return true;
    });

    EXPECT_CALL(l2cap_interface_, ConnectCreditBasedReq(BT_PSM_EATT, test_address, _))
    EXPECT_CALL(mock_stack_l2cap_interface_,
                L2CA_ConnectCreditBasedReq(BT_PSM_EATT, test_address, _))
            .WillOnce(Return(test_local_cids));
    ON_CALL(mock_stack_l2cap_interface_, L2CA_DisconnectReq(test_local_cids[0]))
            .WillByDefault(Return(true));

    eatt_instance_->Connect(test_address);

@@ -90,7 +93,9 @@ protected:
      /* Collision should be handled only if all channels has been rejected in
       * first place.*/
      if (num_of_accepted_connections == 0) {
        EXPECT_CALL(l2cap_interface_, ConnectCreditBasedReq(BT_PSM_EATT, test_address, _)).Times(1);
        EXPECT_CALL(mock_stack_l2cap_interface_,
                    L2CA_ConnectCreditBasedReq(BT_PSM_EATT, test_address, _))
                .Times(1);
      }

      l2cap_app_info_.pL2CA_CreditBasedCollisionInd_Cb(test_address);
@@ -141,14 +146,15 @@ protected:
    });

    std::vector<uint16_t> test_local_cids{61, 62, 63, 64, 65};
    EXPECT_CALL(l2cap_interface_, ConnectCreditBasedReq(BT_PSM_EATT, test_address, _))
    EXPECT_CALL(mock_stack_l2cap_interface_,
                L2CA_ConnectCreditBasedReq(BT_PSM_EATT, test_address, _))
            .WillOnce(Return(test_local_cids));

    eatt_instance_->Connect(test_address);

    // Let the remote connect while we are trying to connect
    EXPECT_CALL(l2cap_interface_,
                ConnectCreditBasedRsp(test_address, 1, incoming_cids,
    EXPECT_CALL(mock_stack_l2cap_interface_,
                L2CA_ConnectCreditBasedRsp(test_address, 1, incoming_cids,
                                           tL2CAP_LE_RESULT_CODE::L2CAP_LE_RESULT_CONN_OK, _))
            .WillOnce(Return(true));
    l2cap_app_info_.pL2CA_CreditBasedConnectInd_Cb(test_address, incoming_cids, BT_PSM_EATT,
@@ -199,20 +205,23 @@ protected:
    for (uint16_t cid : connected_cids_) {
      l2cap_app_info_.pL2CA_DisconnectInd_Cb(cid, true);
    }
    ASSERT_TRUE(test_tcb.eatt == 0);
    ASSERT_EQ(0, test_tcb.eatt);
  }

  void DisconnectEattDevice(std::vector<uint16_t> cids) {
    EXPECT_CALL(l2cap_interface_, DisconnectRequest(_)).Times(cids.size());
    EXPECT_CALL(mock_stack_l2cap_interface_, L2CA_DisconnectReq(_)).Times(cids.size());
    eatt_instance_->Disconnect(test_address);

    ASSERT_TRUE(test_tcb.eatt == 0);
    ASSERT_EQ(0, test_tcb.eatt);
  }

  void SetUp() override {
    bluetooth::testing::stack::l2cap::set_interface(&mock_stack_l2cap_interface_);
    tL2CAP_APPL_INFO l2cap_callbacks{};

    le_buffer_size_.le_data_packet_length_ = 128;
    le_buffer_size_.total_num_le_packets_ = 24;
    ON_CALL(controller_, GetLeBufferSize).WillByDefault(Return(le_buffer_size_));
    EXPECT_CALL(controller_, GetLeBufferSize).WillRepeatedly(Return(le_buffer_size_));
    bluetooth::l2cap::SetMockInterface(&l2cap_interface_);
    bluetooth::manager::SetMockBtmApiInterface(&btm_api_interface_);
    bluetooth::manager::SetMockBtifStorageInterface(&btif_storage_interface_);
@@ -222,14 +231,17 @@ protected:
    // Clear the static memory for each test case
    memset(&test_tcb, 0, sizeof(test_tcb));

    EXPECT_CALL(l2cap_interface_, RegisterLECoc(BT_PSM_EATT, _, _))
            .WillOnce(DoAll(SaveArg<1>(&l2cap_app_info_), Return(BT_PSM_EATT)));
    EXPECT_CALL(mock_stack_l2cap_interface_, L2CA_RegisterLECoc(BT_PSM_EATT, _, _, _))
            .WillOnce(DoAll(SaveArg<1>(&l2cap_app_info_), ::testing::ReturnArg<0>()));

    ON_CALL(btif_storage_interface_, LoadBondedEatt).WillByDefault([]() { return; });

    hci_role_ = HCI_ROLE_CENTRAL;

    ON_CALL(l2cap_interface_, GetBleConnRole(_)).WillByDefault(DoAll(Return(hci_role_)));
    EXPECT_CALL(l2cap_interface_, LeCreditDefault()).WillRepeatedly(DoAll(Return(0xfff)));

    EXPECT_CALL(mock_stack_l2cap_interface_, L2CA_GetBleConnRole(_))
            .WillRepeatedly(DoAll(Return(hci_role_)));

    eatt_instance_ = EattExtension::GetInstance();
    eatt_instance_->Start();
@@ -240,15 +252,16 @@ protected:
  void TearDown() override {
    com::android::bluetooth::flags::provider_->reset_flags();

    EXPECT_CALL(l2cap_interface_, DeregisterLECoc(BT_PSM_EATT)).Times(1);
    EXPECT_CALL(mock_stack_l2cap_interface_, L2CA_DeregisterLECoc(BT_PSM_EATT)).Times(1);

    eatt_instance_->Stop();
    eatt_instance_ = nullptr;
    hci_role_ = 0;
    hci_role_ = HCI_ROLE_CENTRAL;
    connected_cids_.clear();

    bluetooth::gatt::SetMockGattInterface(nullptr);
    bluetooth::l2cap::SetMockInterface(nullptr);
    bluetooth::testing::stack::l2cap::reset_interface();
    bluetooth::manager::SetMockBtifStorageInterface(nullptr);
    bluetooth::manager::SetMockBtmApiInterface(nullptr);
    bluetooth::hci::testing::mock_controller_ = nullptr;
@@ -256,9 +269,12 @@ protected:
    Test::TearDown();
  }

  tL2CAP_APPL_INFO reg_info_;

  bluetooth::manager::MockBtifStorageInterface btif_storage_interface_;
  bluetooth::manager::MockBtmApiInterface btm_api_interface_;
  bluetooth::l2cap::MockL2capInterface l2cap_interface_;
  bluetooth::testing::stack::l2cap::Mock mock_stack_l2cap_interface_;
  bluetooth::gatt::MockGattInterface gatt_interface_;
  bluetooth::hci::testing::MockControllerInterface controller_;
  bluetooth::hci::LeBufferSize le_buffer_size_;
@@ -266,7 +282,7 @@ protected:
  tL2CAP_APPL_INFO l2cap_app_info_;
  EattExtension* eatt_instance_;
  std::vector<uint16_t> connected_cids_;
  uint8_t hci_role_ = HCI_ROLE_CENTRAL;
  tHCI_ROLE hci_role_ = HCI_ROLE_CENTRAL;
};

TEST_F(EattTest, ConnectSucceed) {
@@ -279,8 +295,8 @@ TEST_F(EattTest, IncomingEattConnectionByUnknownDevice) {

  ON_CALL(btm_api_interface_, IsEncrypted)
          .WillByDefault([](const RawAddress& addr, tBT_TRANSPORT transport) { return true; });
  EXPECT_CALL(l2cap_interface_,
              ConnectCreditBasedRsp(test_address, 1, incoming_cids,
  EXPECT_CALL(mock_stack_l2cap_interface_,
              L2CA_ConnectCreditBasedRsp(test_address, 1, incoming_cids,
                                         tL2CAP_LE_RESULT_CODE::L2CAP_LE_RESULT_CONN_OK, _))
          .WillOnce(Return(true));

@@ -307,8 +323,8 @@ TEST_F(EattTest, IncomingEattConnectionByKnownDevice) {
  eatt_instance_->Connect(test_address);
  std::vector<uint16_t> incoming_cids{71, 72, 73, 74, 75};

  EXPECT_CALL(l2cap_interface_,
              ConnectCreditBasedRsp(test_address, 1, incoming_cids,
  EXPECT_CALL(mock_stack_l2cap_interface_,
              L2CA_ConnectCreditBasedRsp(test_address, 1, incoming_cids,
                                         tL2CAP_LE_RESULT_CODE::L2CAP_LE_RESULT_CONN_OK, _))
          .WillOnce(Return(true));

@@ -339,8 +355,9 @@ TEST_F(EattTest, IncomingEattConnectionByKnownDeviceEncryptionOff) {
  eatt_instance_->Connect(test_address);
  std::vector<uint16_t> incoming_cids{71, 72, 73, 74, 75};

  EXPECT_CALL(l2cap_interface_,
              ConnectCreditBasedRsp(test_address, 1, _,
  EXPECT_CALL(
          mock_stack_l2cap_interface_,
          L2CA_ConnectCreditBasedRsp(test_address, 1, _,
                                     tL2CAP_LE_RESULT_CODE::L2CAP_LE_RESULT_INSUFFICIENT_ENCRYP, _))
          .WillOnce(Return(true));

@@ -357,8 +374,8 @@ TEST_F(EattTest, IncomingEattConnectionByUnknownDeviceEncryptionOff) {
          .WillByDefault([](const RawAddress& addr, tBT_TRANSPORT transport) { return false; });
  ON_CALL(btm_api_interface_, IsLinkKeyKnown)
          .WillByDefault([](const RawAddress& addr, tBT_TRANSPORT transport) { return false; });
  EXPECT_CALL(l2cap_interface_,
              ConnectCreditBasedRsp(
  EXPECT_CALL(mock_stack_l2cap_interface_,
              L2CA_ConnectCreditBasedRsp(
                      test_address, 1, _,
                      tL2CAP_LE_RESULT_CODE::L2CAP_LE_RESULT_INSUFFICIENT_AUTHENTICATION, _))
          .WillOnce(Return(true));
@@ -375,8 +392,8 @@ TEST_F(EattTest, ReconnectInitiatedByRemoteSucceed) {
  ON_CALL(btm_api_interface_, IsEncrypted)
          .WillByDefault([](const RawAddress& addr, tBT_TRANSPORT transport) { return true; });

  EXPECT_CALL(l2cap_interface_,
              ConnectCreditBasedRsp(test_address, 1, incoming_cids,
  EXPECT_CALL(mock_stack_l2cap_interface_,
              L2CA_ConnectCreditBasedRsp(test_address, 1, incoming_cids,
                                         tL2CAP_LE_RESULT_CODE::L2CAP_LE_RESULT_CONN_OK, _))
          .WillOnce(Return(true));

@@ -416,13 +433,15 @@ TEST_F(EattTest, ConnectFailedEattNotSupported) {
    return false;
  });

  EXPECT_CALL(l2cap_interface_, ConnectCreditBasedReq(BT_PSM_EATT, test_address, _)).Times(0);
  EXPECT_CALL(mock_stack_l2cap_interface_, L2CA_ConnectCreditBasedReq(BT_PSM_EATT, test_address, _))
          .Times(0);
  eatt_instance_->Connect(test_address);
  ASSERT_TRUE(eatt_instance_->IsEattSupportedByPeer(test_address) == false);
}

TEST_F(EattTest, ConnectFailedSlaveOnTheLink) {
  EXPECT_CALL(l2cap_interface_, ConnectCreditBasedReq(BT_PSM_EATT, test_address, _)).Times(0);
  EXPECT_CALL(mock_stack_l2cap_interface_, L2CA_ConnectCreditBasedReq(BT_PSM_EATT, test_address, _))
          .Times(0);

  hci_role_ = HCI_ROLE_PERIPHERAL;
  eatt_instance_->Connect(test_address);
@@ -448,7 +467,7 @@ TEST_F(EattTest, ReconfigAllSucceed) {
  ConnectDeviceEattSupported(3);

  std::vector<uint16_t> cids;
  EXPECT_CALL(l2cap_interface_, ReconfigCreditBasedConnsReq(_, _, _))
  EXPECT_CALL(mock_stack_l2cap_interface_, L2CA_ReconfigCreditBasedConnsReq(_, _, _))
          .WillOnce(DoAll(SaveArg<1>(&cids), Return(true)));

  uint16_t new_mtu = 300;
@@ -473,7 +492,7 @@ TEST_F(EattTest, ReconfigAllFailed) {
  ConnectDeviceEattSupported(4);

  std::vector<uint16_t> cids;
  EXPECT_CALL(l2cap_interface_, ReconfigCreditBasedConnsReq(_, _, _))
  EXPECT_CALL(mock_stack_l2cap_interface_, L2CA_ReconfigCreditBasedConnsReq(_, _, _))
          .WillOnce(DoAll(SaveArg<1>(&cids), Return(true)));

  uint16_t new_mtu = 300;
@@ -499,13 +518,13 @@ TEST_F(EattTest, ReconfigSingleSucceed) {
  ConnectDeviceEattSupported(2);

  std::vector<uint16_t> cids;
  EXPECT_CALL(l2cap_interface_, ReconfigCreditBasedConnsReq(_, _, _))
  EXPECT_CALL(mock_stack_l2cap_interface_, L2CA_ReconfigCreditBasedConnsReq(_, _, _))
          .WillOnce(DoAll(SaveArg<1>(&cids), Return(true)));

  uint16_t new_mtu = 300;
  eatt_instance_->Reconfigure(test_address, connected_cids_[1], new_mtu);

  ASSERT_TRUE(cids.size() == 1);
  ASSERT_EQ(1U, cids.size());

  tL2CAP_LE_CFG_INFO cfg = {.result = tL2CAP_CFG_RESULT::L2CAP_CFG_OK, .mtu = new_mtu};

@@ -524,7 +543,7 @@ TEST_F(EattTest, ReconfigSingleFailed) {
  ConnectDeviceEattSupported(2);

  std::vector<uint16_t> cids;
  EXPECT_CALL(l2cap_interface_, ReconfigCreditBasedConnsReq(_, _, _))
  EXPECT_CALL(mock_stack_l2cap_interface_, L2CA_ReconfigCreditBasedConnsReq(_, _, _))
          .WillOnce(DoAll(SaveArg<1>(&cids), Return(true)));

  uint16_t new_mtu = 300;
@@ -605,7 +624,7 @@ TEST_F(EattTest, ChannelUnavailableWhileOpening) {
  ON_CALL(gatt_interface_, GetEattSupport).WillByDefault(Return(true));

  // expect
  EXPECT_CALL(l2cap_interface_, ConnectCreditBasedReq(BT_PSM_EATT, test_address, _))
  EXPECT_CALL(mock_stack_l2cap_interface_, L2CA_ConnectCreditBasedReq(BT_PSM_EATT, test_address, _))
          .WillOnce(Return(std::vector<uint16_t>{61}));

  // act: start
@@ -622,7 +641,8 @@ TEST_F(EattTest, ChannelUnavailableWhileOpening) {

TEST_F(EattTest, ChannelUnavailableWhileReconfiguring) {
  // arrange
  ON_CALL(l2cap_interface_, ReconfigCreditBasedConnsReq(_, _, _)).WillByDefault(Return(true));
  ON_CALL(mock_stack_l2cap_interface_, L2CA_ReconfigCreditBasedConnsReq(_, _, _))
          .WillByDefault(Return(true));
  ConnectDeviceEattSupported(/* num_of_accepted_connections = */ 1);

  // act: reconfigure, then get available channels
@@ -643,7 +663,7 @@ TEST_F(EattTest, DisconnectChannelOnIndicationConfirmationTimeout) {

  eatt_instance_->StartIndicationConfirmationTimer(test_address, test_local_cids[0]);

  EXPECT_CALL(l2cap_interface_, DisconnectRequest(test_local_cids[0])).Times(1);
  EXPECT_CALL(mock_stack_l2cap_interface_, L2CA_DisconnectReq(test_local_cids[0])).Times(1);
  fake_osi_alarm_set_on_mloop_.cb(fake_osi_alarm_set_on_mloop_.data);
}

+0 −507

File deleted.

Preview size limit exceeded, changes collapsed.