summaryrefslogtreecommitdiff
path: root/chromium/components/cryptauth/ble
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-01-31 16:33:43 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-02-06 16:33:22 +0000
commitda51f56cc21233c2d30f0fe0d171727c3102b2e0 (patch)
tree4e579ab70ce4b19bee7984237f3ce05a96d59d83 /chromium/components/cryptauth/ble
parentc8c2d1901aec01e934adf561a9fdf0cc776cdef8 (diff)
downloadqtwebengine-chromium-da51f56cc21233c2d30f0fe0d171727c3102b2e0.tar.gz
BASELINE: Update Chromium to 65.0.3525.40
Also imports missing submodules Change-Id: I36901b7c6a325cda3d2c10cedb2186c25af3b79b Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/components/cryptauth/ble')
-rw-r--r--chromium/components/cryptauth/ble/ble_advertisement_generator.cc17
-rw-r--r--chromium/components/cryptauth/ble/ble_advertisement_generator.h11
-rw-r--r--chromium/components/cryptauth/ble/ble_advertisement_generator_unittest.cc10
-rw-r--r--chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection.cc68
-rw-r--r--chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection.h7
-rw-r--r--chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection_unittest.cc38
-rw-r--r--chromium/components/cryptauth/ble/fake_ble_advertisement_generator.cc2
-rw-r--r--chromium/components/cryptauth/ble/fake_ble_advertisement_generator.h2
8 files changed, 106 insertions, 49 deletions
diff --git a/chromium/components/cryptauth/ble/ble_advertisement_generator.cc b/chromium/components/cryptauth/ble/ble_advertisement_generator.cc
index 29b0dca7129..da4f92be229 100644
--- a/chromium/components/cryptauth/ble/ble_advertisement_generator.cc
+++ b/chromium/components/cryptauth/ble/ble_advertisement_generator.cc
@@ -9,6 +9,7 @@
#include "base/memory/ptr_util.h"
#include "components/cryptauth/local_device_data_provider.h"
#include "components/cryptauth/remote_beacon_seed_fetcher.h"
+#include "components/cryptauth/remote_device.h"
#include "components/proximity_auth/logging/logging.h"
namespace cryptauth {
@@ -19,14 +20,14 @@ BleAdvertisementGenerator* BleAdvertisementGenerator::instance_ = nullptr;
// static
std::unique_ptr<DataWithTimestamp>
BleAdvertisementGenerator::GenerateBleAdvertisement(
- const RemoteDevice& remote_device,
+ const std::string& device_id,
LocalDeviceDataProvider* local_device_data_provider,
RemoteBeaconSeedFetcher* remote_beacon_seed_fetcher) {
if (!instance_)
instance_ = new BleAdvertisementGenerator();
return instance_->GenerateBleAdvertisementInternal(
- remote_device, local_device_data_provider, remote_beacon_seed_fetcher);
+ device_id, local_device_data_provider, remote_beacon_seed_fetcher);
}
// static
@@ -42,7 +43,7 @@ BleAdvertisementGenerator::~BleAdvertisementGenerator() {}
std::unique_ptr<DataWithTimestamp>
BleAdvertisementGenerator::GenerateBleAdvertisementInternal(
- const RemoteDevice& remote_device,
+ const std::string& device_id,
LocalDeviceDataProvider* local_device_data_provider,
RemoteBeaconSeedFetcher* remote_beacon_seed_fetcher) {
std::string local_device_public_key;
@@ -60,17 +61,17 @@ BleAdvertisementGenerator::GenerateBleAdvertisementInternal(
}
std::vector<BeaconSeed> remote_beacon_seeds;
- if (!remote_beacon_seed_fetcher->FetchSeedsForDevice(remote_device,
- &remote_beacon_seeds)) {
+ if (!remote_beacon_seed_fetcher->FetchSeedsForDeviceId(
+ device_id, &remote_beacon_seeds)) {
PA_LOG(WARNING) << "Error fetching beacon seeds for device with ID "
- << remote_device.GetTruncatedDeviceIdForLogs() << ". "
+ << RemoteDevice::TruncateDeviceIdForLogs(device_id) << ". "
<< "Cannot advertise without seeds.";
return nullptr;
}
if (remote_beacon_seeds.empty()) {
PA_LOG(WARNING) << "No synced seeds exist for device with ID "
- << remote_device.GetTruncatedDeviceIdForLogs() << ". "
+ << RemoteDevice::TruncateDeviceIdForLogs(device_id) << ". "
<< "Cannot advertise without seeds.";
return nullptr;
}
@@ -80,7 +81,7 @@ BleAdvertisementGenerator::GenerateBleAdvertisementInternal(
remote_beacon_seeds);
if (!service_data) {
PA_LOG(WARNING) << "Error generating advertisement for device with ID "
- << remote_device.GetTruncatedDeviceIdForLogs() << ". "
+ << RemoteDevice::TruncateDeviceIdForLogs(device_id) << ". "
<< "Cannot advertise.";
return nullptr;
}
diff --git a/chromium/components/cryptauth/ble/ble_advertisement_generator.h b/chromium/components/cryptauth/ble/ble_advertisement_generator.h
index 69ce5a37741..38b8d8f01f9 100644
--- a/chromium/components/cryptauth/ble/ble_advertisement_generator.h
+++ b/chromium/components/cryptauth/ble/ble_advertisement_generator.h
@@ -9,7 +9,6 @@
#include "base/macros.h"
#include "components/cryptauth/foreground_eid_generator.h"
-#include "components/cryptauth/remote_device.h"
namespace chromeos {
namespace tether {
@@ -26,11 +25,11 @@ class RemoteBeaconSeedFetcher;
// Generates advertisements for the ProximityAuth BLE advertisement scheme.
class BleAdvertisementGenerator {
public:
- // Generates an advertisement from the current device to |remote_device|. The
- // generated advertisement should be used immediately since it is based on
- // the current timestamp.
+ // Generates an advertisement from the current device to the device with ID
+ // |device_id|. The generated advertisement should be used immediately since
+ // it is based on the current timestamp.
static std::unique_ptr<DataWithTimestamp> GenerateBleAdvertisement(
- const RemoteDevice& remote_device,
+ const std::string& device_id,
LocalDeviceDataProvider* local_device_data_provider,
RemoteBeaconSeedFetcher* remote_beacon_seed_fetcher);
@@ -40,7 +39,7 @@ class BleAdvertisementGenerator {
BleAdvertisementGenerator();
virtual std::unique_ptr<DataWithTimestamp> GenerateBleAdvertisementInternal(
- const RemoteDevice& remote_device,
+ const std::string& device_id,
LocalDeviceDataProvider* local_device_data_provider,
RemoteBeaconSeedFetcher* remote_beacon_seed_fetcher);
diff --git a/chromium/components/cryptauth/ble/ble_advertisement_generator_unittest.cc b/chromium/components/cryptauth/ble/ble_advertisement_generator_unittest.cc
index 942ef4ca5a8..33bd0d7e99d 100644
--- a/chromium/components/cryptauth/ble/ble_advertisement_generator_unittest.cc
+++ b/chromium/components/cryptauth/ble/ble_advertisement_generator_unittest.cc
@@ -51,7 +51,8 @@ class CryptAuthBleAdvertisementGeneratorTest : public testing::Test {
mock_seed_fetcher_ = base::MakeUnique<MockRemoteBeaconSeedFetcher>();
std::vector<BeaconSeed> device_0_beacon_seeds =
CreateFakeBeaconSeedsForDevice(fake_device_);
- mock_seed_fetcher_->SetSeedsForDevice(fake_device_, &device_0_beacon_seeds);
+ mock_seed_fetcher_->SetSeedsForDeviceId(fake_device_.GetDeviceId(),
+ &device_0_beacon_seeds);
mock_local_data_provider_ = base::MakeUnique<MockLocalDeviceDataProvider>();
mock_local_data_provider_->SetPublicKey(
@@ -68,7 +69,7 @@ class CryptAuthBleAdvertisementGeneratorTest : public testing::Test {
std::unique_ptr<DataWithTimestamp> GenerateBleAdvertisement() {
return generator_->GenerateBleAdvertisementInternal(
- fake_device_, mock_local_data_provider_.get(),
+ fake_device_.GetDeviceId(), mock_local_data_provider_.get(),
mock_seed_fetcher_.get());
}
@@ -97,13 +98,14 @@ TEST_F(CryptAuthBleAdvertisementGeneratorTest, EmptyPublicKey) {
}
TEST_F(CryptAuthBleAdvertisementGeneratorTest, NoBeaconSeeds) {
- mock_seed_fetcher_->SetSeedsForDevice(fake_device_, nullptr);
+ mock_seed_fetcher_->SetSeedsForDeviceId(fake_device_.GetDeviceId(), nullptr);
EXPECT_EQ(nullptr, GenerateBleAdvertisement());
}
TEST_F(CryptAuthBleAdvertisementGeneratorTest, EmptyBeaconSeeds) {
std::vector<BeaconSeed> empty_seeds;
- mock_seed_fetcher_->SetSeedsForDevice(fake_device_, &empty_seeds);
+ mock_seed_fetcher_->SetSeedsForDeviceId(fake_device_.GetDeviceId(),
+ &empty_seeds);
EXPECT_EQ(nullptr, GenerateBleAdvertisement());
}
diff --git a/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection.cc b/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection.cc
index 58c41891a3f..7bbbce231fe 100644
--- a/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection.cc
+++ b/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection.cc
@@ -44,6 +44,7 @@ const int kGattConnectionTimeoutSeconds = 15;
const int kGattCharacteristicsTimeoutSeconds = 10;
const int kNotifySessionTimeoutSeconds = 5;
const int kConnectionResponseTimeoutSeconds = 2;
+const int kSendingMessageTimeoutSeconds = 5;
} // namespace
@@ -100,6 +101,8 @@ base::TimeDelta BluetoothLowEnergyWeaveClientConnection::GetTimeoutForSubStatus(
return base::TimeDelta::FromSeconds(kGattCharacteristicsTimeoutSeconds);
case SubStatus::WAITING_NOTIFY_SESSION:
return base::TimeDelta::FromSeconds(kNotifySessionTimeoutSeconds);
+ case SubStatus::CONNECTED_AND_SENDING_MESSAGE:
+ return base::TimeDelta::FromSeconds(kSendingMessageTimeoutSeconds);
default:
// Max signifies that there should be no timeout.
return base::TimeDelta::Max();
@@ -126,8 +129,10 @@ std::string BluetoothLowEnergyWeaveClientConnection::SubStatusToString(
return "[notify session is ready]";
case SubStatus::WAITING_CONNECTION_RESPONSE:
return "[waiting for \"connection response\" uWeave packet]";
- case SubStatus::CONNECTED:
- return "[connected]";
+ case SubStatus::CONNECTED_AND_IDLE:
+ return "[connected and idle]";
+ case SubStatus::CONNECTED_AND_SENDING_MESSAGE:
+ return "[connected and sending message]";
default:
return "[invalid state]";
}
@@ -227,7 +232,7 @@ void BluetoothLowEnergyWeaveClientConnection::CreateGattConnection() {
}
void BluetoothLowEnergyWeaveClientConnection::Disconnect() {
- if (sub_status_ == SubStatus::CONNECTED) {
+ if (IsConnected()) {
PA_LOG(INFO) << "Disconnection requested; sending \"connection close\" "
<< "uWeave packet to " << GetDeviceInfoLogString() << ".";
@@ -292,25 +297,31 @@ void BluetoothLowEnergyWeaveClientConnection::SetSubStatus(
}
// Sets the status of base class Connection.
- if (new_sub_status == SubStatus::CONNECTED)
- SetStatus(Status::CONNECTED);
- else if (new_sub_status == SubStatus::DISCONNECTED)
- SetStatus(Status::DISCONNECTED);
- else
- SetStatus(Status::IN_PROGRESS);
+ switch (new_sub_status) {
+ case SubStatus::CONNECTED_AND_IDLE:
+ case SubStatus::CONNECTED_AND_SENDING_MESSAGE:
+ SetStatus(Status::CONNECTED);
+ break;
+ case SubStatus::DISCONNECTED:
+ SetStatus(Status::DISCONNECTED);
+ break;
+ default:
+ SetStatus(Status::IN_PROGRESS);
+ }
}
void BluetoothLowEnergyWeaveClientConnection::OnTimeoutForSubStatus(
- SubStatus status) {
- // Ensure that |sub_status| is still the active status.
- DCHECK(status == sub_status());
+ SubStatus timed_out_sub_status) {
+ // Ensure that |timed_out_sub_status| is still the active status.
+ DCHECK(timed_out_sub_status == sub_status());
PA_LOG(ERROR) << "Timed out waiting during SubStatus "
- << SubStatusToString(status) << ". Destroying connection.";
+ << SubStatusToString(timed_out_sub_status) << ". "
+ << "Destroying connection.";
BleWeaveConnectionResult result =
BleWeaveConnectionResult::BLE_WEAVE_CONNECTION_RESULT_MAX;
- switch (status) {
+ switch (timed_out_sub_status) {
case SubStatus::WAITING_CONNECTION_LATENCY:
result = BleWeaveConnectionResult::
BLE_WEAVE_CONNECTION_RESULT_TIMEOUT_SETTING_CONNECTION_LATENCY;
@@ -331,9 +342,14 @@ void BluetoothLowEnergyWeaveClientConnection::OnTimeoutForSubStatus(
result = BleWeaveConnectionResult::
BLE_WEAVE_CONNECTION_RESULT_TIMEOUT_WAITING_FOR_CONNECTION_RESPONSE;
break;
+ case SubStatus::CONNECTED_AND_SENDING_MESSAGE:
+ result = BleWeaveConnectionResult::
+ BLE_WEAVE_CONNECTION_RESULT_TIMEOUT_WAITING_FOR_MESSAGE_TO_SEND;
+ break;
default:
NOTREACHED();
}
+
DestroyConnection(result);
}
@@ -350,7 +366,7 @@ void BluetoothLowEnergyWeaveClientConnection::SetupTestDoubles(
void BluetoothLowEnergyWeaveClientConnection::SendMessageImpl(
std::unique_ptr<WireMessage> message) {
- DCHECK(sub_status() == SubStatus::CONNECTED);
+ DCHECK(IsConnected());
// Split |message| up into multiple packets which can be sent as one uWeave
// message.
@@ -421,7 +437,7 @@ void BluetoothLowEnergyWeaveClientConnection::GattCharacteristicValueChanged(
return;
if (sub_status() != SubStatus::WAITING_CONNECTION_RESPONSE &&
- sub_status() != SubStatus::CONNECTED) {
+ !IsConnected()) {
PA_LOG(WARNING) << "Received message from " << GetDeviceInfoLogString()
<< ", but was not expecting one. sub_status() = "
<< sub_status();
@@ -459,7 +475,6 @@ void BluetoothLowEnergyWeaveClientConnection::GattCharacteristicValueChanged(
void BluetoothLowEnergyWeaveClientConnection::CompleteConnection() {
DCHECK(sub_status() == SubStatus::WAITING_CONNECTION_RESPONSE);
- SetSubStatus(SubStatus::CONNECTED);
uint16_t max_packet_size = packet_receiver_->GetMaxPacketSize();
PA_LOG(INFO) << "Received uWeave \"connection response\" packet; connection "
@@ -470,6 +485,8 @@ void BluetoothLowEnergyWeaveClientConnection::CompleteConnection() {
// |packet_receiver_| should have received a max packet size from the GATT
// server.
packet_generator_->SetMaxPacketSize(max_packet_size);
+
+ SetSubStatus(SubStatus::CONNECTED_AND_IDLE);
}
void BluetoothLowEnergyWeaveClientConnection::OnSetConnectionLatencyError() {
@@ -664,6 +681,13 @@ void BluetoothLowEnergyWeaveClientConnection::SendPendingWriteRequest() {
return;
}
+ // If the current status is CONNECTED_AND_IDLE, transition to
+ // CONNECTED_AND_SENDING_MESSAGE. This function also runs when the status is
+ // WAITING_CONNECTION_RESPONSE; in that case, the status should remain
+ // unchanged until the connection response has been received.
+ if (sub_status() == SubStatus::CONNECTED_AND_IDLE)
+ SetSubStatus(SubStatus::CONNECTED_AND_SENDING_MESSAGE);
+
characteristic->WriteRemoteCharacteristic(
pending_write_request_->value,
base::Bind(&BluetoothLowEnergyWeaveClientConnection::
@@ -676,7 +700,9 @@ void BluetoothLowEnergyWeaveClientConnection::SendPendingWriteRequest() {
void BluetoothLowEnergyWeaveClientConnection::OnRemoteCharacteristicWritten() {
DCHECK(sub_status() == SubStatus::WAITING_CONNECTION_RESPONSE ||
- sub_status() == SubStatus::CONNECTED);
+ sub_status() == SubStatus::CONNECTED_AND_SENDING_MESSAGE);
+ if (sub_status() == SubStatus::CONNECTED_AND_SENDING_MESSAGE)
+ SetSubStatus(SubStatus::CONNECTED_AND_IDLE);
RecordGattWriteCharacteristicResult(
GattServiceOperationResult::GATT_SERVICE_OPERATION_RESULT_SUCCESS);
@@ -735,7 +761,9 @@ void BluetoothLowEnergyWeaveClientConnection::OnRemoteCharacteristicWritten() {
void BluetoothLowEnergyWeaveClientConnection::OnWriteRemoteCharacteristicError(
device::BluetoothRemoteGattService::GattErrorCode error) {
DCHECK(sub_status() == SubStatus::WAITING_CONNECTION_RESPONSE ||
- sub_status() == SubStatus::CONNECTED);
+ sub_status() == SubStatus::CONNECTED_AND_SENDING_MESSAGE);
+ if (sub_status() == SubStatus::CONNECTED_AND_SENDING_MESSAGE)
+ SetSubStatus(SubStatus::CONNECTED_AND_IDLE);
RecordGattWriteCharacteristicResult(
BluetoothRemoteDeviceGattServiceGattErrorCodeToGattServiceOperationResult(
@@ -795,7 +823,7 @@ void BluetoothLowEnergyWeaveClientConnection::OnDidSendMessage(
void BluetoothLowEnergyWeaveClientConnection::
ClearQueueAndSendConnectionClose() {
DCHECK(sub_status() == SubStatus::WAITING_CONNECTION_RESPONSE ||
- sub_status() == SubStatus::CONNECTED);
+ IsConnected());
// The connection is now in an invalid state. Clear queued writes.
while (!queued_write_requests_.empty())
diff --git a/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection.h b/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection.h
index b1e43f1b9b7..75d76e3561e 100644
--- a/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection.h
+++ b/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection.h
@@ -84,7 +84,8 @@ class BluetoothLowEnergyWeaveClientConnection
WAITING_NOTIFY_SESSION,
NOTIFY_SESSION_READY,
WAITING_CONNECTION_RESPONSE,
- CONNECTED,
+ CONNECTED_AND_IDLE,
+ CONNECTED_AND_SENDING_MESSAGE,
};
// Constructs the Connection object; a subsequent call to Connect() is
@@ -120,6 +121,7 @@ class BluetoothLowEnergyWeaveClientConnection
BLE_WEAVE_CONNECTION_RESULT_ERROR_WRITE_QUEUE_OUT_OF_SYNC = 12,
BLE_WEAVE_CONNECTION_RESULT_ERROR_DEVICE_LOST = 13,
BLE_WEAVE_CONNECTION_RESULT_ERROR_CONNECTION_DROPPED = 14,
+ BLE_WEAVE_CONNECTION_RESULT_TIMEOUT_WAITING_FOR_MESSAGE_TO_SEND = 15,
BLE_WEAVE_CONNECTION_RESULT_MAX
};
@@ -225,7 +227,8 @@ class BluetoothLowEnergyWeaveClientConnection
Timeout_NotifySession);
FRIEND_TEST_ALL_PREFIXES(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
Timeout_ConnectionResponse);
-
+ FRIEND_TEST_ALL_PREFIXES(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
+ Timeout_SendingMessage);
enum WriteRequestType {
REGULAR,
MESSAGE_COMPLETE,
diff --git a/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection_unittest.cc b/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection_unittest.cc
index 3ae4ade0ee5..3864a1e81af 100644
--- a/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection_unittest.cc
+++ b/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection_unittest.cc
@@ -546,14 +546,14 @@ class CryptAuthBluetoothLowEnergyWeaveClientConnectionTest
NOTREACHED();
}
- EXPECT_EQ(connection->sub_status(), SubStatus::CONNECTED);
+ EXPECT_EQ(connection->sub_status(), SubStatus::CONNECTED_AND_IDLE);
EXPECT_EQ(connection->status(), Connection::CONNECTED);
}
// Transitions |connection| to a DISCONNECTED state regardless of its initial
// state.
void Disconnect(TestBluetoothLowEnergyWeaveClientConnection* connection) {
- if (connection->sub_status() == SubStatus::CONNECTED) {
+ if (connection->IsConnected()) {
EXPECT_CALL(*tx_characteristic_, WriteRemoteCharacteristic(_, _, _))
.WillOnce(
DoAll(SaveArg<0>(&last_value_written_on_tx_characteristic_),
@@ -563,7 +563,7 @@ class CryptAuthBluetoothLowEnergyWeaveClientConnectionTest
connection->Disconnect();
- if (connection->sub_status() == SubStatus::CONNECTED) {
+ if (connection->IsConnected()) {
connection->DestroyConnection(
BluetoothLowEnergyWeaveClientConnection::BleWeaveConnectionResult::
BLE_WEAVE_CONNECTION_RESULT_CLOSED_NORMALLY);
@@ -733,7 +733,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection(
CreateConnection(true /* should_set_low_connection_latency */));
InitializeConnection(connection.get(), kDefaultMaxPacketSize);
- EXPECT_EQ(connection->sub_status(), SubStatus::CONNECTED);
+ EXPECT_EQ(connection->sub_status(), SubStatus::CONNECTED_AND_IDLE);
Disconnect(connection.get());
VerifyBleWeaveConnectionResult(
@@ -746,7 +746,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection(
CreateConnection(false /* should_set_low_connection_latency */));
InitializeConnection(connection.get(), kDefaultMaxPacketSize);
- EXPECT_EQ(connection->sub_status(), SubStatus::CONNECTED);
+ EXPECT_EQ(connection->sub_status(), SubStatus::CONNECTED_AND_IDLE);
Disconnect(connection.get());
VerifyBleWeaveConnectionResult(
@@ -1244,7 +1244,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
CreateConnection(true /* should_set_low_connection_latency */));
InitializeConnection(connection.get(), kDefaultMaxPacketSize);
- EXPECT_EQ(connection->sub_status(), SubStatus::CONNECTED);
+ EXPECT_EQ(connection->sub_status(), SubStatus::CONNECTED_AND_IDLE);
EXPECT_CALL(*tx_characteristic_, WriteRemoteCharacteristic(_, _, _))
.WillOnce(
@@ -1252,7 +1252,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
SaveArg<1>(&write_remote_characteristic_success_callback_),
SaveArg<2>(&write_remote_characteristic_error_callback_)));
connection->Disconnect();
- EXPECT_EQ(connection->sub_status(), SubStatus::CONNECTED);
+ EXPECT_EQ(connection->sub_status(), SubStatus::CONNECTED_AND_SENDING_MESSAGE);
for (int i = 0; i < kMaxNumberOfTries; i++) {
EXPECT_EQ(last_value_written_on_tx_characteristic_,
@@ -1508,6 +1508,30 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
BLE_WEAVE_CONNECTION_RESULT_TIMEOUT_WAITING_FOR_CONNECTION_RESPONSE);
}
+TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
+ Timeout_SendingMessage) {
+ std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection(
+ CreateConnection(true /* should_set_low_connection_latency */));
+
+ InitializeConnection(connection.get(), kDefaultMaxPacketSize);
+ EXPECT_EQ(connection->sub_status(), SubStatus::CONNECTED_AND_IDLE);
+ EXPECT_CALL(*tx_characteristic_, WriteRemoteCharacteristic(_, _, _));
+
+ connection->SendMessage(
+ std::make_unique<FakeWireMessage>(kSmallMessage, kTestFeature));
+ EXPECT_EQ(connection->sub_status(), SubStatus::CONNECTED_AND_SENDING_MESSAGE);
+
+ // Simulate a timeout.
+ test_timer_->Fire();
+
+ EXPECT_EQ(connection->sub_status(), SubStatus::DISCONNECTED);
+ EXPECT_EQ(connection->status(), Connection::DISCONNECTED);
+
+ VerifyBleWeaveConnectionResult(
+ BluetoothLowEnergyWeaveClientConnection::BleWeaveConnectionResult::
+ BLE_WEAVE_CONNECTION_RESULT_TIMEOUT_WAITING_FOR_MESSAGE_TO_SEND);
+}
+
} // namespace weave
} // namespace cryptauth
diff --git a/chromium/components/cryptauth/ble/fake_ble_advertisement_generator.cc b/chromium/components/cryptauth/ble/fake_ble_advertisement_generator.cc
index c2e1a3065cd..f95ad9e4e4c 100644
--- a/chromium/components/cryptauth/ble/fake_ble_advertisement_generator.cc
+++ b/chromium/components/cryptauth/ble/fake_ble_advertisement_generator.cc
@@ -12,7 +12,7 @@ FakeBleAdvertisementGenerator::~FakeBleAdvertisementGenerator() {}
std::unique_ptr<DataWithTimestamp>
FakeBleAdvertisementGenerator::GenerateBleAdvertisementInternal(
- const RemoteDevice& remote_device,
+ const std::string& device_id,
LocalDeviceDataProvider* local_device_data_provider,
RemoteBeaconSeedFetcher* remote_beacon_seed_fetcher) {
return std::move(advertisement_);
diff --git a/chromium/components/cryptauth/ble/fake_ble_advertisement_generator.h b/chromium/components/cryptauth/ble/fake_ble_advertisement_generator.h
index f79685e91d1..1dad8026a72 100644
--- a/chromium/components/cryptauth/ble/fake_ble_advertisement_generator.h
+++ b/chromium/components/cryptauth/ble/fake_ble_advertisement_generator.h
@@ -27,7 +27,7 @@ class FakeBleAdvertisementGenerator : public BleAdvertisementGenerator {
protected:
std::unique_ptr<DataWithTimestamp> GenerateBleAdvertisementInternal(
- const RemoteDevice& remote_device,
+ const std::string& device_id,
LocalDeviceDataProvider* local_device_data_provider,
RemoteBeaconSeedFetcher* remote_beacon_seed_fetcher) override;