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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "google_apis/gcm/base/mcs_util.h" | 8 #include "google_apis/gcm/base/mcs_util.h" |
9 #include "net/socket/stream_socket.h" | 9 #include "net/socket/stream_socket.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 write_callback_(write_callback), | 32 write_callback_(write_callback), |
33 fail_login_(false), | 33 fail_login_(false), |
34 fail_send_(false), | 34 fail_send_(false), |
35 initialized_(false) { | 35 initialized_(false) { |
36 } | 36 } |
37 | 37 |
38 FakeConnectionHandler::~FakeConnectionHandler() { | 38 FakeConnectionHandler::~FakeConnectionHandler() { |
39 } | 39 } |
40 | 40 |
41 void FakeConnectionHandler::Init(const mcs_proto::LoginRequest& login_request, | 41 void FakeConnectionHandler::Init(const mcs_proto::LoginRequest& login_request, |
42 scoped_ptr<net::StreamSocket> socket) { | 42 net::StreamSocket* socket) { |
43 EXPECT_EQ(expected_outgoing_messages_.front().SerializeAsString(), | 43 EXPECT_EQ(expected_outgoing_messages_.front().SerializeAsString(), |
44 login_request.SerializeAsString()); | 44 login_request.SerializeAsString()); |
45 expected_outgoing_messages_.pop_front(); | 45 expected_outgoing_messages_.pop_front(); |
46 DVLOG(1) << "Received init call."; | 46 DVLOG(1) << "Received init call."; |
47 read_callback_.Run(BuildLoginResponse(fail_login_)); | 47 read_callback_.Run(BuildLoginResponse(fail_login_)); |
48 initialized_ = !fail_login_; | 48 initialized_ = !fail_login_; |
49 } | 49 } |
50 | 50 |
51 bool FakeConnectionHandler::CanSendMessage() const { | 51 bool FakeConnectionHandler::CanSendMessage() const { |
52 return initialized_; | 52 return initialized_; |
(...skipping 24 matching lines...) Expand all Loading... |
77 | 77 |
78 bool FakeConnectionHandler::AllOutgoingMessagesReceived() const { | 78 bool FakeConnectionHandler::AllOutgoingMessagesReceived() const { |
79 return expected_outgoing_messages_.empty(); | 79 return expected_outgoing_messages_.empty(); |
80 } | 80 } |
81 | 81 |
82 void FakeConnectionHandler::ReceiveMessage(const MCSMessage& message) { | 82 void FakeConnectionHandler::ReceiveMessage(const MCSMessage& message) { |
83 read_callback_.Run(message.CloneProtobuf()); | 83 read_callback_.Run(message.CloneProtobuf()); |
84 } | 84 } |
85 | 85 |
86 } // namespace gcm | 86 } // namespace gcm |
OLD | NEW |