OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "google_apis/gcm/engine/fake_connection_handler.h" | 5 #include "google_apis/gcm/engine/fake_connection_handler.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "google_apis/gcm/base/mcs_util.h" | 10 #include "google_apis/gcm/base/mcs_util.h" |
9 #include "net/socket/stream_socket.h" | 11 #include "net/socket/stream_socket.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
11 | 13 |
12 namespace gcm { | 14 namespace gcm { |
13 | 15 |
14 namespace { | 16 namespace { |
15 | 17 |
16 // Build a basic login response. | 18 // Build a basic login response. |
17 scoped_ptr<google::protobuf::MessageLite> BuildLoginResponse(bool fail_login) { | 19 scoped_ptr<google::protobuf::MessageLite> BuildLoginResponse(bool fail_login) { |
18 scoped_ptr<mcs_proto::LoginResponse> login_response( | 20 scoped_ptr<mcs_proto::LoginResponse> login_response( |
19 new mcs_proto::LoginResponse()); | 21 new mcs_proto::LoginResponse()); |
20 login_response->set_id("id"); | 22 login_response->set_id("id"); |
21 if (fail_login) | 23 if (fail_login) |
22 login_response->mutable_error()->set_code(1); | 24 login_response->mutable_error()->set_code(1); |
23 return login_response.Pass(); | 25 return std::move(login_response); |
24 } | 26 } |
25 | 27 |
26 } // namespace | 28 } // namespace |
27 | 29 |
28 FakeConnectionHandler::FakeConnectionHandler( | 30 FakeConnectionHandler::FakeConnectionHandler( |
29 const ConnectionHandler::ProtoReceivedCallback& read_callback, | 31 const ConnectionHandler::ProtoReceivedCallback& read_callback, |
30 const ConnectionHandler::ProtoSentCallback& write_callback) | 32 const ConnectionHandler::ProtoSentCallback& write_callback) |
31 : read_callback_(read_callback), | 33 : read_callback_(read_callback), |
32 write_callback_(write_callback), | 34 write_callback_(write_callback), |
33 fail_login_(false), | 35 fail_login_(false), |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 86 |
85 bool FakeConnectionHandler::AllOutgoingMessagesReceived() const { | 87 bool FakeConnectionHandler::AllOutgoingMessagesReceived() const { |
86 return expected_outgoing_messages_.empty(); | 88 return expected_outgoing_messages_.empty(); |
87 } | 89 } |
88 | 90 |
89 void FakeConnectionHandler::ReceiveMessage(const MCSMessage& message) { | 91 void FakeConnectionHandler::ReceiveMessage(const MCSMessage& message) { |
90 read_callback_.Run(message.CloneProtobuf()); | 92 read_callback_.Run(message.CloneProtobuf()); |
91 } | 93 } |
92 | 94 |
93 } // namespace gcm | 95 } // namespace gcm |
OLD | NEW |