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

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: Restore scoped_ptr to mock and nits Created 4 years, 10 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 <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 std::move(owned_resolver_factory), nullptr))); 325 std::move(owned_resolver_factory), nullptr)));
326 326
327 TestDelegate request_delegate; 327 TestDelegate request_delegate;
328 scoped_ptr<URLRequest> url_request(request_context()->CreateRequest( 328 scoped_ptr<URLRequest> url_request(request_context()->CreateRequest(
329 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate)); 329 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate));
330 url_request->Start(); 330 url_request->Start();
331 331
332 // Verify PAC request is in progress. 332 // Verify PAC request is in progress.
333 EXPECT_EQ(net::LoadState::LOAD_STATE_RESOLVING_PROXY_FOR_URL, 333 EXPECT_EQ(net::LoadState::LOAD_STATE_RESOLVING_PROXY_FOR_URL,
334 url_request->GetLoadState().state); 334 url_request->GetLoadState().state);
335 EXPECT_EQ(1u, resolver_factory->resolver()->pending_requests().size()); 335 EXPECT_EQ(1u, resolver_factory->resolver()->pending_jobs().size());
336 EXPECT_EQ(0u, resolver_factory->resolver()->cancelled_requests().size()); 336 EXPECT_EQ(0u, resolver_factory->resolver()->cancelled_jobs().size());
337 337
338 // Destroying the request should cancel the PAC request. 338 // Destroying the request should cancel the PAC request.
339 url_request.reset(); 339 url_request.reset();
340 EXPECT_EQ(0u, resolver_factory->resolver()->pending_requests().size()); 340 EXPECT_EQ(0u, resolver_factory->resolver()->pending_jobs().size());
341 EXPECT_EQ(1u, resolver_factory->resolver()->cancelled_requests().size()); 341 EXPECT_EQ(1u, resolver_factory->resolver()->cancelled_jobs().size());
342 } 342 }
343 343
344 // Make sure PAC requests are cancelled on request cancellation. Requests can 344 // Make sure PAC requests are cancelled on request cancellation. Requests can
345 // hang around a bit without being deleted in the cancellation case, so the 345 // hang around a bit without being deleted in the cancellation case, so the
346 // above test is not sufficient. 346 // above test is not sufficient.
347 TEST_F(URLRequestFtpJobTest, FtpProxyRequestCancelRequest) { 347 TEST_F(URLRequestFtpJobTest, FtpProxyRequestCancelRequest) {
348 scoped_ptr<MockProxyResolverFactory> owned_resolver_factory( 348 scoped_ptr<MockProxyResolverFactory> owned_resolver_factory(
349 new MockProxyResolverFactory()); 349 new MockProxyResolverFactory());
350 MockProxyResolverFactory* resolver_factory = owned_resolver_factory.get(); 350 MockProxyResolverFactory* resolver_factory = owned_resolver_factory.get();
351 351
352 // Use a PAC URL so that URLRequestFtpJob's |pac_request_| field is non-NULL. 352 // Use a PAC URL so that URLRequestFtpJob's |pac_request_| field is non-NULL.
353 request_context()->set_proxy_service(make_scoped_ptr(new ProxyService( 353 request_context()->set_proxy_service(make_scoped_ptr(new ProxyService(
354 make_scoped_ptr(new ProxyConfigServiceFixed( 354 make_scoped_ptr(new ProxyConfigServiceFixed(
355 ProxyConfig::CreateFromCustomPacURL(GURL("http://foo")))), 355 ProxyConfig::CreateFromCustomPacURL(GURL("http://foo")))),
356 std::move(owned_resolver_factory), nullptr))); 356 std::move(owned_resolver_factory), nullptr)));
357 357
358 TestDelegate request_delegate; 358 TestDelegate request_delegate;
359 scoped_ptr<URLRequest> url_request(request_context()->CreateRequest( 359 scoped_ptr<URLRequest> url_request(request_context()->CreateRequest(
360 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate)); 360 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate));
361 361
362 // Verify PAC request is in progress. 362 // Verify PAC request is in progress.
363 url_request->Start(); 363 url_request->Start();
364 EXPECT_EQ(net::LoadState::LOAD_STATE_RESOLVING_PROXY_FOR_URL, 364 EXPECT_EQ(net::LoadState::LOAD_STATE_RESOLVING_PROXY_FOR_URL,
365 url_request->GetLoadState().state); 365 url_request->GetLoadState().state);
366 EXPECT_EQ(1u, resolver_factory->resolver()->pending_requests().size()); 366 EXPECT_EQ(1u, resolver_factory->resolver()->pending_jobs().size());
367 EXPECT_EQ(0u, resolver_factory->resolver()->cancelled_requests().size()); 367 EXPECT_EQ(0u, resolver_factory->resolver()->cancelled_jobs().size());
368 368
369 // Cancelling the request should cancel the PAC request. 369 // Cancelling the request should cancel the PAC request.
370 url_request->Cancel(); 370 url_request->Cancel();
371 EXPECT_EQ(net::LoadState::LOAD_STATE_IDLE, url_request->GetLoadState().state); 371 EXPECT_EQ(net::LoadState::LOAD_STATE_IDLE, url_request->GetLoadState().state);
372 EXPECT_EQ(0u, resolver_factory->resolver()->pending_requests().size()); 372 EXPECT_EQ(0u, resolver_factory->resolver()->pending_jobs().size());
373 EXPECT_EQ(1u, resolver_factory->resolver()->cancelled_requests().size()); 373 EXPECT_EQ(1u, resolver_factory->resolver()->cancelled_jobs().size());
374 } 374 }
375 375
376 TEST_F(URLRequestFtpJobTest, FtpProxyRequestNeedProxyAuthNoCredentials) { 376 TEST_F(URLRequestFtpJobTest, FtpProxyRequestNeedProxyAuthNoCredentials) {
377 MockWrite writes[] = { 377 MockWrite writes[] = {
378 MockWrite(ASYNC, 0, "GET ftp://ftp.example.com/ HTTP/1.1\r\n" 378 MockWrite(ASYNC, 0, "GET ftp://ftp.example.com/ HTTP/1.1\r\n"
379 "Host: ftp.example.com\r\n" 379 "Host: ftp.example.com\r\n"
380 "Proxy-Connection: keep-alive\r\n\r\n"), 380 "Proxy-Connection: keep-alive\r\n\r\n"),
381 }; 381 };
382 MockRead reads[] = { 382 MockRead reads[] = {
383 // No credentials. 383 // No credentials.
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 EXPECT_TRUE(url_request2->status().is_success()); 791 EXPECT_TRUE(url_request2->status().is_success());
792 EXPECT_EQ(2, network_delegate()->completed_requests()); 792 EXPECT_EQ(2, network_delegate()->completed_requests());
793 EXPECT_EQ(0, network_delegate()->error_count()); 793 EXPECT_EQ(0, network_delegate()->error_count());
794 EXPECT_FALSE(request_delegate2.auth_required_called()); 794 EXPECT_FALSE(request_delegate2.auth_required_called());
795 EXPECT_EQ("test2.html", request_delegate2.data_received()); 795 EXPECT_EQ("test2.html", request_delegate2.data_received());
796 } 796 }
797 797
798 } // namespace 798 } // namespace
799 799
800 } // namespace net 800 } // 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