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

Side by Side Diff: net/url_request/url_request_ftp_job_unittest.cc

Issue 2299963002: Reland "Change ProxyResolver::GetProxyForURL() to take a unique_ptr<Request>* " (Closed)
Patch Set: remove fields proposed by eroman Created 4 years, 2 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
« no previous file with comments | « net/proxy/proxy_service_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/url_request/url_request_ftp_job.h" 5 #include "net/url_request/url_request_ftp_job.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 std::move(owned_resolver_factory), nullptr))); 334 std::move(owned_resolver_factory), nullptr)));
335 335
336 TestDelegate request_delegate; 336 TestDelegate request_delegate;
337 std::unique_ptr<URLRequest> url_request(request_context()->CreateRequest( 337 std::unique_ptr<URLRequest> url_request(request_context()->CreateRequest(
338 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate)); 338 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate));
339 url_request->Start(); 339 url_request->Start();
340 340
341 // Verify PAC request is in progress. 341 // Verify PAC request is in progress.
342 EXPECT_EQ(net::LoadState::LOAD_STATE_RESOLVING_PROXY_FOR_URL, 342 EXPECT_EQ(net::LoadState::LOAD_STATE_RESOLVING_PROXY_FOR_URL,
343 url_request->GetLoadState().state); 343 url_request->GetLoadState().state);
344 EXPECT_EQ(1u, resolver_factory->resolver()->pending_requests().size()); 344 EXPECT_EQ(1u, resolver_factory->resolver()->pending_jobs().size());
345 EXPECT_EQ(0u, resolver_factory->resolver()->cancelled_requests().size()); 345 EXPECT_EQ(0u, resolver_factory->resolver()->cancelled_jobs().size());
346 346
347 // Destroying the request should cancel the PAC request. 347 // Destroying the request should cancel the PAC request.
348 url_request.reset(); 348 url_request.reset();
349 EXPECT_EQ(0u, resolver_factory->resolver()->pending_requests().size()); 349 EXPECT_EQ(0u, resolver_factory->resolver()->pending_jobs().size());
350 EXPECT_EQ(1u, resolver_factory->resolver()->cancelled_requests().size()); 350 EXPECT_EQ(1u, resolver_factory->resolver()->cancelled_jobs().size());
351 } 351 }
352 352
353 // Make sure PAC requests are cancelled on request cancellation. Requests can 353 // Make sure PAC requests are cancelled on request cancellation. Requests can
354 // hang around a bit without being deleted in the cancellation case, so the 354 // hang around a bit without being deleted in the cancellation case, so the
355 // above test is not sufficient. 355 // above test is not sufficient.
356 TEST_F(URLRequestFtpJobTest, FtpProxyRequestCancelRequest) { 356 TEST_F(URLRequestFtpJobTest, FtpProxyRequestCancelRequest) {
357 std::unique_ptr<MockProxyResolverFactory> owned_resolver_factory( 357 std::unique_ptr<MockProxyResolverFactory> owned_resolver_factory(
358 new MockProxyResolverFactory()); 358 new MockProxyResolverFactory());
359 MockProxyResolverFactory* resolver_factory = owned_resolver_factory.get(); 359 MockProxyResolverFactory* resolver_factory = owned_resolver_factory.get();
360 360
361 // Use a PAC URL so that URLRequestFtpJob's |pac_request_| field is non-NULL. 361 // Use a PAC URL so that URLRequestFtpJob's |pac_request_| field is non-NULL.
362 request_context()->set_proxy_service(base::WrapUnique(new ProxyService( 362 request_context()->set_proxy_service(base::WrapUnique(new ProxyService(
363 base::WrapUnique(new ProxyConfigServiceFixed( 363 base::WrapUnique(new ProxyConfigServiceFixed(
364 ProxyConfig::CreateFromCustomPacURL(GURL("http://foo")))), 364 ProxyConfig::CreateFromCustomPacURL(GURL("http://foo")))),
365 std::move(owned_resolver_factory), nullptr))); 365 std::move(owned_resolver_factory), nullptr)));
366 366
367 TestDelegate request_delegate; 367 TestDelegate request_delegate;
368 std::unique_ptr<URLRequest> url_request(request_context()->CreateRequest( 368 std::unique_ptr<URLRequest> url_request(request_context()->CreateRequest(
369 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate)); 369 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate));
370 370
371 // Verify PAC request is in progress. 371 // Verify PAC request is in progress.
372 url_request->Start(); 372 url_request->Start();
373 EXPECT_EQ(net::LoadState::LOAD_STATE_RESOLVING_PROXY_FOR_URL, 373 EXPECT_EQ(net::LoadState::LOAD_STATE_RESOLVING_PROXY_FOR_URL,
374 url_request->GetLoadState().state); 374 url_request->GetLoadState().state);
375 EXPECT_EQ(1u, resolver_factory->resolver()->pending_requests().size()); 375 EXPECT_EQ(1u, resolver_factory->resolver()->pending_jobs().size());
376 EXPECT_EQ(0u, resolver_factory->resolver()->cancelled_requests().size()); 376 EXPECT_EQ(0u, resolver_factory->resolver()->cancelled_jobs().size());
377 377
378 // Cancelling the request should cancel the PAC request. 378 // Cancelling the request should cancel the PAC request.
379 url_request->Cancel(); 379 url_request->Cancel();
380 EXPECT_EQ(net::LoadState::LOAD_STATE_IDLE, url_request->GetLoadState().state); 380 EXPECT_EQ(net::LoadState::LOAD_STATE_IDLE, url_request->GetLoadState().state);
381 EXPECT_EQ(0u, resolver_factory->resolver()->pending_requests().size()); 381 EXPECT_EQ(0u, resolver_factory->resolver()->pending_jobs().size());
382 EXPECT_EQ(1u, resolver_factory->resolver()->cancelled_requests().size()); 382 EXPECT_EQ(1u, resolver_factory->resolver()->cancelled_jobs().size());
383 } 383 }
384 384
385 TEST_F(URLRequestFtpJobTest, FtpProxyRequestNeedProxyAuthNoCredentials) { 385 TEST_F(URLRequestFtpJobTest, FtpProxyRequestNeedProxyAuthNoCredentials) {
386 MockWrite writes[] = { 386 MockWrite writes[] = {
387 MockWrite(ASYNC, 0, "GET ftp://ftp.example.com/ HTTP/1.1\r\n" 387 MockWrite(ASYNC, 0, "GET ftp://ftp.example.com/ HTTP/1.1\r\n"
388 "Host: ftp.example.com\r\n" 388 "Host: ftp.example.com\r\n"
389 "Proxy-Connection: keep-alive\r\n\r\n"), 389 "Proxy-Connection: keep-alive\r\n\r\n"),
390 }; 390 };
391 MockRead reads[] = { 391 MockRead reads[] = {
392 // No credentials. 392 // No credentials.
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 EXPECT_TRUE(url_request2->status().is_success()); 801 EXPECT_TRUE(url_request2->status().is_success());
802 EXPECT_EQ(2, network_delegate()->completed_requests()); 802 EXPECT_EQ(2, network_delegate()->completed_requests());
803 EXPECT_EQ(0, network_delegate()->error_count()); 803 EXPECT_EQ(0, network_delegate()->error_count());
804 EXPECT_FALSE(request_delegate2.auth_required_called()); 804 EXPECT_FALSE(request_delegate2.auth_required_called());
805 EXPECT_EQ("test2.html", request_delegate2.data_received()); 805 EXPECT_EQ("test2.html", request_delegate2.data_received());
806 } 806 }
807 807
808 } // namespace 808 } // namespace
809 809
810 } // namespace net 810 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_service_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698