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

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

Issue 1439053002: Change ProxyResolver::GetProxyForURL() to take a scoped_ptr<Request>* rather than a RequestHandle* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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) 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 "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 owned_resolver_factory.Pass(), nullptr))); 321 owned_resolver_factory.Pass(), nullptr)));
322 322
323 TestDelegate request_delegate; 323 TestDelegate request_delegate;
324 scoped_ptr<URLRequest> url_request(request_context()->CreateRequest( 324 scoped_ptr<URLRequest> url_request(request_context()->CreateRequest(
325 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate)); 325 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate));
326 url_request->Start(); 326 url_request->Start();
327 327
328 // Verify PAC request is in progress. 328 // Verify PAC request is in progress.
329 EXPECT_EQ(net::LoadState::LOAD_STATE_RESOLVING_PROXY_FOR_URL, 329 EXPECT_EQ(net::LoadState::LOAD_STATE_RESOLVING_PROXY_FOR_URL,
330 url_request->GetLoadState().state); 330 url_request->GetLoadState().state);
331 EXPECT_EQ(1u, resolver_factory->resolver()->pending_requests().size()); 331 EXPECT_EQ(1u, resolver_factory->resolver()->pending_jobs().size());
332 EXPECT_EQ(0u, resolver_factory->resolver()->cancelled_requests().size()); 332 EXPECT_EQ(0u, resolver_factory->resolver()->cancelled_jobs().size());
333 333
334 // Destroying the request should cancel the PAC request. 334 // Destroying the request should cancel the PAC request.
335 url_request.reset(); 335 url_request.reset();
336 EXPECT_EQ(0u, resolver_factory->resolver()->pending_requests().size()); 336 EXPECT_EQ(0u, resolver_factory->resolver()->pending_jobs().size());
337 EXPECT_EQ(1u, resolver_factory->resolver()->cancelled_requests().size()); 337 EXPECT_EQ(1u, resolver_factory->resolver()->cancelled_jobs().size());
338 } 338 }
339 339
340 // Make sure PAC requests are cancelled on request cancellation. Requests can 340 // Make sure PAC requests are cancelled on request cancellation. Requests can
341 // hang around a bit without being deleted in the cancellation case, so the 341 // hang around a bit without being deleted in the cancellation case, so the
342 // above test is not sufficient. 342 // above test is not sufficient.
343 TEST_F(URLRequestFtpJobTest, FtpProxyRequestCancelRequest) { 343 TEST_F(URLRequestFtpJobTest, FtpProxyRequestCancelRequest) {
344 scoped_ptr<MockProxyResolverFactory> owned_resolver_factory( 344 scoped_ptr<MockProxyResolverFactory> owned_resolver_factory(
345 new MockProxyResolverFactory()); 345 new MockProxyResolverFactory());
346 MockProxyResolverFactory* resolver_factory = owned_resolver_factory.get(); 346 MockProxyResolverFactory* resolver_factory = owned_resolver_factory.get();
347 347
348 // Use a PAC URL so that URLRequestFtpJob's |pac_request_| field is non-NULL. 348 // Use a PAC URL so that URLRequestFtpJob's |pac_request_| field is non-NULL.
349 request_context()->set_proxy_service(make_scoped_ptr(new ProxyService( 349 request_context()->set_proxy_service(make_scoped_ptr(new ProxyService(
350 make_scoped_ptr(new ProxyConfigServiceFixed( 350 make_scoped_ptr(new ProxyConfigServiceFixed(
351 ProxyConfig::CreateFromCustomPacURL(GURL("http://foo")))), 351 ProxyConfig::CreateFromCustomPacURL(GURL("http://foo")))),
352 owned_resolver_factory.Pass(), nullptr))); 352 owned_resolver_factory.Pass(), nullptr)));
353 353
354 TestDelegate request_delegate; 354 TestDelegate request_delegate;
355 scoped_ptr<URLRequest> url_request(request_context()->CreateRequest( 355 scoped_ptr<URLRequest> url_request(request_context()->CreateRequest(
356 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate)); 356 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate));
357 357
358 // Verify PAC request is in progress. 358 // Verify PAC request is in progress.
359 url_request->Start(); 359 url_request->Start();
360 EXPECT_EQ(net::LoadState::LOAD_STATE_RESOLVING_PROXY_FOR_URL, 360 EXPECT_EQ(net::LoadState::LOAD_STATE_RESOLVING_PROXY_FOR_URL,
361 url_request->GetLoadState().state); 361 url_request->GetLoadState().state);
362 EXPECT_EQ(1u, resolver_factory->resolver()->pending_requests().size()); 362 EXPECT_EQ(1u, resolver_factory->resolver()->pending_jobs().size());
363 EXPECT_EQ(0u, resolver_factory->resolver()->cancelled_requests().size()); 363 EXPECT_EQ(0u, resolver_factory->resolver()->cancelled_jobs().size());
364 364
365 // Cancelling the request should cancel the PAC request. 365 // Cancelling the request should cancel the PAC request.
366 url_request->Cancel(); 366 url_request->Cancel();
367 EXPECT_EQ(net::LoadState::LOAD_STATE_IDLE, url_request->GetLoadState().state); 367 EXPECT_EQ(net::LoadState::LOAD_STATE_IDLE, url_request->GetLoadState().state);
368 EXPECT_EQ(0u, resolver_factory->resolver()->pending_requests().size()); 368 EXPECT_EQ(0u, resolver_factory->resolver()->pending_jobs().size());
369 EXPECT_EQ(1u, resolver_factory->resolver()->cancelled_requests().size()); 369 EXPECT_EQ(1u, resolver_factory->resolver()->cancelled_jobs().size());
370 } 370 }
371 371
372 TEST_F(URLRequestFtpJobTest, FtpProxyRequestNeedProxyAuthNoCredentials) { 372 TEST_F(URLRequestFtpJobTest, FtpProxyRequestNeedProxyAuthNoCredentials) {
373 MockWrite writes[] = { 373 MockWrite writes[] = {
374 MockWrite(ASYNC, 0, "GET ftp://ftp.example.com/ HTTP/1.1\r\n" 374 MockWrite(ASYNC, 0, "GET ftp://ftp.example.com/ HTTP/1.1\r\n"
375 "Host: ftp.example.com\r\n" 375 "Host: ftp.example.com\r\n"
376 "Proxy-Connection: keep-alive\r\n\r\n"), 376 "Proxy-Connection: keep-alive\r\n\r\n"),
377 }; 377 };
378 MockRead reads[] = { 378 MockRead reads[] = {
379 // No credentials. 379 // No credentials.
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 EXPECT_TRUE(url_request2->status().is_success()); 787 EXPECT_TRUE(url_request2->status().is_success());
788 EXPECT_EQ(2, network_delegate()->completed_requests()); 788 EXPECT_EQ(2, network_delegate()->completed_requests());
789 EXPECT_EQ(0, network_delegate()->error_count()); 789 EXPECT_EQ(0, network_delegate()->error_count());
790 EXPECT_FALSE(request_delegate2.auth_required_called()); 790 EXPECT_FALSE(request_delegate2.auth_required_called());
791 EXPECT_EQ("test2.html", request_delegate2.data_received()); 791 EXPECT_EQ("test2.html", request_delegate2.data_received());
792 } 792 }
793 793
794 } // namespace 794 } // namespace
795 795
796 } // namespace net 796 } // namespace net
OLDNEW
« net/proxy/proxy_resolver_factory_mojo.cc ('K') | « net/proxy/proxy_service_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698