| 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_, GetNameForDisplay()) | 260 ON_CALL(*device_, GetName()) |
| 261 .WillByDefault(Return(base::UTF8ToUTF16(kTestRemoteDeviceName))); | 261 .WillByDefault(Return(std::string(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_, GetNameForDisplay()) | 276 ON_CALL(*device_, GetName()).WillByDefault(Return(std::string("Other name"))); |
| 277 .WillByDefault(Return(base::UTF8ToUTF16("Other name"))); | |
| 278 | 277 |
| 279 EXPECT_CALL(connection_finder, CreateConnectionProxy()).Times(0); | 278 EXPECT_CALL(connection_finder, CreateConnectionProxy()).Times(0); |
| 280 connection_finder.DeviceAdded(adapter_.get(), device_.get()); | 279 connection_finder.DeviceAdded(adapter_.get(), device_.get()); |
| 281 } | 280 } |
| 282 | 281 |
| 283 TEST_F(ProximityAuthBluetoothLowEnergyConnectionFinderTest, | 282 TEST_F(ProximityAuthBluetoothLowEnergyConnectionFinderTest, |
| 284 Find_CreatesConnectionWhenRightDeviceIsAdded_HasPublicAddress) { | 283 Find_CreatesConnectionWhenRightDeviceIsAdded_HasPublicAddress) { |
| 285 StrictMock<MockBluetoothLowEnergyConnectionFinder> connection_finder( | 284 StrictMock<MockBluetoothLowEnergyConnectionFinder> connection_finder( |
| 286 nullptr, BluetoothLowEnergyConnectionFinder::FIND_ANY_DEVICE); | 285 nullptr, BluetoothLowEnergyConnectionFinder::FIND_ANY_DEVICE); |
| 287 | 286 |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 // Completing the connection. | 485 // Completing the connection. |
| 487 base::RunLoop run_loop; | 486 base::RunLoop run_loop; |
| 488 ASSERT_FALSE(last_found_connection_); | 487 ASSERT_FALSE(last_found_connection_); |
| 489 connection->SetStatus(Connection::IN_PROGRESS); | 488 connection->SetStatus(Connection::IN_PROGRESS); |
| 490 connection->SetStatus(Connection::CONNECTED); | 489 connection->SetStatus(Connection::CONNECTED); |
| 491 run_loop.RunUntilIdle(); | 490 run_loop.RunUntilIdle(); |
| 492 EXPECT_TRUE(last_found_connection_); | 491 EXPECT_TRUE(last_found_connection_); |
| 493 } | 492 } |
| 494 | 493 |
| 495 } // namespace proximity_auth | 494 } // namespace proximity_auth |
| OLD | NEW |