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

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: Fixing the formatting for the changed files. 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_impl_unittest.cc b/remoting/host/security_key/remote_security_key_message_reader_impl_unittest.cc
index 88d5d71fc109a9d2bdde13eb182873bf5e900bdd..88817e9210632e60d9ebef4a466dabef4d8a71b2 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,26 @@ 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, SingleMessageWithLargePayload) {
std::string payload(kMaxSecurityKeyMessageByteCount -
SecurityKeyMessage::kMessageTypeSizeBytes,
@@ -210,13 +230,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++) {

Powered by Google App Engine
This is Rietveld 408576698