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

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

Issue 2332643002: Change net/nqe and some url_request tests to use new URLRequest API (Closed)
Patch Set: add ftp job unittests and http job files Created 4 years, 3 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/nqe/throughput_analyzer_unittest.cc ('k') | net/url_request/url_request_http_job.cc » ('j') | 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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 303
304 TestDelegate request_delegate; 304 TestDelegate request_delegate;
305 std::unique_ptr<URLRequest> url_request(request_context()->CreateRequest( 305 std::unique_ptr<URLRequest> url_request(request_context()->CreateRequest(
306 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate)); 306 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate));
307 url_request->Start(); 307 url_request->Start();
308 ASSERT_TRUE(url_request->is_pending()); 308 ASSERT_TRUE(url_request->is_pending());
309 309
310 // The TestDelegate will by default quit the message loop on completion. 310 // The TestDelegate will by default quit the message loop on completion.
311 base::RunLoop().Run(); 311 base::RunLoop().Run();
312 312
313 EXPECT_TRUE(url_request->status().is_success()); 313 EXPECT_THAT(request_delegate.request_status(), IsOk());
314 EXPECT_TRUE(url_request->proxy_server().Equals( 314 EXPECT_TRUE(url_request->proxy_server().Equals(
315 HostPortPair::FromString("localhost:80"))); 315 HostPortPair::FromString("localhost:80")));
316 EXPECT_EQ(1, network_delegate()->completed_requests()); 316 EXPECT_EQ(1, network_delegate()->completed_requests());
317 EXPECT_EQ(0, network_delegate()->error_count()); 317 EXPECT_EQ(0, network_delegate()->error_count());
318 EXPECT_FALSE(request_delegate.auth_required_called()); 318 EXPECT_FALSE(request_delegate.auth_required_called());
319 EXPECT_EQ("test.html", request_delegate.data_received()); 319 EXPECT_EQ("test.html", request_delegate.data_received());
320 } 320 }
321 321
322 // Regression test for http://crbug.com/237526. 322 // Regression test for http://crbug.com/237526.
323 TEST_F(URLRequestFtpJobTest, FtpProxyRequestOrphanJob) { 323 TEST_F(URLRequestFtpJobTest, FtpProxyRequestOrphanJob) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 399
400 TestDelegate request_delegate; 400 TestDelegate request_delegate;
401 std::unique_ptr<URLRequest> url_request(request_context()->CreateRequest( 401 std::unique_ptr<URLRequest> url_request(request_context()->CreateRequest(
402 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate)); 402 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate));
403 url_request->Start(); 403 url_request->Start();
404 ASSERT_TRUE(url_request->is_pending()); 404 ASSERT_TRUE(url_request->is_pending());
405 405
406 // The TestDelegate will by default quit the message loop on completion. 406 // The TestDelegate will by default quit the message loop on completion.
407 base::RunLoop().Run(); 407 base::RunLoop().Run();
408 408
409 EXPECT_TRUE(url_request->status().is_success()); 409 EXPECT_THAT(request_delegate.request_status(), IsOk());
410 EXPECT_TRUE(url_request->proxy_server().Equals( 410 EXPECT_TRUE(url_request->proxy_server().Equals(
411 HostPortPair::FromString("localhost:80"))); 411 HostPortPair::FromString("localhost:80")));
412 EXPECT_EQ(1, network_delegate()->completed_requests()); 412 EXPECT_EQ(1, network_delegate()->completed_requests());
413 EXPECT_EQ(0, network_delegate()->error_count()); 413 EXPECT_EQ(0, network_delegate()->error_count());
414 EXPECT_TRUE(request_delegate.auth_required_called()); 414 EXPECT_TRUE(request_delegate.auth_required_called());
415 EXPECT_EQ("test.html", request_delegate.data_received()); 415 EXPECT_EQ("test.html", request_delegate.data_received());
416 } 416 }
417 417
418 TEST_F(URLRequestFtpJobTest, FtpProxyRequestNeedProxyAuthWithCredentials) { 418 TEST_F(URLRequestFtpJobTest, FtpProxyRequestNeedProxyAuthWithCredentials) {
419 MockWrite writes[] = { 419 MockWrite writes[] = {
(...skipping 25 matching lines...) Expand all
445 request_delegate.set_credentials( 445 request_delegate.set_credentials(
446 AuthCredentials(ASCIIToUTF16("myuser"), ASCIIToUTF16("mypass"))); 446 AuthCredentials(ASCIIToUTF16("myuser"), ASCIIToUTF16("mypass")));
447 std::unique_ptr<URLRequest> url_request(request_context()->CreateRequest( 447 std::unique_ptr<URLRequest> url_request(request_context()->CreateRequest(
448 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate)); 448 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate));
449 url_request->Start(); 449 url_request->Start();
450 ASSERT_TRUE(url_request->is_pending()); 450 ASSERT_TRUE(url_request->is_pending());
451 451
452 // The TestDelegate will by default quit the message loop on completion. 452 // The TestDelegate will by default quit the message loop on completion.
453 base::RunLoop().Run(); 453 base::RunLoop().Run();
454 454
455 EXPECT_TRUE(url_request->status().is_success()); 455 EXPECT_THAT(request_delegate.request_status(), IsOk());
456 EXPECT_EQ(1, network_delegate()->completed_requests()); 456 EXPECT_EQ(1, network_delegate()->completed_requests());
457 EXPECT_EQ(0, network_delegate()->error_count()); 457 EXPECT_EQ(0, network_delegate()->error_count());
458 EXPECT_TRUE(request_delegate.auth_required_called()); 458 EXPECT_TRUE(request_delegate.auth_required_called());
459 EXPECT_EQ("test2.html", request_delegate.data_received()); 459 EXPECT_EQ("test2.html", request_delegate.data_received());
460 } 460 }
461 461
462 TEST_F(URLRequestFtpJobTest, FtpProxyRequestNeedServerAuthNoCredentials) { 462 TEST_F(URLRequestFtpJobTest, FtpProxyRequestNeedServerAuthNoCredentials) {
463 MockWrite writes[] = { 463 MockWrite writes[] = {
464 MockWrite(ASYNC, 0, "GET ftp://ftp.example.com/ HTTP/1.1\r\n" 464 MockWrite(ASYNC, 0, "GET ftp://ftp.example.com/ HTTP/1.1\r\n"
465 "Host: ftp.example.com\r\n" 465 "Host: ftp.example.com\r\n"
(...skipping 12 matching lines...) Expand all
478 478
479 TestDelegate request_delegate; 479 TestDelegate request_delegate;
480 std::unique_ptr<URLRequest> url_request(request_context()->CreateRequest( 480 std::unique_ptr<URLRequest> url_request(request_context()->CreateRequest(
481 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate)); 481 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate));
482 url_request->Start(); 482 url_request->Start();
483 ASSERT_TRUE(url_request->is_pending()); 483 ASSERT_TRUE(url_request->is_pending());
484 484
485 // The TestDelegate will by default quit the message loop on completion. 485 // The TestDelegate will by default quit the message loop on completion.
486 base::RunLoop().Run(); 486 base::RunLoop().Run();
487 487
488 EXPECT_TRUE(url_request->status().is_success()); 488 EXPECT_THAT(request_delegate.request_status(), IsOk());
489 EXPECT_EQ(1, network_delegate()->completed_requests()); 489 EXPECT_EQ(1, network_delegate()->completed_requests());
490 EXPECT_EQ(0, network_delegate()->error_count()); 490 EXPECT_EQ(0, network_delegate()->error_count());
491 EXPECT_TRUE(request_delegate.auth_required_called()); 491 EXPECT_TRUE(request_delegate.auth_required_called());
492 EXPECT_EQ("test.html", request_delegate.data_received()); 492 EXPECT_EQ("test.html", request_delegate.data_received());
493 } 493 }
494 494
495 TEST_F(URLRequestFtpJobTest, FtpProxyRequestNeedServerAuthWithCredentials) { 495 TEST_F(URLRequestFtpJobTest, FtpProxyRequestNeedServerAuthWithCredentials) {
496 MockWrite writes[] = { 496 MockWrite writes[] = {
497 MockWrite(ASYNC, 0, "GET ftp://ftp.example.com/ HTTP/1.1\r\n" 497 MockWrite(ASYNC, 0, "GET ftp://ftp.example.com/ HTTP/1.1\r\n"
498 "Host: ftp.example.com\r\n" 498 "Host: ftp.example.com\r\n"
(...skipping 23 matching lines...) Expand all
522 request_delegate.set_credentials( 522 request_delegate.set_credentials(
523 AuthCredentials(ASCIIToUTF16("myuser"), ASCIIToUTF16("mypass"))); 523 AuthCredentials(ASCIIToUTF16("myuser"), ASCIIToUTF16("mypass")));
524 std::unique_ptr<URLRequest> url_request(request_context()->CreateRequest( 524 std::unique_ptr<URLRequest> url_request(request_context()->CreateRequest(
525 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate)); 525 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate));
526 url_request->Start(); 526 url_request->Start();
527 ASSERT_TRUE(url_request->is_pending()); 527 ASSERT_TRUE(url_request->is_pending());
528 528
529 // The TestDelegate will by default quit the message loop on completion. 529 // The TestDelegate will by default quit the message loop on completion.
530 base::RunLoop().Run(); 530 base::RunLoop().Run();
531 531
532 EXPECT_TRUE(url_request->status().is_success()); 532 EXPECT_THAT(request_delegate.request_status(), IsOk());
533 EXPECT_EQ(1, network_delegate()->completed_requests()); 533 EXPECT_EQ(1, network_delegate()->completed_requests());
534 EXPECT_EQ(0, network_delegate()->error_count()); 534 EXPECT_EQ(0, network_delegate()->error_count());
535 EXPECT_TRUE(request_delegate.auth_required_called()); 535 EXPECT_TRUE(request_delegate.auth_required_called());
536 EXPECT_EQ("test2.html", request_delegate.data_received()); 536 EXPECT_EQ("test2.html", request_delegate.data_received());
537 } 537 }
538 538
539 TEST_F(URLRequestFtpJobTest, FtpProxyRequestNeedProxyAndServerAuth) { 539 TEST_F(URLRequestFtpJobTest, FtpProxyRequestNeedProxyAndServerAuth) {
540 MockWrite writes[] = { 540 MockWrite writes[] = {
541 MockWrite(ASYNC, 0, "GET ftp://ftp.example.com/ HTTP/1.1\r\n" 541 MockWrite(ASYNC, 0, "GET ftp://ftp.example.com/ HTTP/1.1\r\n"
542 "Host: ftp.example.com\r\n" 542 "Host: ftp.example.com\r\n"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 596
597 ASSERT_TRUE(request_delegate.auth_required_called()); 597 ASSERT_TRUE(request_delegate.auth_required_called());
598 EXPECT_EQ(0, network_delegate()->completed_requests()); 598 EXPECT_EQ(0, network_delegate()->completed_requests());
599 EXPECT_EQ(0, network_delegate()->error_count()); 599 EXPECT_EQ(0, network_delegate()->error_count());
600 url_request->SetAuth( 600 url_request->SetAuth(
601 AuthCredentials(ASCIIToUTF16("proxyuser"), ASCIIToUTF16("proxypass"))); 601 AuthCredentials(ASCIIToUTF16("proxyuser"), ASCIIToUTF16("proxypass")));
602 602
603 // Run until server auth is requested. 603 // Run until server auth is requested.
604 base::RunLoop().Run(); 604 base::RunLoop().Run();
605 605
606 EXPECT_TRUE(url_request->status().is_success());
607 EXPECT_EQ(0, network_delegate()->completed_requests()); 606 EXPECT_EQ(0, network_delegate()->completed_requests());
608 EXPECT_EQ(0, network_delegate()->error_count()); 607 EXPECT_EQ(0, network_delegate()->error_count());
609 url_request->SetAuth( 608 url_request->SetAuth(
610 AuthCredentials(ASCIIToUTF16("myuser"), ASCIIToUTF16("mypass"))); 609 AuthCredentials(ASCIIToUTF16("myuser"), ASCIIToUTF16("mypass")));
611 610
612 // The TestDelegate will by default quit the message loop on completion. 611 // The TestDelegate will by default quit the message loop on completion.
613 base::RunLoop().Run(); 612 base::RunLoop().Run();
614 613
615 EXPECT_TRUE(url_request->status().is_success()); 614 EXPECT_THAT(request_delegate.request_status(), IsOk());
616 EXPECT_EQ(1, network_delegate()->completed_requests()); 615 EXPECT_EQ(1, network_delegate()->completed_requests());
617 EXPECT_EQ(0, network_delegate()->error_count()); 616 EXPECT_EQ(0, network_delegate()->error_count());
618 EXPECT_TRUE(request_delegate.auth_required_called()); 617 EXPECT_TRUE(request_delegate.auth_required_called());
619 EXPECT_EQ("test2.html", request_delegate.data_received()); 618 EXPECT_EQ("test2.html", request_delegate.data_received());
620 } 619 }
621 620
622 TEST_F(URLRequestFtpJobTest, FtpProxyRequestDoNotSaveCookies) { 621 TEST_F(URLRequestFtpJobTest, FtpProxyRequestDoNotSaveCookies) {
623 MockWrite writes[] = { 622 MockWrite writes[] = {
624 MockWrite(ASYNC, 0, "GET ftp://ftp.example.com/ HTTP/1.1\r\n" 623 MockWrite(ASYNC, 0, "GET ftp://ftp.example.com/ HTTP/1.1\r\n"
625 "Host: ftp.example.com\r\n" 624 "Host: ftp.example.com\r\n"
(...skipping 10 matching lines...) Expand all
636 635
637 TestDelegate request_delegate; 636 TestDelegate request_delegate;
638 std::unique_ptr<URLRequest> url_request(request_context()->CreateRequest( 637 std::unique_ptr<URLRequest> url_request(request_context()->CreateRequest(
639 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate)); 638 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate));
640 url_request->Start(); 639 url_request->Start();
641 ASSERT_TRUE(url_request->is_pending()); 640 ASSERT_TRUE(url_request->is_pending());
642 641
643 // The TestDelegate will by default quit the message loop on completion. 642 // The TestDelegate will by default quit the message loop on completion.
644 base::RunLoop().Run(); 643 base::RunLoop().Run();
645 644
646 EXPECT_TRUE(url_request->status().is_success()); 645 EXPECT_THAT(request_delegate.request_status(), IsOk());
647 EXPECT_EQ(1, network_delegate()->completed_requests()); 646 EXPECT_EQ(1, network_delegate()->completed_requests());
648 EXPECT_EQ(0, network_delegate()->error_count()); 647 EXPECT_EQ(0, network_delegate()->error_count());
649 648
650 // Make sure we do not accept cookies. 649 // Make sure we do not accept cookies.
651 EXPECT_EQ(0, network_delegate()->set_cookie_count()); 650 EXPECT_EQ(0, network_delegate()->set_cookie_count());
652 651
653 EXPECT_FALSE(request_delegate.auth_required_called()); 652 EXPECT_FALSE(request_delegate.auth_required_called());
654 EXPECT_EQ("test.html", request_delegate.data_received()); 653 EXPECT_EQ("test.html", request_delegate.data_received());
655 } 654 }
656 655
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 EXPECT_TRUE(url_request2->status().is_success()); 797 EXPECT_TRUE(url_request2->status().is_success());
799 EXPECT_EQ(2, network_delegate()->completed_requests()); 798 EXPECT_EQ(2, network_delegate()->completed_requests());
800 EXPECT_EQ(0, network_delegate()->error_count()); 799 EXPECT_EQ(0, network_delegate()->error_count());
801 EXPECT_FALSE(request_delegate2.auth_required_called()); 800 EXPECT_FALSE(request_delegate2.auth_required_called());
802 EXPECT_EQ("test2.html", request_delegate2.data_received()); 801 EXPECT_EQ("test2.html", request_delegate2.data_received());
803 } 802 }
804 803
805 } // namespace 804 } // namespace
806 805
807 } // namespace net 806 } // namespace net
OLDNEW
« no previous file with comments | « net/nqe/throughput_analyzer_unittest.cc ('k') | net/url_request/url_request_http_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698