| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_HTTP_HTTP_STREAM_FACTORY_TEST_UTIL_H_ |
| 6 #define NET_HTTP_HTTP_STREAM_FACTORY_TEST_UTIL_H_ |
| 7 |
| 8 #include "base/memory/ptr_util.h" |
| 9 #include "net/http/http_stream.h" |
| 10 #include "net/http/http_stream_factory.h" |
| 11 #include "net/http/http_stream_factory_impl.h" |
| 12 #include "net/http/http_stream_factory_impl_job.h" |
| 13 #include "net/http/http_stream_factory_impl_job_controller.h" |
| 14 #include "net/proxy/proxy_info.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" |
| 16 |
| 17 namespace net { |
| 18 |
| 19 // This delegate does nothing when called. |
| 20 class MockHttpStreamRequestDelegate : public HttpStreamRequest::Delegate { |
| 21 public: |
| 22 MockHttpStreamRequestDelegate(); |
| 23 |
| 24 ~MockHttpStreamRequestDelegate() override; |
| 25 |
| 26 MOCK_METHOD3(OnStreamReady, |
| 27 void(const SSLConfig& used_ssl_config, |
| 28 const ProxyInfo& used_proxy_info, |
| 29 HttpStream* stream)); |
| 30 |
| 31 MOCK_METHOD3(OnBidirectionalStreamImplReady, |
| 32 void(const SSLConfig& used_ssl_config, |
| 33 const ProxyInfo& used_proxy_info, |
| 34 BidirectionalStreamImpl* stream)); |
| 35 |
| 36 MOCK_METHOD3(OnWebSocketHandshakeStreamReady, |
| 37 void(const SSLConfig& used_ssl_config, |
| 38 const ProxyInfo& used_proxy_info, |
| 39 WebSocketHandshakeStreamBase* stream)); |
| 40 |
| 41 MOCK_METHOD3(OnStreamFailed, |
| 42 void(int status, |
| 43 const SSLConfig& used_ssl_config, |
| 44 SSLFailureState ssl_failure_state)); |
| 45 |
| 46 MOCK_METHOD3(OnCertificateError, |
| 47 void(int status, |
| 48 const SSLConfig& used_ssl_config, |
| 49 const SSLInfo& ssl_info)); |
| 50 |
| 51 MOCK_METHOD4(OnNeedsProxyAuth, |
| 52 void(const HttpResponseInfo& proxy_response, |
| 53 const SSLConfig& used_ssl_config, |
| 54 const ProxyInfo& used_proxy_info, |
| 55 HttpAuthController* auth_controller)); |
| 56 |
| 57 MOCK_METHOD2(OnNeedsClientAuth, |
| 58 void(const SSLConfig& used_ssl_config, |
| 59 SSLCertRequestInfo* cert_info)); |
| 60 |
| 61 MOCK_METHOD4(OnHttpsProxyTunnelResponse, |
| 62 void(const HttpResponseInfo& response_info, |
| 63 const SSLConfig& used_ssl_config, |
| 64 const ProxyInfo& used_proxy_info, |
| 65 HttpStream* stream)); |
| 66 |
| 67 MOCK_METHOD0(OnQuicBroken, void()); |
| 68 |
| 69 private: |
| 70 DISALLOW_COPY_AND_ASSIGN(MockHttpStreamRequestDelegate); |
| 71 }; |
| 72 |
| 73 class TestHttpStreamFactoryImplJob : public HttpStreamFactoryImpl::Job { |
| 74 public: |
| 75 TestHttpStreamFactoryImplJob(HttpStreamFactoryImpl::Job::Delegate* delegate, |
| 76 HttpStreamFactoryImpl::JobType job_type, |
| 77 HttpNetworkSession* session, |
| 78 const HttpRequestInfo& request_info, |
| 79 RequestPriority priority, |
| 80 const SSLConfig& server_ssl_config, |
| 81 const SSLConfig& proxy_ssl_config, |
| 82 HostPortPair destination, |
| 83 GURL origin_url, |
| 84 NetLog* net_log); |
| 85 |
| 86 TestHttpStreamFactoryImplJob(HttpStreamFactoryImpl::Job::Delegate* delegate, |
| 87 HttpStreamFactoryImpl::JobType job_type, |
| 88 HttpNetworkSession* session, |
| 89 const HttpRequestInfo& request_info, |
| 90 RequestPriority priority, |
| 91 const SSLConfig& server_ssl_config, |
| 92 const SSLConfig& proxy_ssl_config, |
| 93 HostPortPair destination, |
| 94 GURL origin_url, |
| 95 AlternativeService alternative_service, |
| 96 NetLog* net_log); |
| 97 |
| 98 ~TestHttpStreamFactoryImplJob() override; |
| 99 |
| 100 MOCK_METHOD1(Start, void(HttpStreamRequest::StreamType stream_type)); |
| 101 |
| 102 MOCK_METHOD1(MarkOtherJobComplete, void(const Job& job)); |
| 103 |
| 104 MOCK_METHOD0(Orphan, void()); |
| 105 }; |
| 106 |
| 107 class TestJobFactory : public HttpStreamFactoryImpl::JobController::JobFactory { |
| 108 public: |
| 109 TestJobFactory(); |
| 110 ~TestJobFactory() override; |
| 111 |
| 112 HttpStreamFactoryImpl::Job* CreateJob( |
| 113 HttpStreamFactoryImpl::Job::Delegate* delegate, |
| 114 HttpStreamFactoryImpl::JobType job_type, |
| 115 HttpNetworkSession* session, |
| 116 const HttpRequestInfo& request_info, |
| 117 RequestPriority priority, |
| 118 const SSLConfig& server_ssl_config, |
| 119 const SSLConfig& proxy_ssl_config, |
| 120 HostPortPair destination, |
| 121 GURL origin_url, |
| 122 NetLog* net_log) override; |
| 123 |
| 124 HttpStreamFactoryImpl::Job* CreateJob( |
| 125 HttpStreamFactoryImpl::Job::Delegate* delegate, |
| 126 HttpStreamFactoryImpl::JobType job_type, |
| 127 HttpNetworkSession* session, |
| 128 const HttpRequestInfo& request_info, |
| 129 RequestPriority priority, |
| 130 const SSLConfig& server_ssl_config, |
| 131 const SSLConfig& proxy_ssl_config, |
| 132 HostPortPair destination, |
| 133 GURL origin_url, |
| 134 AlternativeService alternative_service, |
| 135 NetLog* net_log) override; |
| 136 |
| 137 TestHttpStreamFactoryImplJob* main_job() const { return main_job_; } |
| 138 TestHttpStreamFactoryImplJob* alternative_job() const { |
| 139 return alternative_job_; |
| 140 } |
| 141 |
| 142 private: |
| 143 TestHttpStreamFactoryImplJob* main_job_; |
| 144 TestHttpStreamFactoryImplJob* alternative_job_; |
| 145 }; |
| 146 |
| 147 } // namespace net |
| 148 |
| 149 #endif // NET_HTTP_HTTP_STREAM_FACTORY_TEST_UTIL_H_ |
| OLD | NEW |