Chromium Code Reviews| 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 17 matching lines...) Expand all Loading... | |
| 61 int(const StringPiece&, | 57 int(const StringPiece&, |
| 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_METHOD1(GetSSLCertRequestInfo, void(net::SSLCertRequestInfo*)); | 63 MOCK_METHOD1(GetSSLCertRequestInfo, void(net::SSLCertRequestInfo*)); |
| 68 MOCK_METHOD2(GetNextProto, | 64 MOCK_METHOD2(GetNextProto, |
| 69 net::SSLClientSocket::NextProtoStatus(std::string*, | 65 net::SSLClientSocket::NextProtoStatus(std::string*, |
| 70 std::string*)); | 66 std::string*)); |
| 71 MOCK_CONST_METHOD0(GetServerBoundCertService, net::ServerBoundCertService*()); | |
| 72 MOCK_CONST_METHOD0(GetUnverifiedServerCertificateChain, | 67 MOCK_CONST_METHOD0(GetUnverifiedServerCertificateChain, |
| 73 scoped_refptr<net::X509Certificate>()); | 68 scoped_refptr<net::X509Certificate>()); |
| 74 MOCK_CONST_METHOD0(GetChannelIDService, net::ChannelIDService*()); | 69 MOCK_CONST_METHOD0(GetChannelIDService, net::ChannelIDService*()); |
|
wtc
2014/07/30 01:05:59
This file has both GetServerBoundCertService and G
| |
| 75 virtual bool IsConnected() const OVERRIDE { return true; } | 70 virtual bool IsConnected() const OVERRIDE { return true; } |
| 76 | 71 |
| 77 private: | 72 private: |
| 78 DISALLOW_COPY_AND_ASSIGN(MockSSLClientSocket); | 73 DISALLOW_COPY_AND_ASSIGN(MockSSLClientSocket); |
| 79 }; | 74 }; |
| 80 | 75 |
| 81 class MockTCPSocket : public net::TCPClientSocket { | 76 class MockTCPSocket : public net::TCPClientSocket { |
| 82 public: | 77 public: |
| 83 explicit MockTCPSocket(const net::AddressList& address_list) | 78 explicit MockTCPSocket(const net::AddressList& address_list) |
| 84 : net::TCPClientSocket(address_list, NULL, net::NetLog::Source()) {} | 79 : net::TCPClientSocket(address_list, NULL, net::NetLog::Source()) {} |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 total_bytes_written += amount_written_invocation; | 306 total_bytes_written += amount_written_invocation; |
| 312 cb.first.Run(amount_written_invocation); | 307 cb.first.Run(amount_written_invocation); |
| 313 } | 308 } |
| 314 | 309 |
| 315 ASSERT_EQ(total_bytes_requested, total_bytes_written) | 310 ASSERT_EQ(total_bytes_requested, total_bytes_written) |
| 316 << "There should be exactly as many bytes written as originally " | 311 << "There should be exactly as many bytes written as originally " |
| 317 << "requested to Write()."; | 312 << "requested to Write()."; |
| 318 } | 313 } |
| 319 | 314 |
| 320 } // namespace extensions | 315 } // namespace extensions |
| OLD | NEW |