| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/message_loop.h" | |
| 8 #include "net/socket/socket.h" | 7 #include "net/socket/socket.h" |
| 9 #include "remoting/protocol/fake_session.h" | 8 #include "remoting/protocol/fake_session.h" |
| 10 #include "remoting/protocol/message_reader.h" | 9 #include "remoting/protocol/message_reader.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
| 13 #include "third_party/libjingle/source/talk/base/byteorder.h" | 12 #include "third_party/libjingle/source/talk/base/byteorder.h" |
| 14 | 13 |
| 15 using testing::_; | 14 using testing::_; |
| 16 using testing::DoAll; | 15 using testing::DoAll; |
| 17 using testing::Mock; | 16 using testing::Mock; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 std::string result(buffer->total_bytes(), ' '); | 56 std::string result(buffer->total_bytes(), ' '); |
| 58 buffer->CopyTo(const_cast<char*>(result.data()), result.size()); | 57 buffer->CopyTo(const_cast<char*>(result.data()), result.size()); |
| 59 return result == expected; | 58 return result == expected; |
| 60 } | 59 } |
| 61 | 60 |
| 62 void RunAndDeleteTask(Task* task) { | 61 void RunAndDeleteTask(Task* task) { |
| 63 task->Run(); | 62 task->Run(); |
| 64 delete task; | 63 delete task; |
| 65 } | 64 } |
| 66 | 65 |
| 67 // MessageLoop must be first here, so that is is destroyed the last. | |
| 68 MessageLoop message_loop_; | |
| 69 | |
| 70 scoped_refptr<MessageReader> reader_; | 66 scoped_refptr<MessageReader> reader_; |
| 71 FakeSocket socket_; | 67 FakeSocket socket_; |
| 72 MockMessageReceivedCallback callback_; | 68 MockMessageReceivedCallback callback_; |
| 73 }; | 69 }; |
| 74 | 70 |
| 75 // Receive one message and process it with delay | 71 // Receive one message and process it with delay |
| 76 TEST_F(MessageReaderTest, OneMessage_Delay) { | 72 TEST_F(MessageReaderTest, OneMessage_Delay) { |
| 77 CompoundBuffer* buffer; | 73 CompoundBuffer* buffer; |
| 78 Task* done_task; | 74 Task* done_task; |
| 79 | 75 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 // finished processing the previous message. | 234 // finished processing the previous message. |
| 239 EXPECT_FALSE(socket_.read_pending()); | 235 EXPECT_FALSE(socket_.read_pending()); |
| 240 | 236 |
| 241 RunAndDeleteTask(done_task); | 237 RunAndDeleteTask(done_task); |
| 242 | 238 |
| 243 EXPECT_TRUE(socket_.read_pending()); | 239 EXPECT_TRUE(socket_.read_pending()); |
| 244 } | 240 } |
| 245 | 241 |
| 246 } // namespace protocol | 242 } // namespace protocol |
| 247 } // namespace remoting | 243 } // namespace remoting |
| OLD | NEW |