| Index: remoting/host/security_key/security_key_message_writer_impl_unittest.cc
|
| diff --git a/remoting/host/security_key/remote_security_key_message_writer_impl_unittest.cc b/remoting/host/security_key/security_key_message_writer_impl_unittest.cc
|
| similarity index 72%
|
| rename from remoting/host/security_key/remote_security_key_message_writer_impl_unittest.cc
|
| rename to remoting/host/security_key/security_key_message_writer_impl_unittest.cc
|
| index 58847727259dfea22e4478003b30a9f3cefebabb..7545ab61b3688493d9370d5cb98415078711278c 100644
|
| --- a/remoting/host/security_key/remote_security_key_message_writer_impl_unittest.cc
|
| +++ b/remoting/host/security_key/security_key_message_writer_impl_unittest.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "remoting/host/security_key/remote_security_key_message_writer_impl.h"
|
| +#include "remoting/host/security_key/security_key_message_writer_impl.h"
|
|
|
| #include <cstdint>
|
| #include <memory>
|
| @@ -20,17 +20,17 @@
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| namespace {
|
| -const remoting::RemoteSecurityKeyMessageType kTestMessageType =
|
| - remoting::RemoteSecurityKeyMessageType::CONNECT;
|
| +const remoting::SecurityKeyMessageType kTestMessageType =
|
| + remoting::SecurityKeyMessageType::CONNECT;
|
| const unsigned int kLargeMessageSizeBytes = 200000;
|
| } // namespace
|
|
|
| namespace remoting {
|
|
|
| -class RemoteSecurityKeyMessageWriterImplTest : public testing::Test {
|
| +class SecurityKeyMessageWriterImplTest : public testing::Test {
|
| public:
|
| - RemoteSecurityKeyMessageWriterImplTest();
|
| - ~RemoteSecurityKeyMessageWriterImplTest() override;
|
| + SecurityKeyMessageWriterImplTest();
|
| + ~SecurityKeyMessageWriterImplTest() override;
|
|
|
| // Run on a separate thread, this method reads the message written to the
|
| // output stream and returns the result.
|
| @@ -48,7 +48,7 @@ class RemoteSecurityKeyMessageWriterImplTest : public testing::Test {
|
| // they were written correctly.
|
| void WriteMessageToOutput(const std::string& payload);
|
|
|
| - std::unique_ptr<RemoteSecurityKeyMessageWriter> writer_;
|
| + std::unique_ptr<SecurityKeyMessageWriter> writer_;
|
| base::File read_file_;
|
| base::File write_file_;
|
|
|
| @@ -56,16 +56,14 @@ class RemoteSecurityKeyMessageWriterImplTest : public testing::Test {
|
| std::string message_result_;
|
|
|
| private:
|
| - DISALLOW_COPY_AND_ASSIGN(RemoteSecurityKeyMessageWriterImplTest);
|
| + DISALLOW_COPY_AND_ASSIGN(SecurityKeyMessageWriterImplTest);
|
| };
|
|
|
| -RemoteSecurityKeyMessageWriterImplTest::
|
| - RemoteSecurityKeyMessageWriterImplTest() {}
|
| +SecurityKeyMessageWriterImplTest::SecurityKeyMessageWriterImplTest() {}
|
|
|
| -RemoteSecurityKeyMessageWriterImplTest::
|
| - ~RemoteSecurityKeyMessageWriterImplTest() {}
|
| +SecurityKeyMessageWriterImplTest::~SecurityKeyMessageWriterImplTest() {}
|
|
|
| -std::string RemoteSecurityKeyMessageWriterImplTest::ReadMessage(
|
| +std::string SecurityKeyMessageWriterImplTest::ReadMessage(
|
| int payload_length_bytes) {
|
| std::string message_header(SecurityKeyMessage::kHeaderSizeBytes, '\0');
|
| read_file_.ReadAtCurrentPos(string_as_array(&message_header),
|
| @@ -84,19 +82,19 @@ std::string RemoteSecurityKeyMessageWriterImplTest::ReadMessage(
|
| return message_header + message_type + message_data;
|
| }
|
|
|
| -void RemoteSecurityKeyMessageWriterImplTest::OnReadComplete(
|
| +void SecurityKeyMessageWriterImplTest::OnReadComplete(
|
| const base::Closure& done_callback,
|
| const std::string& result) {
|
| message_result_ = result;
|
| done_callback.Run();
|
| }
|
|
|
| -void RemoteSecurityKeyMessageWriterImplTest::SetUp() {
|
| +void SecurityKeyMessageWriterImplTest::SetUp() {
|
| ASSERT_TRUE(MakePipe(&read_file_, &write_file_));
|
| - writer_.reset(new RemoteSecurityKeyMessageWriterImpl(std::move(write_file_)));
|
| + writer_.reset(new SecurityKeyMessageWriterImpl(std::move(write_file_)));
|
| }
|
|
|
| -void RemoteSecurityKeyMessageWriterImplTest::WriteMessageToOutput(
|
| +void SecurityKeyMessageWriterImplTest::WriteMessageToOutput(
|
| const std::string& payload) {
|
| // Thread used for blocking IO operations.
|
| base::Thread reader_thread("ReaderThread");
|
| @@ -111,9 +109,9 @@ void RemoteSecurityKeyMessageWriterImplTest::WriteMessageToOutput(
|
|
|
| ASSERT_TRUE(base::PostTaskAndReplyWithResult(
|
| reader_thread.task_runner().get(), FROM_HERE,
|
| - base::Bind(&RemoteSecurityKeyMessageWriterImplTest::ReadMessage,
|
| + base::Bind(&SecurityKeyMessageWriterImplTest::ReadMessage,
|
| base::Unretained(this), payload.size()),
|
| - base::Bind(&RemoteSecurityKeyMessageWriterImplTest::OnReadComplete,
|
| + base::Bind(&SecurityKeyMessageWriterImplTest::OnReadComplete,
|
| base::Unretained(this), run_loop.QuitClosure())));
|
|
|
| if (payload.size()) {
|
| @@ -129,7 +127,7 @@ void RemoteSecurityKeyMessageWriterImplTest::WriteMessageToOutput(
|
| payload.size();
|
| ASSERT_EQ(message_result_.size(), total_size);
|
|
|
| - RemoteSecurityKeyMessageType type =
|
| + SecurityKeyMessageType type =
|
| SecurityKeyMessage::MessageTypeFromValue(message_result_[4]);
|
| ASSERT_EQ(kTestMessageType, type);
|
|
|
| @@ -143,26 +141,26 @@ void RemoteSecurityKeyMessageWriterImplTest::WriteMessageToOutput(
|
| ASSERT_LE(read_file_.ReadAtCurrentPos(&unused, 1), 0);
|
| }
|
|
|
| -TEST_F(RemoteSecurityKeyMessageWriterImplTest, WriteMessageWithoutPayload) {
|
| +TEST_F(SecurityKeyMessageWriterImplTest, WriteMessageWithoutPayload) {
|
| std::string empty_payload;
|
| WriteMessageToOutput(empty_payload);
|
| }
|
|
|
| -TEST_F(RemoteSecurityKeyMessageWriterImplTest, WriteMessageWithPayload) {
|
| +TEST_F(SecurityKeyMessageWriterImplTest, WriteMessageWithPayload) {
|
| WriteMessageToOutput("Super-test-payload!");
|
| }
|
|
|
| -TEST_F(RemoteSecurityKeyMessageWriterImplTest, WriteMessageWithLargePayload) {
|
| +TEST_F(SecurityKeyMessageWriterImplTest, WriteMessageWithLargePayload) {
|
| WriteMessageToOutput(std::string(kLargeMessageSizeBytes, 'Y'));
|
| }
|
|
|
| -TEST_F(RemoteSecurityKeyMessageWriterImplTest, WriteMultipleMessages) {
|
| +TEST_F(SecurityKeyMessageWriterImplTest, WriteMultipleMessages) {
|
| int total_messages_to_write = 10;
|
| for (int i = 0; i < total_messages_to_write; i++) {
|
| if (i % 2 == 0) {
|
| - ASSERT_TRUE(writer_->WriteMessage(RemoteSecurityKeyMessageType::CONNECT));
|
| + ASSERT_TRUE(writer_->WriteMessage(SecurityKeyMessageType::CONNECT));
|
| } else {
|
| - ASSERT_TRUE(writer_->WriteMessage(RemoteSecurityKeyMessageType::REQUEST));
|
| + ASSERT_TRUE(writer_->WriteMessage(SecurityKeyMessageType::REQUEST));
|
| }
|
| }
|
|
|
| @@ -179,12 +177,12 @@ TEST_F(RemoteSecurityKeyMessageWriterImplTest, WriteMultipleMessages) {
|
| read_file_.ReadAtCurrentPos(string_as_array(&message_type), length);
|
| ASSERT_EQ(length, bytes_read);
|
|
|
| - RemoteSecurityKeyMessageType type =
|
| + SecurityKeyMessageType type =
|
| SecurityKeyMessage::MessageTypeFromValue(message_type[0]);
|
| if (i % 2 == 0) {
|
| - ASSERT_EQ(RemoteSecurityKeyMessageType::CONNECT, type);
|
| + ASSERT_EQ(SecurityKeyMessageType::CONNECT, type);
|
| } else {
|
| - ASSERT_EQ(RemoteSecurityKeyMessageType::REQUEST, type);
|
| + ASSERT_EQ(SecurityKeyMessageType::REQUEST, type);
|
| }
|
| }
|
|
|
| @@ -194,7 +192,7 @@ TEST_F(RemoteSecurityKeyMessageWriterImplTest, WriteMultipleMessages) {
|
| ASSERT_LE(read_file_.ReadAtCurrentPos(&unused, 1), 0);
|
| }
|
|
|
| -TEST_F(RemoteSecurityKeyMessageWriterImplTest, EnsureWriteFailsWhenPipeClosed) {
|
| +TEST_F(SecurityKeyMessageWriterImplTest, EnsureWriteFailsWhenPipeClosed) {
|
| // Close the read end so that writing fails immediately.
|
| read_file_.Close();
|
|
|
|
|