| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "extensions/browser/api/socket/tcp_socket.h" | 5 #include "extensions/browser/api/socket/tcp_socket.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "net/base/address_list.h" | 9 #include "net/base/address_list.h" |
| 10 #include "net/base/completion_callback.h" | 10 #include "net/base/completion_callback.h" |
| 11 #include "net/base/io_buffer.h" | 11 #include "net/base/io_buffer.h" |
| 12 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
| 13 #include "net/base/rand_callback.h" | 13 #include "net/base/rand_callback.h" |
| 14 #include "net/socket/tcp_client_socket.h" | 14 #include "net/socket/tcp_client_socket.h" |
| 15 #include "net/socket/tcp_server_socket.h" | 15 #include "net/socket/tcp_server_socket.h" |
| 16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
| 17 | 17 |
| 18 using testing::_; | 18 using testing::_; |
| 19 using testing::DoAll; | 19 using testing::DoAll; |
| 20 using testing::Return; | 20 using testing::Return; |
| 21 using testing::SaveArg; | 21 using testing::SaveArg; |
| 22 | 22 |
| 23 namespace extensions { | 23 namespace extensions { |
| 24 | 24 |
| 25 class MockTCPSocket : public net::TCPClientSocket { | 25 class MockTCPSocket : public net::TCPClientSocket { |
| 26 public: | 26 public: |
| 27 explicit MockTCPSocket(const net::AddressList& address_list) | 27 explicit MockTCPSocket(const net::AddressList& address_list) |
| 28 : net::TCPClientSocket(address_list, NULL, net::NetLog::Source()) { | 28 : net::TCPClientSocket(address_list, NULL, NULL, net::NetLog::Source()) {} |
| 29 } | |
| 30 | 29 |
| 31 MOCK_METHOD3(Read, int(net::IOBuffer* buf, int buf_len, | 30 MOCK_METHOD3(Read, int(net::IOBuffer* buf, int buf_len, |
| 32 const net::CompletionCallback& callback)); | 31 const net::CompletionCallback& callback)); |
| 33 MOCK_METHOD3(Write, int(net::IOBuffer* buf, int buf_len, | 32 MOCK_METHOD3(Write, int(net::IOBuffer* buf, int buf_len, |
| 34 const net::CompletionCallback& callback)); | 33 const net::CompletionCallback& callback)); |
| 35 MOCK_METHOD2(SetKeepAlive, bool(bool enable, int delay)); | 34 MOCK_METHOD2(SetKeepAlive, bool(bool enable, int delay)); |
| 36 MOCK_METHOD1(SetNoDelay, bool(bool no_delay)); | 35 MOCK_METHOD1(SetNoDelay, bool(bool no_delay)); |
| 37 bool IsConnected() const override { | 36 bool IsConnected() const override { |
| 38 return true; | 37 return true; |
| 39 } | 38 } |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 239 |
| 241 EXPECT_CALL(handler, OnAcceptMock(_, _)); | 240 EXPECT_CALL(handler, OnAcceptMock(_, _)); |
| 242 | 241 |
| 243 std::string err_msg; | 242 std::string err_msg; |
| 244 EXPECT_EQ(net::OK, socket->Listen("127.0.0.1", 9999, 10, &err_msg)); | 243 EXPECT_EQ(net::OK, socket->Listen("127.0.0.1", 9999, 10, &err_msg)); |
| 245 socket->Accept(base::Bind(&CompleteHandler::OnAccept, | 244 socket->Accept(base::Bind(&CompleteHandler::OnAccept, |
| 246 base::Unretained(&handler))); | 245 base::Unretained(&handler))); |
| 247 } | 246 } |
| 248 | 247 |
| 249 } // namespace extensions | 248 } // namespace extensions |
| OLD | NEW |