OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/proximity_auth/ble/bluetooth_low_energy_connection_finder.h
" | 5 #include "components/proximity_auth/ble/bluetooth_low_energy_connection_finder.h
" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 | 250 |
251 TEST_F(ProximityAuthBluetoothLowEnergyConnectionFinderTest, | 251 TEST_F(ProximityAuthBluetoothLowEnergyConnectionFinderTest, |
252 Find_CreatesConnectionWhenRightDeviceIsAdded_NoPublicAddress) { | 252 Find_CreatesConnectionWhenRightDeviceIsAdded_NoPublicAddress) { |
253 StrictMock<MockBluetoothLowEnergyConnectionFinder> connection_finder( | 253 StrictMock<MockBluetoothLowEnergyConnectionFinder> connection_finder( |
254 nullptr, BluetoothLowEnergyConnectionFinder::FIND_ANY_DEVICE); | 254 nullptr, BluetoothLowEnergyConnectionFinder::FIND_ANY_DEVICE); |
255 | 255 |
256 FindAndExpectStartDiscovery(connection_finder); | 256 FindAndExpectStartDiscovery(connection_finder); |
257 ExpectRemoveObserver(); | 257 ExpectRemoveObserver(); |
258 | 258 |
259 PrepareDevice(kServiceUUID, kTestRemoteDeviceBluetoothAddress, false); | 259 PrepareDevice(kServiceUUID, kTestRemoteDeviceBluetoothAddress, false); |
260 ON_CALL(*device_, GetName()) | 260 ON_CALL(*device_, GetNameForDisplay()) |
261 .WillByDefault(Return(base::UTF8ToUTF16(kTestRemoteDeviceName))); | 261 .WillByDefault(Return(base::UTF8ToUTF16(kTestRemoteDeviceName))); |
262 | 262 |
263 connection_finder.ExpectCreateConnection(); | 263 connection_finder.ExpectCreateConnection(); |
264 connection_finder.DeviceAdded(adapter_.get(), device_.get()); | 264 connection_finder.DeviceAdded(adapter_.get(), device_.get()); |
265 } | 265 } |
266 | 266 |
267 TEST_F(ProximityAuthBluetoothLowEnergyConnectionFinderTest, | 267 TEST_F(ProximityAuthBluetoothLowEnergyConnectionFinderTest, |
268 Find_DoesntCreatesConnectionWhenWrongDeviceIsAdded_NoPublicAddress) { | 268 Find_DoesntCreatesConnectionWhenWrongDeviceIsAdded_NoPublicAddress) { |
269 StrictMock<MockBluetoothLowEnergyConnectionFinder> connection_finder( | 269 StrictMock<MockBluetoothLowEnergyConnectionFinder> connection_finder( |
270 nullptr, BluetoothLowEnergyConnectionFinder::FIND_ANY_DEVICE); | 270 nullptr, BluetoothLowEnergyConnectionFinder::FIND_ANY_DEVICE); |
271 | 271 |
272 FindAndExpectStartDiscovery(connection_finder); | 272 FindAndExpectStartDiscovery(connection_finder); |
273 ExpectRemoveObserver(); | 273 ExpectRemoveObserver(); |
274 | 274 |
275 PrepareDevice(kOtherUUID, kTestRemoteDeviceBluetoothAddress, false); | 275 PrepareDevice(kOtherUUID, kTestRemoteDeviceBluetoothAddress, false); |
276 ON_CALL(*device_, GetName()) | 276 ON_CALL(*device_, GetNameForDisplay()) |
277 .WillByDefault(Return(base::UTF8ToUTF16("Other name"))); | 277 .WillByDefault(Return(base::UTF8ToUTF16("Other name"))); |
278 | 278 |
279 EXPECT_CALL(connection_finder, CreateConnectionProxy()).Times(0); | 279 EXPECT_CALL(connection_finder, CreateConnectionProxy()).Times(0); |
280 connection_finder.DeviceAdded(adapter_.get(), device_.get()); | 280 connection_finder.DeviceAdded(adapter_.get(), device_.get()); |
281 } | 281 } |
282 | 282 |
283 TEST_F(ProximityAuthBluetoothLowEnergyConnectionFinderTest, | 283 TEST_F(ProximityAuthBluetoothLowEnergyConnectionFinderTest, |
284 Find_CreatesConnectionWhenRightDeviceIsAdded_HasPublicAddress) { | 284 Find_CreatesConnectionWhenRightDeviceIsAdded_HasPublicAddress) { |
285 StrictMock<MockBluetoothLowEnergyConnectionFinder> connection_finder( | 285 StrictMock<MockBluetoothLowEnergyConnectionFinder> connection_finder( |
286 nullptr, BluetoothLowEnergyConnectionFinder::FIND_ANY_DEVICE); | 286 nullptr, BluetoothLowEnergyConnectionFinder::FIND_ANY_DEVICE); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 // Completing the connection. | 486 // Completing the connection. |
487 base::RunLoop run_loop; | 487 base::RunLoop run_loop; |
488 ASSERT_FALSE(last_found_connection_); | 488 ASSERT_FALSE(last_found_connection_); |
489 connection->SetStatus(Connection::IN_PROGRESS); | 489 connection->SetStatus(Connection::IN_PROGRESS); |
490 connection->SetStatus(Connection::CONNECTED); | 490 connection->SetStatus(Connection::CONNECTED); |
491 run_loop.RunUntilIdle(); | 491 run_loop.RunUntilIdle(); |
492 EXPECT_TRUE(last_found_connection_); | 492 EXPECT_TRUE(last_found_connection_); |
493 } | 493 } |
494 | 494 |
495 } // namespace proximity_auth | 495 } // namespace proximity_auth |
OLD | NEW |