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" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 const StringPiece&, | 59 const StringPiece&, |
60 unsigned char*, | 60 unsigned char*, |
61 unsigned int)); | 61 unsigned int)); |
62 MOCK_METHOD1(GetTLSUniqueChannelBinding, int(std::string*)); | 62 MOCK_METHOD1(GetTLSUniqueChannelBinding, int(std::string*)); |
63 MOCK_METHOD1(GetSSLCertRequestInfo, void(net::SSLCertRequestInfo*)); | 63 MOCK_METHOD1(GetSSLCertRequestInfo, void(net::SSLCertRequestInfo*)); |
64 MOCK_METHOD1(GetNextProto, | 64 MOCK_METHOD1(GetNextProto, |
65 net::SSLClientSocket::NextProtoStatus(std::string*)); | 65 net::SSLClientSocket::NextProtoStatus(std::string*)); |
66 MOCK_CONST_METHOD0(GetUnverifiedServerCertificateChain, | 66 MOCK_CONST_METHOD0(GetUnverifiedServerCertificateChain, |
67 scoped_refptr<net::X509Certificate>()); | 67 scoped_refptr<net::X509Certificate>()); |
68 MOCK_CONST_METHOD0(GetChannelIDService, net::ChannelIDService*()); | 68 MOCK_CONST_METHOD0(GetChannelIDService, net::ChannelIDService*()); |
69 virtual bool IsConnected() const override { return true; } | 69 bool IsConnected() const override { return true; } |
70 | 70 |
71 private: | 71 private: |
72 DISALLOW_COPY_AND_ASSIGN(MockSSLClientSocket); | 72 DISALLOW_COPY_AND_ASSIGN(MockSSLClientSocket); |
73 }; | 73 }; |
74 | 74 |
75 class MockTCPSocket : public net::TCPClientSocket { | 75 class MockTCPSocket : public net::TCPClientSocket { |
76 public: | 76 public: |
77 explicit MockTCPSocket(const net::AddressList& address_list) | 77 explicit MockTCPSocket(const net::AddressList& address_list) |
78 : net::TCPClientSocket(address_list, NULL, net::NetLog::Source()) {} | 78 : net::TCPClientSocket(address_list, NULL, net::NetLog::Source()) {} |
79 | 79 |
80 MOCK_METHOD3(Read, | 80 MOCK_METHOD3(Read, |
81 int(net::IOBuffer* buf, | 81 int(net::IOBuffer* buf, |
82 int buf_len, | 82 int buf_len, |
83 const net::CompletionCallback& callback)); | 83 const net::CompletionCallback& callback)); |
84 MOCK_METHOD3(Write, | 84 MOCK_METHOD3(Write, |
85 int(net::IOBuffer* buf, | 85 int(net::IOBuffer* buf, |
86 int buf_len, | 86 int buf_len, |
87 const net::CompletionCallback& callback)); | 87 const net::CompletionCallback& callback)); |
88 MOCK_METHOD2(SetKeepAlive, bool(bool enable, int delay)); | 88 MOCK_METHOD2(SetKeepAlive, bool(bool enable, int delay)); |
89 MOCK_METHOD1(SetNoDelay, bool(bool no_delay)); | 89 MOCK_METHOD1(SetNoDelay, bool(bool no_delay)); |
90 | 90 |
91 virtual bool IsConnected() const override { return true; } | 91 bool IsConnected() const override { return true; } |
92 | 92 |
93 private: | 93 private: |
94 DISALLOW_COPY_AND_ASSIGN(MockTCPSocket); | 94 DISALLOW_COPY_AND_ASSIGN(MockTCPSocket); |
95 }; | 95 }; |
96 | 96 |
97 class CompleteHandler { | 97 class CompleteHandler { |
98 public: | 98 public: |
99 CompleteHandler() {} | 99 CompleteHandler() {} |
100 MOCK_METHOD1(OnComplete, void(int result_code)); | 100 MOCK_METHOD1(OnComplete, void(int result_code)); |
101 MOCK_METHOD2(OnReadComplete, | 101 MOCK_METHOD2(OnReadComplete, |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 total_bytes_written += amount_written_invocation; | 304 total_bytes_written += amount_written_invocation; |
305 cb.first.Run(amount_written_invocation); | 305 cb.first.Run(amount_written_invocation); |
306 } | 306 } |
307 | 307 |
308 ASSERT_EQ(total_bytes_requested, total_bytes_written) | 308 ASSERT_EQ(total_bytes_requested, total_bytes_written) |
309 << "There should be exactly as many bytes written as originally " | 309 << "There should be exactly as many bytes written as originally " |
310 << "requested to Write()."; | 310 << "requested to Write()."; |
311 } | 311 } |
312 | 312 |
313 } // namespace extensions | 313 } // namespace extensions |
OLD | NEW |