Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 372 | 372 |
| 373 MOCK_METHOD1(OnPrivetRegisterDoneInternal, | 373 MOCK_METHOD1(OnPrivetRegisterDoneInternal, |
| 374 void(const std::string& device_id)); | 374 void(const std::string& device_id)); |
| 375 }; | 375 }; |
| 376 | 376 |
| 377 class MockLocalPrintDelegate : public PrivetLocalPrintOperation::Delegate { | 377 class MockLocalPrintDelegate : public PrivetLocalPrintOperation::Delegate { |
| 378 public: | 378 public: |
| 379 MockLocalPrintDelegate() {} | 379 MockLocalPrintDelegate() {} |
| 380 ~MockLocalPrintDelegate() {} | 380 ~MockLocalPrintDelegate() {} |
| 381 | 381 |
| 382 virtual void OnPrivetPrintingRequestPDF( | |
| 383 const PrivetLocalPrintOperation* print_operation) { | |
| 384 OnPrivetPrintingRequestPDFInternal(); | |
| 385 } | |
| 386 | |
| 387 MOCK_METHOD0(OnPrivetPrintingRequestPDFInternal, void()); | |
| 388 | |
| 389 virtual void OnPrivetPrintingRequestPWGRaster( | |
| 390 const PrivetLocalPrintOperation* print_operation) { | |
| 391 OnPrivetPrintingRequestPWGRasterInternal(); | |
| 392 } | |
| 393 | |
| 394 MOCK_METHOD0(OnPrivetPrintingRequestPWGRasterInternal, void()); | |
| 395 | |
| 396 virtual void OnPrivetPrintingDone( | 382 virtual void OnPrivetPrintingDone( |
| 397 const PrivetLocalPrintOperation* print_operation) { | 383 const PrivetLocalPrintOperation* print_operation) { |
| 398 OnPrivetPrintingDoneInternal(); | 384 OnPrivetPrintingDoneInternal(); |
| 399 } | 385 } |
| 400 | 386 |
| 401 MOCK_METHOD0(OnPrivetPrintingDoneInternal, void()); | 387 MOCK_METHOD0(OnPrivetPrintingDoneInternal, void()); |
| 402 | 388 |
| 403 virtual void OnPrivetPrintingError( | 389 virtual void OnPrivetPrintingError( |
| 404 const PrivetLocalPrintOperation* print_operation, int http_code) { | 390 const PrivetLocalPrintOperation* print_operation, int http_code) { |
| 405 OnPrivetPrintingErrorInternal(http_code); | 391 OnPrivetPrintingErrorInternal(http_code); |
| 406 } | 392 } |
| 407 | 393 |
| 408 MOCK_METHOD1(OnPrivetPrintingErrorInternal, void(int http_code)); | 394 MOCK_METHOD1(OnPrivetPrintingErrorInternal, void(int http_code)); |
| 409 }; | 395 }; |
| 410 | 396 |
| 397 // A note on PWG raster conversion: The PWG raster converter used simply | |
| 398 // converts strings to file paths based on them by appending "test.pdf", since | |
| 399 // it's easier to test that way. Instead of using a mock, we simply check if the | |
| 400 // request is uploading a file that is based on this pattern. | |
| 401 class FakePWGRasterConverter : public PWGRasterConverter { | |
| 402 public: | |
| 403 FakePWGRasterConverter() { | |
| 404 } | |
| 405 | |
| 406 virtual ~FakePWGRasterConverter() { | |
| 407 } | |
| 408 | |
| 409 virtual void SetResultCallback(const ResultCallback& callback) OVERRIDE { | |
| 410 callback_ = callback; | |
| 411 } | |
| 412 | |
| 413 virtual void SetPDFData(scoped_refptr<base::RefCountedBytes> data) OVERRIDE { | |
| 414 std::string data_str((const char*)data->front(), data->size()); | |
| 415 data_ = data_str; | |
| 416 } | |
| 417 | |
| 418 virtual void Start() OVERRIDE { | |
| 419 callback_.Run(true, base::FilePath(data_ + "test.pdf")); | |
| 420 } | |
| 421 | |
| 422 private: | |
| 423 ResultCallback callback_; | |
| 424 std::string data_; | |
| 425 }; | |
| 426 | |
| 427 | |
| 411 class PrivetInfoTest : public PrivetHTTPTest { | 428 class PrivetInfoTest : public PrivetHTTPTest { |
| 412 public: | 429 public: |
| 413 PrivetInfoTest() {} | 430 PrivetInfoTest() {} |
| 414 | 431 |
| 415 virtual ~PrivetInfoTest() {} | 432 virtual ~PrivetInfoTest() {} |
| 416 | 433 |
| 417 virtual void SetUp() OVERRIDE { | 434 virtual void SetUp() OVERRIDE { |
| 418 info_operation_ = privet_client_->CreateInfoOperation(&info_delegate_); | 435 info_operation_ = privet_client_->CreateInfoOperation(&info_delegate_); |
| 419 } | 436 } |
| 420 | 437 |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 775 | 792 |
| 776 class PrivetLocalPrintTest : public PrivetHTTPTest { | 793 class PrivetLocalPrintTest : public PrivetHTTPTest { |
| 777 public: | 794 public: |
| 778 PrivetLocalPrintTest() {} | 795 PrivetLocalPrintTest() {} |
| 779 | 796 |
| 780 virtual ~PrivetLocalPrintTest() {} | 797 virtual ~PrivetLocalPrintTest() {} |
| 781 | 798 |
| 782 virtual void SetUp() OVERRIDE { | 799 virtual void SetUp() OVERRIDE { |
| 783 local_print_operation_ = privet_client_->CreateLocalPrintOperation( | 800 local_print_operation_ = privet_client_->CreateLocalPrintOperation( |
| 784 &local_print_delegate_); | 801 &local_print_delegate_); |
| 802 | |
| 803 local_print_operation_->SetPWGRasterConverterForTesting( | |
| 804 scoped_ptr<PWGRasterConverter>(new FakePWGRasterConverter)); | |
| 805 } | |
| 806 | |
| 807 scoped_refptr<base::RefCountedBytes> RefCountedBytesFromString( | |
| 808 std::string str) { | |
| 809 std::vector<unsigned char> str_vec; | |
| 810 str_vec.insert(str_vec.begin(), str.begin(), str.end()); | |
| 811 return scoped_refptr<base::RefCountedBytes>( | |
| 812 base::RefCountedBytes::TakeVector(&str_vec)); | |
| 785 } | 813 } |
| 786 | 814 |
| 787 protected: | 815 protected: |
| 788 scoped_ptr<PrivetLocalPrintOperation> local_print_operation_; | 816 scoped_ptr<PrivetLocalPrintOperation> local_print_operation_; |
| 789 StrictMock<MockLocalPrintDelegate> local_print_delegate_; | 817 StrictMock<MockLocalPrintDelegate> local_print_delegate_; |
| 790 }; | 818 }; |
| 791 | 819 |
| 792 TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrint) { | 820 TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrint) { |
| 793 local_print_operation_->SetUsername("sample@gmail.com"); | 821 local_print_operation_->SetUsername("sample@gmail.com"); |
| 794 local_print_operation_->SetJobname("Sample job name"); | 822 local_print_operation_->SetJobname("Sample job name"); |
| 823 local_print_operation_->SetData(RefCountedBytesFromString( | |
| 824 "Sample print data")); | |
| 795 local_print_operation_->Start(); | 825 local_print_operation_->Start(); |
| 796 | 826 |
| 797 EXPECT_TRUE(SuccessfulResponseToURL( | 827 EXPECT_TRUE(SuccessfulResponseToURL( |
| 798 GURL("http://10.0.0.8:6006/privet/info"), | 828 GURL("http://10.0.0.8:6006/privet/info"), |
| 799 kSampleInfoResponse)); | 829 kSampleInfoResponse)); |
| 800 | 830 |
| 801 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingRequestPDFInternal()); | |
| 802 | |
| 803 EXPECT_TRUE(SuccessfulResponseToURL( | 831 EXPECT_TRUE(SuccessfulResponseToURL( |
| 804 GURL("http://10.0.0.8:6006/privet/capabilities"), | 832 GURL("http://10.0.0.8:6006/privet/capabilities"), |
| 805 kSampleCapabilitiesResponse)); | 833 kSampleCapabilitiesResponse)); |
| 806 | 834 |
| 807 local_print_operation_->SendData("Sample print data"); | |
| 808 | |
| 809 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); | 835 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); |
| 810 | 836 |
| 811 // TODO(noamsml): Is encoding spaces as pluses standard? | 837 // TODO(noamsml): Is encoding spaces as pluses standard? |
| 812 EXPECT_TRUE(SuccessfulResponseToURLAndData( | 838 EXPECT_TRUE(SuccessfulResponseToURLAndData( |
| 813 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" | 839 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" |
| 814 "user=sample%40gmail.com&jobname=Sample+job+name"), | 840 "user=sample%40gmail.com&jobname=Sample+job+name"), |
| 815 "Sample print data", | 841 "Sample print data", |
| 816 kSampleLocalPrintResponse)); | 842 kSampleLocalPrintResponse)); |
| 817 }; | 843 }; |
| 818 | 844 |
| 819 TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrintWithAnyMimetype) { | 845 TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrintWithAnyMimetype) { |
| 820 local_print_operation_->SetUsername("sample@gmail.com"); | 846 local_print_operation_->SetUsername("sample@gmail.com"); |
| 821 local_print_operation_->SetJobname("Sample job name"); | 847 local_print_operation_->SetJobname("Sample job name"); |
| 848 local_print_operation_->SetData(RefCountedBytesFromString( | |
|
Vitaly Buka (NO REVIEWS)
2013/11/15 06:48:38
line break before RefCountedBytesFromString
Noam Samuel
2013/11/15 19:13:46
Done.
| |
| 849 "Sample print data")); | |
| 822 local_print_operation_->Start(); | 850 local_print_operation_->Start(); |
| 823 | 851 |
| 824 EXPECT_TRUE(SuccessfulResponseToURL( | 852 EXPECT_TRUE(SuccessfulResponseToURL( |
| 825 GURL("http://10.0.0.8:6006/privet/info"), | 853 GURL("http://10.0.0.8:6006/privet/info"), |
| 826 kSampleInfoResponse)); | 854 kSampleInfoResponse)); |
| 827 | 855 |
| 828 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingRequestPDFInternal()); | |
| 829 | |
| 830 EXPECT_TRUE(SuccessfulResponseToURL( | 856 EXPECT_TRUE(SuccessfulResponseToURL( |
| 831 GURL("http://10.0.0.8:6006/privet/capabilities"), | 857 GURL("http://10.0.0.8:6006/privet/capabilities"), |
| 832 kSampleCapabilitiesResponseWithAnyMimetype)); | 858 kSampleCapabilitiesResponseWithAnyMimetype)); |
| 833 | 859 |
| 834 local_print_operation_->SendData("Sample print data"); | |
| 835 | |
| 836 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); | 860 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); |
| 837 | 861 |
| 838 // TODO(noamsml): Is encoding spaces as pluses standard? | 862 // TODO(noamsml): Is encoding spaces as pluses standard? |
| 839 EXPECT_TRUE(SuccessfulResponseToURLAndData( | 863 EXPECT_TRUE(SuccessfulResponseToURLAndData( |
| 840 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" | 864 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" |
| 841 "user=sample%40gmail.com&jobname=Sample+job+name"), | 865 "user=sample%40gmail.com&jobname=Sample+job+name"), |
| 842 "Sample print data", | 866 "Sample print data", |
| 843 kSampleLocalPrintResponse)); | 867 kSampleLocalPrintResponse)); |
| 844 }; | 868 }; |
| 845 | 869 |
| 846 TEST_F(PrivetLocalPrintTest, SuccessfulPWGLocalPrint) { | 870 TEST_F(PrivetLocalPrintTest, SuccessfulPWGLocalPrint) { |
| 847 local_print_operation_->SetUsername("sample@gmail.com"); | 871 local_print_operation_->SetUsername("sample@gmail.com"); |
| 848 local_print_operation_->SetJobname("Sample job name"); | 872 local_print_operation_->SetJobname("Sample job name"); |
| 873 local_print_operation_->SetData(RefCountedBytesFromString( | |
|
Vitaly Buka (NO REVIEWS)
2013/11/15 06:48:38
same
Noam Samuel
2013/11/15 19:13:46
Done.
| |
| 874 "path/to/")); | |
| 849 local_print_operation_->Start(); | 875 local_print_operation_->Start(); |
| 850 | 876 |
| 851 EXPECT_TRUE(SuccessfulResponseToURL( | 877 EXPECT_TRUE(SuccessfulResponseToURL( |
| 852 GURL("http://10.0.0.8:6006/privet/info"), | 878 GURL("http://10.0.0.8:6006/privet/info"), |
| 853 kSampleInfoResponse)); | 879 kSampleInfoResponse)); |
| 854 | 880 |
| 855 EXPECT_CALL(local_print_delegate_, | |
| 856 OnPrivetPrintingRequestPWGRasterInternal()); | |
| 857 | |
| 858 EXPECT_TRUE(SuccessfulResponseToURL( | 881 EXPECT_TRUE(SuccessfulResponseToURL( |
| 859 GURL("http://10.0.0.8:6006/privet/capabilities"), | 882 GURL("http://10.0.0.8:6006/privet/capabilities"), |
| 860 kSampleCapabilitiesResponsePWGOnly)); | 883 kSampleCapabilitiesResponsePWGOnly)); |
| 861 | 884 |
| 862 local_print_operation_->SendDataFile(base::FilePath("sample/file/path")); | |
| 863 | |
| 864 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); | 885 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); |
| 865 | 886 |
| 866 // TODO(noamsml): Is encoding spaces as pluses standard? | 887 // TODO(noamsml): Is encoding spaces as pluses standard? |
| 867 EXPECT_TRUE(SuccessfulResponseToURLAndFilePath( | 888 EXPECT_TRUE(SuccessfulResponseToURLAndFilePath( |
| 868 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" | 889 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" |
| 869 "user=sample%40gmail.com&jobname=Sample+job+name"), | 890 "user=sample%40gmail.com&jobname=Sample+job+name"), |
| 870 base::FilePath("sample/file/path"), | 891 base::FilePath("path/to/test.pdf"), |
| 871 kSampleLocalPrintResponse)); | 892 kSampleLocalPrintResponse)); |
| 872 }; | 893 }; |
| 873 | 894 |
| 874 TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrintWithCreatejob) { | 895 TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrintWithCreatejob) { |
| 875 local_print_operation_->SetUsername("sample@gmail.com"); | 896 local_print_operation_->SetUsername("sample@gmail.com"); |
| 876 local_print_operation_->SetJobname("Sample job name"); | 897 local_print_operation_->SetJobname("Sample job name"); |
| 877 local_print_operation_->SetTicket("Sample print ticket"); | 898 local_print_operation_->SetTicket("Sample print ticket"); |
| 899 local_print_operation_->SetData(RefCountedBytesFromString( | |
|
Vitaly Buka (NO REVIEWS)
2013/11/15 06:48:38
same
Noam Samuel
2013/11/15 19:13:46
Done.
| |
| 900 "Sample print data")); | |
| 878 local_print_operation_->Start(); | 901 local_print_operation_->Start(); |
| 879 | 902 |
| 880 EXPECT_TRUE(SuccessfulResponseToURL( | 903 EXPECT_TRUE(SuccessfulResponseToURL( |
| 881 GURL("http://10.0.0.8:6006/privet/info"), | 904 GURL("http://10.0.0.8:6006/privet/info"), |
| 882 kSampleInfoResponseWithCreatejob)); | 905 kSampleInfoResponseWithCreatejob)); |
| 883 | 906 |
| 884 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingRequestPDFInternal()); | |
| 885 | |
| 886 EXPECT_TRUE(SuccessfulResponseToURL( | 907 EXPECT_TRUE(SuccessfulResponseToURL( |
| 887 GURL("http://10.0.0.8:6006/privet/capabilities"), | 908 GURL("http://10.0.0.8:6006/privet/capabilities"), |
| 888 kSampleCapabilitiesResponse)); | 909 kSampleCapabilitiesResponse)); |
| 889 | 910 |
| 890 local_print_operation_->SendData("Sample print data"); | |
| 891 | |
| 892 EXPECT_TRUE(SuccessfulResponseToURLAndData( | 911 EXPECT_TRUE(SuccessfulResponseToURLAndData( |
| 893 GURL("http://10.0.0.8:6006/privet/printer/createjob"), | 912 GURL("http://10.0.0.8:6006/privet/printer/createjob"), |
| 894 "Sample print ticket", | 913 "Sample print ticket", |
| 895 kSampleCreatejobResponse)); | 914 kSampleCreatejobResponse)); |
| 896 | 915 |
| 897 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); | 916 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); |
| 898 | 917 |
| 899 // TODO(noamsml): Is encoding spaces as pluses standard? | 918 // TODO(noamsml): Is encoding spaces as pluses standard? |
| 900 EXPECT_TRUE(SuccessfulResponseToURLAndData( | 919 EXPECT_TRUE(SuccessfulResponseToURLAndData( |
| 901 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" | 920 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" |
| 902 "user=sample%40gmail.com&jobname=Sample+job+name&job_id=1234"), | 921 "user=sample%40gmail.com&jobname=Sample+job+name&job_id=1234"), |
| 903 "Sample print data", | 922 "Sample print data", |
| 904 kSampleLocalPrintResponse)); | 923 kSampleLocalPrintResponse)); |
| 905 }; | 924 }; |
| 906 | 925 |
| 907 TEST_F(PrivetLocalPrintTest, PDFPrintInvalidDocumentTypeRetry) { | 926 TEST_F(PrivetLocalPrintTest, PDFPrintInvalidDocumentTypeRetry) { |
| 908 local_print_operation_->SetUsername("sample@gmail.com"); | 927 local_print_operation_->SetUsername("sample@gmail.com"); |
| 909 local_print_operation_->SetJobname("Sample job name"); | 928 local_print_operation_->SetJobname("Sample job name"); |
| 910 local_print_operation_->SetTicket("Sample print ticket"); | 929 local_print_operation_->SetTicket("Sample print ticket"); |
| 930 local_print_operation_->SetData(RefCountedBytesFromString( | |
| 931 "sample/path/")); | |
| 911 local_print_operation_->Start(); | 932 local_print_operation_->Start(); |
| 912 | 933 |
| 913 EXPECT_TRUE(SuccessfulResponseToURL( | 934 EXPECT_TRUE(SuccessfulResponseToURL( |
| 914 GURL("http://10.0.0.8:6006/privet/info"), | 935 GURL("http://10.0.0.8:6006/privet/info"), |
| 915 kSampleInfoResponseWithCreatejob)); | 936 kSampleInfoResponseWithCreatejob)); |
| 916 | 937 |
| 917 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingRequestPDFInternal()); | |
| 918 | |
| 919 EXPECT_TRUE(SuccessfulResponseToURL( | 938 EXPECT_TRUE(SuccessfulResponseToURL( |
| 920 GURL("http://10.0.0.8:6006/privet/capabilities"), | 939 GURL("http://10.0.0.8:6006/privet/capabilities"), |
| 921 kSampleCapabilitiesResponse)); | 940 kSampleCapabilitiesResponse)); |
| 922 | 941 |
| 923 local_print_operation_->SendData("Sample print data"); | |
| 924 | |
| 925 EXPECT_TRUE(SuccessfulResponseToURLAndData( | 942 EXPECT_TRUE(SuccessfulResponseToURLAndData( |
| 926 GURL("http://10.0.0.8:6006/privet/printer/createjob"), | 943 GURL("http://10.0.0.8:6006/privet/printer/createjob"), |
| 927 "Sample print ticket", | 944 "Sample print ticket", |
| 928 kSampleCreatejobResponse)); | 945 kSampleCreatejobResponse)); |
| 929 | 946 |
| 930 EXPECT_CALL(local_print_delegate_, | |
| 931 OnPrivetPrintingRequestPWGRasterInternal()); | |
| 932 | |
| 933 // TODO(noamsml): Is encoding spaces as pluses standard? | 947 // TODO(noamsml): Is encoding spaces as pluses standard? |
| 934 EXPECT_TRUE(SuccessfulResponseToURLAndData( | 948 EXPECT_TRUE(SuccessfulResponseToURLAndData( |
| 935 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" | 949 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" |
| 936 "user=sample%40gmail.com&jobname=Sample+job+name&job_id=1234"), | 950 "user=sample%40gmail.com&jobname=Sample+job+name&job_id=1234"), |
| 937 "Sample print data", | 951 "sample/path/", |
| 938 kSampleInvalidDocumentTypeResponse)); | 952 kSampleInvalidDocumentTypeResponse)); |
| 939 | 953 |
| 940 local_print_operation_->SendData("Sample print data2"); | |
| 941 | |
| 942 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); | 954 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); |
| 943 | 955 |
| 944 EXPECT_TRUE(SuccessfulResponseToURLAndData( | 956 EXPECT_TRUE(SuccessfulResponseToURLAndFilePath( |
| 945 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" | 957 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" |
| 946 "user=sample%40gmail.com&jobname=Sample+job+name&job_id=1234"), | 958 "user=sample%40gmail.com&jobname=Sample+job+name&job_id=1234"), |
| 947 "Sample print data2", | 959 base::FilePath("sample/path/test.pdf"), |
| 948 kSampleLocalPrintResponse)); | 960 kSampleLocalPrintResponse)); |
| 949 }; | 961 }; |
| 950 | 962 |
| 951 TEST_F(PrivetLocalPrintTest, LocalPrintRetryOnInvalidJobID) { | 963 TEST_F(PrivetLocalPrintTest, LocalPrintRetryOnInvalidJobID) { |
| 952 local_print_operation_->SetUsername("sample@gmail.com"); | 964 local_print_operation_->SetUsername("sample@gmail.com"); |
| 953 local_print_operation_->SetJobname("Sample job name"); | 965 local_print_operation_->SetJobname("Sample job name"); |
| 954 local_print_operation_->SetTicket("Sample print ticket"); | 966 local_print_operation_->SetTicket("Sample print ticket"); |
| 967 local_print_operation_->SetData(RefCountedBytesFromString( | |
| 968 "Sample print data")); | |
| 955 local_print_operation_->Start(); | 969 local_print_operation_->Start(); |
| 956 | 970 |
| 957 EXPECT_TRUE(SuccessfulResponseToURL( | 971 EXPECT_TRUE(SuccessfulResponseToURL( |
| 958 GURL("http://10.0.0.8:6006/privet/info"), | 972 GURL("http://10.0.0.8:6006/privet/info"), |
| 959 kSampleInfoResponseWithCreatejob)); | 973 kSampleInfoResponseWithCreatejob)); |
| 960 | 974 |
| 961 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingRequestPDFInternal()); | |
| 962 | |
| 963 EXPECT_TRUE(SuccessfulResponseToURL( | 975 EXPECT_TRUE(SuccessfulResponseToURL( |
| 964 GURL("http://10.0.0.8:6006/privet/capabilities"), | 976 GURL("http://10.0.0.8:6006/privet/capabilities"), |
| 965 kSampleCapabilitiesResponse)); | 977 kSampleCapabilitiesResponse)); |
| 966 | 978 |
| 967 local_print_operation_->SendData("Sample print data"); | |
| 968 | |
| 969 EXPECT_TRUE(SuccessfulResponseToURLAndData( | 979 EXPECT_TRUE(SuccessfulResponseToURLAndData( |
| 970 GURL("http://10.0.0.8:6006/privet/printer/createjob"), | 980 GURL("http://10.0.0.8:6006/privet/printer/createjob"), |
| 971 "Sample print ticket", | 981 "Sample print ticket", |
| 972 kSampleCreatejobResponse)); | 982 kSampleCreatejobResponse)); |
| 973 | 983 |
| 974 EXPECT_TRUE(SuccessfulResponseToURLAndData( | 984 EXPECT_TRUE(SuccessfulResponseToURLAndData( |
| 975 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" | 985 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" |
| 976 "user=sample%40gmail.com&jobname=Sample+job+name&job_id=1234"), | 986 "user=sample%40gmail.com&jobname=Sample+job+name&job_id=1234"), |
| 977 "Sample print data", | 987 "Sample print data", |
| 978 kSampleErrorResponsePrinterBusy)); | 988 kSampleErrorResponsePrinterBusy)); |
| 979 | 989 |
| 980 RunFor(base::TimeDelta::FromSeconds(3)); | 990 RunFor(base::TimeDelta::FromSeconds(3)); |
| 981 | 991 |
| 982 EXPECT_TRUE(SuccessfulResponseToURL( | 992 EXPECT_TRUE(SuccessfulResponseToURL( |
| 983 GURL("http://10.0.0.8:6006/privet/printer/createjob"), | 993 GURL("http://10.0.0.8:6006/privet/printer/createjob"), |
| 984 kSampleCreatejobResponse)); | 994 kSampleCreatejobResponse)); |
| 985 }; | 995 }; |
| 986 | 996 |
| 987 | 997 |
| 988 } // namespace | 998 } // namespace |
| 989 | 999 |
| 990 } // namespace local_discovery | 1000 } // namespace local_discovery |
| OLD | NEW |