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 <string> | 8 #include <string> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/callback.h" | 11 #include "base/callback.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.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 "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 const int kTestConnectionId = 42; | 20 const int kTestConnectionId = 42; |
21 const int kInitialConnectTimeoutMs = 250; | 21 const int kInitialConnectTimeoutMs = 250; |
22 const int kConnectionTimeoutErrorDeltaMs = 100; | 22 const int kConnectionTimeoutErrorDeltaMs = 100; |
(...skipping 20 matching lines...) Expand all Loading... |
43 void WaitForOperationComplete(); | 43 void WaitForOperationComplete(); |
44 | 44 |
45 // Used as a callback to signal receipt of a security key request message. | 45 // Used as a callback to signal receipt of a security key request message. |
46 void SendRequestToClient(int connection_id, const std::string& data); | 46 void SendRequestToClient(int connection_id, const std::string& data); |
47 | 47 |
48 // IPC tests require a valid MessageLoop to run. | 48 // IPC tests require a valid MessageLoop to run. |
49 base::MessageLoopForIO message_loop_; | 49 base::MessageLoopForIO message_loop_; |
50 | 50 |
51 // Used to allow |message_loop_| to run during tests. The instance is reset | 51 // Used to allow |message_loop_| to run during tests. The instance is reset |
52 // after each stage of the tests has been completed. | 52 // after each stage of the tests has been completed. |
53 scoped_ptr<base::RunLoop> run_loop_; | 53 std::unique_ptr<base::RunLoop> run_loop_; |
54 | 54 |
55 // The object under test. | 55 // The object under test. |
56 scoped_ptr<RemoteSecurityKeyIpcServer> remote_security_key_ipc_server_; | 56 std::unique_ptr<RemoteSecurityKeyIpcServer> remote_security_key_ipc_server_; |
57 | 57 |
58 // Used to validate the object under test uses the correct ID when | 58 // Used to validate the object under test uses the correct ID when |
59 // communicating over the IPC channel. | 59 // communicating over the IPC channel. |
60 int last_connection_id_received_ = -1; | 60 int last_connection_id_received_ = -1; |
61 | 61 |
62 // Stores the contents of the last IPC message received for validation. | 62 // Stores the contents of the last IPC message received for validation. |
63 std::string last_message_received_; | 63 std::string last_message_received_; |
64 | 64 |
65 private: | 65 private: |
66 DISALLOW_COPY_AND_ASSIGN(RemoteSecurityKeyIpcServerTest); | 66 DISALLOW_COPY_AND_ASSIGN(RemoteSecurityKeyIpcServerTest); |
(...skipping 290 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. | 357 // Now wait for the timeout period for the connection to be torn down. |
358 base::Time start_time(base::Time::NowFromSystemTime()); | 358 base::Time start_time(base::Time::NowFromSystemTime()); |
359 WaitForOperationComplete(); | 359 WaitForOperationComplete(); |
360 base::TimeDelta elapsed_time = base::Time::NowFromSystemTime() - start_time; | 360 base::TimeDelta elapsed_time = base::Time::NowFromSystemTime() - start_time; |
361 | 361 |
362 ASSERT_NEAR(elapsed_time.InMilliseconds(), kInitialConnectTimeoutMs, | 362 ASSERT_NEAR(elapsed_time.InMilliseconds(), kInitialConnectTimeoutMs, |
363 kConnectionTimeoutErrorDeltaMs); | 363 kConnectionTimeoutErrorDeltaMs); |
364 } | 364 } |
365 | 365 |
366 } // namespace remoting | 366 } // namespace remoting |
OLD | NEW |