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> |
| 10 |
9 #include "base/bind.h" | 11 #include "base/bind.h" |
10 #include "base/macros.h" | 12 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
13 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
14 #include "net/base/ip_address.h" | 15 #include "net/base/ip_address.h" |
15 #include "net/socket/socket_test_util.h" | 16 #include "net/socket/socket_test_util.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 | 18 |
18 namespace gcm { | 19 namespace gcm { |
19 namespace { | 20 namespace { |
20 | 21 |
21 typedef std::vector<net::MockRead> ReadList; | 22 typedef std::vector<net::MockRead> ReadList; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 private: | 59 private: |
59 void OpenConnection(); | 60 void OpenConnection(); |
60 void ResetInputStream(); | 61 void ResetInputStream(); |
61 void ResetOutputStream(); | 62 void ResetOutputStream(); |
62 | 63 |
63 void ConnectCallback(int result); | 64 void ConnectCallback(int result); |
64 | 65 |
65 // SocketStreams and their data providers. | 66 // SocketStreams and their data providers. |
66 ReadList mock_reads_; | 67 ReadList mock_reads_; |
67 WriteList mock_writes_; | 68 WriteList mock_writes_; |
68 scoped_ptr<net::StaticSocketDataProvider> data_provider_; | 69 std::unique_ptr<net::StaticSocketDataProvider> data_provider_; |
69 scoped_ptr<SocketInputStream> socket_input_stream_; | 70 std::unique_ptr<SocketInputStream> socket_input_stream_; |
70 scoped_ptr<SocketOutputStream> socket_output_stream_; | 71 std::unique_ptr<SocketOutputStream> socket_output_stream_; |
71 | 72 |
72 // net:: components. | 73 // net:: components. |
73 scoped_ptr<net::StreamSocket> socket_; | 74 std::unique_ptr<net::StreamSocket> socket_; |
74 net::MockClientSocketFactory socket_factory_; | 75 net::MockClientSocketFactory socket_factory_; |
75 net::AddressList address_list_; | 76 net::AddressList address_list_; |
76 | 77 |
77 base::MessageLoopForIO message_loop_; | 78 base::MessageLoopForIO message_loop_; |
78 }; | 79 }; |
79 | 80 |
80 GCMSocketStreamTest::GCMSocketStreamTest() { | 81 GCMSocketStreamTest::GCMSocketStreamTest() { |
81 address_list_ = net::AddressList::CreateFromIPAddress( | 82 address_list_ = net::AddressList::CreateFromIPAddress( |
82 net::IPAddress::IPv4Localhost(), 5228); | 83 net::IPAddress::IPv4Localhost(), 5228); |
83 } | 84 } |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 TEST_F(GCMSocketStreamTest, WriteDisconnected) { | 392 TEST_F(GCMSocketStreamTest, WriteDisconnected) { |
392 BuildSocket(ReadList(), WriteList()); | 393 BuildSocket(ReadList(), WriteList()); |
393 socket()->Disconnect(); | 394 socket()->Disconnect(); |
394 DoOutputStreamWrite(base::StringPiece(kWriteData, kWriteDataSize)); | 395 DoOutputStreamWrite(base::StringPiece(kWriteData, kWriteDataSize)); |
395 ASSERT_EQ(SocketOutputStream::CLOSED, output_stream()->GetState()); | 396 ASSERT_EQ(SocketOutputStream::CLOSED, output_stream()->GetState()); |
396 ASSERT_EQ(net::ERR_CONNECTION_CLOSED, output_stream()->last_error()); | 397 ASSERT_EQ(net::ERR_CONNECTION_CLOSED, output_stream()->last_error()); |
397 } | 398 } |
398 | 399 |
399 } // namespace | 400 } // namespace |
400 } // namespace gcm | 401 } // namespace gcm |
OLD | NEW |