OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/tls_socket.h" | 5 #include "extensions/browser/api/socket/tls_socket.h" |
6 | 6 |
7 #include <deque> | 7 #include <deque> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
12 #include "net/base/address_list.h" | 12 #include "net/base/address_list.h" |
13 #include "net/base/completion_callback.h" | 13 #include "net/base/completion_callback.h" |
14 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
15 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
16 #include "net/base/rand_callback.h" | 16 #include "net/base/rand_callback.h" |
17 #include "net/socket/ssl_client_socket.h" | 17 #include "net/socket/ssl_client_socket.h" |
18 #include "net/socket/tcp_client_socket.h" | 18 #include "net/socket/tcp_client_socket.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
20 | 20 |
21 using testing::_; | 21 using testing::_; |
22 using testing::DoAll; | 22 using testing::DoAll; |
23 using testing::Invoke; | 23 using testing::Invoke; |
24 using testing::Gt; | 24 using testing::Gt; |
25 using testing::Return; | 25 using testing::Return; |
26 using testing::SaveArg; | 26 using testing::SaveArg; |
27 using testing::WithArgs; | 27 using testing::WithArgs; |
28 using base::StringPiece; | 28 using base::StringPiece; |
29 | 29 |
30 namespace net { | |
31 class ServerBoundCertService; | |
32 } | |
33 | |
34 namespace extensions { | 30 namespace extensions { |
35 | 31 |
36 class MockSSLClientSocket : public net::SSLClientSocket { | 32 class MockSSLClientSocket : public net::SSLClientSocket { |
37 public: | 33 public: |
38 MockSSLClientSocket() {} | 34 MockSSLClientSocket() {} |
39 MOCK_METHOD0(Disconnect, void()); | 35 MOCK_METHOD0(Disconnect, void()); |
40 MOCK_METHOD3(Read, | 36 MOCK_METHOD3(Read, |
41 int(net::IOBuffer* buf, | 37 int(net::IOBuffer* buf, |
42 int buf_len, | 38 int buf_len, |
43 const net::CompletionCallback& callback)); | 39 const net::CompletionCallback& callback)); |
(...skipping 18 matching lines...) Expand all Loading... |
62 bool, | 58 bool, |
63 const StringPiece&, | 59 const StringPiece&, |
64 unsigned char*, | 60 unsigned char*, |
65 unsigned int)); | 61 unsigned int)); |
66 MOCK_METHOD1(GetTLSUniqueChannelBinding, int(std::string*)); | 62 MOCK_METHOD1(GetTLSUniqueChannelBinding, int(std::string*)); |
67 MOCK_CONST_METHOD0(InSessionCache, bool()); | 63 MOCK_CONST_METHOD0(InSessionCache, bool()); |
68 MOCK_METHOD1(SetHandshakeCompletionCallback, void(const base::Closure&)); | 64 MOCK_METHOD1(SetHandshakeCompletionCallback, void(const base::Closure&)); |
69 MOCK_METHOD1(GetSSLCertRequestInfo, void(net::SSLCertRequestInfo*)); | 65 MOCK_METHOD1(GetSSLCertRequestInfo, void(net::SSLCertRequestInfo*)); |
70 MOCK_METHOD1(GetNextProto, | 66 MOCK_METHOD1(GetNextProto, |
71 net::SSLClientSocket::NextProtoStatus(std::string*)); | 67 net::SSLClientSocket::NextProtoStatus(std::string*)); |
72 MOCK_CONST_METHOD0(GetServerBoundCertService, net::ServerBoundCertService*()); | |
73 MOCK_CONST_METHOD0(GetUnverifiedServerCertificateChain, | 68 MOCK_CONST_METHOD0(GetUnverifiedServerCertificateChain, |
74 scoped_refptr<net::X509Certificate>()); | 69 scoped_refptr<net::X509Certificate>()); |
75 MOCK_CONST_METHOD0(GetChannelIDService, net::ChannelIDService*()); | 70 MOCK_CONST_METHOD0(GetChannelIDService, net::ChannelIDService*()); |
76 virtual bool IsConnected() const OVERRIDE { return true; } | 71 virtual bool IsConnected() const OVERRIDE { return true; } |
77 | 72 |
78 private: | 73 private: |
79 DISALLOW_COPY_AND_ASSIGN(MockSSLClientSocket); | 74 DISALLOW_COPY_AND_ASSIGN(MockSSLClientSocket); |
80 }; | 75 }; |
81 | 76 |
82 class MockTCPSocket : public net::TCPClientSocket { | 77 class MockTCPSocket : public net::TCPClientSocket { |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 total_bytes_written += amount_written_invocation; | 307 total_bytes_written += amount_written_invocation; |
313 cb.first.Run(amount_written_invocation); | 308 cb.first.Run(amount_written_invocation); |
314 } | 309 } |
315 | 310 |
316 ASSERT_EQ(total_bytes_requested, total_bytes_written) | 311 ASSERT_EQ(total_bytes_requested, total_bytes_written) |
317 << "There should be exactly as many bytes written as originally " | 312 << "There should be exactly as many bytes written as originally " |
318 << "requested to Write()."; | 313 << "requested to Write()."; |
319 } | 314 } |
320 | 315 |
321 } // namespace extensions | 316 } // namespace extensions |
OLD | NEW |