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

Side by Side Diff: chrome/browser/local_discovery/privet_http_unittest.cc

Issue 166373006: Use persistent map of privet tokens for PrivetURLFetcher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "chrome/browser/local_discovery/privet_http_impl.h" 7 #include "chrome/browser/local_discovery/privet_http_impl.h"
8 #include "net/base/host_port_pair.h" 8 #include "net/base/host_port_pair.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/url_request/test_url_fetcher_factory.h" 10 #include "net/url_request/test_url_fetcher_factory.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 // Uploaded chunks can be retrieved with the |upload_chunks()| getter. 195 // Uploaded chunks can be retrieved with the |upload_chunks()| getter.
196 MOCK_METHOD1(OnChunkUpload, void(int fetcher_id)); 196 MOCK_METHOD1(OnChunkUpload, void(int fetcher_id));
197 197
198 // Callback issued correspondingly to the destructor. 198 // Callback issued correspondingly to the destructor.
199 MOCK_METHOD1(OnRequestEnd, void(int fetcher_id)); 199 MOCK_METHOD1(OnRequestEnd, void(int fetcher_id));
200 }; 200 };
201 201
202 class PrivetHTTPTest : public ::testing::Test { 202 class PrivetHTTPTest : public ::testing::Test {
203 public: 203 public:
204 PrivetHTTPTest() { 204 PrivetHTTPTest() {
205 PrivetURLFetcher::ResetTokenMapForTests();
206
205 request_context_= new net::TestURLRequestContextGetter( 207 request_context_= new net::TestURLRequestContextGetter(
206 base::MessageLoopProxy::current()); 208 base::MessageLoopProxy::current());
207 privet_client_.reset(new PrivetHTTPClientImpl( 209 privet_client_.reset(new PrivetHTTPClientImpl(
208 "sampleDevice._privet._tcp.local", 210 "sampleDevice._privet._tcp.local",
209 net::HostPortPair("10.0.0.8", 6006), 211 net::HostPortPair("10.0.0.8", 6006),
210 request_context_.get())); 212 request_context_.get()));
211 fetcher_factory_.SetDelegateForTests(&fetcher_delegate_); 213 fetcher_factory_.SetDelegateForTests(&fetcher_delegate_);
212 } 214 }
213 215
214 virtual ~PrivetHTTPTest() { 216 virtual ~PrivetHTTPTest() {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 EXPECT_EQ(GURL("http://10.0.0.8:6006/privet/info"), 437 EXPECT_EQ(GURL("http://10.0.0.8:6006/privet/info"),
436 fetcher->GetOriginalURL()); 438 fetcher->GetOriginalURL());
437 439
438 fetcher->SetResponseString(kSampleInfoResponse); 440 fetcher->SetResponseString(kSampleInfoResponse);
439 fetcher->set_status(net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 441 fetcher->set_status(net::URLRequestStatus(net::URLRequestStatus::SUCCESS,
440 net::OK)); 442 net::OK));
441 fetcher->set_response_code(200); 443 fetcher->set_response_code(200);
442 444
443 EXPECT_CALL(info_callback_, OnPrivetJSONDoneInternal()); 445 EXPECT_CALL(info_callback_, OnPrivetJSONDoneInternal());
444 fetcher->delegate()->OnURLFetchComplete(fetcher); 446 fetcher->delegate()->OnURLFetchComplete(fetcher);
445
446 std::string name;
447
448 privet_client_->GetCachedInfo()->GetString("name", &name);
449 EXPECT_EQ("Common printer", name);
450 };
451
452 TEST_F(PrivetInfoTest, InfoSaveToken) {
453 info_operation_->Start();
454
455 net::TestURLFetcher* fetcher = fetcher_factory_.GetFetcherByID(0);
456 ASSERT_TRUE(fetcher != NULL);
457 fetcher->SetResponseString(kSampleInfoResponse);
458 fetcher->set_status(net::URLRequestStatus(net::URLRequestStatus::SUCCESS,
459 net::OK));
460 fetcher->set_response_code(200);
461
462 EXPECT_CALL(info_callback_, OnPrivetJSONDoneInternal());
463 fetcher->delegate()->OnURLFetchComplete(fetcher);
464
465 info_operation_ =
466 privet_client_->CreateInfoOperation(info_callback_.callback());
467 info_operation_->Start();
468
469 fetcher = fetcher_factory_.GetFetcherByID(0);
470 ASSERT_TRUE(fetcher != NULL);
471 net::HttpRequestHeaders headers;
472 fetcher->GetExtraRequestHeaders(&headers);
473 std::string header_token;
474 ASSERT_TRUE(headers.GetHeader("X-Privet-Token", &header_token));
475 EXPECT_EQ("SampleTokenForTesting", header_token);
476 }; 447 };
477 448
478 TEST_F(PrivetInfoTest, InfoFailureHTTP) { 449 TEST_F(PrivetInfoTest, InfoFailureHTTP) {
479 info_operation_->Start(); 450 info_operation_->Start();
480 451
481 net::TestURLFetcher* fetcher = fetcher_factory_.GetFetcherByID(0); 452 net::TestURLFetcher* fetcher = fetcher_factory_.GetFetcherByID(0);
482 ASSERT_TRUE(fetcher != NULL); 453 ASSERT_TRUE(fetcher != NULL);
483 fetcher->set_status(net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 454 fetcher->set_status(net::URLRequestStatus(net::URLRequestStatus::SUCCESS,
484 net::OK)); 455 net::OK));
485 fetcher->set_response_code(404); 456 fetcher->set_response_code(404);
486 457
487 EXPECT_CALL(info_callback_, OnPrivetJSONDoneInternal()); 458 EXPECT_CALL(info_callback_, OnPrivetJSONDoneInternal());
488 fetcher->delegate()->OnURLFetchComplete(fetcher); 459 fetcher->delegate()->OnURLFetchComplete(fetcher);
489 EXPECT_EQ(NULL, privet_client_->GetCachedInfo());
490 }; 460 };
491 461
492 class PrivetRegisterTest : public PrivetHTTPTest { 462 class PrivetRegisterTest : public PrivetHTTPTest {
493 public: 463 public:
494 PrivetRegisterTest() { 464 PrivetRegisterTest() {
495 } 465 }
496 virtual ~PrivetRegisterTest() { 466 virtual ~PrivetRegisterTest() {
497 } 467 }
498 468
499 virtual void SetUp() OVERRIDE { 469 virtual void SetUp() OVERRIDE {
(...skipping 21 matching lines...) Expand all
521 return true; 491 return true;
522 } 492 }
523 493
524 scoped_ptr<PrivetJSONOperation> info_operation_; 494 scoped_ptr<PrivetJSONOperation> info_operation_;
525 NiceMock<MockJSONCallback> info_callback_; 495 NiceMock<MockJSONCallback> info_callback_;
526 scoped_ptr<PrivetRegisterOperation> register_operation_; 496 scoped_ptr<PrivetRegisterOperation> register_operation_;
527 StrictMock<MockRegisterDelegate> register_delegate_; 497 StrictMock<MockRegisterDelegate> register_delegate_;
528 }; 498 };
529 499
530 TEST_F(PrivetRegisterTest, RegisterSuccessSimple) { 500 TEST_F(PrivetRegisterTest, RegisterSuccessSimple) {
531 // Start with info request first to populate XSRF token. 501 register_operation_->Start();
532 info_operation_->Start();
533 502
534 EXPECT_TRUE(SuccessfulResponseToURL( 503 EXPECT_TRUE(SuccessfulResponseToURL(
535 GURL("http://10.0.0.8:6006/privet/info"), 504 GURL("http://10.0.0.8:6006/privet/info"),
536 kSampleInfoResponse)); 505 kSampleInfoResponse));
537 506
538 register_operation_->Start();
539
540 EXPECT_TRUE(SuccessfulResponseToURL( 507 EXPECT_TRUE(SuccessfulResponseToURL(
541 GURL("http://10.0.0.8:6006/privet/register?" 508 GURL("http://10.0.0.8:6006/privet/register?"
542 "action=start&user=example%40google.com"), 509 "action=start&user=example%40google.com"),
543 kSampleRegisterStartResponse)); 510 kSampleRegisterStartResponse));
544 511
545 EXPECT_CALL(register_delegate_, OnPrivetRegisterClaimTokenInternal( 512 EXPECT_CALL(register_delegate_, OnPrivetRegisterClaimTokenInternal(
546 "MySampleToken", 513 "MySampleToken",
547 GURL("https://domain.com/SoMeUrL"))); 514 GURL("https://domain.com/SoMeUrL")));
548 515
549 EXPECT_TRUE(SuccessfulResponseToURL( 516 EXPECT_TRUE(SuccessfulResponseToURL(
550 GURL("http://10.0.0.8:6006/privet/register?" 517 GURL("http://10.0.0.8:6006/privet/register?"
551 "action=getClaimToken&user=example%40google.com"), 518 "action=getClaimToken&user=example%40google.com"),
552 kSampleRegisterGetClaimTokenResponse)); 519 kSampleRegisterGetClaimTokenResponse));
553 520
554 register_operation_->CompleteRegistration(); 521 register_operation_->CompleteRegistration();
555 522
556 EXPECT_TRUE(SuccessfulResponseToURL( 523 EXPECT_TRUE(SuccessfulResponseToURL(
557 GURL("http://10.0.0.8:6006/privet/register?" 524 GURL("http://10.0.0.8:6006/privet/register?"
558 "action=complete&user=example%40google.com"), 525 "action=complete&user=example%40google.com"),
559 kSampleRegisterCompleteResponse)); 526 kSampleRegisterCompleteResponse));
560 527
561 EXPECT_CALL(register_delegate_, OnPrivetRegisterDoneInternal( 528 EXPECT_CALL(register_delegate_, OnPrivetRegisterDoneInternal(
562 "MyDeviceID")); 529 "MyDeviceID"));
563 530
564 EXPECT_TRUE(SuccessfulResponseToURL( 531 EXPECT_TRUE(SuccessfulResponseToURL(
565 GURL("http://10.0.0.8:6006/privet/info"), 532 GURL("http://10.0.0.8:6006/privet/info"),
566 kSampleInfoResponseRegistered)); 533 kSampleInfoResponseRegistered));
567 } 534 }
568 535
569 TEST_F(PrivetRegisterTest, RegisterNoInfoCall) {
570 register_operation_->Start();
571
572 EXPECT_TRUE(SuccessfulResponseToURL(
573 GURL("http://10.0.0.8:6006/privet/info"),
574 kSampleInfoResponse));
575
576 EXPECT_TRUE(SuccessfulResponseToURL(
577 GURL("http://10.0.0.8:6006/privet/register?"
578 "action=start&user=example%40google.com"),
579 kSampleRegisterStartResponse));
580 }
581
582 TEST_F(PrivetRegisterTest, RegisterXSRFFailure) { 536 TEST_F(PrivetRegisterTest, RegisterXSRFFailure) {
583 register_operation_->Start(); 537 register_operation_->Start();
584 538
585 EXPECT_TRUE(SuccessfulResponseToURL( 539 EXPECT_TRUE(SuccessfulResponseToURL(
586 GURL("http://10.0.0.8:6006/privet/info"), 540 GURL("http://10.0.0.8:6006/privet/info"),
587 kSampleInfoResponse)); 541 kSampleInfoResponse));
588 542
589 EXPECT_TRUE(SuccessfulResponseToURL( 543 EXPECT_TRUE(SuccessfulResponseToURL(
590 GURL("http://10.0.0.8:6006/privet/register?" 544 GURL("http://10.0.0.8:6006/privet/register?"
591 "action=start&user=example%40google.com"), 545 "action=start&user=example%40google.com"),
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 "start", 619 "start",
666 PrivetRegisterOperation::FAILURE_TOKEN, 620 PrivetRegisterOperation::FAILURE_TOKEN,
667 -1)); 621 -1));
668 622
669 EXPECT_TRUE(SuccessfulResponseToURL( 623 EXPECT_TRUE(SuccessfulResponseToURL(
670 GURL("http://10.0.0.8:6006/privet/info"), 624 GURL("http://10.0.0.8:6006/privet/info"),
671 kSampleInfoResponseBadJson)); 625 kSampleInfoResponseBadJson));
672 } 626 }
673 627
674 TEST_F(PrivetRegisterTest, RegisterCancel) { 628 TEST_F(PrivetRegisterTest, RegisterCancel) {
675 // Start with info request first to populate XSRF token. 629 register_operation_->Start();
676 info_operation_->Start();
677 630
678 EXPECT_TRUE(SuccessfulResponseToURL( 631 EXPECT_TRUE(SuccessfulResponseToURL(
679 GURL("http://10.0.0.8:6006/privet/info"), 632 GURL("http://10.0.0.8:6006/privet/info"),
680 kSampleInfoResponse)); 633 kSampleInfoResponse));
681 634
682 register_operation_->Start();
683
684 EXPECT_TRUE(SuccessfulResponseToURL( 635 EXPECT_TRUE(SuccessfulResponseToURL(
685 GURL("http://10.0.0.8:6006/privet/register?" 636 GURL("http://10.0.0.8:6006/privet/register?"
686 "action=start&user=example%40google.com"), 637 "action=start&user=example%40google.com"),
687 kSampleRegisterStartResponse)); 638 kSampleRegisterStartResponse));
688 639
689 register_operation_->Cancel(); 640 register_operation_->Cancel();
690 641
691 EXPECT_TRUE(SuccessfulResponseToURL( 642 EXPECT_TRUE(SuccessfulResponseToURL(
692 GURL("http://10.0.0.8:6006/privet/register?" 643 GURL("http://10.0.0.8:6006/privet/register?"
693 "action=cancel&user=example%40google.com"), 644 "action=cancel&user=example%40google.com"),
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 kSampleCapabilitiesResponse)); 730 kSampleCapabilitiesResponse));
780 }; 731 };
781 732
782 class PrivetLocalPrintTest : public PrivetHTTPTest { 733 class PrivetLocalPrintTest : public PrivetHTTPTest {
783 public: 734 public:
784 PrivetLocalPrintTest() {} 735 PrivetLocalPrintTest() {}
785 736
786 virtual ~PrivetLocalPrintTest() {} 737 virtual ~PrivetLocalPrintTest() {}
787 738
788 virtual void SetUp() OVERRIDE { 739 virtual void SetUp() OVERRIDE {
740 PrivetURLFetcher::ResetTokenMapForTests();
741
789 local_print_operation_ = privet_client_->CreateLocalPrintOperation( 742 local_print_operation_ = privet_client_->CreateLocalPrintOperation(
790 &local_print_delegate_); 743 &local_print_delegate_);
791 744
792 local_print_operation_->SetPWGRasterConverterForTesting( 745 local_print_operation_->SetPWGRasterConverterForTesting(
793 scoped_ptr<PWGRasterConverter>(new FakePWGRasterConverter)); 746 scoped_ptr<PWGRasterConverter>(new FakePWGRasterConverter));
794 } 747 }
795 748
796 scoped_refptr<base::RefCountedBytes> RefCountedBytesFromString( 749 scoped_refptr<base::RefCountedBytes> RefCountedBytesFromString(
797 std::string str) { 750 std::string str) {
798 std::vector<unsigned char> str_vec; 751 std::vector<unsigned char> str_vec;
(...skipping 11 matching lines...) Expand all
810 local_print_operation_->SetUsername("sample@gmail.com"); 763 local_print_operation_->SetUsername("sample@gmail.com");
811 local_print_operation_->SetJobname("Sample job name"); 764 local_print_operation_->SetJobname("Sample job name");
812 local_print_operation_->SetData(RefCountedBytesFromString( 765 local_print_operation_->SetData(RefCountedBytesFromString(
813 "Sample print data")); 766 "Sample print data"));
814 local_print_operation_->Start(); 767 local_print_operation_->Start();
815 768
816 EXPECT_TRUE(SuccessfulResponseToURL( 769 EXPECT_TRUE(SuccessfulResponseToURL(
817 GURL("http://10.0.0.8:6006/privet/info"), 770 GURL("http://10.0.0.8:6006/privet/info"),
818 kSampleInfoResponse)); 771 kSampleInfoResponse));
819 772
820 EXPECT_TRUE(SuccessfulResponseToURL( 773 EXPECT_TRUE(SuccessfulResponseToURL(GURL("http://10.0.0.8:6006/privet/info"),
821 GURL("http://10.0.0.8:6006/privet/capabilities"), 774 kSampleInfoResponse));
822 kSampleCapabilitiesResponse)); 775
776 EXPECT_TRUE(
777 SuccessfulResponseToURL(GURL("http://10.0.0.8:6006/privet/capabilities"),
778 kSampleCapabilitiesResponse));
823 779
824 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); 780 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal());
825 781
826 // TODO(noamsml): Is encoding spaces as pluses standard? 782 // TODO(noamsml): Is encoding spaces as pluses standard?
827 EXPECT_TRUE(SuccessfulResponseToURLAndData( 783 EXPECT_TRUE(SuccessfulResponseToURLAndData(
828 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" 784 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?"
829 "client_name=Chrome&user_name=sample%40gmail.com&" 785 "client_name=Chrome&user_name=sample%40gmail.com&"
830 "job_name=Sample+job+name"), 786 "job_name=Sample+job+name"),
831 "Sample print data", 787 "Sample print data",
832 kSampleLocalPrintResponse)); 788 kSampleLocalPrintResponse));
833 }; 789 };
834 790
835 TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrintWithAnyMimetype) { 791 TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrintWithAnyMimetype) {
836 local_print_operation_->SetUsername("sample@gmail.com"); 792 local_print_operation_->SetUsername("sample@gmail.com");
837 local_print_operation_->SetJobname("Sample job name"); 793 local_print_operation_->SetJobname("Sample job name");
838 local_print_operation_->SetData( 794 local_print_operation_->SetData(
839 RefCountedBytesFromString("Sample print data")); 795 RefCountedBytesFromString("Sample print data"));
840 local_print_operation_->Start(); 796 local_print_operation_->Start();
841 797
842 EXPECT_TRUE(SuccessfulResponseToURL( 798 EXPECT_TRUE(SuccessfulResponseToURL(
843 GURL("http://10.0.0.8:6006/privet/info"), 799 GURL("http://10.0.0.8:6006/privet/info"),
844 kSampleInfoResponse)); 800 kSampleInfoResponse));
845 801
846 EXPECT_TRUE(SuccessfulResponseToURL( 802 EXPECT_TRUE(SuccessfulResponseToURL(GURL("http://10.0.0.8:6006/privet/info"),
847 GURL("http://10.0.0.8:6006/privet/capabilities"), 803 kSampleInfoResponse));
848 kSampleCapabilitiesResponseWithAnyMimetype)); 804
805 EXPECT_TRUE(
806 SuccessfulResponseToURL(GURL("http://10.0.0.8:6006/privet/capabilities"),
807 kSampleCapabilitiesResponseWithAnyMimetype));
849 808
850 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); 809 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal());
851 810
852 // TODO(noamsml): Is encoding spaces as pluses standard? 811 // TODO(noamsml): Is encoding spaces as pluses standard?
853 EXPECT_TRUE(SuccessfulResponseToURLAndData( 812 EXPECT_TRUE(SuccessfulResponseToURLAndData(
854 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" 813 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?"
855 "client_name=Chrome&user_name=sample%40gmail.com&" 814 "client_name=Chrome&user_name=sample%40gmail.com&"
856 "job_name=Sample+job+name"), 815 "job_name=Sample+job+name"),
857 "Sample print data", 816 "Sample print data",
858 kSampleLocalPrintResponse)); 817 kSampleLocalPrintResponse));
859 }; 818 };
860 819
861 TEST_F(PrivetLocalPrintTest, SuccessfulPWGLocalPrint) { 820 TEST_F(PrivetLocalPrintTest, SuccessfulPWGLocalPrint) {
862 local_print_operation_->SetUsername("sample@gmail.com"); 821 local_print_operation_->SetUsername("sample@gmail.com");
863 local_print_operation_->SetJobname("Sample job name"); 822 local_print_operation_->SetJobname("Sample job name");
864 local_print_operation_->SetData( 823 local_print_operation_->SetData(
865 RefCountedBytesFromString("path/to/")); 824 RefCountedBytesFromString("path/to/"));
866 local_print_operation_->Start(); 825 local_print_operation_->Start();
867 826
868 EXPECT_TRUE(SuccessfulResponseToURL( 827 EXPECT_TRUE(SuccessfulResponseToURL(
869 GURL("http://10.0.0.8:6006/privet/info"), 828 GURL("http://10.0.0.8:6006/privet/info"),
870 kSampleInfoResponse)); 829 kSampleInfoResponse));
871 830
872 EXPECT_TRUE(SuccessfulResponseToURL( 831 EXPECT_TRUE(SuccessfulResponseToURL(GURL("http://10.0.0.8:6006/privet/info"),
873 GURL("http://10.0.0.8:6006/privet/capabilities"), 832 kSampleInfoResponse));
874 kSampleCapabilitiesResponsePWGOnly)); 833
834 EXPECT_TRUE(
835 SuccessfulResponseToURL(GURL("http://10.0.0.8:6006/privet/capabilities"),
836 kSampleCapabilitiesResponsePWGOnly));
875 837
876 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); 838 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal());
877 839
878 // TODO(noamsml): Is encoding spaces as pluses standard? 840 // TODO(noamsml): Is encoding spaces as pluses standard?
879 EXPECT_TRUE(SuccessfulResponseToURLAndFilePath( 841 EXPECT_TRUE(SuccessfulResponseToURLAndFilePath(
880 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" 842 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?"
881 "client_name=Chrome&user_name=sample%40gmail.com" 843 "client_name=Chrome&user_name=sample%40gmail.com"
882 "&job_name=Sample+job+name"), 844 "&job_name=Sample+job+name"),
883 base::FilePath(FILE_PATH_LITERAL("path/to/test.pdf")), 845 base::FilePath(FILE_PATH_LITERAL("path/to/test.pdf")),
884 kSampleLocalPrintResponse)); 846 kSampleLocalPrintResponse));
885 }; 847 };
886 848
887 TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrintWithCreatejob) { 849 TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrintWithCreatejob) {
888 local_print_operation_->SetUsername("sample@gmail.com"); 850 local_print_operation_->SetUsername("sample@gmail.com");
889 local_print_operation_->SetJobname("Sample job name"); 851 local_print_operation_->SetJobname("Sample job name");
890 local_print_operation_->SetTicket("Sample print ticket"); 852 local_print_operation_->SetTicket("Sample print ticket");
891 local_print_operation_->SetData( 853 local_print_operation_->SetData(
892 RefCountedBytesFromString("Sample print data")); 854 RefCountedBytesFromString("Sample print data"));
893 local_print_operation_->Start(); 855 local_print_operation_->Start();
894 856
895 EXPECT_TRUE(SuccessfulResponseToURL( 857 EXPECT_TRUE(SuccessfulResponseToURL(
896 GURL("http://10.0.0.8:6006/privet/info"), 858 GURL("http://10.0.0.8:6006/privet/info"),
897 kSampleInfoResponseWithCreatejob)); 859 kSampleInfoResponseWithCreatejob));
898 860
899 EXPECT_TRUE(SuccessfulResponseToURL( 861 EXPECT_TRUE(SuccessfulResponseToURL(GURL("http://10.0.0.8:6006/privet/info"),
900 GURL("http://10.0.0.8:6006/privet/capabilities"), 862 kSampleInfoResponse));
901 kSampleCapabilitiesResponse)); 863
864 EXPECT_TRUE(
865 SuccessfulResponseToURL(GURL("http://10.0.0.8:6006/privet/capabilities"),
866 kSampleCapabilitiesResponse));
902 867
903 EXPECT_TRUE(SuccessfulResponseToURLAndData( 868 EXPECT_TRUE(SuccessfulResponseToURLAndData(
904 GURL("http://10.0.0.8:6006/privet/printer/createjob"), 869 GURL("http://10.0.0.8:6006/privet/printer/createjob"),
905 "Sample print ticket", 870 "Sample print ticket",
906 kSampleCreatejobResponse)); 871 kSampleCreatejobResponse));
907 872
908 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); 873 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal());
909 874
910 // TODO(noamsml): Is encoding spaces as pluses standard? 875 // TODO(noamsml): Is encoding spaces as pluses standard?
911 EXPECT_TRUE(SuccessfulResponseToURLAndData( 876 EXPECT_TRUE(SuccessfulResponseToURLAndData(
912 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" 877 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?"
913 "client_name=Chrome&user_name=sample%40gmail.com&" 878 "client_name=Chrome&user_name=sample%40gmail.com&"
914 "job_name=Sample+job+name&job_id=1234"), 879 "job_name=Sample+job+name&job_id=1234"),
915 "Sample print data", 880 "Sample print data",
916 kSampleLocalPrintResponse)); 881 kSampleLocalPrintResponse));
917 }; 882 };
918 883
919 TEST_F(PrivetLocalPrintTest, PDFPrintInvalidDocumentTypeRetry) { 884 TEST_F(PrivetLocalPrintTest, PDFPrintInvalidDocumentTypeRetry) {
920 local_print_operation_->SetUsername("sample@gmail.com"); 885 local_print_operation_->SetUsername("sample@gmail.com");
921 local_print_operation_->SetJobname("Sample job name"); 886 local_print_operation_->SetJobname("Sample job name");
922 local_print_operation_->SetTicket("Sample print ticket"); 887 local_print_operation_->SetTicket("Sample print ticket");
923 local_print_operation_->SetData( 888 local_print_operation_->SetData(
924 RefCountedBytesFromString("sample/path/")); 889 RefCountedBytesFromString("sample/path/"));
925 local_print_operation_->Start(); 890 local_print_operation_->Start();
926 891
927 EXPECT_TRUE(SuccessfulResponseToURL( 892 EXPECT_TRUE(SuccessfulResponseToURL(
928 GURL("http://10.0.0.8:6006/privet/info"), 893 GURL("http://10.0.0.8:6006/privet/info"),
929 kSampleInfoResponseWithCreatejob)); 894 kSampleInfoResponseWithCreatejob));
930 895
931 EXPECT_TRUE(SuccessfulResponseToURL( 896 EXPECT_TRUE(SuccessfulResponseToURL(GURL("http://10.0.0.8:6006/privet/info"),
932 GURL("http://10.0.0.8:6006/privet/capabilities"), 897 kSampleInfoResponse));
933 kSampleCapabilitiesResponse)); 898
899 EXPECT_TRUE(
900 SuccessfulResponseToURL(GURL("http://10.0.0.8:6006/privet/capabilities"),
901 kSampleCapabilitiesResponse));
934 902
935 EXPECT_TRUE(SuccessfulResponseToURLAndData( 903 EXPECT_TRUE(SuccessfulResponseToURLAndData(
936 GURL("http://10.0.0.8:6006/privet/printer/createjob"), 904 GURL("http://10.0.0.8:6006/privet/printer/createjob"),
937 "Sample print ticket", 905 "Sample print ticket",
938 kSampleCreatejobResponse)); 906 kSampleCreatejobResponse));
939 907
940 // TODO(noamsml): Is encoding spaces as pluses standard? 908 // TODO(noamsml): Is encoding spaces as pluses standard?
941 EXPECT_TRUE(SuccessfulResponseToURLAndData( 909 EXPECT_TRUE(SuccessfulResponseToURLAndData(
942 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" 910 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?"
943 "client_name=Chrome&user_name=sample%40gmail.com&" 911 "client_name=Chrome&user_name=sample%40gmail.com&"
(...skipping 16 matching lines...) Expand all
960 local_print_operation_->SetJobname("Sample job name"); 928 local_print_operation_->SetJobname("Sample job name");
961 local_print_operation_->SetTicket("Sample print ticket"); 929 local_print_operation_->SetTicket("Sample print ticket");
962 local_print_operation_->SetData( 930 local_print_operation_->SetData(
963 RefCountedBytesFromString("Sample print data")); 931 RefCountedBytesFromString("Sample print data"));
964 local_print_operation_->Start(); 932 local_print_operation_->Start();
965 933
966 EXPECT_TRUE(SuccessfulResponseToURL( 934 EXPECT_TRUE(SuccessfulResponseToURL(
967 GURL("http://10.0.0.8:6006/privet/info"), 935 GURL("http://10.0.0.8:6006/privet/info"),
968 kSampleInfoResponseWithCreatejob)); 936 kSampleInfoResponseWithCreatejob));
969 937
938 EXPECT_TRUE(SuccessfulResponseToURL(GURL("http://10.0.0.8:6006/privet/info"),
939 kSampleInfoResponse));
940
970 EXPECT_TRUE(SuccessfulResponseToURL( 941 EXPECT_TRUE(SuccessfulResponseToURL(
971 GURL("http://10.0.0.8:6006/privet/capabilities"), 942 GURL("http://10.0.0.8:6006/privet/capabilities"),
972 kSampleCapabilitiesResponse)); 943 kSampleCapabilitiesResponse));
973 944
974 EXPECT_TRUE(SuccessfulResponseToURLAndData( 945 EXPECT_TRUE(SuccessfulResponseToURLAndData(
975 GURL("http://10.0.0.8:6006/privet/printer/createjob"), 946 GURL("http://10.0.0.8:6006/privet/printer/createjob"),
976 "Sample print ticket", 947 "Sample print ticket",
977 kSampleCreatejobResponse)); 948 kSampleCreatejobResponse));
978 949
979 EXPECT_TRUE(SuccessfulResponseToURLAndData( 950 EXPECT_TRUE(SuccessfulResponseToURLAndData(
980 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" 951 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?"
981 "client_name=Chrome&user_name=sample%40gmail.com&" 952 "client_name=Chrome&user_name=sample%40gmail.com&"
982 "job_name=Sample+job+name&job_id=1234"), 953 "job_name=Sample+job+name&job_id=1234"),
983 "Sample print data", 954 "Sample print data",
984 kSampleErrorResponsePrinterBusy)); 955 kSampleErrorResponsePrinterBusy));
985 956
986 RunFor(base::TimeDelta::FromSeconds(3)); 957 RunFor(base::TimeDelta::FromSeconds(3));
987 958
988 EXPECT_TRUE(SuccessfulResponseToURL( 959 EXPECT_TRUE(SuccessfulResponseToURL(
989 GURL("http://10.0.0.8:6006/privet/printer/createjob"), 960 GURL("http://10.0.0.8:6006/privet/printer/createjob"),
990 kSampleCreatejobResponse)); 961 kSampleCreatejobResponse));
991 }; 962 };
992 963
993 964
994 } // namespace 965 } // namespace
995 966
996 } // namespace local_discovery 967 } // namespace local_discovery
OLDNEW
« no previous file with comments | « chrome/browser/local_discovery/privet_http_impl.cc ('k') | chrome/browser/local_discovery/privet_url_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698