OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 14 #include "net/base/net_errors.h" |
14 #include "net/socket/socket.h" | 15 #include "net/socket/socket.h" |
15 #include "remoting/protocol/fake_session.h" | 16 #include "remoting/protocol/fake_session.h" |
16 #include "remoting/protocol/message_reader.h" | 17 #include "remoting/protocol/message_reader.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
19 #include "third_party/libjingle/source/talk/base/byteorder.h" | 20 #include "third_party/libjingle/source/talk/base/byteorder.h" |
20 | 21 |
21 using testing::_; | 22 using testing::_; |
22 using testing::DoAll; | 23 using testing::DoAll; |
23 using testing::Mock; | 24 using testing::Mock; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 base::Closure done_task; | 282 base::Closure done_task; |
282 EXPECT_CALL(callback_, OnMessage(_)) | 283 EXPECT_CALL(callback_, OnMessage(_)) |
283 .Times(1) | 284 .Times(1) |
284 .WillOnce(SaveArg<0>(&done_task)); | 285 .WillOnce(SaveArg<0>(&done_task)); |
285 AddMessage(kTestMessage2); | 286 AddMessage(kTestMessage2); |
286 EXPECT_TRUE(CompareResult(messages_[1], kTestMessage2)); | 287 EXPECT_TRUE(CompareResult(messages_[1], kTestMessage2)); |
287 | 288 |
288 done_task.Run(); | 289 done_task.Run(); |
289 } | 290 } |
290 | 291 |
| 292 // Read() returns error. |
| 293 TEST_F(MessageReaderTest, ReadError) { |
| 294 socket_.set_next_read_error(net::ERR_FAILED); |
| 295 |
| 296 // Add a message. It should never be read after the error above. |
| 297 AddMessage(kTestMessage1); |
| 298 |
| 299 EXPECT_CALL(callback_, OnMessage(_)) |
| 300 .Times(0); |
| 301 |
| 302 InitReader(); |
| 303 } |
| 304 |
291 } // namespace protocol | 305 } // namespace protocol |
292 } // namespace remoting | 306 } // namespace remoting |
OLD | NEW |