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

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

Issue 1900733002: Fixing a Dr. Memory hang in the remoting_unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing CR 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
« no previous file with comments | « remoting/host/security_key/remote_security_key_message_reader_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_impl_unittest.cc b/remoting/host/security_key/remote_security_key_message_reader_impl_unittest.cc
index 88d5d71fc109a9d2bdde13eb182873bf5e900bdd..c9c2d92ef3f5a9135b9b383f5dfd1a413695b26e 100644
--- a/remoting/host/security_key/remote_security_key_message_reader_impl_unittest.cc
+++ b/remoting/host/security_key/remote_security_key_message_reader_impl_unittest.cc
@@ -148,6 +148,49 @@ TEST_F(RemoteSecurityKeyMessageReaderImplTest, SingleMessageWithPayload) {
CloseWriteFileAndRunLoop();
}
+TEST_F(RemoteSecurityKeyMessageReaderImplTest, SingleMessageViaSingleWrite) {
+ // All other tests write in 2-3 chunks, this writes the message in one shot.
+ std::string payload("LLLLTI am the best payload in the history of testing.");
+ // Overwite the 'L' values with the actual length.
+ uint8_t length = payload.size() - SecurityKeyMessage::kHeaderSizeBytes;
+ payload[0] = static_cast<char>(length);
+ payload[1] = 0;
+ payload[2] = 0;
+ payload[3] = 0;
+ // Overwite the 'T' value with the actual type.
+ payload[4] = static_cast<char>(kTestMessageType);
+ WriteData(payload.data(), payload.size());
+ RunLoop();
+ ASSERT_EQ(1u, messages_received_.size());
+ ASSERT_EQ(kTestMessageType, messages_received_[0]->type());
+ ASSERT_EQ(payload.substr(5), messages_received_[0]->payload());
+
+ CloseWriteFileAndRunLoop();
+}
+
+TEST_F(RemoteSecurityKeyMessageReaderImplTest, SingleMessageViaMultipleWrites) {
+ // All other tests write in 2-3 chunks, this writes the message byte by byte.
+ std::string payload("LLLLTI am the worst payload in the history of testing.");
+ // Overwite the 'L' values with the actual length.
+ uint8_t length = payload.size() - SecurityKeyMessage::kHeaderSizeBytes;
+ payload[0] = static_cast<char>(length);
+ payload[1] = 0;
+ payload[2] = 0;
+ payload[3] = 0;
+ // Overwite the 'T' value with the actual type.
+ payload[4] = static_cast<char>(kTestMessageType);
+
+ for (uint32_t i = 0; i < payload.size(); i++) {
+ WriteData(&payload[i], 1);
+ }
+ RunLoop();
+ ASSERT_EQ(1u, messages_received_.size());
+ ASSERT_EQ(kTestMessageType, messages_received_[0]->type());
+ ASSERT_EQ(payload.substr(5), messages_received_[0]->payload());
+
+ CloseWriteFileAndRunLoop();
+}
+
TEST_F(RemoteSecurityKeyMessageReaderImplTest, SingleMessageWithLargePayload) {
std::string payload(kMaxSecurityKeyMessageByteCount -
SecurityKeyMessage::kMessageTypeSizeBytes,
@@ -210,13 +253,11 @@ TEST_F(RemoteSecurityKeyMessageReaderImplTest, MultipleMessages) {
"", "Short", "", "Medium Length", "",
"Longer than medium, but not super long",
"", std::string(2048, 'Y'), ""});
-
- for (auto& payload : payloads) {
- WriteMessage(kTestMessageType, payload);
+ for (size_t i = 0; i < payloads.size(); i++) {
+ WriteMessage(kTestMessageType, payloads[i]);
RunLoop();
+ ASSERT_EQ(i + 1, messages_received_.size());
}
-
- ASSERT_EQ(payloads.size(), messages_received_.size());
CloseWriteFileAndRunLoop();
for (size_t i = 0; i < payloads.size(); i++) {
« no previous file with comments | « remoting/host/security_key/remote_security_key_message_reader_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698