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_message_writer.h" | 5 #include "remoting/host/security_key/remote_security_key_message_writer_impl.h" |
6 | 6 |
7 #include <cstdint> | 7 #include <cstdint> |
| 8 #include <memory> |
8 #include <utility> | 9 #include <utility> |
9 | 10 |
10 #include "base/bind.h" | 11 #include "base/bind.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/task_runner_util.h" | 15 #include "base/task_runner_util.h" |
16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "remoting/host/security_key/remote_security_key_message_writer_impl.h" | |
19 #include "remoting/host/security_key/security_key_message.h" | 18 #include "remoting/host/security_key/security_key_message.h" |
20 #include "remoting/host/setup/test_util.h" | 19 #include "remoting/host/setup/test_util.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
22 | 21 |
23 namespace { | 22 namespace { |
24 const remoting::RemoteSecurityKeyMessageType kTestMessageType = | 23 const remoting::RemoteSecurityKeyMessageType kTestMessageType = |
25 remoting::RemoteSecurityKeyMessageType::CONNECT; | 24 remoting::RemoteSecurityKeyMessageType::CONNECT; |
26 const unsigned int kLargeMessageSizeBytes = 200000; | 25 const unsigned int kLargeMessageSizeBytes = 200000; |
27 } // namespace | 26 } // namespace |
28 | 27 |
(...skipping 13 matching lines...) Expand all Loading... |
42 const std::string& result); | 41 const std::string& result); |
43 | 42 |
44 protected: | 43 protected: |
45 // testing::Test interface. | 44 // testing::Test interface. |
46 void SetUp() override; | 45 void SetUp() override; |
47 | 46 |
48 // Writes |kTestMessageType| and |payload| to the output stream and verifies | 47 // Writes |kTestMessageType| and |payload| to the output stream and verifies |
49 // they were written correctly. | 48 // they were written correctly. |
50 void WriteMessageToOutput(const std::string& payload); | 49 void WriteMessageToOutput(const std::string& payload); |
51 | 50 |
52 scoped_ptr<RemoteSecurityKeyMessageWriter> writer_; | 51 std::unique_ptr<RemoteSecurityKeyMessageWriter> writer_; |
53 base::File read_file_; | 52 base::File read_file_; |
54 base::File write_file_; | 53 base::File write_file_; |
55 | 54 |
56 // Stores the result of the last read operation. | 55 // Stores the result of the last read operation. |
57 std::string message_result_; | 56 std::string message_result_; |
58 | 57 |
59 private: | 58 private: |
60 DISALLOW_COPY_AND_ASSIGN(RemoteSecurityKeyMessageWriterImplTest); | 59 DISALLOW_COPY_AND_ASSIGN(RemoteSecurityKeyMessageWriterImplTest); |
61 }; | 60 }; |
62 | 61 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 } | 195 } |
197 | 196 |
198 TEST_F(RemoteSecurityKeyMessageWriterImplTest, EnsureWriteFailsWhenPipeClosed) { | 197 TEST_F(RemoteSecurityKeyMessageWriterImplTest, EnsureWriteFailsWhenPipeClosed) { |
199 // Close the read end so that writing fails immediately. | 198 // Close the read end so that writing fails immediately. |
200 read_file_.Close(); | 199 read_file_.Close(); |
201 | 200 |
202 EXPECT_FALSE(writer_->WriteMessage(kTestMessageType)); | 201 EXPECT_FALSE(writer_->WriteMessage(kTestMessageType)); |
203 } | 202 } |
204 | 203 |
205 } // namespace remoting | 204 } // namespace remoting |
OLD | NEW |