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" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 buffer->CopyTo(const_cast<char*>(result.data()), result.size()); | 91 buffer->CopyTo(const_cast<char*>(result.data()), result.size()); |
92 return result == expected; | 92 return result == expected; |
93 } | 93 } |
94 | 94 |
95 void OnMessage(scoped_ptr<CompoundBuffer> buffer, | 95 void OnMessage(scoped_ptr<CompoundBuffer> buffer, |
96 const base::Closure& done_callback) { | 96 const base::Closure& done_callback) { |
97 messages_.push_back(buffer.release()); | 97 messages_.push_back(buffer.release()); |
98 callback_.OnMessage(done_callback); | 98 callback_.OnMessage(done_callback); |
99 } | 99 } |
100 | 100 |
101 MessageLoop message_loop_; | 101 base::MessageLoop message_loop_; |
102 scoped_ptr<MessageReader> reader_; | 102 scoped_ptr<MessageReader> reader_; |
103 FakeSocket socket_; | 103 FakeSocket socket_; |
104 MockMessageReceivedCallback callback_; | 104 MockMessageReceivedCallback callback_; |
105 std::vector<CompoundBuffer*> messages_; | 105 std::vector<CompoundBuffer*> messages_; |
106 bool in_callback_; | 106 bool in_callback_; |
107 }; | 107 }; |
108 | 108 |
109 // Receive one message and process it with delay | 109 // Receive one message and process it with delay |
110 TEST_F(MessageReaderTest, OneMessage_Delay) { | 110 TEST_F(MessageReaderTest, OneMessage_Delay) { |
111 base::Closure done_task; | 111 base::Closure done_task; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 EXPECT_CALL(callback_, OnMessage(_)) | 317 EXPECT_CALL(callback_, OnMessage(_)) |
318 .Times(1) | 318 .Times(1) |
319 .WillOnce(Invoke(this, &MessageReaderTest::DeleteReader)); | 319 .WillOnce(Invoke(this, &MessageReaderTest::DeleteReader)); |
320 | 320 |
321 InitReader(); | 321 InitReader(); |
322 message_loop_.RunUntilIdle(); | 322 message_loop_.RunUntilIdle(); |
323 } | 323 } |
324 | 324 |
325 } // namespace protocol | 325 } // namespace protocol |
326 } // namespace remoting | 326 } // namespace remoting |
OLD | NEW |