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

Commit a18c574c authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes Icc17d7f7,I0f4d7668 into main am: fa3c1f37

parents 1634867f fa3c1f37
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1956,6 +1956,7 @@ class CsisClientImpl : public CsisClient {
        callbacks_->OnConnectionState(evt.remote_bda,
                                      ConnectionState::DISCONNECTED);
      DoDisconnectCleanUp(device);
      StartOpportunisticConnect(evt.remote_bda);
      return;
    }

+32 −7
Original line number Diff line number Diff line
@@ -580,9 +580,10 @@ class CsisClientTest : public ::testing::Test {
    gatt_callback(BTA_GATTC_ENC_CMPL_CB_EVT, (tBTA_GATTC*)&event_data);
  }

  void InjectConnectedEvent(const RawAddress& address, uint16_t conn_id) {
  void InjectConnectedEvent(const RawAddress& address, uint16_t conn_id,
                            tGATT_STATUS status = GATT_SUCCESS) {
    tBTA_GATTC_OPEN event_data = {
        .status = GATT_SUCCESS,
            .status = status,
            .conn_id = conn_id,
            .client_if = gatt_if,
            .remote_bda = address,
@@ -760,6 +761,30 @@ TEST_F(CsisClientTest, test_connect) {
  TestAppUnregister();
}

TEST_F(CsisClientTest, test_verify_opportunistic_connect_active_after_connect_timeout) {
  TestAppRegister();

  std::vector<uint8_t> no_set_info;

  DeviceGroups::AddFromStorage(test_address, no_set_info);
  CsisClient::AddFromStorage(test_address, no_set_info);

  Mock::VerifyAndClearExpectations(&gatt_interface);
  Mock::VerifyAndClearExpectations(callbacks.get());

  EXPECT_CALL(*callbacks, OnConnectionState(test_address, ConnectionState::DISCONNECTED)).Times(1);
  TestConnect(test_address);

  EXPECT_CALL(gatt_interface, CancelOpen(gatt_if, test_address, _)).Times(0);
  EXPECT_CALL(gatt_interface, Open(gatt_if, test_address, BTM_BLE_DIRECT_CONNECTION, true))
          .Times(1);

  InjectConnectedEvent(test_address, 0, GATT_ERROR);
  Mock::VerifyAndClearExpectations(&gatt_interface);
  Mock::VerifyAndClearExpectations(callbacks.get());
  TestAppUnregister();
}

TEST_F(CsisClientTest, test_disconnect_non_connected) {
  TestAppRegister();
  TestConnect(test_address);
+1 −0
Original line number Diff line number Diff line
@@ -172,6 +172,7 @@ class VolumeControlImpl : public VolumeControl {
    if (status != GATT_SUCCESS) {
      log::info("Failed to connect to Volume Control device");
      device_cleanup_helper(device, device->connecting_actively);
      StartOpportunisticConnect(address);
      return;
    }

+27 −7
Original line number Diff line number Diff line
@@ -422,9 +422,10 @@ class VolumeControlTest : public ::testing::Test {
    TestAppUnregister();
  }

  void GetConnectedEvent(const RawAddress& address, uint16_t conn_id) {
  void GetConnectedEvent(const RawAddress& address, uint16_t conn_id,
                         tGATT_STATUS status = GATT_SUCCESS) {
    tBTA_GATTC_OPEN event_data = {
        .status = GATT_SUCCESS,
            .status = status,
            .conn_id = conn_id,
            .client_if = gatt_if,
            .remote_bda = address,
@@ -650,6 +651,25 @@ TEST_F(VolumeControlTest, test_reconnect_after_interrupted_discovery) {
  TestAppUnregister();
}

TEST_F(VolumeControlTest, test_verify_opportunistic_connect_active_after_connect_timeout) {
  const RawAddress address = GetTestAddress(0);

  TestAppRegister();
  TestAddFromStorage(address);
  Mock::VerifyAndClearExpectations(&gatt_interface);

  EXPECT_CALL(*callbacks, OnConnectionState(ConnectionState::DISCONNECTED, address)).Times(1);
  TestConnect(address);

  EXPECT_CALL(gatt_interface, CancelOpen(gatt_if, address, _)).Times(0);
  EXPECT_CALL(gatt_interface, Open(gatt_if, address, BTM_BLE_DIRECT_CONNECTION, true)).Times(1);

  GetConnectedEvent(address, 1, GATT_ERROR);
  Mock::VerifyAndClearExpectations(callbacks.get());
  Mock::VerifyAndClearExpectations(&gatt_interface);
  TestAppUnregister();
}

TEST_F(VolumeControlTest, test_reconnect_after_timeout) {
  const RawAddress address = GetTestAddress(0);