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/connection_handler_impl.h" | 5 #include "google_apis/gcm/engine/connection_handler_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/test/test_timeouts.h" | 15 #include "base/test/test_timeouts.h" |
16 #include "google/protobuf/io/coded_stream.h" | 16 #include "google/protobuf/io/coded_stream.h" |
17 #include "google/protobuf/io/zero_copy_stream_impl_lite.h" | 17 #include "google/protobuf/io/zero_copy_stream_impl_lite.h" |
18 #include "google/protobuf/wire_format_lite.h" | 18 #include "google/protobuf/wire_format_lite.h" |
19 #include "google_apis/gcm/base/mcs_util.h" | 19 #include "google_apis/gcm/base/mcs_util.h" |
20 #include "google_apis/gcm/base/socket_stream.h" | 20 #include "google_apis/gcm/base/socket_stream.h" |
21 #include "google_apis/gcm/protocol/mcs.pb.h" | 21 #include "google_apis/gcm/protocol/mcs.pb.h" |
| 22 #include "net/base/ip_address.h" |
22 #include "net/socket/socket_test_util.h" | 23 #include "net/socket/socket_test_util.h" |
23 #include "net/socket/stream_socket.h" | 24 #include "net/socket/stream_socket.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
25 | 26 |
26 namespace gcm { | 27 namespace gcm { |
27 namespace { | 28 namespace { |
28 | 29 |
29 typedef scoped_ptr<google::protobuf::MessageLite> ScopedMessage; | 30 typedef scoped_ptr<google::protobuf::MessageLite> ScopedMessage; |
30 typedef std::vector<net::MockRead> ReadList; | 31 typedef std::vector<net::MockRead> ReadList; |
31 typedef std::vector<net::MockWrite> WriteList; | 32 typedef std::vector<net::MockWrite> WriteList; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 scoped_ptr<net::StreamSocket> socket_; | 183 scoped_ptr<net::StreamSocket> socket_; |
183 net::MockClientSocketFactory socket_factory_; | 184 net::MockClientSocketFactory socket_factory_; |
184 net::AddressList address_list_; | 185 net::AddressList address_list_; |
185 | 186 |
186 base::MessageLoopForIO message_loop_; | 187 base::MessageLoopForIO message_loop_; |
187 scoped_ptr<base::RunLoop> run_loop_; | 188 scoped_ptr<base::RunLoop> run_loop_; |
188 }; | 189 }; |
189 | 190 |
190 GCMConnectionHandlerImplTest::GCMConnectionHandlerImplTest() | 191 GCMConnectionHandlerImplTest::GCMConnectionHandlerImplTest() |
191 : last_error_(0) { | 192 : last_error_(0) { |
192 net::IPAddressNumber ip_number; | 193 address_list_ = net::AddressList::CreateFromIPAddress( |
193 net::ParseIPLiteralToNumber("127.0.0.1", &ip_number); | 194 net::IPAddress::IPv4Localhost(), kMCSPort); |
194 address_list_ = net::AddressList::CreateFromIPAddress(ip_number, kMCSPort); | |
195 } | 195 } |
196 | 196 |
197 GCMConnectionHandlerImplTest::~GCMConnectionHandlerImplTest() { | 197 GCMConnectionHandlerImplTest::~GCMConnectionHandlerImplTest() { |
198 } | 198 } |
199 | 199 |
200 net::StreamSocket* GCMConnectionHandlerImplTest::BuildSocket( | 200 net::StreamSocket* GCMConnectionHandlerImplTest::BuildSocket( |
201 const ReadList& read_list, | 201 const ReadList& read_list, |
202 const WriteList& write_list) { | 202 const WriteList& write_list) { |
203 mock_reads_ = read_list; | 203 mock_reads_ = read_list; |
204 mock_writes_ = write_list; | 204 mock_writes_ = write_list; |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 WaitForMessage(); // The login send. | 902 WaitForMessage(); // The login send. |
903 WaitForMessage(); // The login response. | 903 WaitForMessage(); // The login response. |
904 received_message.reset(); | 904 received_message.reset(); |
905 WaitForMessage(); // The invalid message. | 905 WaitForMessage(); // The invalid message. |
906 EXPECT_FALSE(received_message.get()); | 906 EXPECT_FALSE(received_message.get()); |
907 EXPECT_EQ(net::ERR_FAILED, last_error()); | 907 EXPECT_EQ(net::ERR_FAILED, last_error()); |
908 } | 908 } |
909 | 909 |
910 } // namespace | 910 } // namespace |
911 } // namespace gcm | 911 } // namespace gcm |
OLD | NEW |