Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Unified Diff: remoting/host/security_key/remote_security_key_message_reader_impl_unittest.cc

Issue 1852283003: Updating Message Reader and Writer classes to use an interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing feedback Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/host/security_key/remote_security_key_message_reader_impl_unittest.cc
diff --git a/remoting/host/security_key/remote_security_key_message_reader_unittest.cc b/remoting/host/security_key/remote_security_key_message_reader_impl_unittest.cc
similarity index 75%
rename from remoting/host/security_key/remote_security_key_message_reader_unittest.cc
rename to remoting/host/security_key/remote_security_key_message_reader_impl_unittest.cc
index 0fa82c0e710176f3b82b60c9592306c19bd77032..bac8980ac3c80de0ab172e6c303387c8f9ad3b93 100644
--- a/remoting/host/security_key/remote_security_key_message_reader_unittest.cc
+++ b/remoting/host/security_key/remote_security_key_message_reader_impl_unittest.cc
@@ -12,6 +12,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
+#include "remoting/host/security_key/remote_security_key_message_reader_impl.h"
#include "remoting/host/security_key/security_key_message.h"
#include "remoting/host/setup/test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -24,10 +25,10 @@ const uint32_t kMaxSecurityKeyMessageByteCount = 256 * 1024;
namespace remoting {
-class RemoteSecurityKeyMessageReaderTest : public testing::Test {
+class RemoteSecurityKeyMessageReaderImplTest : public testing::Test {
public:
- RemoteSecurityKeyMessageReaderTest();
- ~RemoteSecurityKeyMessageReaderTest() override;
+ RemoteSecurityKeyMessageReaderImplTest();
+ ~RemoteSecurityKeyMessageReaderImplTest() override;
// SecurityKeyMessageCallback passed to the Reader. Stores |message| so it can
// be verified by tests.
@@ -57,36 +58,38 @@ class RemoteSecurityKeyMessageReaderTest : public testing::Test {
base::MessageLoopForIO message_loop_;
base::RunLoop run_loop_;
- DISALLOW_COPY_AND_ASSIGN(RemoteSecurityKeyMessageReaderTest);
+ DISALLOW_COPY_AND_ASSIGN(RemoteSecurityKeyMessageReaderImplTest);
};
-RemoteSecurityKeyMessageReaderTest::RemoteSecurityKeyMessageReaderTest() {}
+RemoteSecurityKeyMessageReaderImplTest::
+ RemoteSecurityKeyMessageReaderImplTest() {}
-RemoteSecurityKeyMessageReaderTest::~RemoteSecurityKeyMessageReaderTest() {}
+RemoteSecurityKeyMessageReaderImplTest::
+ ~RemoteSecurityKeyMessageReaderImplTest() {}
-void RemoteSecurityKeyMessageReaderTest::SetUp() {
+void RemoteSecurityKeyMessageReaderImplTest::SetUp() {
ASSERT_TRUE(MakePipe(&read_file_, &write_file_));
- reader_.reset(new RemoteSecurityKeyMessageReader(std::move(read_file_)));
+ reader_.reset(new RemoteSecurityKeyMessageReaderImpl(std::move(read_file_)));
// base::Unretained is safe since no further tasks can run after
// RunLoop::Run() returns.
- reader_->Start(base::Bind(&RemoteSecurityKeyMessageReaderTest::OnMessage,
+ reader_->Start(base::Bind(&RemoteSecurityKeyMessageReaderImplTest::OnMessage,
base::Unretained(this)),
run_loop_.QuitClosure());
}
-void RemoteSecurityKeyMessageReaderTest::Run() {
+void RemoteSecurityKeyMessageReaderImplTest::Run() {
// Close the write-end, so the reader doesn't block waiting for more data.
write_file_.Close();
run_loop_.Run();
}
-void RemoteSecurityKeyMessageReaderTest::OnMessage(
+void RemoteSecurityKeyMessageReaderImplTest::OnMessage(
scoped_ptr<SecurityKeyMessage> message) {
messages_received_.push_back(std::move(message));
}
-void RemoteSecurityKeyMessageReaderTest::WriteMessage(
+void RemoteSecurityKeyMessageReaderImplTest::WriteMessage(
RemoteSecurityKeyMessageType message_type,
const std::string& message_payload) {
uint32_t length =
@@ -100,13 +103,13 @@ void RemoteSecurityKeyMessageReaderTest::WriteMessage(
}
}
-void RemoteSecurityKeyMessageReaderTest::WriteData(const char* data,
- int length) {
+void RemoteSecurityKeyMessageReaderImplTest::WriteData(const char* data,
+ int length) {
int written = write_file_.WriteAtCurrentPos(data, length);
ASSERT_EQ(length, written);
}
-TEST_F(RemoteSecurityKeyMessageReaderTest, EnsureReaderTornDownCleanly) {
+TEST_F(RemoteSecurityKeyMessageReaderImplTest, EnsureReaderTornDownCleanly) {
// This test is different from the others as the files used for reading and
// writing are still open when the reader instance is destroyed. This test is
// meant to ensure that no asserts/exceptions/hangs occur during shutdown.
@@ -114,7 +117,7 @@ TEST_F(RemoteSecurityKeyMessageReaderTest, EnsureReaderTornDownCleanly) {
reader_.reset();
}
-TEST_F(RemoteSecurityKeyMessageReaderTest, SingleMessageWithNoPayload) {
+TEST_F(RemoteSecurityKeyMessageReaderImplTest, SingleMessageWithNoPayload) {
WriteMessage(kTestMessageType, std::string());
Run();
ASSERT_EQ(1u, messages_received_.size());
@@ -122,7 +125,7 @@ TEST_F(RemoteSecurityKeyMessageReaderTest, SingleMessageWithNoPayload) {
ASSERT_EQ("", messages_received_[0]->payload());
}
-TEST_F(RemoteSecurityKeyMessageReaderTest, SingleMessageWithPayload) {
+TEST_F(RemoteSecurityKeyMessageReaderImplTest, SingleMessageWithPayload) {
std::string payload("I AM A VALID MESSAGE PAYLOAD!!!!!!!!!!!!!!!!!!!!!!");
WriteMessage(kTestMessageType, payload);
Run();
@@ -131,7 +134,7 @@ TEST_F(RemoteSecurityKeyMessageReaderTest, SingleMessageWithPayload) {
ASSERT_EQ(payload, messages_received_[0]->payload());
}
-TEST_F(RemoteSecurityKeyMessageReaderTest, SingleMessageWithLargePayload) {
+TEST_F(RemoteSecurityKeyMessageReaderImplTest, SingleMessageWithLargePayload) {
std::string payload(kMaxSecurityKeyMessageByteCount -
SecurityKeyMessage::kMessageTypeSizeBytes,
'Y');
@@ -142,12 +145,12 @@ TEST_F(RemoteSecurityKeyMessageReaderTest, SingleMessageWithLargePayload) {
ASSERT_EQ(payload, messages_received_[0]->payload());
}
-TEST_F(RemoteSecurityKeyMessageReaderTest, EmptyFile) {
+TEST_F(RemoteSecurityKeyMessageReaderImplTest, EmptyFile) {
Run();
ASSERT_EQ(0u, messages_received_.size());
}
-TEST_F(RemoteSecurityKeyMessageReaderTest, InvalidMessageLength) {
+TEST_F(RemoteSecurityKeyMessageReaderImplTest, InvalidMessageLength) {
uint32_t length = kMaxSecurityKeyMessageByteCount + 1;
ASSERT_FALSE(SecurityKeyMessage::IsValidMessageSize(length));
WriteData(reinterpret_cast<char*>(&length), sizeof(length));
@@ -155,28 +158,28 @@ TEST_F(RemoteSecurityKeyMessageReaderTest, InvalidMessageLength) {
ASSERT_EQ(0u, messages_received_.size());
}
-TEST_F(RemoteSecurityKeyMessageReaderTest, ShortHeader) {
+TEST_F(RemoteSecurityKeyMessageReaderImplTest, ShortHeader) {
// Write only 3 bytes - the message length header is supposed to be 4 bytes.
WriteData("xxx", SecurityKeyMessage::kHeaderSizeBytes - 1);
Run();
ASSERT_EQ(0u, messages_received_.size());
}
-TEST_F(RemoteSecurityKeyMessageReaderTest, ZeroLengthMessage) {
+TEST_F(RemoteSecurityKeyMessageReaderImplTest, ZeroLengthMessage) {
uint32_t length = 0;
WriteData(reinterpret_cast<char*>(&length), sizeof(length));
Run();
ASSERT_EQ(0u, messages_received_.size());
}
-TEST_F(RemoteSecurityKeyMessageReaderTest, MissingControlCode) {
+TEST_F(RemoteSecurityKeyMessageReaderImplTest, MissingControlCode) {
uint32_t length = 1;
WriteData(reinterpret_cast<char*>(&length), sizeof(length));
Run();
ASSERT_EQ(0u, messages_received_.size());
}
-TEST_F(RemoteSecurityKeyMessageReaderTest, MissingPayload) {
+TEST_F(RemoteSecurityKeyMessageReaderImplTest, MissingPayload) {
uint32_t length = 2;
WriteData(reinterpret_cast<char*>(&length), sizeof(length));
@@ -186,7 +189,7 @@ TEST_F(RemoteSecurityKeyMessageReaderTest, MissingPayload) {
ASSERT_EQ(0u, messages_received_.size());
}
-TEST_F(RemoteSecurityKeyMessageReaderTest, MultipleMessages) {
+TEST_F(RemoteSecurityKeyMessageReaderImplTest, MultipleMessages) {
std::vector<std::string> payloads({"", "S", // Really short
"", "Short", "", "Medium Length", "",
"Longer than medium, but not super long",

Powered by Google App Engine
This is Rietveld 408576698