Chromium Code Reviews| 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/security_key_ipc_server.h" | 5 #include "remoting/host/security_key/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/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "ipc/ipc_channel.h" | 16 #include "ipc/ipc_channel.h" |
| 17 #include "mojo/edk/embedder/embedder.h" | 17 #include "mojo/edk/embedder/embedder.h" |
| 18 #include "mojo/edk/embedder/named_platform_handle_utils.h" | 18 #include "mojo/edk/embedder/named_platform_handle_utils.h" |
| 19 #include "mojo/edk/embedder/scoped_ipc_support.h" | |
| 20 #include "remoting/host/client_session_details.h" | 19 #include "remoting/host/client_session_details.h" |
| 21 #include "remoting/host/security_key/fake_security_key_ipc_client.h" | 20 #include "remoting/host/security_key/fake_security_key_ipc_client.h" |
| 22 #include "remoting/host/security_key/security_key_ipc_constants.h" | 21 #include "remoting/host/security_key/security_key_ipc_constants.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 23 |
| 25 namespace { | 24 namespace { |
| 26 const int kTestConnectionId = 42; | 25 const int kTestConnectionId = 42; |
| 27 const int kInitialConnectTimeoutMs = 250; | 26 const int kInitialConnectTimeoutMs = 250; |
| 28 const int kConnectionTimeoutErrorDeltaMs = 100; | 27 const int kConnectionTimeoutErrorDeltaMs = 100; |
| 29 const int kLargeMessageSizeBytes = 256 * 1024; | 28 const int kLargeMessageSizeBytes = 256 * 1024; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 45 void SendRequestToClient(int connection_id, const std::string& data); | 44 void SendRequestToClient(int connection_id, const std::string& data); |
| 46 | 45 |
| 47 protected: | 46 protected: |
| 48 // Returns a unique IPC channel name which prevents conflicts when running | 47 // Returns a unique IPC channel name which prevents conflicts when running |
| 49 // tests concurrently. | 48 // tests concurrently. |
| 50 std::string GetUniqueTestChannelName(); | 49 std::string GetUniqueTestChannelName(); |
| 51 | 50 |
| 52 // Waits until the current |run_loop_| instance is signaled, then resets it. | 51 // Waits until the current |run_loop_| instance is signaled, then resets it. |
| 53 void WaitForOperationComplete(); | 52 void WaitForOperationComplete(); |
| 54 | 53 |
| 54 // Waits until all tasks have been run on the current message loop. | |
| 55 void WaitForPendingOperations(); | |
| 56 | |
| 55 // ClientSessionControl overrides: | 57 // ClientSessionControl overrides: |
| 56 ClientSessionControl* session_control() override { return nullptr; } | 58 ClientSessionControl* session_control() override { return nullptr; } |
| 57 uint32_t desktop_session_id() const override { return peer_session_id_; } | 59 uint32_t desktop_session_id() const override { return peer_session_id_; } |
| 58 | 60 |
| 59 // IPC tests require a valid MessageLoop to run. | 61 // IPC tests require a valid MessageLoop to run. |
| 60 base::MessageLoopForIO message_loop_; | 62 base::MessageLoopForIO message_loop_; |
| 61 | 63 |
| 62 mojo::edk::ScopedIPCSupport ipc_support_; | |
| 63 | |
| 64 // Used to allow |message_loop_| to run during tests. The instance is reset | 64 // Used to allow |message_loop_| to run during tests. The instance is reset |
| 65 // after each stage of the tests has been completed. | 65 // after each stage of the tests has been completed. |
| 66 std::unique_ptr<base::RunLoop> run_loop_; | 66 std::unique_ptr<base::RunLoop> run_loop_; |
| 67 | 67 |
| 68 // The object under test. | 68 // The object under test. |
| 69 std::unique_ptr<SecurityKeyIpcServer> security_key_ipc_server_; | 69 std::unique_ptr<SecurityKeyIpcServer> security_key_ipc_server_; |
| 70 | 70 |
| 71 // Used to validate the object under test uses the correct ID when | 71 // Used to validate the object under test uses the correct ID when |
| 72 // communicating over the IPC channel. | 72 // communicating over the IPC channel. |
| 73 int last_connection_id_received_ = -1; | 73 int last_connection_id_received_ = -1; |
| 74 | 74 |
| 75 // Stores the contents of the last IPC message received for validation. | 75 // Stores the contents of the last IPC message received for validation. |
| 76 std::string last_message_received_; | 76 std::string last_message_received_; |
| 77 | 77 |
| 78 uint32_t peer_session_id_ = UINT32_MAX; | 78 uint32_t peer_session_id_ = UINT32_MAX; |
| 79 | 79 |
| 80 private: | 80 private: |
| 81 DISALLOW_COPY_AND_ASSIGN(SecurityKeyIpcServerTest); | 81 DISALLOW_COPY_AND_ASSIGN(SecurityKeyIpcServerTest); |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 SecurityKeyIpcServerTest::SecurityKeyIpcServerTest() | 84 SecurityKeyIpcServerTest::SecurityKeyIpcServerTest() |
| 85 : ipc_support_(message_loop_.task_runner(), | 85 : run_loop_(new base::RunLoop()) { |
| 86 mojo::edk::ScopedIPCSupport::ShutdownPolicy::FAST), | |
| 87 run_loop_(new base::RunLoop()) { | |
| 88 #if defined(OS_WIN) | 86 #if defined(OS_WIN) |
| 89 EXPECT_TRUE(ProcessIdToSessionId( | 87 EXPECT_TRUE(ProcessIdToSessionId( |
| 90 GetCurrentProcessId(), reinterpret_cast<DWORD*>(&peer_session_id_))); | 88 GetCurrentProcessId(), reinterpret_cast<DWORD*>(&peer_session_id_))); |
| 91 #endif // defined(OS_WIN) | 89 #endif // defined(OS_WIN) |
| 92 | 90 |
| 93 security_key_ipc_server_ = remoting::SecurityKeyIpcServer::Create( | 91 security_key_ipc_server_ = remoting::SecurityKeyIpcServer::Create( |
| 94 kTestConnectionId, this, | 92 kTestConnectionId, this, |
| 95 base::TimeDelta::FromMilliseconds(kInitialConnectTimeoutMs), | 93 base::TimeDelta::FromMilliseconds(kInitialConnectTimeoutMs), |
| 96 base::Bind(&SecurityKeyIpcServerTest::SendRequestToClient, | 94 base::Bind(&SecurityKeyIpcServerTest::SendRequestToClient, |
| 97 base::Unretained(this)), | 95 base::Unretained(this)), |
| 98 base::Bind(&base::DoNothing), | 96 base::Bind(&base::DoNothing), |
| 99 base::Bind(&SecurityKeyIpcServerTest::OperationComplete, | 97 base::Bind(&SecurityKeyIpcServerTest::OperationComplete, |
| 100 base::Unretained(this))); | 98 base::Unretained(this))); |
| 101 } | 99 } |
| 102 | 100 |
| 103 SecurityKeyIpcServerTest::~SecurityKeyIpcServerTest() {} | 101 SecurityKeyIpcServerTest::~SecurityKeyIpcServerTest() {} |
| 104 | 102 |
| 105 void SecurityKeyIpcServerTest::OperationComplete() { | 103 void SecurityKeyIpcServerTest::OperationComplete() { |
| 106 run_loop_->Quit(); | 104 run_loop_->Quit(); |
| 107 } | 105 } |
| 108 | 106 |
| 109 void SecurityKeyIpcServerTest::WaitForOperationComplete() { | 107 void SecurityKeyIpcServerTest::WaitForOperationComplete() { |
| 110 run_loop_->Run(); | 108 run_loop_->Run(); |
| 111 run_loop_.reset(new base::RunLoop()); | 109 run_loop_.reset(new base::RunLoop()); |
| 112 } | 110 } |
| 113 | 111 |
| 112 void SecurityKeyIpcServerTest::WaitForPendingOperations() { | |
|
Sergey Ulanov
2017/02/02 01:46:40
Maybe call this RunPendingTasks()? This function d
joedow
2017/02/03 22:32:46
Done.
| |
| 113 // Ensure we have a new, runnable instance. | |
| 114 run_loop_.reset(new base::RunLoop()); | |
|
Sergey Ulanov
2017/02/02 01:46:40
Each RunLoop is usable only once, i.e. Run[UntilId
joedow
2017/02/03 22:32:46
Excellent suggestion, thanks!
| |
| 115 | |
| 116 // Run until there are no pending work items in the queue. | |
| 117 run_loop_->RunUntilIdle(); | |
| 118 | |
| 119 // Create a new instance for future operations. | |
| 120 run_loop_.reset(new base::RunLoop()); | |
| 121 } | |
| 122 | |
| 114 void SecurityKeyIpcServerTest::SendRequestToClient(int connection_id, | 123 void SecurityKeyIpcServerTest::SendRequestToClient(int connection_id, |
| 115 const std::string& data) { | 124 const std::string& data) { |
| 116 last_connection_id_received_ = connection_id; | 125 last_connection_id_received_ = connection_id; |
| 117 last_message_received_ = data; | 126 last_message_received_ = data; |
| 118 OperationComplete(); | 127 OperationComplete(); |
| 119 } | 128 } |
| 120 | 129 |
| 121 std::string SecurityKeyIpcServerTest::GetUniqueTestChannelName() { | 130 std::string SecurityKeyIpcServerTest::GetUniqueTestChannelName() { |
| 122 return GetChannelNamePathPrefixForTest() + "Super_Awesome_Test_Channel." + | 131 return GetChannelNamePathPrefixForTest() + "Super_Awesome_Test_Channel." + |
| 123 IPC::Channel::GenerateUniqueRandomChannelID(); | 132 IPC::Channel::GenerateUniqueRandomChannelID(); |
| 124 } | 133 } |
| 125 | 134 |
| 126 TEST_F(SecurityKeyIpcServerTest, HandleSingleSecurityKeyRequest) { | 135 TEST_F(SecurityKeyIpcServerTest, HandleSingleSecurityKeyRequest) { |
| 127 mojo::edk::NamedPlatformHandle channel_handle(GetUniqueTestChannelName()); | 136 mojo::edk::NamedPlatformHandle channel_handle(GetUniqueTestChannelName()); |
| 128 ASSERT_TRUE(security_key_ipc_server_->CreateChannel( | 137 ASSERT_TRUE(security_key_ipc_server_->CreateChannel( |
| 129 channel_handle, | 138 channel_handle, |
| 130 /*request_timeout=*/base::TimeDelta::FromMilliseconds(500))); | 139 /*request_timeout=*/base::TimeDelta::FromMilliseconds(500))); |
| 131 | 140 |
| 132 // Create a fake client and connect to the IPC server channel. | 141 // Create a fake client and connect to the IPC server channel. |
| 133 FakeSecurityKeyIpcClient fake_ipc_client(base::Bind( | 142 FakeSecurityKeyIpcClient fake_ipc_client(base::Bind( |
| 134 &SecurityKeyIpcServerTest::OperationComplete, base::Unretained(this))); | 143 &SecurityKeyIpcServerTest::OperationComplete, base::Unretained(this))); |
| 135 ASSERT_TRUE(fake_ipc_client.ConnectViaIpc(channel_handle)); | 144 ASSERT_TRUE(fake_ipc_client.ConnectViaIpc(channel_handle)); |
| 136 WaitForOperationComplete(); | 145 WaitForOperationComplete(); |
| 137 | 146 |
| 147 ASSERT_TRUE(fake_ipc_client.ipc_channel_connected()); | |
| 138 ASSERT_FALSE(fake_ipc_client.invalid_session_error()); | 148 ASSERT_FALSE(fake_ipc_client.invalid_session_error()); |
| 139 ASSERT_TRUE(fake_ipc_client.connection_ready()); | 149 ASSERT_TRUE(fake_ipc_client.connection_ready()); |
| 140 ASSERT_TRUE(fake_ipc_client.ipc_channel_connected()); | |
| 141 | 150 |
| 142 // Send a request from the IPC client to the IPC server. | 151 // Send a request from the IPC client to the IPC server. |
| 143 std::string request_data("Blergh!"); | 152 std::string request_data("Blergh!"); |
| 144 fake_ipc_client.SendSecurityKeyRequestViaIpc(request_data); | 153 fake_ipc_client.SendSecurityKeyRequestViaIpc(request_data); |
| 145 WaitForOperationComplete(); | 154 WaitForOperationComplete(); |
| 146 | 155 |
| 147 // Verify the request was received. | 156 // Verify the request was received. |
| 148 ASSERT_EQ(kTestConnectionId, last_connection_id_received_); | 157 ASSERT_EQ(kTestConnectionId, last_connection_id_received_); |
| 149 ASSERT_EQ(request_data, last_message_received_); | 158 ASSERT_EQ(request_data, last_message_received_); |
| 150 | 159 |
| 151 // Send a response from the IPC server to the IPC client. | 160 // Send a response from the IPC server to the IPC client. |
| 152 std::string response_data("Blargh!"); | 161 std::string response_data("Blargh!"); |
| 153 ASSERT_TRUE(security_key_ipc_server_->SendResponse(response_data)); | 162 ASSERT_TRUE(security_key_ipc_server_->SendResponse(response_data)); |
| 154 WaitForOperationComplete(); | 163 WaitForOperationComplete(); |
| 155 | 164 |
| 156 // Verify the request was received. | 165 // Verify the request was received. |
| 157 ASSERT_EQ(response_data, fake_ipc_client.last_message_received()); | 166 ASSERT_EQ(response_data, fake_ipc_client.last_message_received()); |
| 158 | 167 |
| 159 // Typically the client will be the one to close the connection. | 168 // Typically the client will be the one to close the connection. |
| 160 fake_ipc_client.CloseIpcConnection(); | 169 fake_ipc_client.CloseIpcConnection(); |
| 170 WaitForOperationComplete(); | |
|
Sergey Ulanov
2017/02/02 01:46:40
Since this needs to be done after every test maybe
joedow
2017/02/03 22:32:46
There are some cases which do not complete the con
| |
| 161 } | 171 } |
| 162 | 172 |
| 163 TEST_F(SecurityKeyIpcServerTest, HandleLargeSecurityKeyRequest) { | 173 TEST_F(SecurityKeyIpcServerTest, HandleLargeSecurityKeyRequest) { |
| 164 mojo::edk::NamedPlatformHandle channel_handle(GetUniqueTestChannelName()); | 174 mojo::edk::NamedPlatformHandle channel_handle(GetUniqueTestChannelName()); |
| 165 ASSERT_TRUE(security_key_ipc_server_->CreateChannel( | 175 ASSERT_TRUE(security_key_ipc_server_->CreateChannel( |
| 166 channel_handle, | 176 channel_handle, |
| 167 /*request_timeout=*/base::TimeDelta::FromMilliseconds(500))); | 177 /*request_timeout=*/base::TimeDelta::FromMilliseconds(500))); |
| 168 | 178 |
| 169 // Create a fake client and connect to the IPC server channel. | 179 // Create a fake client and connect to the IPC server channel. |
| 170 FakeSecurityKeyIpcClient fake_ipc_client(base::Bind( | 180 FakeSecurityKeyIpcClient fake_ipc_client(base::Bind( |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 188 // Send a response from the IPC server to the IPC client. | 198 // Send a response from the IPC server to the IPC client. |
| 189 std::string response_data(kLargeMessageSizeBytes, 'Z'); | 199 std::string response_data(kLargeMessageSizeBytes, 'Z'); |
| 190 ASSERT_TRUE(security_key_ipc_server_->SendResponse(response_data)); | 200 ASSERT_TRUE(security_key_ipc_server_->SendResponse(response_data)); |
| 191 WaitForOperationComplete(); | 201 WaitForOperationComplete(); |
| 192 | 202 |
| 193 // Verify the request was received. | 203 // Verify the request was received. |
| 194 ASSERT_EQ(response_data, fake_ipc_client.last_message_received()); | 204 ASSERT_EQ(response_data, fake_ipc_client.last_message_received()); |
| 195 | 205 |
| 196 // Typically the client will be the one to close the connection. | 206 // Typically the client will be the one to close the connection. |
| 197 fake_ipc_client.CloseIpcConnection(); | 207 fake_ipc_client.CloseIpcConnection(); |
| 208 WaitForOperationComplete(); | |
| 198 } | 209 } |
| 199 | 210 |
| 200 TEST_F(SecurityKeyIpcServerTest, HandleReallyLargeSecurityKeyRequest) { | 211 TEST_F(SecurityKeyIpcServerTest, HandleReallyLargeSecurityKeyRequest) { |
| 201 mojo::edk::NamedPlatformHandle channel_handle(GetUniqueTestChannelName()); | 212 mojo::edk::NamedPlatformHandle channel_handle(GetUniqueTestChannelName()); |
| 202 ASSERT_TRUE(security_key_ipc_server_->CreateChannel( | 213 ASSERT_TRUE(security_key_ipc_server_->CreateChannel( |
| 203 channel_handle, | 214 channel_handle, |
| 204 /*request_timeout=*/base::TimeDelta::FromMilliseconds(500))); | 215 /*request_timeout=*/base::TimeDelta::FromMilliseconds(500))); |
| 205 | 216 |
| 206 // Create a fake client and connect to the IPC server channel. | 217 // Create a fake client and connect to the IPC server channel. |
| 207 FakeSecurityKeyIpcClient fake_ipc_client(base::Bind( | 218 FakeSecurityKeyIpcClient fake_ipc_client(base::Bind( |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 225 // Send a response from the IPC server to the IPC client. | 236 // Send a response from the IPC server to the IPC client. |
| 226 std::string response_data(kLargeMessageSizeBytes * 2, 'Z'); | 237 std::string response_data(kLargeMessageSizeBytes * 2, 'Z'); |
| 227 ASSERT_TRUE(security_key_ipc_server_->SendResponse(response_data)); | 238 ASSERT_TRUE(security_key_ipc_server_->SendResponse(response_data)); |
| 228 WaitForOperationComplete(); | 239 WaitForOperationComplete(); |
| 229 | 240 |
| 230 // Verify the request was received. | 241 // Verify the request was received. |
| 231 ASSERT_EQ(response_data, fake_ipc_client.last_message_received()); | 242 ASSERT_EQ(response_data, fake_ipc_client.last_message_received()); |
| 232 | 243 |
| 233 // Typically the client will be the one to close the connection. | 244 // Typically the client will be the one to close the connection. |
| 234 fake_ipc_client.CloseIpcConnection(); | 245 fake_ipc_client.CloseIpcConnection(); |
| 246 WaitForOperationComplete(); | |
| 235 } | 247 } |
| 236 | 248 |
| 237 TEST_F(SecurityKeyIpcServerTest, HandleMultipleSecurityKeyRequests) { | 249 TEST_F(SecurityKeyIpcServerTest, HandleMultipleSecurityKeyRequests) { |
| 238 mojo::edk::NamedPlatformHandle channel_handle(GetUniqueTestChannelName()); | 250 mojo::edk::NamedPlatformHandle channel_handle(GetUniqueTestChannelName()); |
| 239 ASSERT_TRUE(security_key_ipc_server_->CreateChannel( | 251 ASSERT_TRUE(security_key_ipc_server_->CreateChannel( |
| 240 channel_handle, | 252 channel_handle, |
| 241 /*request_timeout=*/base::TimeDelta::FromMilliseconds(500))); | 253 /*request_timeout=*/base::TimeDelta::FromMilliseconds(500))); |
| 242 | 254 |
| 243 // Create a fake client and connect to the IPC server channel. | 255 // Create a fake client and connect to the IPC server channel. |
| 244 FakeSecurityKeyIpcClient fake_ipc_client(base::Bind( | 256 FakeSecurityKeyIpcClient fake_ipc_client(base::Bind( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 279 // Send a response from the IPC server to the IPC client. | 291 // Send a response from the IPC server to the IPC client. |
| 280 std::string response_data_2("Meh!"); | 292 std::string response_data_2("Meh!"); |
| 281 ASSERT_TRUE(security_key_ipc_server_->SendResponse(response_data_2)); | 293 ASSERT_TRUE(security_key_ipc_server_->SendResponse(response_data_2)); |
| 282 WaitForOperationComplete(); | 294 WaitForOperationComplete(); |
| 283 | 295 |
| 284 // Verify the response was received. | 296 // Verify the response was received. |
| 285 ASSERT_EQ(response_data_2, fake_ipc_client.last_message_received()); | 297 ASSERT_EQ(response_data_2, fake_ipc_client.last_message_received()); |
| 286 | 298 |
| 287 // Typically the client will be the one to close the connection. | 299 // Typically the client will be the one to close the connection. |
| 288 fake_ipc_client.CloseIpcConnection(); | 300 fake_ipc_client.CloseIpcConnection(); |
| 301 WaitForOperationComplete(); | |
| 289 } | 302 } |
| 290 | 303 |
| 291 TEST_F(SecurityKeyIpcServerTest, InitialIpcConnectionTimeout_ConnectOnly) { | 304 TEST_F(SecurityKeyIpcServerTest, InitialIpcConnectionTimeout_ConnectOnly) { |
| 292 // Create a channel, then wait for the done callback to be called indicating | 305 // Create a channel, then wait for the done callback to be called indicating |
| 293 // the connection was closed. This test simulates the IPC Server being | 306 // the connection was closed. This test simulates the IPC Server being |
| 294 // created, the client connecting to the OS channel, but never communicating | 307 // created, the client connecting to the OS channel, but never communicating |
| 295 // over the channel. | 308 // over the channel. |
| 296 mojo::edk::NamedPlatformHandle channel_handle(GetUniqueTestChannelName()); | 309 mojo::edk::NamedPlatformHandle channel_handle(GetUniqueTestChannelName()); |
| 297 ASSERT_TRUE(security_key_ipc_server_->CreateChannel( | 310 ASSERT_TRUE(security_key_ipc_server_->CreateChannel( |
| 298 channel_handle, | 311 channel_handle, |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 469 // Send a response from the IPC server to the IPC client. | 482 // Send a response from the IPC server to the IPC client. |
| 470 std::string response_data("Blargh!"); | 483 std::string response_data("Blargh!"); |
| 471 ASSERT_TRUE(security_key_ipc_server_->SendResponse(response_data)); | 484 ASSERT_TRUE(security_key_ipc_server_->SendResponse(response_data)); |
| 472 WaitForOperationComplete(); | 485 WaitForOperationComplete(); |
| 473 | 486 |
| 474 // Verify the request was received. | 487 // Verify the request was received. |
| 475 ASSERT_EQ(response_data, fake_ipc_client.last_message_received()); | 488 ASSERT_EQ(response_data, fake_ipc_client.last_message_received()); |
| 476 | 489 |
| 477 // Typically the client will be the one to close the connection. | 490 // Typically the client will be the one to close the connection. |
| 478 fake_ipc_client.CloseIpcConnection(); | 491 fake_ipc_client.CloseIpcConnection(); |
| 492 WaitForOperationComplete(); | |
| 479 } | 493 } |
| 480 | 494 |
| 481 #if defined(OS_WIN) | 495 #if defined(OS_WIN) |
| 482 TEST_F(SecurityKeyIpcServerTest, IpcConnectionFailsFromInvalidSession) { | 496 TEST_F(SecurityKeyIpcServerTest, IpcConnectionFailsFromInvalidSession) { |
| 483 // Change the expected session ID to not match the current session. | 497 // Change the expected session ID to not match the current session. |
| 484 peer_session_id_++; | 498 peer_session_id_++; |
| 485 | 499 |
| 486 base::TimeDelta request_timeout(base::TimeDelta::FromMilliseconds(500)); | 500 base::TimeDelta request_timeout(base::TimeDelta::FromMilliseconds(500)); |
| 487 mojo::edk::NamedPlatformHandle channel_handle(GetUniqueTestChannelName()); | 501 mojo::edk::NamedPlatformHandle channel_handle(GetUniqueTestChannelName()); |
| 488 ASSERT_TRUE( | 502 ASSERT_TRUE( |
| 489 security_key_ipc_server_->CreateChannel(channel_handle, request_timeout)); | 503 security_key_ipc_server_->CreateChannel(channel_handle, request_timeout)); |
| 490 | 504 |
| 491 // Create a fake client and attempt to connect to the IPC server channel. | 505 // Create a fake client and attempt to connect to the IPC server channel. |
| 492 FakeSecurityKeyIpcClient fake_ipc_client(base::Bind( | 506 FakeSecurityKeyIpcClient fake_ipc_client(base::Bind(&base::DoNothing)); |
| 493 &SecurityKeyIpcServerTest::OperationComplete, base::Unretained(this))); | |
| 494 ASSERT_TRUE(fake_ipc_client.ConnectViaIpc(channel_handle)); | 507 ASSERT_TRUE(fake_ipc_client.ConnectViaIpc(channel_handle)); |
| 495 WaitForOperationComplete(); | 508 WaitForOperationComplete(); |
| 496 WaitForOperationComplete(); | |
| 497 WaitForOperationComplete(); | |
| 498 | 509 |
| 499 // Verify the connection failed. | 510 // Verify the connection failed. |
| 500 ASSERT_TRUE(fake_ipc_client.invalid_session_error()); | 511 ASSERT_TRUE(fake_ipc_client.invalid_session_error()); |
| 501 ASSERT_FALSE(fake_ipc_client.connection_ready()); | 512 ASSERT_FALSE(fake_ipc_client.connection_ready()); |
| 513 | |
| 514 WaitForPendingOperations(); | |
| 502 ASSERT_FALSE(fake_ipc_client.ipc_channel_connected()); | 515 ASSERT_FALSE(fake_ipc_client.ipc_channel_connected()); |
| 503 } | 516 } |
| 504 #endif // defined(OS_WIN) | 517 #endif // defined(OS_WIN) |
| 505 | 518 |
| 506 } // namespace remoting | 519 } // namespace remoting |
| OLD | NEW |