Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(424)

Unified Diff: remoting/host/security_key/security_key_ipc_client_unittest.cc

Issue 2478443002: Use ChannelMojo for remote security key channels. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/host/security_key/security_key_ipc_client_unittest.cc
diff --git a/remoting/host/security_key/security_key_ipc_client_unittest.cc b/remoting/host/security_key/security_key_ipc_client_unittest.cc
index 68f56ad09d4a0fd4fe1bb722a77b0d02f31099f4..717381d62070f8b97309a75a70fbfedf388c1450 100644
--- a/remoting/host/security_key/security_key_ipc_client_unittest.cc
+++ b/remoting/host/security_key/security_key_ipc_client_unittest.cc
@@ -12,7 +12,7 @@
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "ipc/ipc_channel.h"
-#include "remoting/host/security_key/fake_ipc_security_key_auth_handler.h"
+#include "mojo/edk/test/scoped_ipc_support.h"
#include "remoting/host/security_key/fake_security_key_ipc_server.h"
#include "remoting/host/security_key/security_key_ipc_constants.h"
joedow 2016/11/03 22:25:18 Remove this header since |fake_security_key_auth_h
Sam McNally 2016/11/04 02:51:09 I'm not sure what you mean. The fake auth handler
joedow 2016/11/04 15:19:04 I noticed the files hadn't been deleted in that pa
#include "testing/gtest/include/gtest/gtest.h"
@@ -66,6 +66,8 @@ class SecurityKeyIpcClientTest : public testing::Test {
// IPC tests require a valid MessageLoop to run.
base::MessageLoopForIO message_loop_;
+ mojo::edk::test::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_;
@@ -73,10 +75,6 @@ class SecurityKeyIpcClientTest : public testing::Test {
// The object under test.
SecurityKeyIpcClient security_key_ipc_client_;
- // Provides a connection details message to |security_key_ipc_client_|
- // for testing.
- FakeIpcSecurityKeyAuthHandler fake_security_key_auth_handler_;
-
// Used to send/receive security key IPC messages for testing.
FakeSecurityKeyIpcServer fake_ipc_server_;
@@ -98,13 +96,15 @@ class SecurityKeyIpcClientTest : public testing::Test {
};
SecurityKeyIpcClientTest::SecurityKeyIpcClientTest()
- : run_loop_(new base::RunLoop()),
+ : ipc_support_(message_loop_.task_runner()),
+ run_loop_(new base::RunLoop()),
fake_ipc_server_(
kTestConnectionId,
/*client_session_details=*/nullptr,
/*initial_connect_timeout=*/base::TimeDelta::FromMilliseconds(500),
base::Bind(&SecurityKeyIpcClientTest::SendMessageToClient,
base::Unretained(this)),
+ base::Bind(&base::DoNothing),
base::Bind(&SecurityKeyIpcClientTest::OperationComplete,
base::Unretained(this),
/*failed=*/false)) {}
@@ -153,25 +153,13 @@ std::string SecurityKeyIpcClientTest::GenerateUniqueTestChannelName() {
void SecurityKeyIpcClientTest::EstablishConnection(bool expect_success) {
// Start up the security key forwarding session IPC channel first, that way
// we can provide the channel using the fake SecurityKeyAuthHandler later on.
- std::string ipc_session_channel_name = GenerateUniqueTestChannelName();
+ mojo::edk::NamedPlatformHandle channel_handle(
+ GenerateUniqueTestChannelName());
+ security_key_ipc_client_.SetIpcChannelHandleForTest(channel_handle);
ASSERT_TRUE(fake_ipc_server_.CreateChannel(
- ipc_session_channel_name,
+ channel_handle,
/*request_timeout=*/base::TimeDelta::FromMilliseconds(500)));
- ASSERT_TRUE(IPC::Channel::IsNamedServerInitialized(ipc_session_channel_name));
- fake_security_key_auth_handler_.set_ipc_security_key_channel_name(
- ipc_session_channel_name);
-
- // Set up the channel name for the initial IPC channel.
- std::string ipc_server_channel_name = GenerateUniqueTestChannelName();
- fake_security_key_auth_handler_.set_ipc_server_channel_name(
- ipc_server_channel_name);
- security_key_ipc_client_.SetInitialIpcChannelNameForTest(
- ipc_server_channel_name);
-
- // Create the initial IPC channel and verify it was set up correctly.
- ASSERT_FALSE(security_key_ipc_client_.WaitForSecurityKeyIpcServerChannel());
- fake_security_key_auth_handler_.CreateSecurityKeyConnection();
- ASSERT_TRUE(IPC::Channel::IsNamedServerInitialized(ipc_server_channel_name));
+
ASSERT_TRUE(security_key_ipc_client_.WaitForSecurityKeyIpcServerChannel());
// Establish the IPC channel so we can begin sending and receiving security
@@ -286,37 +274,8 @@ TEST_F(SecurityKeyIpcClientTest, SendRequestBeforeEstablishingConnection) {
}
TEST_F(SecurityKeyIpcClientTest, NonExistentMainIpcServerChannel) {
- std::string ipc_server_channel_name(kNonexistentIpcChannelName);
- security_key_ipc_client_.SetInitialIpcChannelNameForTest(
- ipc_server_channel_name);
-
- // Attempt to establish the conection (should fail since the IPC channel does
- // not exist).
- security_key_ipc_client_.EstablishIpcConnection(
- base::Bind(&SecurityKeyIpcClientTest::OperationComplete,
- base::Unretained(this), /*failed=*/false),
- base::Bind(&SecurityKeyIpcClientTest::OperationComplete,
- base::Unretained(this), /*failed=*/true));
- WaitForOperationComplete();
- ASSERT_TRUE(operation_failed_);
-}
-
-TEST_F(SecurityKeyIpcClientTest, NonExistentIpcSessionChannel) {
- fake_security_key_auth_handler_.set_ipc_security_key_channel_name(
- kNonexistentIpcChannelName);
-
- // Set up the channel name for the initial IPC channel.
- std::string ipc_server_channel_name = GenerateUniqueTestChannelName();
- fake_security_key_auth_handler_.set_ipc_server_channel_name(
- ipc_server_channel_name);
- security_key_ipc_client_.SetInitialIpcChannelNameForTest(
- ipc_server_channel_name);
-
- // Create the initial IPC channel and verify it was set up correctly.
- ASSERT_FALSE(security_key_ipc_client_.WaitForSecurityKeyIpcServerChannel());
- fake_security_key_auth_handler_.CreateSecurityKeyConnection();
- ASSERT_TRUE(IPC::Channel::IsNamedServerInitialized(ipc_server_channel_name));
- ASSERT_TRUE(security_key_ipc_client_.WaitForSecurityKeyIpcServerChannel());
+ security_key_ipc_client_.SetIpcChannelHandleForTest(
+ mojo::edk::NamedPlatformHandle(kNonexistentIpcChannelName));
// Attempt to establish the conection (should fail since the IPC channel does
// not exist).

Powered by Google App Engine
This is Rietveld 408576698