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

Unified Diff: remoting/protocol/message_reader_unittest.cc

Issue 10703159: Fix MessageReader to handle errors properly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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/protocol/message_reader.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/message_reader_unittest.cc
diff --git a/remoting/protocol/message_reader_unittest.cc b/remoting/protocol/message_reader_unittest.cc
index c228f93c29ce8d8087e860e3941a37babbcd13ab..78673438bbde9aed80328550a9d87073854ab296 100644
--- a/remoting/protocol/message_reader_unittest.cc
+++ b/remoting/protocol/message_reader_unittest.cc
@@ -11,6 +11,7 @@
#include "base/stl_util.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
+#include "net/base/net_errors.h"
#include "net/socket/socket.h"
#include "remoting/protocol/fake_session.h"
#include "remoting/protocol/message_reader.h"
@@ -269,7 +270,6 @@ TEST_F(MessageReaderTest, UseSocketOnCorrectThread) {
other_thread_.Start();
EXPECT_CALL(callback_, OnMessage(_))
- .Times(1)
.WillOnce(Invoke(this, &MessageReaderTest::RunDoneTaskOnOtherThread));
InitReader();
@@ -277,10 +277,11 @@ TEST_F(MessageReaderTest, UseSocketOnCorrectThread) {
run_task_finished_.Wait();
message_loop_.RunAllPending();
+ Mock::VerifyAndClearExpectations(&callback_);
+
// Write another message and verify that we receive it.
base::Closure done_task;
EXPECT_CALL(callback_, OnMessage(_))
- .Times(1)
.WillOnce(SaveArg<0>(&done_task));
AddMessage(kTestMessage2);
EXPECT_TRUE(CompareResult(messages_[1], kTestMessage2));
@@ -288,5 +289,18 @@ TEST_F(MessageReaderTest, UseSocketOnCorrectThread) {
done_task.Run();
}
+// Read() returns error.
+TEST_F(MessageReaderTest, ReadError) {
+ socket_.set_next_read_error(net::ERR_FAILED);
+
+ // Add a message. It should never be read after the error above.
+ AddMessage(kTestMessage1);
+
+ EXPECT_CALL(callback_, OnMessage(_))
+ .Times(0);
+
+ InitReader();
+}
+
} // namespace protocol
} // namespace remoting
« no previous file with comments | « remoting/protocol/message_reader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698