OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 void InitReader() { | 62 void InitReader() { |
63 reader_->Init(&socket_, base::Bind( | 63 reader_->Init(&socket_, base::Bind( |
64 &MockMessageReceivedCallback::OnMessage, base::Unretained(&callback_))); | 64 &MockMessageReceivedCallback::OnMessage, base::Unretained(&callback_))); |
65 } | 65 } |
66 | 66 |
67 void AddMessage(const std::string& message) { | 67 void AddMessage(const std::string& message) { |
68 std::string data = std::string(4, ' ') + message; | 68 std::string data = std::string(4, ' ') + message; |
69 talk_base::SetBE32(const_cast<char*>(data.data()), message.size()); | 69 talk_base::SetBE32(const_cast<char*>(data.data()), message.size()); |
70 | 70 |
71 socket_.AppendInputData(data.data(), data.size()); | 71 socket_.AppendInputData(std::vector<char>(data.begin(), data.end())); |
72 } | 72 } |
73 | 73 |
74 bool CompareResult(CompoundBuffer* buffer, const std::string& expected) { | 74 bool CompareResult(CompoundBuffer* buffer, const std::string& expected) { |
75 std::string result(buffer->total_bytes(), ' '); | 75 std::string result(buffer->total_bytes(), ' '); |
76 buffer->CopyTo(const_cast<char*>(result.data()), result.size()); | 76 buffer->CopyTo(const_cast<char*>(result.data()), result.size()); |
77 return result == expected; | 77 return result == expected; |
78 } | 78 } |
79 | 79 |
80 void RunAndDeleteTask(const base::Closure& task) { | 80 void RunAndDeleteTask(const base::Closure& task) { |
81 task.Run(); | 81 task.Run(); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 .WillOnce(DoAll(SaveArg<0>(&buffer), | 285 .WillOnce(DoAll(SaveArg<0>(&buffer), |
286 SaveArg<1>(&done_task))); | 286 SaveArg<1>(&done_task))); |
287 AddMessage(kTestMessage2); | 287 AddMessage(kTestMessage2); |
288 EXPECT_TRUE(CompareResult(buffer, kTestMessage2)); | 288 EXPECT_TRUE(CompareResult(buffer, kTestMessage2)); |
289 | 289 |
290 RunAndDeleteTask(done_task); | 290 RunAndDeleteTask(done_task); |
291 } | 291 } |
292 | 292 |
293 } // namespace protocol | 293 } // namespace protocol |
294 } // namespace remoting | 294 } // namespace remoting |
OLD | NEW |