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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "extensions/browser/api/socket/tcp_socket.h" | 8 #include "extensions/browser/api/socket/tcp_socket.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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 247 |
249 EXPECT_CALL(handler, OnAcceptMock(_, _)); | 248 EXPECT_CALL(handler, OnAcceptMock(_, _)); |
250 | 249 |
251 std::string err_msg; | 250 std::string err_msg; |
252 EXPECT_EQ(net::OK, socket->Listen("127.0.0.1", 9999, 10, &err_msg)); | 251 EXPECT_EQ(net::OK, socket->Listen("127.0.0.1", 9999, 10, &err_msg)); |
253 socket->Accept(base::Bind(&CompleteHandler::OnAccept, | 252 socket->Accept(base::Bind(&CompleteHandler::OnAccept, |
254 base::Unretained(&handler))); | 253 base::Unretained(&handler))); |
255 } | 254 } |
256 | 255 |
257 } // namespace extensions | 256 } // namespace extensions |
OLD | NEW |