Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: chromeos/components/tether/ble_connection_manager_unittest.cc

Issue 2804123002: BleConnectionManager: Check when receiving BLE advertisements if a SecureChannel already exists. No… (Closed)
Patch Set: khorimoto@ comments. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/components/tether/ble_connection_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/components/tether/ble_connection_manager_unittest.cc
diff --git a/chromeos/components/tether/ble_connection_manager_unittest.cc b/chromeos/components/tether/ble_connection_manager_unittest.cc
index 6ce9b41a3ec45201bbea31425c6c59c92372823b..725db7b00be33dc95896306b2c3375cf9d8255f4 100644
--- a/chromeos/components/tether/ble_connection_manager_unittest.cc
+++ b/chromeos/components/tether/ble_connection_manager_unittest.cc
@@ -685,6 +685,43 @@ TEST_F(BleConnectionManagerTest, TestSuccessfulConnection_SendAndReceive) {
VerifyDeviceNotRegistered(test_devices_[0]);
}
+// Test for fix to crbug.com/706640. This test will crash without the fix.
+TEST_F(BleConnectionManagerTest,
+ TestSuccessfulConnection_MultipleAdvertisementsReceived) {
+ EXPECT_CALL(*mock_ble_scanner_,
+ RegisterScanFilterForDevice(test_devices_[0]));
+ EXPECT_CALL(*mock_ble_advertiser_,
+ StartAdvertisingToDevice(test_devices_[0]));
+ EXPECT_CALL(*mock_ble_scanner_,
+ UnregisterScanFilterForDevice(test_devices_[0]));
+ EXPECT_CALL(*mock_ble_advertiser_, StopAdvertisingToDevice(test_devices_[0]));
+
+ manager_->RegisterRemoteDevice(test_devices_[0],
+ MessageType::TETHER_AVAILABILITY_REQUEST);
+ VerifyAdvertisingTimeoutSet(test_devices_[0]);
+ VerifyConnectionStateChanges(std::vector<SecureChannelStatusChange>{
+ {test_devices_[0], cryptauth::SecureChannel::Status::DISCONNECTED,
+ cryptauth::SecureChannel::Status::CONNECTING}});
+
+ fake_secure_channel_factory_->SetExpectedDeviceAddress(
+ std::string(kBluetoothAddress1));
+
+ // Simulate multiple advertisements being received:
+ mock_ble_scanner_->SimulateScanResults(std::string(kBluetoothAddress1),
+ test_devices_[0]);
+ FakeSecureChannel* channel = GetChannelForDevice(test_devices_[0]);
+
+ mock_ble_scanner_->SimulateScanResults(std::string(kBluetoothAddress1),
+ test_devices_[0]);
+ // Verify that a new channel has not been created:
+ EXPECT_EQ(channel, GetChannelForDevice(test_devices_[0]));
+
+ mock_ble_scanner_->SimulateScanResults(std::string(kBluetoothAddress1),
+ test_devices_[0]);
+ // Verify that a new channel has not been created:
+ EXPECT_EQ(channel, GetChannelForDevice(test_devices_[0]));
+}
+
TEST_F(BleConnectionManagerTest,
TestSuccessfulConnection_MultipleConnectionReasons) {
EXPECT_CALL(*mock_ble_scanner_,
« no previous file with comments | « chromeos/components/tether/ble_connection_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698