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/base/socket_stream.h" | 5 #include "google_apis/gcm/base/socket_stream.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
15 #include "net/base/ip_address.h" | 15 #include "net/base/ip_address.h" |
| 16 #include "net/log/net_log_source.h" |
16 #include "net/socket/socket_test_util.h" | 17 #include "net/socket/socket_test_util.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 | 19 |
19 namespace gcm { | 20 namespace gcm { |
20 namespace { | 21 namespace { |
21 | 22 |
22 typedef std::vector<net::MockRead> ReadList; | 23 typedef std::vector<net::MockRead> ReadList; |
23 typedef std::vector<net::MockWrite> WriteList; | 24 typedef std::vector<net::MockWrite> WriteList; |
24 | 25 |
25 const char kReadData[] = "read_data"; | 26 const char kReadData[] = "read_data"; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 net::ERR_IO_PENDING) { | 170 net::ERR_IO_PENDING) { |
170 run_loop.Run(); | 171 run_loop.Run(); |
171 } | 172 } |
172 if (input_stream()->GetState() == SocketInputStream::CLOSED) | 173 if (input_stream()->GetState() == SocketInputStream::CLOSED) |
173 return; | 174 return; |
174 } | 175 } |
175 } | 176 } |
176 | 177 |
177 void GCMSocketStreamTest::OpenConnection() { | 178 void GCMSocketStreamTest::OpenConnection() { |
178 socket_ = socket_factory_.CreateTransportClientSocket( | 179 socket_ = socket_factory_.CreateTransportClientSocket( |
179 address_list_, NULL, NULL, net::NetLog::Source()); | 180 address_list_, NULL, NULL, net::NetLogSource()); |
180 socket_->Connect( | 181 socket_->Connect( |
181 base::Bind(&GCMSocketStreamTest::ConnectCallback, | 182 base::Bind(&GCMSocketStreamTest::ConnectCallback, |
182 base::Unretained(this))); | 183 base::Unretained(this))); |
183 PumpLoop(); | 184 PumpLoop(); |
184 } | 185 } |
185 | 186 |
186 void GCMSocketStreamTest::ConnectCallback(int result) {} | 187 void GCMSocketStreamTest::ConnectCallback(int result) {} |
187 | 188 |
188 void GCMSocketStreamTest::ResetInputStream() { | 189 void GCMSocketStreamTest::ResetInputStream() { |
189 DCHECK(socket_.get()); | 190 DCHECK(socket_.get()); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 TEST_F(GCMSocketStreamTest, WriteDisconnected) { | 393 TEST_F(GCMSocketStreamTest, WriteDisconnected) { |
393 BuildSocket(ReadList(), WriteList()); | 394 BuildSocket(ReadList(), WriteList()); |
394 socket()->Disconnect(); | 395 socket()->Disconnect(); |
395 DoOutputStreamWrite(base::StringPiece(kWriteData, kWriteDataSize)); | 396 DoOutputStreamWrite(base::StringPiece(kWriteData, kWriteDataSize)); |
396 ASSERT_EQ(SocketOutputStream::CLOSED, output_stream()->GetState()); | 397 ASSERT_EQ(SocketOutputStream::CLOSED, output_stream()->GetState()); |
397 ASSERT_EQ(net::ERR_CONNECTION_CLOSED, output_stream()->last_error()); | 398 ASSERT_EQ(net::ERR_CONNECTION_CLOSED, output_stream()->last_error()); |
398 } | 399 } |
399 | 400 |
400 } // namespace | 401 } // namespace |
401 } // namespace gcm | 402 } // namespace gcm |
OLD | NEW |