Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: net/http/http_stream_factory_test_util.h

Issue 1952423002: JobController 2: Remove reference between HttpStreamFactoryImpl::Jobs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Job_Controller_1
Patch Set: use unmocked Job::Start() and asyncronous Proxy resolution in tests Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 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 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 #ifndef NET_HTTP_HTTP_STREAM_FACTORY_TEST_UTIL_H_ 5 #ifndef NET_HTTP_HTTP_STREAM_FACTORY_TEST_UTIL_H_
6 #define NET_HTTP_HTTP_STREAM_FACTORY_TEST_UTIL_H_ 6 #define NET_HTTP_HTTP_STREAM_FACTORY_TEST_UTIL_H_
7 7
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "net/http/http_stream.h" 9 #include "net/http/http_stream.h"
10 #include "net/http/http_stream_factory.h" 10 #include "net/http/http_stream_factory.h"
11 #include "net/http/http_stream_factory_impl.h" 11 #include "net/http/http_stream_factory_impl.h"
12 #include "net/http/http_stream_factory_impl_job.h" 12 #include "net/http/http_stream_factory_impl_job.h"
13 #include "net/http/http_stream_factory_impl_job_controller.h" 13 #include "net/http/http_stream_factory_impl_job_controller.h"
14 #include "net/proxy/proxy_info.h" 14 #include "net/proxy/proxy_info.h"
15 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
16 16
17 using testing::_;
18 using testing::Invoke;
19
17 namespace net { 20 namespace net {
18 21
19 class HttpStreamFactoryImplPeer { 22 class HttpStreamFactoryImplPeer {
20 public: 23 public:
21 static void AddJobController( 24 static void AddJobController(
22 HttpStreamFactoryImpl* factory, 25 HttpStreamFactoryImpl* factory,
23 HttpStreamFactoryImpl::JobController* job_controller) { 26 HttpStreamFactoryImpl::JobController* job_controller) {
24 factory->job_controller_set_.insert(base::WrapUnique(job_controller)); 27 factory->job_controller_set_.insert(base::WrapUnique(job_controller));
25 } 28 }
26 29
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 RequestPriority priority, 111 RequestPriority priority,
109 const SSLConfig& server_ssl_config, 112 const SSLConfig& server_ssl_config,
110 const SSLConfig& proxy_ssl_config, 113 const SSLConfig& proxy_ssl_config,
111 HostPortPair destination, 114 HostPortPair destination,
112 GURL origin_url, 115 GURL origin_url,
113 AlternativeService alternative_service, 116 AlternativeService alternative_service,
114 NetLog* net_log); 117 NetLog* net_log);
115 118
116 ~MockHttpStreamFactoryImplJob() override; 119 ~MockHttpStreamFactoryImplJob() override;
117 120
121 void UnmockedStart(HttpStreamRequest::StreamType stream_type) {
122 set_stream_type(stream_type);
123 StartInternal();
124 };
125
118 MOCK_METHOD1(Start, void(HttpStreamRequest::StreamType stream_type)); 126 MOCK_METHOD1(Start, void(HttpStreamRequest::StreamType stream_type));
119 127
128 MOCK_METHOD0(Resume, void());
129
120 MOCK_METHOD1(MarkOtherJobComplete, void(const Job& job)); 130 MOCK_METHOD1(MarkOtherJobComplete, void(const Job& job));
121 131
122 MOCK_METHOD0(Orphan, void()); 132 MOCK_METHOD0(Orphan, void());
123 }; 133 };
124 134
125 // JobFactory for creating MockHttpStreamFactoryImplJobs. 135 // JobFactory for creating MockHttpStreamFactoryImplJobs.
126 class TestJobFactory : public HttpStreamFactoryImpl::JobFactory { 136 class TestJobFactory : public HttpStreamFactoryImpl::JobFactory {
127 public: 137 public:
128 TestJobFactory(); 138 TestJobFactory();
129 ~TestJobFactory() override; 139 ~TestJobFactory() override;
(...skipping 21 matching lines...) Expand all
151 HostPortPair destination, 161 HostPortPair destination,
152 GURL origin_url, 162 GURL origin_url,
153 AlternativeService alternative_service, 163 AlternativeService alternative_service,
154 NetLog* net_log) override; 164 NetLog* net_log) override;
155 165
156 MockHttpStreamFactoryImplJob* main_job() const { return main_job_; } 166 MockHttpStreamFactoryImplJob* main_job() const { return main_job_; }
157 MockHttpStreamFactoryImplJob* alternative_job() const { 167 MockHttpStreamFactoryImplJob* alternative_job() const {
158 return alternative_job_; 168 return alternative_job_;
159 } 169 }
160 170
171 void DisableMockStartForJobs() { disable_mocked_start_ = true; }
172
173 void UseDifferentURLForMainJob(GURL url) {
174 override_main_job_url_ = true;
175 main_job_alternative_url_ = url;
176 }
177
161 private: 178 private:
162 MockHttpStreamFactoryImplJob* main_job_; 179 MockHttpStreamFactoryImplJob* main_job_;
163 MockHttpStreamFactoryImplJob* alternative_job_; 180 MockHttpStreamFactoryImplJob* alternative_job_;
181 bool disable_mocked_start_;
182 bool override_main_job_url_;
183 GURL main_job_alternative_url_;
164 }; 184 };
165 185
166 } // namespace net 186 } // namespace net
167 187
168 #endif // NET_HTTP_HTTP_STREAM_FACTORY_TEST_UTIL_H_ 188 #endif // NET_HTTP_HTTP_STREAM_FACTORY_TEST_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698