| 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/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 task.Run(); | 60 task.Run(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 // Used by the DeleteFromCallback() test. | 63 // Used by the DeleteFromCallback() test. |
| 64 void DeleteReader(const base::Closure& task) { | 64 void DeleteReader(const base::Closure& task) { |
| 65 reader_.reset(); | 65 reader_.reset(); |
| 66 task.Run(); | 66 task.Run(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 protected: | 69 protected: |
| 70 void SetUp() override { reader_.reset(new MessageReader()); } | 70 void SetUp() override { |
| 71 reader_.reset(new MessageReader()); |
| 72 } |
| 71 | 73 |
| 72 void TearDown() override { STLDeleteElements(&messages_); } | 74 void TearDown() override { STLDeleteElements(&messages_); } |
| 73 | 75 |
| 74 void InitReader() { | 76 void InitReader() { |
| 75 reader_->Init(&socket_, base::Bind( | 77 reader_->SetMessageReceivedCallback( |
| 76 &MessageReaderTest::OnMessage, base::Unretained(this))); | 78 base::Bind(&MessageReaderTest::OnMessage, base::Unretained(this))); |
| 79 reader_->StartReading(&socket_); |
| 77 } | 80 } |
| 78 | 81 |
| 79 void AddMessage(const std::string& message) { | 82 void AddMessage(const std::string& message) { |
| 80 std::string data = std::string(4, ' ') + message; | 83 std::string data = std::string(4, ' ') + message; |
| 81 rtc::SetBE32(const_cast<char*>(data.data()), message.size()); | 84 rtc::SetBE32(const_cast<char*>(data.data()), message.size()); |
| 82 | 85 |
| 83 socket_.AppendInputData(data); | 86 socket_.AppendInputData(data); |
| 84 } | 87 } |
| 85 | 88 |
| 86 bool CompareResult(CompoundBuffer* buffer, const std::string& expected) { | 89 bool CompareResult(CompoundBuffer* buffer, const std::string& expected) { |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 EXPECT_CALL(callback_, OnMessage(_)) | 317 EXPECT_CALL(callback_, OnMessage(_)) |
| 315 .Times(1) | 318 .Times(1) |
| 316 .WillOnce(Invoke(this, &MessageReaderTest::DeleteReader)); | 319 .WillOnce(Invoke(this, &MessageReaderTest::DeleteReader)); |
| 317 | 320 |
| 318 InitReader(); | 321 InitReader(); |
| 319 base::RunLoop().RunUntilIdle(); | 322 base::RunLoop().RunUntilIdle(); |
| 320 } | 323 } |
| 321 | 324 |
| 322 } // namespace protocol | 325 } // namespace protocol |
| 323 } // namespace remoting | 326 } // namespace remoting |
| OLD | NEW |