| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "remoting/host/security_key/remote_security_key_ipc_server.h" | 5 #include "remoting/host/security_key/remote_security_key_ipc_server.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "ipc/ipc_channel.h" | 15 #include "ipc/ipc_channel.h" |
| 16 #include "remoting/host/security_key/fake_remote_security_key_ipc_client.h" | 16 #include "remoting/host/security_key/fake_remote_security_key_ipc_client.h" |
| 17 #include "remoting/host/security_key/remote_security_key_ipc_constants.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 const int kTestConnectionId = 42; | 21 const int kTestConnectionId = 42; |
| 21 const int kInitialConnectTimeoutMs = 250; | 22 const int kInitialConnectTimeoutMs = 250; |
| 22 const int kConnectionTimeoutErrorDeltaMs = 100; | 23 const int kConnectionTimeoutErrorDeltaMs = 100; |
| 23 const int kLargeMessageSizeBytes = 256 * 1024; | 24 const int kLargeMessageSizeBytes = 256 * 1024; |
| 24 } // namespace | 25 } // namespace |
| 25 | 26 |
| 26 namespace remoting { | 27 namespace remoting { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 92 |
| 92 void RemoteSecurityKeyIpcServerTest::SendRequestToClient( | 93 void RemoteSecurityKeyIpcServerTest::SendRequestToClient( |
| 93 int connection_id, | 94 int connection_id, |
| 94 const std::string& data) { | 95 const std::string& data) { |
| 95 last_connection_id_received_ = connection_id; | 96 last_connection_id_received_ = connection_id; |
| 96 last_message_received_ = data; | 97 last_message_received_ = data; |
| 97 OperationComplete(); | 98 OperationComplete(); |
| 98 } | 99 } |
| 99 | 100 |
| 100 std::string RemoteSecurityKeyIpcServerTest::GetUniqueTestChannelName() { | 101 std::string RemoteSecurityKeyIpcServerTest::GetUniqueTestChannelName() { |
| 101 std::string channel_name("Super_Awesome_Test_Channel."); | 102 return GetChannelNamePathPrefixForTest() + "Super_Awesome_Test_Channel." + |
| 102 channel_name.append(IPC::Channel::GenerateUniqueRandomChannelID()); | 103 IPC::Channel::GenerateUniqueRandomChannelID(); |
| 103 | |
| 104 return channel_name; | |
| 105 } | 104 } |
| 106 | 105 |
| 107 TEST_F(RemoteSecurityKeyIpcServerTest, HandleSingleGnubbyRequest) { | 106 TEST_F(RemoteSecurityKeyIpcServerTest, HandleSingleGnubbyRequest) { |
| 108 std::string channel_name(GetUniqueTestChannelName()); | 107 std::string channel_name(GetUniqueTestChannelName()); |
| 109 ASSERT_TRUE(remote_security_key_ipc_server_->CreateChannel( | 108 ASSERT_TRUE(remote_security_key_ipc_server_->CreateChannel( |
| 110 channel_name, | 109 channel_name, |
| 111 /*request_timeout=*/base::TimeDelta::FromMilliseconds(500))); | 110 /*request_timeout=*/base::TimeDelta::FromMilliseconds(500))); |
| 112 | 111 |
| 113 // Create a fake client and connect to the IPC server channel. | 112 // Create a fake client and connect to the IPC server channel. |
| 114 FakeRemoteSecurityKeyIpcClient fake_ipc_client( | 113 FakeRemoteSecurityKeyIpcClient fake_ipc_client( |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 // Now wait for the timeout period for the connection to be torn down. | 356 // Now wait for the timeout period for the connection to be torn down. |
| 358 base::Time start_time(base::Time::NowFromSystemTime()); | 357 base::Time start_time(base::Time::NowFromSystemTime()); |
| 359 WaitForOperationComplete(); | 358 WaitForOperationComplete(); |
| 360 base::TimeDelta elapsed_time = base::Time::NowFromSystemTime() - start_time; | 359 base::TimeDelta elapsed_time = base::Time::NowFromSystemTime() - start_time; |
| 361 | 360 |
| 362 ASSERT_NEAR(elapsed_time.InMilliseconds(), request_timeout.InMilliseconds(), | 361 ASSERT_NEAR(elapsed_time.InMilliseconds(), request_timeout.InMilliseconds(), |
| 363 kConnectionTimeoutErrorDeltaMs); | 362 kConnectionTimeoutErrorDeltaMs); |
| 364 } | 363 } |
| 365 | 364 |
| 366 } // namespace remoting | 365 } // namespace remoting |
| OLD | NEW |