| Index: components/proximity_auth/remote_device_life_cycle_impl_unittest.cc
|
| diff --git a/components/proximity_auth/remote_device_life_cycle_impl_unittest.cc b/components/proximity_auth/remote_device_life_cycle_impl_unittest.cc
|
| index 913c9efcf0fa5cdda97bd1e3336bd9b523968d1e..9abc9b268457148952a75828c5dd2086d2ab019a 100644
|
| --- a/components/proximity_auth/remote_device_life_cycle_impl_unittest.cc
|
| +++ b/components/proximity_auth/remote_device_life_cycle_impl_unittest.cc
|
| @@ -13,13 +13,13 @@
|
| #include "base/macros.h"
|
| #include "base/test/test_simple_task_runner.h"
|
| #include "base/threading/thread_task_runner_handle.h"
|
| +#include "components/cryptauth/connection_finder.h"
|
| +#include "components/cryptauth/cryptauth_test_util.h"
|
| +#include "components/cryptauth/fake_connection.h"
|
| +#include "components/cryptauth/wire_message.h"
|
| #include "components/proximity_auth/authenticator.h"
|
| -#include "components/proximity_auth/connection_finder.h"
|
| -#include "components/proximity_auth/fake_connection.h"
|
| #include "components/proximity_auth/messenger.h"
|
| -#include "components/proximity_auth/proximity_auth_test_util.h"
|
| #include "components/proximity_auth/secure_context.h"
|
| -#include "components/proximity_auth/wire_message.h"
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -59,7 +59,7 @@ class StubSecureContext : public SecureContext {
|
| DISALLOW_COPY_AND_ASSIGN(StubSecureContext);
|
| };
|
|
|
| -class FakeConnectionFinder : public ConnectionFinder {
|
| +class FakeConnectionFinder : public cryptauth::ConnectionFinder {
|
| public:
|
| FakeConnectionFinder(const cryptauth::RemoteDevice& remote_device)
|
| : remote_device_(remote_device), connection_(nullptr) {}
|
| @@ -67,38 +67,40 @@ class FakeConnectionFinder : public ConnectionFinder {
|
|
|
| void OnConnectionFound() {
|
| ASSERT_FALSE(connection_callback_.is_null());
|
| - std::unique_ptr<FakeConnection> scoped_connection_(
|
| - new FakeConnection(remote_device_));
|
| + std::unique_ptr<cryptauth::FakeConnection> scoped_connection_(
|
| + new cryptauth::FakeConnection(remote_device_));
|
| connection_ = scoped_connection_.get();
|
| connection_callback_.Run(std::move(scoped_connection_));
|
| }
|
|
|
| - FakeConnection* connection() { return connection_; }
|
| + cryptauth::FakeConnection* connection() { return connection_; }
|
|
|
| private:
|
| - // ConnectionFinder:
|
| - void Find(const ConnectionCallback& connection_callback) override {
|
| + // cryptauth::ConnectionFinder:
|
| + void Find(const cryptauth::ConnectionFinder::ConnectionCallback&
|
| + connection_callback) override {
|
| ASSERT_TRUE(connection_callback_.is_null());
|
| connection_callback_ = connection_callback;
|
| }
|
|
|
| const cryptauth::RemoteDevice remote_device_;
|
|
|
| - FakeConnection* connection_;
|
| + cryptauth::FakeConnection* connection_;
|
|
|
| - ConnectionCallback connection_callback_;
|
| + cryptauth::ConnectionFinder::ConnectionCallback connection_callback_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(FakeConnectionFinder);
|
| };
|
|
|
| class FakeAuthenticator : public Authenticator {
|
| public:
|
| - FakeAuthenticator(Connection* connection) : connection_(connection) {}
|
| + FakeAuthenticator(cryptauth::Connection* connection)
|
| + : connection_(connection) {}
|
| ~FakeAuthenticator() override {
|
| // This object should be destroyed immediately after authentication is
|
| // complete in order not to outlive the underlying connection.
|
| EXPECT_FALSE(callback_.is_null());
|
| - EXPECT_EQ(kTestRemoteDevicePublicKey,
|
| + EXPECT_EQ(cryptauth::kTestRemoteDevicePublicKey,
|
| connection_->remote_device().public_key);
|
| }
|
|
|
| @@ -117,7 +119,7 @@ class FakeAuthenticator : public Authenticator {
|
| callback_ = callback;
|
| }
|
|
|
| - Connection* connection_;
|
| + cryptauth::Connection* connection_;
|
|
|
| AuthenticationCallback callback_;
|
|
|
| @@ -138,7 +140,8 @@ class TestableRemoteDeviceLifeCycleImpl : public RemoteDeviceLifeCycleImpl {
|
| FakeAuthenticator* authenticator() { return authenticator_; }
|
|
|
| private:
|
| - std::unique_ptr<ConnectionFinder> CreateConnectionFinder() override {
|
| + std::unique_ptr<cryptauth::ConnectionFinder> CreateConnectionFinder()
|
| + override {
|
| std::unique_ptr<FakeConnectionFinder> scoped_connection_finder(
|
| new FakeConnectionFinder(remote_device_));
|
| connection_finder_ = scoped_connection_finder.get();
|
| @@ -167,7 +170,7 @@ class ProximityAuthRemoteDeviceLifeCycleImplTest
|
| public RemoteDeviceLifeCycle::Observer {
|
| protected:
|
| ProximityAuthRemoteDeviceLifeCycleImplTest()
|
| - : life_cycle_(CreateClassicRemoteDeviceForTest()),
|
| + : life_cycle_(cryptauth::CreateClassicRemoteDeviceForTest()),
|
| task_runner_(new base::TestSimpleTaskRunner()),
|
| thread_task_runner_handle_(task_runner_) {}
|
|
|
| @@ -190,7 +193,7 @@ class ProximityAuthRemoteDeviceLifeCycleImplTest
|
| life_cycle_.GetState());
|
| }
|
|
|
| - FakeConnection* OnConnectionFound() {
|
| + cryptauth::FakeConnection* OnConnectionFound() {
|
| EXPECT_EQ(RemoteDeviceLifeCycle::State::FINDING_CONNECTION,
|
| life_cycle_.GetState());
|
|
|
| @@ -241,7 +244,7 @@ class ProximityAuthRemoteDeviceLifeCycleImplTest
|
|
|
| TEST_F(ProximityAuthRemoteDeviceLifeCycleImplTest, GetRemoteDevice) {
|
| cryptauth::RemoteDevice expected_remote_device =
|
| - CreateClassicRemoteDeviceForTest();
|
| + cryptauth::CreateClassicRemoteDeviceForTest();
|
| cryptauth::RemoteDevice remote_device = life_cycle_.GetRemoteDevice();
|
| EXPECT_EQ(expected_remote_device.user_id, remote_device.user_id);
|
| EXPECT_EQ(expected_remote_device.name, remote_device.name);
|
| @@ -255,7 +258,7 @@ TEST_F(ProximityAuthRemoteDeviceLifeCycleImplTest, GetRemoteDevice) {
|
| TEST_F(ProximityAuthRemoteDeviceLifeCycleImplTest, AuthenticateAndDisconnect) {
|
| StartLifeCycle();
|
| for (size_t i = 0; i < 3; ++i) {
|
| - Connection* connection = OnConnectionFound();
|
| + cryptauth::Connection* connection = OnConnectionFound();
|
| Authenticate(Authenticator::Result::SUCCESS);
|
| EXPECT_TRUE(life_cycle_.GetMessenger());
|
|
|
| @@ -308,7 +311,7 @@ TEST_F(ProximityAuthRemoteDeviceLifeCycleImplTest,
|
| task_runner_->RunUntilIdle();
|
|
|
| // Authentication succeeds on second pass.
|
| - Connection* connection = OnConnectionFound();
|
| + cryptauth::Connection* connection = OnConnectionFound();
|
| Authenticate(Authenticator::Result::SUCCESS);
|
| EXPECT_TRUE(life_cycle_.GetMessenger());
|
| EXPECT_CALL(*this, OnLifeCycleStateChanged(_, _));
|
|
|