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

Side by Side Diff: net/http/http_stream_factory_impl_job_controller_unittest.cc

Issue 2140673002: Remove SPDY/3.1 tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 #include "net/http/http_stream_factory_impl_job_controller.h" 5 #include "net/http/http_stream_factory_impl_job_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "net/http/http_basic_stream.h" 9 #include "net/http/http_basic_stream.h"
10 #include "net/http/http_stream_factory_impl_request.h" 10 #include "net/http/http_stream_factory_impl_request.h"
(...skipping 16 matching lines...) Expand all
27 delete stream; 27 delete stream;
28 } 28 }
29 29
30 } // anonymous namespace 30 } // anonymous namespace
31 31
32 class HttpStreamFactoryImplJobControllerTest 32 class HttpStreamFactoryImplJobControllerTest
33 : public ::testing::Test, 33 : public ::testing::Test,
34 public ::testing::WithParamInterface<NextProto> { 34 public ::testing::WithParamInterface<NextProto> {
35 public: 35 public:
36 HttpStreamFactoryImplJobControllerTest() 36 HttpStreamFactoryImplJobControllerTest()
37 : session_deps_(GetParam(), ProxyService::CreateDirect()) { 37 : session_deps_(ProxyService::CreateDirect()) {
38 session_deps_.enable_quic = true; 38 session_deps_.enable_quic = true;
39 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); 39 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_);
40 factory_ = 40 factory_ =
41 static_cast<HttpStreamFactoryImpl*>(session_->http_stream_factory()); 41 static_cast<HttpStreamFactoryImpl*>(session_->http_stream_factory());
42 job_controller_ = new HttpStreamFactoryImpl::JobController( 42 job_controller_ = new HttpStreamFactoryImpl::JobController(
43 factory_, &request_delegate_, session_.get(), &job_factory_); 43 factory_, &request_delegate_, session_.get(), &job_factory_);
44 HttpStreamFactoryImplPeer::AddJobController(factory_, job_controller_); 44 HttpStreamFactoryImplPeer::AddJobController(factory_, job_controller_);
45 } 45 }
46 46
47 ~HttpStreamFactoryImplJobControllerTest() {} 47 ~HttpStreamFactoryImplJobControllerTest() {}
(...skipping 11 matching lines...) Expand all
59 MockHttpStreamRequestDelegate request_delegate_; 59 MockHttpStreamRequestDelegate request_delegate_;
60 SpdySessionDependencies session_deps_; 60 SpdySessionDependencies session_deps_;
61 std::unique_ptr<HttpNetworkSession> session_; 61 std::unique_ptr<HttpNetworkSession> session_;
62 HttpStreamFactoryImpl* factory_; 62 HttpStreamFactoryImpl* factory_;
63 HttpStreamFactoryImpl::JobController* job_controller_; 63 HttpStreamFactoryImpl::JobController* job_controller_;
64 std::unique_ptr<HttpStreamFactoryImpl::Request> request_; 64 std::unique_ptr<HttpStreamFactoryImpl::Request> request_;
65 65
66 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImplJobControllerTest); 66 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImplJobControllerTest);
67 }; 67 };
68 68
69 INSTANTIATE_TEST_CASE_P(NextProto, 69 TEST_F(HttpStreamFactoryImplJobControllerTest,
70 HttpStreamFactoryImplJobControllerTest,
71 testing::Values(kProtoSPDY31, kProtoHTTP2));
72
73 TEST_P(HttpStreamFactoryImplJobControllerTest,
74 OnStreamFailedWithNoAlternativeJob) { 70 OnStreamFailedWithNoAlternativeJob) {
75 HttpRequestInfo request_info; 71 HttpRequestInfo request_info;
76 request_info.method = "GET"; 72 request_info.method = "GET";
77 request_info.url = GURL("http://www.google.com"); 73 request_info.url = GURL("http://www.google.com");
78 74
79 request_.reset( 75 request_.reset(
80 job_controller_->Start(request_info, &request_delegate_, nullptr, 76 job_controller_->Start(request_info, &request_delegate_, nullptr,
81 BoundNetLog(), HttpStreamRequest::HTTP_STREAM, 77 BoundNetLog(), HttpStreamRequest::HTTP_STREAM,
82 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); 78 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
83 79
84 EXPECT_TRUE(job_controller_->main_job()); 80 EXPECT_TRUE(job_controller_->main_job());
85 81
86 // There's no other alternative job. Thus when stream failed, it should 82 // There's no other alternative job. Thus when stream failed, it should
87 // notify Request of the stream failure. 83 // notify Request of the stream failure.
88 EXPECT_CALL(request_delegate_, OnStreamFailed(ERR_FAILED, _)).Times(1); 84 EXPECT_CALL(request_delegate_, OnStreamFailed(ERR_FAILED, _)).Times(1);
89 job_controller_->OnStreamFailed(job_factory_.main_job(), ERR_FAILED, 85 job_controller_->OnStreamFailed(job_factory_.main_job(), ERR_FAILED,
90 SSLConfig()); 86 SSLConfig());
91 } 87 }
92 88
93 TEST_P(HttpStreamFactoryImplJobControllerTest, 89 TEST_F(HttpStreamFactoryImplJobControllerTest,
94 OnStreamReadyWithNoAlternativeJob) { 90 OnStreamReadyWithNoAlternativeJob) {
95 HttpRequestInfo request_info; 91 HttpRequestInfo request_info;
96 request_info.method = "GET"; 92 request_info.method = "GET";
97 request_info.url = GURL("http://www.google.com"); 93 request_info.url = GURL("http://www.google.com");
98 94
99 request_.reset( 95 request_.reset(
100 job_controller_->Start(request_info, &request_delegate_, nullptr, 96 job_controller_->Start(request_info, &request_delegate_, nullptr,
101 BoundNetLog(), HttpStreamRequest::HTTP_STREAM, 97 BoundNetLog(), HttpStreamRequest::HTTP_STREAM,
102 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); 98 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
103 EXPECT_TRUE(job_controller_->main_job()); 99 EXPECT_TRUE(job_controller_->main_job());
104 100
105 // There's no other alternative job. Thus when stream is ready, it should 101 // There's no other alternative job. Thus when stream is ready, it should
106 // notify Request. 102 // notify Request.
107 HttpStream* http_stream = 103 HttpStream* http_stream =
108 new HttpBasicStream(new ClientSocketHandle(), false); 104 new HttpBasicStream(new ClientSocketHandle(), false);
109 job_factory_.main_job()->SetStream(http_stream); 105 job_factory_.main_job()->SetStream(http_stream);
110 106
111 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, http_stream)) 107 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, http_stream))
112 .WillOnce(Invoke(DeleteHttpStreamPointer)); 108 .WillOnce(Invoke(DeleteHttpStreamPointer));
113 job_controller_->OnStreamReady(job_factory_.main_job(), SSLConfig(), 109 job_controller_->OnStreamReady(job_factory_.main_job(), SSLConfig(),
114 ProxyInfo()); 110 ProxyInfo());
115 } 111 }
116 112
117 // Test we cancel Jobs correctly when the Request is explicitly canceled 113 // Test we cancel Jobs correctly when the Request is explicitly canceled
118 // before any Job is bound to Request. 114 // before any Job is bound to Request.
119 TEST_P(HttpStreamFactoryImplJobControllerTest, CancelJobsBeforeBinding) { 115 TEST_F(HttpStreamFactoryImplJobControllerTest, CancelJobsBeforeBinding) {
120 HttpRequestInfo request_info; 116 HttpRequestInfo request_info;
121 request_info.method = "GET"; 117 request_info.method = "GET";
122 request_info.url = GURL("https://www.google.com"); 118 request_info.url = GURL("https://www.google.com");
123 119
124 url::SchemeHostPort server(request_info.url); 120 url::SchemeHostPort server(request_info.url);
125 AlternativeService alternative_service(QUIC, server.host(), 443); 121 AlternativeService alternative_service(QUIC, server.host(), 443);
126 SetAlternativeService(request_info, alternative_service); 122 SetAlternativeService(request_info, alternative_service);
127 123
128 request_.reset( 124 request_.reset(
129 job_controller_->Start(request_info, &request_delegate_, nullptr, 125 job_controller_->Start(request_info, &request_delegate_, nullptr,
130 BoundNetLog(), HttpStreamRequest::HTTP_STREAM, 126 BoundNetLog(), HttpStreamRequest::HTTP_STREAM,
131 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); 127 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
132 EXPECT_TRUE(job_controller_->main_job()); 128 EXPECT_TRUE(job_controller_->main_job());
133 EXPECT_TRUE(job_controller_->alternative_job()); 129 EXPECT_TRUE(job_controller_->alternative_job());
134 130
135 // Reset the Request will cancel all the Jobs since there's no Job determined 131 // Reset the Request will cancel all the Jobs since there's no Job determined
136 // to serve Request yet and JobController will notify the factory to delete 132 // to serve Request yet and JobController will notify the factory to delete
137 // itself upon completion. 133 // itself upon completion.
138 request_.reset(); 134 request_.reset();
139 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); 135 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_));
140 } 136 }
141 137
142 TEST_P(HttpStreamFactoryImplJobControllerTest, OnStreamFailedForBothJobs) { 138 TEST_F(HttpStreamFactoryImplJobControllerTest, OnStreamFailedForBothJobs) {
143 HttpRequestInfo request_info; 139 HttpRequestInfo request_info;
144 request_info.method = "GET"; 140 request_info.method = "GET";
145 request_info.url = GURL("https://www.google.com"); 141 request_info.url = GURL("https://www.google.com");
146 142
147 url::SchemeHostPort server(request_info.url); 143 url::SchemeHostPort server(request_info.url);
148 AlternativeService alternative_service(QUIC, server.host(), 443); 144 AlternativeService alternative_service(QUIC, server.host(), 443);
149 SetAlternativeService(request_info, alternative_service); 145 SetAlternativeService(request_info, alternative_service);
150 146
151 request_.reset( 147 request_.reset(
152 job_controller_->Start(request_info, &request_delegate_, nullptr, 148 job_controller_->Start(request_info, &request_delegate_, nullptr,
(...skipping 12 matching lines...) Expand all
165 EXPECT_TRUE(!job_controller_->alternative_job()); 161 EXPECT_TRUE(!job_controller_->alternative_job());
166 EXPECT_TRUE(job_controller_->main_job()); 162 EXPECT_TRUE(job_controller_->main_job());
167 163
168 // The failure of second Job should be reported to Request as there's no more 164 // The failure of second Job should be reported to Request as there's no more
169 // pending Job to serve the Request. 165 // pending Job to serve the Request.
170 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(1); 166 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(1);
171 job_controller_->OnStreamFailed(job_factory_.main_job(), ERR_FAILED, 167 job_controller_->OnStreamFailed(job_factory_.main_job(), ERR_FAILED,
172 SSLConfig()); 168 SSLConfig());
173 } 169 }
174 170
175 TEST_P(HttpStreamFactoryImplJobControllerTest, 171 TEST_F(HttpStreamFactoryImplJobControllerTest,
176 SecondJobFailsAfterFirstJobSucceeds) { 172 SecondJobFailsAfterFirstJobSucceeds) {
177 HttpRequestInfo request_info; 173 HttpRequestInfo request_info;
178 request_info.method = "GET"; 174 request_info.method = "GET";
179 request_info.url = GURL("https://www.google.com"); 175 request_info.url = GURL("https://www.google.com");
180 176
181 url::SchemeHostPort server(request_info.url); 177 url::SchemeHostPort server(request_info.url);
182 AlternativeService alternative_service(QUIC, server.host(), 443); 178 AlternativeService alternative_service(QUIC, server.host(), 443);
183 SetAlternativeService(request_info, alternative_service); 179 SetAlternativeService(request_info, alternative_service);
184 180
185 request_.reset( 181 request_.reset(
(...skipping 21 matching lines...) Expand all
207 // is already successfully served. 203 // is already successfully served.
208 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); 204 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0);
209 job_controller_->OnStreamFailed(job_factory_.alternative_job(), ERR_FAILED, 205 job_controller_->OnStreamFailed(job_factory_.alternative_job(), ERR_FAILED,
210 SSLConfig()); 206 SSLConfig());
211 207
212 // Reset the request as it's been successfully served. 208 // Reset the request as it's been successfully served.
213 request_.reset(); 209 request_.reset();
214 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); 210 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_));
215 } 211 }
216 212
217 TEST_P(HttpStreamFactoryImplJobControllerTest, 213 TEST_F(HttpStreamFactoryImplJobControllerTest,
218 SecondJobSucceedsAfterFirstJobFailed) { 214 SecondJobSucceedsAfterFirstJobFailed) {
219 HttpRequestInfo request_info; 215 HttpRequestInfo request_info;
220 request_info.method = "GET"; 216 request_info.method = "GET";
221 request_info.url = GURL("https://www.google.com"); 217 request_info.url = GURL("https://www.google.com");
222 218
223 url::SchemeHostPort server(request_info.url); 219 url::SchemeHostPort server(request_info.url);
224 AlternativeService alternative_service(QUIC, server.host(), 443); 220 AlternativeService alternative_service(QUIC, server.host(), 443);
225 SetAlternativeService(request_info, alternative_service); 221 SetAlternativeService(request_info, alternative_service);
226 222
227 request_.reset( 223 request_.reset(
(...skipping 18 matching lines...) Expand all
246 job_factory_.alternative_job()->SetStream(http_stream); 242 job_factory_.alternative_job()->SetStream(http_stream);
247 243
248 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, http_stream)) 244 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, http_stream))
249 .WillOnce(Invoke(DeleteHttpStreamPointer)); 245 .WillOnce(Invoke(DeleteHttpStreamPointer));
250 job_controller_->OnStreamReady(job_factory_.alternative_job(), SSLConfig(), 246 job_controller_->OnStreamReady(job_factory_.alternative_job(), SSLConfig(),
251 ProxyInfo()); 247 ProxyInfo());
252 } 248 }
253 249
254 // Regression test for crbug/621069. 250 // Regression test for crbug/621069.
255 // Get load state after main job fails and before alternative job succeeds. 251 // Get load state after main job fails and before alternative job succeeds.
256 TEST_P(HttpStreamFactoryImplJobControllerTest, GetLoadStateAfterMainJobFailed) { 252 TEST_F(HttpStreamFactoryImplJobControllerTest, GetLoadStateAfterMainJobFailed) {
257 HttpRequestInfo request_info; 253 HttpRequestInfo request_info;
258 request_info.method = "GET"; 254 request_info.method = "GET";
259 request_info.url = GURL("https://www.google.com"); 255 request_info.url = GURL("https://www.google.com");
260 256
261 url::SchemeHostPort server(request_info.url); 257 url::SchemeHostPort server(request_info.url);
262 AlternativeService alternative_service(QUIC, server.host(), 443); 258 AlternativeService alternative_service(QUIC, server.host(), 443);
263 SetAlternativeService(request_info, alternative_service); 259 SetAlternativeService(request_info, alternative_service);
264 260
265 request_.reset( 261 request_.reset(
266 job_controller_->Start(request_info, &request_delegate_, nullptr, 262 job_controller_->Start(request_info, &request_delegate_, nullptr,
(...skipping 19 matching lines...) Expand all
286 new HttpBasicStream(new ClientSocketHandle(), false); 282 new HttpBasicStream(new ClientSocketHandle(), false);
287 job_factory_.alternative_job()->SetStream(http_stream); 283 job_factory_.alternative_job()->SetStream(http_stream);
288 284
289 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, http_stream)) 285 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, http_stream))
290 .WillOnce(Invoke(DeleteHttpStreamPointer)); 286 .WillOnce(Invoke(DeleteHttpStreamPointer));
291 job_controller_->OnStreamReady(job_factory_.alternative_job(), SSLConfig(), 287 job_controller_->OnStreamReady(job_factory_.alternative_job(), SSLConfig(),
292 ProxyInfo()); 288 ProxyInfo());
293 } 289 }
294 290
295 } // namespace net 291 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_proxy_client_socket_pool_unittest.cc ('k') | net/http/http_stream_factory_impl_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698