| Index: remoting/host/security_key/security_key_auth_handler_win_unittest.cc
|
| diff --git a/remoting/host/security_key/security_key_auth_handler_win_unittest.cc b/remoting/host/security_key/security_key_auth_handler_win_unittest.cc
|
| index 58ad21c516d431ccc325d9af451dc49bce5f7c10..f2c670dc882687fc8e967ee610509f5f97fe4884 100644
|
| --- a/remoting/host/security_key/security_key_auth_handler_win_unittest.cc
|
| +++ b/remoting/host/security_key/security_key_auth_handler_win_unittest.cc
|
| @@ -17,7 +17,6 @@
|
| #include "ipc/ipc_listener.h"
|
| #include "ipc/ipc_message.h"
|
| #include "ipc/ipc_message_macros.h"
|
| -#include "mojo/edk/embedder/scoped_ipc_support.h"
|
| #include "remoting/host/host_mock_objects.h"
|
| #include "remoting/host/security_key/fake_security_key_ipc_client.h"
|
| #include "remoting/host/security_key/fake_security_key_ipc_server.h"
|
| @@ -45,6 +44,9 @@ class SecurityKeyAuthHandlerWinTest : public testing::Test {
|
| // Waits until the current |run_loop_| instance is signaled, then resets it.
|
| void WaitForOperationComplete();
|
|
|
| + // Waits until all tasks have been run on the current message loop.
|
| + void WaitForPendingOperations();
|
| +
|
| // Used as a callback given to the object under test, expected to be called
|
| // back when a security key request is received by it.
|
| void SendMessageToClient(int connection_id, const std::string& data);
|
| @@ -88,8 +90,6 @@ class SecurityKeyAuthHandlerWinTest : public testing::Test {
|
| // IPC tests require a valid MessageLoop to run.
|
| base::MessageLoopForIO message_loop_;
|
|
|
| - mojo::edk::ScopedIPCSupport ipc_support_;
|
| -
|
| // Used to allow |message_loop_| to run during tests. The instance is reset
|
| // after each stage of the tests has been completed.
|
| std::unique_ptr<base::RunLoop> run_loop_;
|
| @@ -116,9 +116,7 @@ class SecurityKeyAuthHandlerWinTest : public testing::Test {
|
| };
|
|
|
| SecurityKeyAuthHandlerWinTest::SecurityKeyAuthHandlerWinTest()
|
| - : ipc_support_(message_loop_.task_runner(),
|
| - mojo::edk::ScopedIPCSupport::ShutdownPolicy::FAST),
|
| - run_loop_(new base::RunLoop()) {
|
| + : run_loop_(new base::RunLoop()) {
|
| auth_handler_ = remoting::SecurityKeyAuthHandler::Create(
|
| &mock_client_session_details_,
|
| base::Bind(&SecurityKeyAuthHandlerWinTest::SendMessageToClient,
|
| @@ -137,6 +135,17 @@ void SecurityKeyAuthHandlerWinTest::WaitForOperationComplete() {
|
| run_loop_.reset(new base::RunLoop());
|
| }
|
|
|
| +void SecurityKeyAuthHandlerWinTest::WaitForPendingOperations() {
|
| + // Ensure we have a new, runnable instance.
|
| + run_loop_.reset(new base::RunLoop());
|
| +
|
| + // Run until there are no pending work items in the queue.
|
| + run_loop_->RunUntilIdle();
|
| +
|
| + // Create a new instance for future operations.
|
| + run_loop_.reset(new base::RunLoop());
|
| +}
|
| +
|
| void SecurityKeyAuthHandlerWinTest::SendMessageToClient(
|
| int connection_id,
|
| const std::string& data) {
|
| @@ -164,9 +173,19 @@ void SecurityKeyAuthHandlerWinTest::EstablishIpcConnection(
|
| auth_handler_->GetActiveConnectionCountForTest() + 1;
|
|
|
| ASSERT_FALSE(auth_handler_->IsValidConnectionId(expected_connection_id));
|
| + fake_ipc_client->set_on_channel_connected_callback(
|
| + base::Bind(&SecurityKeyAuthHandlerWinTest::OperationComplete,
|
| + base::Unretained(this)));
|
| ASSERT_TRUE(fake_ipc_client->ConnectViaIpc(channel_handle));
|
| WaitForOperationComplete();
|
|
|
| + // Retrieve the IPC server instance created when the client connected.
|
| + base::WeakPtr<FakeSecurityKeyIpcServer> fake_ipc_server =
|
| + ipc_server_factory_.GetIpcServerObject(expected_connection_id);
|
| + ASSERT_TRUE(fake_ipc_server.get());
|
| + fake_ipc_server->SendConnectionReadyMessage();
|
| + WaitForOperationComplete();
|
| +
|
| // Verify the internal state of the SecurityKeyAuthHandler is correct.
|
| ASSERT_TRUE(auth_handler_->IsValidConnectionId(expected_connection_id));
|
| ASSERT_EQ(expected_connection_count,
|
| @@ -248,7 +267,6 @@ std::string SecurityKeyAuthHandlerWinTest::GetUniqueTestChannelHandle() {
|
| TEST_F(SecurityKeyAuthHandlerWinTest, HandleSingleSecurityKeyRequest) {
|
| mojo::edk::NamedPlatformHandle channel_handle(GetUniqueTestChannelHandle());
|
| CreateSecurityKeyConnection(channel_handle);
|
| -
|
| ASSERT_FALSE(auth_handler_->IsValidConnectionId(kConnectionId1));
|
|
|
| // Create a fake client and connect to the IPC server channel.
|
|
|