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 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
16 #include "base/test/test_timeouts.h" | 16 #include "base/test/test_timeouts.h" |
17 #include "google/protobuf/io/coded_stream.h" | 17 #include "google/protobuf/io/coded_stream.h" |
18 #include "google/protobuf/io/zero_copy_stream_impl_lite.h" | 18 #include "google/protobuf/io/zero_copy_stream_impl_lite.h" |
19 #include "google/protobuf/wire_format_lite.h" | 19 #include "google/protobuf/wire_format_lite.h" |
20 #include "google_apis/gcm/base/mcs_util.h" | 20 #include "google_apis/gcm/base/mcs_util.h" |
21 #include "google_apis/gcm/base/socket_stream.h" | 21 #include "google_apis/gcm/base/socket_stream.h" |
22 #include "google_apis/gcm/protocol/mcs.pb.h" | 22 #include "google_apis/gcm/protocol/mcs.pb.h" |
23 #include "net/base/ip_address.h" | 23 #include "net/base/ip_address.h" |
| 24 #include "net/log/net_log_source.h" |
24 #include "net/socket/socket_test_util.h" | 25 #include "net/socket/socket_test_util.h" |
25 #include "net/socket/stream_socket.h" | 26 #include "net/socket/stream_socket.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
27 | 28 |
28 namespace gcm { | 29 namespace gcm { |
29 namespace { | 30 namespace { |
30 | 31 |
31 typedef std::unique_ptr<google::protobuf::MessageLite> ScopedMessage; | 32 typedef std::unique_ptr<google::protobuf::MessageLite> ScopedMessage; |
32 typedef std::vector<net::MockRead> ReadList; | 33 typedef std::vector<net::MockRead> ReadList; |
33 typedef std::vector<net::MockWrite> WriteList; | 34 typedef std::vector<net::MockWrite> WriteList; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 const WriteList& write_list) { | 204 const WriteList& write_list) { |
204 mock_reads_ = read_list; | 205 mock_reads_ = read_list; |
205 mock_writes_ = write_list; | 206 mock_writes_ = write_list; |
206 data_provider_.reset( | 207 data_provider_.reset( |
207 new net::StaticSocketDataProvider( | 208 new net::StaticSocketDataProvider( |
208 &(mock_reads_[0]), mock_reads_.size(), | 209 &(mock_reads_[0]), mock_reads_.size(), |
209 &(mock_writes_[0]), mock_writes_.size())); | 210 &(mock_writes_[0]), mock_writes_.size())); |
210 socket_factory_.AddSocketDataProvider(data_provider_.get()); | 211 socket_factory_.AddSocketDataProvider(data_provider_.get()); |
211 | 212 |
212 socket_ = socket_factory_.CreateTransportClientSocket( | 213 socket_ = socket_factory_.CreateTransportClientSocket( |
213 address_list_, NULL, NULL, net::NetLog::Source()); | 214 address_list_, NULL, NULL, net::NetLogSource()); |
214 socket_->Connect(net::CompletionCallback()); | 215 socket_->Connect(net::CompletionCallback()); |
215 | 216 |
216 run_loop_.reset(new base::RunLoop()); | 217 run_loop_.reset(new base::RunLoop()); |
217 PumpLoop(); | 218 PumpLoop(); |
218 | 219 |
219 DCHECK(socket_->IsConnected()); | 220 DCHECK(socket_->IsConnected()); |
220 return socket_.get(); | 221 return socket_.get(); |
221 } | 222 } |
222 | 223 |
223 void GCMConnectionHandlerImplTest::PumpLoop() { | 224 void GCMConnectionHandlerImplTest::PumpLoop() { |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 WaitForMessage(); // The login send. | 904 WaitForMessage(); // The login send. |
904 WaitForMessage(); // The login response. | 905 WaitForMessage(); // The login response. |
905 received_message.reset(); | 906 received_message.reset(); |
906 WaitForMessage(); // The invalid message. | 907 WaitForMessage(); // The invalid message. |
907 EXPECT_FALSE(received_message.get()); | 908 EXPECT_FALSE(received_message.get()); |
908 EXPECT_EQ(net::ERR_FAILED, last_error()); | 909 EXPECT_EQ(net::ERR_FAILED, last_error()); |
909 } | 910 } |
910 | 911 |
911 } // namespace | 912 } // namespace |
912 } // namespace gcm | 913 } // namespace gcm |
OLD | NEW |