Index: components/proximity_auth/ble/bluetooth_low_energy_connection_finder_unittest.cc |
diff --git a/components/proximity_auth/ble/bluetooth_low_energy_connection_finder_unittest.cc b/components/proximity_auth/ble/bluetooth_low_energy_connection_finder_unittest.cc |
index 845af2c39ce259fd95eba149881bf9f5ca754432..5f42de9c8c5516c903eb1deb56ddab8f6e8b3b62 100644 |
--- a/components/proximity_auth/ble/bluetooth_low_energy_connection_finder_unittest.cc |
+++ b/components/proximity_auth/ble/bluetooth_low_energy_connection_finder_unittest.cc |
@@ -16,11 +16,12 @@ |
#include "base/run_loop.h" |
#include "base/strings/utf_string_conversions.h" |
#include "base/time/time.h" |
+#include "components/cryptauth/connection.h" |
+#include "components/cryptauth/fake_connection.h" |
#include "components/cryptauth/remote_device.h" |
+#include "components/cryptauth/wire_message.h" |
#include "components/proximity_auth/ble/bluetooth_low_energy_device_whitelist.h" |
-#include "components/proximity_auth/fake_connection.h" |
#include "components/proximity_auth/proximity_auth_test_util.h" |
-#include "components/proximity_auth/wire_message.h" |
#include "device/bluetooth/bluetooth_adapter_factory.h" |
#include "device/bluetooth/bluetooth_uuid.h" |
#include "device/bluetooth/test/mock_bluetooth_adapter.h" |
@@ -75,17 +76,17 @@ class MockBluetoothLowEnergyConnectionFinder |
// Mock methods don't support return type std::unique_ptr<>. This is a |
// possible workaround: mock a proxy method to be called by the target |
// overridden method (CreateConnection). |
- MOCK_METHOD0(CreateConnectionProxy, Connection*()); |
+ MOCK_METHOD0(CreateConnectionProxy, cryptauth::Connection*()); |
// Creates a mock connection and sets an expectation that the mock connection |
// finder's CreateConnection() method will be called and will return the |
// created connection. Returns a reference to the created connection. |
// NOTE: The returned connection's lifetime is managed by the connection |
// finder. |
- FakeConnection* ExpectCreateConnection() { |
- std::unique_ptr<FakeConnection> connection( |
+ cryptauth::FakeConnection* ExpectCreateConnection() { |
+ std::unique_ptr<cryptauth::FakeConnection> connection( |
new FakeConnection(CreateLERemoteDeviceForTest())); |
- FakeConnection* connection_alias = connection.get(); |
+ cryptauth::FakeConnection* connection_alias = connection.get(); |
EXPECT_CALL(*this, CreateConnectionProxy()) |
.WillOnce(Return(connection.release())); |
return connection_alias; |
@@ -94,7 +95,7 @@ class MockBluetoothLowEnergyConnectionFinder |
MOCK_METHOD0(CloseGattConnectionProxy, void(void)); |
protected: |
- std::unique_ptr<Connection> CreateConnection( |
+ std::unique_ptr<cryptauth::Connection> CreateConnection( |
const std::string& device_address) override { |
return base::WrapUnique(CreateConnectionProxy()); |
} |
@@ -135,7 +136,7 @@ class ProximityAuthBluetoothLowEnergyConnectionFinderTest |
.WillByDefault(Return(false)); |
} |
- void OnConnectionFound(std::unique_ptr<Connection> connection) { |
+ void OnConnectionFound(std::unique_ptr<cryptauth::Connection> connection) { |
last_found_connection_ = std::move(connection); |
} |
@@ -175,7 +176,7 @@ class ProximityAuthBluetoothLowEnergyConnectionFinderTest |
scoped_refptr<device::MockBluetoothAdapter> adapter_; |
ConnectionFinder::ConnectionCallback connection_callback_; |
std::unique_ptr<device::MockBluetoothDevice> device_; |
- std::unique_ptr<Connection> last_found_connection_; |
+ std::unique_ptr<cryptauth::Connection> last_found_connection_; |
std::unique_ptr<MockBluetoothLowEnergyDeviceWhitelist> device_whitelist_; |
device::MockBluetoothDiscoverySession* last_discovery_session_alias_; |
@@ -368,15 +369,16 @@ TEST_F(ProximityAuthBluetoothLowEnergyConnectionFinderTest, |
ExpectRemoveObserver(); |
// Finding and creating a connection to the right device. |
- FakeConnection* connection = connection_finder.ExpectCreateConnection(); |
+ cryptauth::FakeConnection* connection = |
+ connection_finder.ExpectCreateConnection(); |
PrepareDevice(kServiceUUID, kTestRemoteDeviceBluetoothAddress, true); |
connection_finder.DeviceAdded(adapter_.get(), device_.get()); |
// Creating a connection. |
base::RunLoop run_loop; |
EXPECT_FALSE(last_found_connection_); |
- connection->SetStatus(Connection::IN_PROGRESS); |
- connection->SetStatus(Connection::CONNECTED); |
+ connection->SetStatus(cryptauth::Connection::IN_PROGRESS); |
+ connection->SetStatus(cryptauth::Connection::CONNECTED); |
run_loop.RunUntilIdle(); |
EXPECT_TRUE(last_found_connection_); |
} |
@@ -391,12 +393,13 @@ TEST_F(ProximityAuthBluetoothLowEnergyConnectionFinderTest, |
// Preparing to create a GATT connection to the right device. |
PrepareDevice(kServiceUUID, kTestRemoteDeviceBluetoothAddress, true); |
- FakeConnection* connection = connection_finder.ExpectCreateConnection(); |
+ cryptauth::FakeConnection* connection = |
+ connection_finder.ExpectCreateConnection(); |
// Trying to create a connection. |
connection_finder.DeviceAdded(adapter_.get(), device_.get()); |
ASSERT_FALSE(last_found_connection_); |
- connection->SetStatus(Connection::IN_PROGRESS); |
+ connection->SetStatus(cryptauth::Connection::IN_PROGRESS); |
// Preparing to restart the discovery session. |
device::BluetoothAdapter::DiscoverySessionCallback discovery_callback; |
@@ -408,7 +411,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyConnectionFinderTest, |
// Connection fails. |
{ |
base::RunLoop run_loop; |
- connection->SetStatus(Connection::DISCONNECTED); |
+ connection->SetStatus(cryptauth::Connection::DISCONNECTED); |
run_loop.RunUntilIdle(); |
} |
@@ -432,8 +435,8 @@ TEST_F(ProximityAuthBluetoothLowEnergyConnectionFinderTest, |
{ |
base::RunLoop run_loop; |
EXPECT_FALSE(last_found_connection_); |
- connection->SetStatus(Connection::IN_PROGRESS); |
- connection->SetStatus(Connection::CONNECTED); |
+ connection->SetStatus(cryptauth::Connection::IN_PROGRESS); |
+ connection->SetStatus(cryptauth::Connection::CONNECTED); |
run_loop.RunUntilIdle(); |
} |
EXPECT_TRUE(last_found_connection_); |
@@ -477,7 +480,8 @@ TEST_F(ProximityAuthBluetoothLowEnergyConnectionFinderTest, |
// Preparing to create a GATT connection to the right device. |
PrepareDevice(kServiceUUID, kTestRemoteDeviceBluetoothAddress, true); |
- FakeConnection* connection = connection_finder.ExpectCreateConnection(); |
+ cryptauth::FakeConnection* connection = |
+ connection_finder.ExpectCreateConnection(); |
// Trying to create a connection. |
connection_finder.DeviceAdded(adapter_.get(), device_.get()); |
@@ -485,8 +489,8 @@ TEST_F(ProximityAuthBluetoothLowEnergyConnectionFinderTest, |
// Completing the connection. |
base::RunLoop run_loop; |
ASSERT_FALSE(last_found_connection_); |
- connection->SetStatus(Connection::IN_PROGRESS); |
- connection->SetStatus(Connection::CONNECTED); |
+ connection->SetStatus(cryptauth::Connection::IN_PROGRESS); |
+ connection->SetStatus(cryptauth::Connection::CONNECTED); |
run_loop.RunUntilIdle(); |
EXPECT_TRUE(last_found_connection_); |
} |