| 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 Start(base::RefCountedBytes* data, |
| 410 const ResultCallback& callback) OVERRIDE { |
| 411 std::string data_str((const char*)data->front(), data->size()); |
| 412 callback.Run(true, base::FilePath().AppendASCII(data_str + "test.pdf")); |
| 413 } |
| 414 }; |
| 415 |
| 416 |
| 411 class PrivetInfoTest : public PrivetHTTPTest { | 417 class PrivetInfoTest : public PrivetHTTPTest { |
| 412 public: | 418 public: |
| 413 PrivetInfoTest() {} | 419 PrivetInfoTest() {} |
| 414 | 420 |
| 415 virtual ~PrivetInfoTest() {} | 421 virtual ~PrivetInfoTest() {} |
| 416 | 422 |
| 417 virtual void SetUp() OVERRIDE { | 423 virtual void SetUp() OVERRIDE { |
| 418 info_operation_ = privet_client_->CreateInfoOperation(&info_delegate_); | 424 info_operation_ = privet_client_->CreateInfoOperation(&info_delegate_); |
| 419 } | 425 } |
| 420 | 426 |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 | 781 |
| 776 class PrivetLocalPrintTest : public PrivetHTTPTest { | 782 class PrivetLocalPrintTest : public PrivetHTTPTest { |
| 777 public: | 783 public: |
| 778 PrivetLocalPrintTest() {} | 784 PrivetLocalPrintTest() {} |
| 779 | 785 |
| 780 virtual ~PrivetLocalPrintTest() {} | 786 virtual ~PrivetLocalPrintTest() {} |
| 781 | 787 |
| 782 virtual void SetUp() OVERRIDE { | 788 virtual void SetUp() OVERRIDE { |
| 783 local_print_operation_ = privet_client_->CreateLocalPrintOperation( | 789 local_print_operation_ = privet_client_->CreateLocalPrintOperation( |
| 784 &local_print_delegate_); | 790 &local_print_delegate_); |
| 791 |
| 792 local_print_operation_->SetPWGRasterConverterForTesting( |
| 793 scoped_ptr<PWGRasterConverter>(new FakePWGRasterConverter)); |
| 794 } |
| 795 |
| 796 scoped_refptr<base::RefCountedBytes> RefCountedBytesFromString( |
| 797 std::string str) { |
| 798 std::vector<unsigned char> str_vec; |
| 799 str_vec.insert(str_vec.begin(), str.begin(), str.end()); |
| 800 return scoped_refptr<base::RefCountedBytes>( |
| 801 base::RefCountedBytes::TakeVector(&str_vec)); |
| 785 } | 802 } |
| 786 | 803 |
| 787 protected: | 804 protected: |
| 788 scoped_ptr<PrivetLocalPrintOperation> local_print_operation_; | 805 scoped_ptr<PrivetLocalPrintOperation> local_print_operation_; |
| 789 StrictMock<MockLocalPrintDelegate> local_print_delegate_; | 806 StrictMock<MockLocalPrintDelegate> local_print_delegate_; |
| 790 }; | 807 }; |
| 791 | 808 |
| 792 TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrint) { | 809 TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrint) { |
| 793 local_print_operation_->SetUsername("sample@gmail.com"); | 810 local_print_operation_->SetUsername("sample@gmail.com"); |
| 794 local_print_operation_->SetJobname("Sample job name"); | 811 local_print_operation_->SetJobname("Sample job name"); |
| 812 local_print_operation_->SetData(RefCountedBytesFromString( |
| 813 "Sample print data")); |
| 795 local_print_operation_->Start(); | 814 local_print_operation_->Start(); |
| 796 | 815 |
| 797 EXPECT_TRUE(SuccessfulResponseToURL( | 816 EXPECT_TRUE(SuccessfulResponseToURL( |
| 798 GURL("http://10.0.0.8:6006/privet/info"), | 817 GURL("http://10.0.0.8:6006/privet/info"), |
| 799 kSampleInfoResponse)); | 818 kSampleInfoResponse)); |
| 800 | 819 |
| 801 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingRequestPDFInternal()); | |
| 802 | |
| 803 EXPECT_TRUE(SuccessfulResponseToURL( | 820 EXPECT_TRUE(SuccessfulResponseToURL( |
| 804 GURL("http://10.0.0.8:6006/privet/capabilities"), | 821 GURL("http://10.0.0.8:6006/privet/capabilities"), |
| 805 kSampleCapabilitiesResponse)); | 822 kSampleCapabilitiesResponse)); |
| 806 | 823 |
| 807 local_print_operation_->SendData("Sample print data"); | |
| 808 | |
| 809 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); | 824 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); |
| 810 | 825 |
| 811 // TODO(noamsml): Is encoding spaces as pluses standard? | 826 // TODO(noamsml): Is encoding spaces as pluses standard? |
| 812 EXPECT_TRUE(SuccessfulResponseToURLAndData( | 827 EXPECT_TRUE(SuccessfulResponseToURLAndData( |
| 813 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" | 828 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" |
| 814 "user=sample%40gmail.com&jobname=Sample+job+name"), | 829 "user=sample%40gmail.com&jobname=Sample+job+name"), |
| 815 "Sample print data", | 830 "Sample print data", |
| 816 kSampleLocalPrintResponse)); | 831 kSampleLocalPrintResponse)); |
| 817 }; | 832 }; |
| 818 | 833 |
| 819 TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrintWithAnyMimetype) { | 834 TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrintWithAnyMimetype) { |
| 820 local_print_operation_->SetUsername("sample@gmail.com"); | 835 local_print_operation_->SetUsername("sample@gmail.com"); |
| 821 local_print_operation_->SetJobname("Sample job name"); | 836 local_print_operation_->SetJobname("Sample job name"); |
| 837 local_print_operation_->SetData( |
| 838 RefCountedBytesFromString("Sample print data")); |
| 822 local_print_operation_->Start(); | 839 local_print_operation_->Start(); |
| 823 | 840 |
| 824 EXPECT_TRUE(SuccessfulResponseToURL( | 841 EXPECT_TRUE(SuccessfulResponseToURL( |
| 825 GURL("http://10.0.0.8:6006/privet/info"), | 842 GURL("http://10.0.0.8:6006/privet/info"), |
| 826 kSampleInfoResponse)); | 843 kSampleInfoResponse)); |
| 827 | 844 |
| 828 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingRequestPDFInternal()); | |
| 829 | |
| 830 EXPECT_TRUE(SuccessfulResponseToURL( | 845 EXPECT_TRUE(SuccessfulResponseToURL( |
| 831 GURL("http://10.0.0.8:6006/privet/capabilities"), | 846 GURL("http://10.0.0.8:6006/privet/capabilities"), |
| 832 kSampleCapabilitiesResponseWithAnyMimetype)); | 847 kSampleCapabilitiesResponseWithAnyMimetype)); |
| 833 | 848 |
| 834 local_print_operation_->SendData("Sample print data"); | |
| 835 | |
| 836 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); | 849 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); |
| 837 | 850 |
| 838 // TODO(noamsml): Is encoding spaces as pluses standard? | 851 // TODO(noamsml): Is encoding spaces as pluses standard? |
| 839 EXPECT_TRUE(SuccessfulResponseToURLAndData( | 852 EXPECT_TRUE(SuccessfulResponseToURLAndData( |
| 840 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" | 853 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" |
| 841 "user=sample%40gmail.com&jobname=Sample+job+name"), | 854 "user=sample%40gmail.com&jobname=Sample+job+name"), |
| 842 "Sample print data", | 855 "Sample print data", |
| 843 kSampleLocalPrintResponse)); | 856 kSampleLocalPrintResponse)); |
| 844 }; | 857 }; |
| 845 | 858 |
| 846 TEST_F(PrivetLocalPrintTest, SuccessfulPWGLocalPrint) { | 859 TEST_F(PrivetLocalPrintTest, SuccessfulPWGLocalPrint) { |
| 847 local_print_operation_->SetUsername("sample@gmail.com"); | 860 local_print_operation_->SetUsername("sample@gmail.com"); |
| 848 local_print_operation_->SetJobname("Sample job name"); | 861 local_print_operation_->SetJobname("Sample job name"); |
| 862 local_print_operation_->SetData( |
| 863 RefCountedBytesFromString("path/to/")); |
| 849 local_print_operation_->Start(); | 864 local_print_operation_->Start(); |
| 850 | 865 |
| 851 EXPECT_TRUE(SuccessfulResponseToURL( | 866 EXPECT_TRUE(SuccessfulResponseToURL( |
| 852 GURL("http://10.0.0.8:6006/privet/info"), | 867 GURL("http://10.0.0.8:6006/privet/info"), |
| 853 kSampleInfoResponse)); | 868 kSampleInfoResponse)); |
| 854 | 869 |
| 855 EXPECT_CALL(local_print_delegate_, | |
| 856 OnPrivetPrintingRequestPWGRasterInternal()); | |
| 857 | |
| 858 EXPECT_TRUE(SuccessfulResponseToURL( | 870 EXPECT_TRUE(SuccessfulResponseToURL( |
| 859 GURL("http://10.0.0.8:6006/privet/capabilities"), | 871 GURL("http://10.0.0.8:6006/privet/capabilities"), |
| 860 kSampleCapabilitiesResponsePWGOnly)); | 872 kSampleCapabilitiesResponsePWGOnly)); |
| 861 | 873 |
| 862 local_print_operation_->SendDataFile( | |
| 863 base::FilePath(FILE_PATH_LITERAL("sample/file/path"))); | |
| 864 | |
| 865 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); | 874 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); |
| 866 | 875 |
| 867 // TODO(noamsml): Is encoding spaces as pluses standard? | 876 // TODO(noamsml): Is encoding spaces as pluses standard? |
| 868 EXPECT_TRUE(SuccessfulResponseToURLAndFilePath( | 877 EXPECT_TRUE(SuccessfulResponseToURLAndFilePath( |
| 869 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" | 878 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" |
| 870 "user=sample%40gmail.com&jobname=Sample+job+name"), | 879 "user=sample%40gmail.com&jobname=Sample+job+name"), |
| 871 base::FilePath(FILE_PATH_LITERAL("sample/file/path")), | 880 base::FilePath(FILE_PATH_LITERAL("path/to/test.pdf")), |
| 872 kSampleLocalPrintResponse)); | 881 kSampleLocalPrintResponse)); |
| 873 }; | 882 }; |
| 874 | 883 |
| 875 TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrintWithCreatejob) { | 884 TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrintWithCreatejob) { |
| 876 local_print_operation_->SetUsername("sample@gmail.com"); | 885 local_print_operation_->SetUsername("sample@gmail.com"); |
| 877 local_print_operation_->SetJobname("Sample job name"); | 886 local_print_operation_->SetJobname("Sample job name"); |
| 878 local_print_operation_->SetTicket("Sample print ticket"); | 887 local_print_operation_->SetTicket("Sample print ticket"); |
| 888 local_print_operation_->SetData( |
| 889 RefCountedBytesFromString("Sample print data")); |
| 879 local_print_operation_->Start(); | 890 local_print_operation_->Start(); |
| 880 | 891 |
| 881 EXPECT_TRUE(SuccessfulResponseToURL( | 892 EXPECT_TRUE(SuccessfulResponseToURL( |
| 882 GURL("http://10.0.0.8:6006/privet/info"), | 893 GURL("http://10.0.0.8:6006/privet/info"), |
| 883 kSampleInfoResponseWithCreatejob)); | 894 kSampleInfoResponseWithCreatejob)); |
| 884 | 895 |
| 885 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingRequestPDFInternal()); | |
| 886 | |
| 887 EXPECT_TRUE(SuccessfulResponseToURL( | 896 EXPECT_TRUE(SuccessfulResponseToURL( |
| 888 GURL("http://10.0.0.8:6006/privet/capabilities"), | 897 GURL("http://10.0.0.8:6006/privet/capabilities"), |
| 889 kSampleCapabilitiesResponse)); | 898 kSampleCapabilitiesResponse)); |
| 890 | 899 |
| 891 local_print_operation_->SendData("Sample print data"); | |
| 892 | |
| 893 EXPECT_TRUE(SuccessfulResponseToURLAndData( | 900 EXPECT_TRUE(SuccessfulResponseToURLAndData( |
| 894 GURL("http://10.0.0.8:6006/privet/printer/createjob"), | 901 GURL("http://10.0.0.8:6006/privet/printer/createjob"), |
| 895 "Sample print ticket", | 902 "Sample print ticket", |
| 896 kSampleCreatejobResponse)); | 903 kSampleCreatejobResponse)); |
| 897 | 904 |
| 898 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); | 905 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); |
| 899 | 906 |
| 900 // TODO(noamsml): Is encoding spaces as pluses standard? | 907 // TODO(noamsml): Is encoding spaces as pluses standard? |
| 901 EXPECT_TRUE(SuccessfulResponseToURLAndData( | 908 EXPECT_TRUE(SuccessfulResponseToURLAndData( |
| 902 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" | 909 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" |
| 903 "user=sample%40gmail.com&jobname=Sample+job+name&job_id=1234"), | 910 "user=sample%40gmail.com&jobname=Sample+job+name&job_id=1234"), |
| 904 "Sample print data", | 911 "Sample print data", |
| 905 kSampleLocalPrintResponse)); | 912 kSampleLocalPrintResponse)); |
| 906 }; | 913 }; |
| 907 | 914 |
| 908 TEST_F(PrivetLocalPrintTest, PDFPrintInvalidDocumentTypeRetry) { | 915 TEST_F(PrivetLocalPrintTest, PDFPrintInvalidDocumentTypeRetry) { |
| 909 local_print_operation_->SetUsername("sample@gmail.com"); | 916 local_print_operation_->SetUsername("sample@gmail.com"); |
| 910 local_print_operation_->SetJobname("Sample job name"); | 917 local_print_operation_->SetJobname("Sample job name"); |
| 911 local_print_operation_->SetTicket("Sample print ticket"); | 918 local_print_operation_->SetTicket("Sample print ticket"); |
| 919 local_print_operation_->SetData( |
| 920 RefCountedBytesFromString("sample/path/")); |
| 912 local_print_operation_->Start(); | 921 local_print_operation_->Start(); |
| 913 | 922 |
| 914 EXPECT_TRUE(SuccessfulResponseToURL( | 923 EXPECT_TRUE(SuccessfulResponseToURL( |
| 915 GURL("http://10.0.0.8:6006/privet/info"), | 924 GURL("http://10.0.0.8:6006/privet/info"), |
| 916 kSampleInfoResponseWithCreatejob)); | 925 kSampleInfoResponseWithCreatejob)); |
| 917 | 926 |
| 918 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingRequestPDFInternal()); | |
| 919 | |
| 920 EXPECT_TRUE(SuccessfulResponseToURL( | 927 EXPECT_TRUE(SuccessfulResponseToURL( |
| 921 GURL("http://10.0.0.8:6006/privet/capabilities"), | 928 GURL("http://10.0.0.8:6006/privet/capabilities"), |
| 922 kSampleCapabilitiesResponse)); | 929 kSampleCapabilitiesResponse)); |
| 923 | 930 |
| 924 local_print_operation_->SendData("Sample print data"); | |
| 925 | |
| 926 EXPECT_TRUE(SuccessfulResponseToURLAndData( | 931 EXPECT_TRUE(SuccessfulResponseToURLAndData( |
| 927 GURL("http://10.0.0.8:6006/privet/printer/createjob"), | 932 GURL("http://10.0.0.8:6006/privet/printer/createjob"), |
| 928 "Sample print ticket", | 933 "Sample print ticket", |
| 929 kSampleCreatejobResponse)); | 934 kSampleCreatejobResponse)); |
| 930 | 935 |
| 931 EXPECT_CALL(local_print_delegate_, | |
| 932 OnPrivetPrintingRequestPWGRasterInternal()); | |
| 933 | |
| 934 // TODO(noamsml): Is encoding spaces as pluses standard? | 936 // TODO(noamsml): Is encoding spaces as pluses standard? |
| 935 EXPECT_TRUE(SuccessfulResponseToURLAndData( | 937 EXPECT_TRUE(SuccessfulResponseToURLAndData( |
| 936 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" | 938 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" |
| 937 "user=sample%40gmail.com&jobname=Sample+job+name&job_id=1234"), | 939 "user=sample%40gmail.com&jobname=Sample+job+name&job_id=1234"), |
| 938 "Sample print data", | 940 "sample/path/", |
| 939 kSampleInvalidDocumentTypeResponse)); | 941 kSampleInvalidDocumentTypeResponse)); |
| 940 | 942 |
| 941 local_print_operation_->SendData("Sample print data2"); | |
| 942 | |
| 943 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); | 943 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal()); |
| 944 | 944 |
| 945 EXPECT_TRUE(SuccessfulResponseToURLAndData( | 945 EXPECT_TRUE(SuccessfulResponseToURLAndFilePath( |
| 946 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" | 946 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" |
| 947 "user=sample%40gmail.com&jobname=Sample+job+name&job_id=1234"), | 947 "user=sample%40gmail.com&jobname=Sample+job+name&job_id=1234"), |
| 948 "Sample print data2", | 948 base::FilePath(FILE_PATH_LITERAL("sample/path/test.pdf")), |
| 949 kSampleLocalPrintResponse)); | 949 kSampleLocalPrintResponse)); |
| 950 }; | 950 }; |
| 951 | 951 |
| 952 TEST_F(PrivetLocalPrintTest, LocalPrintRetryOnInvalidJobID) { | 952 TEST_F(PrivetLocalPrintTest, LocalPrintRetryOnInvalidJobID) { |
| 953 local_print_operation_->SetUsername("sample@gmail.com"); | 953 local_print_operation_->SetUsername("sample@gmail.com"); |
| 954 local_print_operation_->SetJobname("Sample job name"); | 954 local_print_operation_->SetJobname("Sample job name"); |
| 955 local_print_operation_->SetTicket("Sample print ticket"); | 955 local_print_operation_->SetTicket("Sample print ticket"); |
| 956 local_print_operation_->SetData( |
| 957 RefCountedBytesFromString("Sample print data")); |
| 956 local_print_operation_->Start(); | 958 local_print_operation_->Start(); |
| 957 | 959 |
| 958 EXPECT_TRUE(SuccessfulResponseToURL( | 960 EXPECT_TRUE(SuccessfulResponseToURL( |
| 959 GURL("http://10.0.0.8:6006/privet/info"), | 961 GURL("http://10.0.0.8:6006/privet/info"), |
| 960 kSampleInfoResponseWithCreatejob)); | 962 kSampleInfoResponseWithCreatejob)); |
| 961 | 963 |
| 962 EXPECT_CALL(local_print_delegate_, OnPrivetPrintingRequestPDFInternal()); | |
| 963 | |
| 964 EXPECT_TRUE(SuccessfulResponseToURL( | 964 EXPECT_TRUE(SuccessfulResponseToURL( |
| 965 GURL("http://10.0.0.8:6006/privet/capabilities"), | 965 GURL("http://10.0.0.8:6006/privet/capabilities"), |
| 966 kSampleCapabilitiesResponse)); | 966 kSampleCapabilitiesResponse)); |
| 967 | 967 |
| 968 local_print_operation_->SendData("Sample print data"); | |
| 969 | |
| 970 EXPECT_TRUE(SuccessfulResponseToURLAndData( | 968 EXPECT_TRUE(SuccessfulResponseToURLAndData( |
| 971 GURL("http://10.0.0.8:6006/privet/printer/createjob"), | 969 GURL("http://10.0.0.8:6006/privet/printer/createjob"), |
| 972 "Sample print ticket", | 970 "Sample print ticket", |
| 973 kSampleCreatejobResponse)); | 971 kSampleCreatejobResponse)); |
| 974 | 972 |
| 975 EXPECT_TRUE(SuccessfulResponseToURLAndData( | 973 EXPECT_TRUE(SuccessfulResponseToURLAndData( |
| 976 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" | 974 GURL("http://10.0.0.8:6006/privet/printer/submitdoc?" |
| 977 "user=sample%40gmail.com&jobname=Sample+job+name&job_id=1234"), | 975 "user=sample%40gmail.com&jobname=Sample+job+name&job_id=1234"), |
| 978 "Sample print data", | 976 "Sample print data", |
| 979 kSampleErrorResponsePrinterBusy)); | 977 kSampleErrorResponsePrinterBusy)); |
| 980 | 978 |
| 981 RunFor(base::TimeDelta::FromSeconds(3)); | 979 RunFor(base::TimeDelta::FromSeconds(3)); |
| 982 | 980 |
| 983 EXPECT_TRUE(SuccessfulResponseToURL( | 981 EXPECT_TRUE(SuccessfulResponseToURL( |
| 984 GURL("http://10.0.0.8:6006/privet/printer/createjob"), | 982 GURL("http://10.0.0.8:6006/privet/printer/createjob"), |
| 985 kSampleCreatejobResponse)); | 983 kSampleCreatejobResponse)); |
| 986 }; | 984 }; |
| 987 | 985 |
| 988 | 986 |
| 989 } // namespace | 987 } // namespace |
| 990 | 988 |
| 991 } // namespace local_discovery | 989 } // namespace local_discovery |
| OLD | NEW |