| 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/http/http_stream_factory_impl_job_factory.h" |
| 15 #include "net/proxy/proxy_info.h" |
| 16 #include "net/proxy/proxy_service.h" |
| 17 #include "net/spdy/spdy_test_util_common.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" |
| 19 |
| 20 namespace net { |
| 21 |
| 22 // This delegate does nothing when called. |
| 23 class TestHttpStreamRequestDelegate : public HttpStreamRequest::Delegate { |
| 24 public: |
| 25 TestHttpStreamRequestDelegate(); |
| 26 |
| 27 ~TestHttpStreamRequestDelegate() override; |
| 28 |
| 29 MOCK_METHOD3(OnStreamReady, |
| 30 void(const SSLConfig& used_ssl_config, |
| 31 const ProxyInfo& used_proxy_info, |
| 32 HttpStream* stream)); |
| 33 |
| 34 void OnBidirectionalStreamImplReady( |
| 35 const SSLConfig& used_ssl_config, |
| 36 const ProxyInfo& used_proxy_info, |
| 37 BidirectionalStreamImpl* stream) override {} |
| 38 |
| 39 void OnWebSocketHandshakeStreamReady( |
| 40 const SSLConfig& used_ssl_config, |
| 41 const ProxyInfo& used_proxy_info, |
| 42 WebSocketHandshakeStreamBase* stream) override {} |
| 43 |
| 44 MOCK_METHOD3(OnStreamFailed, |
| 45 void(int status, |
| 46 const SSLConfig& used_ssl_config, |
| 47 SSLFailureState ssl_failure_state)); |
| 48 |
| 49 MOCK_METHOD3(OnCertificateError, |
| 50 void(int status, |
| 51 const SSLConfig& used_ssl_config, |
| 52 const SSLInfo& ssl_info)); |
| 53 |
| 54 MOCK_METHOD4(OnNeedsProxyAuth, |
| 55 void(const HttpResponseInfo& proxy_response, |
| 56 const SSLConfig& used_ssl_config, |
| 57 const ProxyInfo& used_proxy_info, |
| 58 HttpAuthController* auth_controller)); |
| 59 |
| 60 MOCK_METHOD2(OnNeedsClientAuth, |
| 61 void(const SSLConfig& used_ssl_config, |
| 62 SSLCertRequestInfo* cert_info)); |
| 63 |
| 64 MOCK_METHOD4(OnHttpsProxyTunnelResponse, |
| 65 void(const HttpResponseInfo& response_info, |
| 66 const SSLConfig& used_ssl_config, |
| 67 const ProxyInfo& used_proxy_info, |
| 68 HttpStream* stream)); |
| 69 |
| 70 MOCK_METHOD0(OnQuicBroken, void()); |
| 71 |
| 72 private: |
| 73 DISALLOW_COPY_AND_ASSIGN(TestHttpStreamRequestDelegate); |
| 74 }; |
| 75 |
| 76 class TestHttpStreamFactoryImplJob : public HttpStreamFactoryImpl::Job { |
| 77 public: |
| 78 TestHttpStreamFactoryImplJob(HttpStreamFactoryImpl::Job::Delegate* delegate, |
| 79 HttpStreamFactoryImpl::JobType job_type, |
| 80 HttpNetworkSession* session, |
| 81 const HttpRequestInfo& request_info, |
| 82 RequestPriority priority, |
| 83 const SSLConfig& server_ssl_config, |
| 84 const SSLConfig& proxy_ssl_config, |
| 85 HostPortPair destination, |
| 86 GURL origin_url, |
| 87 NetLog* net_log); |
| 88 |
| 89 TestHttpStreamFactoryImplJob(HttpStreamFactoryImpl::Job::Delegate* delegate, |
| 90 HttpStreamFactoryImpl::JobType job_type, |
| 91 HttpNetworkSession* session, |
| 92 const HttpRequestInfo& request_info, |
| 93 RequestPriority priority, |
| 94 const SSLConfig& server_ssl_config, |
| 95 const SSLConfig& proxy_ssl_config, |
| 96 HostPortPair destination, |
| 97 GURL origin_url, |
| 98 AlternativeService alternative_service, |
| 99 NetLog* net_log); |
| 100 |
| 101 ~TestHttpStreamFactoryImplJob() override; |
| 102 |
| 103 MOCK_METHOD1(Start, void(HttpStreamRequest::StreamType stream_type)); |
| 104 |
| 105 MOCK_METHOD1(MarkOtherJobComplete, void(const Job& job)); |
| 106 |
| 107 MOCK_METHOD0(Orphan, void()); |
| 108 }; |
| 109 |
| 110 class TestJobFactory : public HttpStreamFactoryImpl::JobFactory { |
| 111 public: |
| 112 TestJobFactory(); |
| 113 ~TestJobFactory() override; |
| 114 |
| 115 HttpStreamFactoryImpl::Job* CreateJob( |
| 116 HttpStreamFactoryImpl::Job::Delegate* delegate, |
| 117 HttpStreamFactoryImpl::JobType job_type, |
| 118 HttpNetworkSession* session, |
| 119 const HttpRequestInfo& request_info, |
| 120 RequestPriority priority, |
| 121 const SSLConfig& server_ssl_config, |
| 122 const SSLConfig& proxy_ssl_config, |
| 123 HostPortPair destination, |
| 124 GURL origin_url, |
| 125 NetLog* net_log) override; |
| 126 |
| 127 HttpStreamFactoryImpl::Job* CreateJob( |
| 128 HttpStreamFactoryImpl::Job::Delegate* delegate, |
| 129 HttpStreamFactoryImpl::JobType job_type, |
| 130 HttpNetworkSession* session, |
| 131 const HttpRequestInfo& request_info, |
| 132 RequestPriority priority, |
| 133 const SSLConfig& server_ssl_config, |
| 134 const SSLConfig& proxy_ssl_config, |
| 135 HostPortPair destination, |
| 136 GURL origin_url, |
| 137 AlternativeService alternative_service, |
| 138 NetLog* net_log) override; |
| 139 |
| 140 void SetMainJob(TestHttpStreamFactoryImplJob* main_job) { |
| 141 main_job_.reset(main_job); |
| 142 } |
| 143 |
| 144 void SetAlternativeJob(TestHttpStreamFactoryImplJob* alternative_job) { |
| 145 alternative_job_.reset(alternative_job); |
| 146 } |
| 147 |
| 148 private: |
| 149 std::unique_ptr<HttpStreamFactoryImpl::Job> main_job_; |
| 150 std::unique_ptr<HttpStreamFactoryImpl::Job> alternative_job_; |
| 151 }; |
| 152 |
| 153 } // namespace net |
| 154 |
| 155 #endif // NET_HTTP_HTTP_STREAM_FACTORY_TEST_UTIL_H_ |
| OLD | NEW |