| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 { | 508 { |
| 509 base::RunLoop run_loop; | 509 base::RunLoop run_loop; |
| 510 drive::AboutGetRequest* request = new drive::AboutGetRequest( | 510 drive::AboutGetRequest* request = new drive::AboutGetRequest( |
| 511 request_sender_.get(), | 511 request_sender_.get(), |
| 512 *url_generator_, | 512 *url_generator_, |
| 513 test_util::CreateQuitCallback( | 513 test_util::CreateQuitCallback( |
| 514 &run_loop, | 514 &run_loop, |
| 515 test_util::CreateCopyResultCallback(&error, &about_resource))); | 515 test_util::CreateCopyResultCallback(&error, &about_resource))); |
| 516 request->set_fields("kind,quotaBytesTotal,quotaBytesUsedAggregate," | 516 request->set_fields("kind,quotaBytesTotal,quotaBytesUsedAggregate," |
| 517 "largestChangeId,rootFolderId"); | 517 "largestChangeId,rootFolderId"); |
| 518 request_sender_->StartRequestWithRetry(request); | 518 request_sender_->StartRequestWithAuthRetry(request); |
| 519 run_loop.Run(); | 519 run_loop.Run(); |
| 520 } | 520 } |
| 521 | 521 |
| 522 EXPECT_EQ(HTTP_SUCCESS, error); | 522 EXPECT_EQ(HTTP_SUCCESS, error); |
| 523 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 523 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 524 EXPECT_EQ("/drive/v2/about?" | 524 EXPECT_EQ("/drive/v2/about?" |
| 525 "fields=kind%2CquotaBytesTotal%2CquotaBytesUsedAggregate%2C" | 525 "fields=kind%2CquotaBytesTotal%2CquotaBytesUsedAggregate%2C" |
| 526 "largestChangeId%2CrootFolderId", | 526 "largestChangeId%2CrootFolderId", |
| 527 http_request_.relative_url); | 527 http_request_.relative_url); |
| 528 | 528 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 558 test_util::CreateQuitCallback( | 558 test_util::CreateQuitCallback( |
| 559 &run_loop, | 559 &run_loop, |
| 560 test_util::CreateCopyResultCallback(&error, &file_resource))); | 560 test_util::CreateCopyResultCallback(&error, &file_resource))); |
| 561 request->set_last_viewed_by_me_date( | 561 request->set_last_viewed_by_me_date( |
| 562 base::Time::FromUTCExploded(kLastViewedByMeDate)); | 562 base::Time::FromUTCExploded(kLastViewedByMeDate)); |
| 563 request->set_mime_type("application/vnd.google-apps.folder"); | 563 request->set_mime_type("application/vnd.google-apps.folder"); |
| 564 request->set_modified_date(base::Time::FromUTCExploded(kModifiedDate)); | 564 request->set_modified_date(base::Time::FromUTCExploded(kModifiedDate)); |
| 565 request->add_parent("root"); | 565 request->add_parent("root"); |
| 566 request->set_title("new directory"); | 566 request->set_title("new directory"); |
| 567 request->set_properties(testing_properties_); | 567 request->set_properties(testing_properties_); |
| 568 request_sender_->StartRequestWithRetry(request); | 568 request_sender_->StartRequestWithAuthRetry(request); |
| 569 run_loop.Run(); | 569 run_loop.Run(); |
| 570 } | 570 } |
| 571 | 571 |
| 572 EXPECT_EQ(HTTP_SUCCESS, error); | 572 EXPECT_EQ(HTTP_SUCCESS, error); |
| 573 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 573 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 574 EXPECT_EQ("/drive/v2/files", http_request_.relative_url); | 574 EXPECT_EQ("/drive/v2/files", http_request_.relative_url); |
| 575 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 575 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| 576 | 576 |
| 577 EXPECT_TRUE(http_request_.has_content); | 577 EXPECT_TRUE(http_request_.has_content); |
| 578 EXPECT_EQ( | 578 EXPECT_EQ( |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 request->set_set_modified_date(true); | 623 request->set_set_modified_date(true); |
| 624 request->set_update_viewed_date(false); | 624 request->set_update_viewed_date(false); |
| 625 | 625 |
| 626 request->set_title("new title"); | 626 request->set_title("new title"); |
| 627 request->set_modified_date(base::Time::FromUTCExploded(kModifiedDate)); | 627 request->set_modified_date(base::Time::FromUTCExploded(kModifiedDate)); |
| 628 request->set_last_viewed_by_me_date( | 628 request->set_last_viewed_by_me_date( |
| 629 base::Time::FromUTCExploded(kLastViewedByMeDate)); | 629 base::Time::FromUTCExploded(kLastViewedByMeDate)); |
| 630 request->add_parent("parent_resource_id"); | 630 request->add_parent("parent_resource_id"); |
| 631 | 631 |
| 632 request->set_properties(testing_properties_); | 632 request->set_properties(testing_properties_); |
| 633 request_sender_->StartRequestWithRetry(request); | 633 request_sender_->StartRequestWithAuthRetry(request); |
| 634 run_loop.Run(); | 634 run_loop.Run(); |
| 635 } | 635 } |
| 636 | 636 |
| 637 EXPECT_EQ(HTTP_SUCCESS, error); | 637 EXPECT_EQ(HTTP_SUCCESS, error); |
| 638 EXPECT_EQ(net::test_server::METHOD_PATCH, http_request_.method); | 638 EXPECT_EQ(net::test_server::METHOD_PATCH, http_request_.method); |
| 639 EXPECT_EQ("/drive/v2/files/resource_id" | 639 EXPECT_EQ("/drive/v2/files/resource_id" |
| 640 "?setModifiedDate=true&updateViewedDate=false", | 640 "?setModifiedDate=true&updateViewedDate=false", |
| 641 http_request_.relative_url); | 641 http_request_.relative_url); |
| 642 | 642 |
| 643 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 643 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 663 scoped_ptr<AboutResource> about_resource; | 663 scoped_ptr<AboutResource> about_resource; |
| 664 | 664 |
| 665 { | 665 { |
| 666 base::RunLoop run_loop; | 666 base::RunLoop run_loop; |
| 667 drive::AboutGetRequest* request = new drive::AboutGetRequest( | 667 drive::AboutGetRequest* request = new drive::AboutGetRequest( |
| 668 request_sender_.get(), | 668 request_sender_.get(), |
| 669 *url_generator_, | 669 *url_generator_, |
| 670 test_util::CreateQuitCallback( | 670 test_util::CreateQuitCallback( |
| 671 &run_loop, | 671 &run_loop, |
| 672 test_util::CreateCopyResultCallback(&error, &about_resource))); | 672 test_util::CreateCopyResultCallback(&error, &about_resource))); |
| 673 request_sender_->StartRequestWithRetry(request); | 673 request_sender_->StartRequestWithAuthRetry(request); |
| 674 run_loop.Run(); | 674 run_loop.Run(); |
| 675 } | 675 } |
| 676 | 676 |
| 677 EXPECT_EQ(HTTP_SUCCESS, error); | 677 EXPECT_EQ(HTTP_SUCCESS, error); |
| 678 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 678 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 679 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); | 679 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); |
| 680 | 680 |
| 681 scoped_ptr<AboutResource> expected( | 681 scoped_ptr<AboutResource> expected( |
| 682 AboutResource::CreateFrom( | 682 AboutResource::CreateFrom( |
| 683 *test_util::LoadJSONFile("drive/about.json"))); | 683 *test_util::LoadJSONFile("drive/about.json"))); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 698 scoped_ptr<AboutResource> about_resource; | 698 scoped_ptr<AboutResource> about_resource; |
| 699 | 699 |
| 700 { | 700 { |
| 701 base::RunLoop run_loop; | 701 base::RunLoop run_loop; |
| 702 drive::AboutGetRequest* request = new drive::AboutGetRequest( | 702 drive::AboutGetRequest* request = new drive::AboutGetRequest( |
| 703 request_sender_.get(), | 703 request_sender_.get(), |
| 704 *url_generator_, | 704 *url_generator_, |
| 705 test_util::CreateQuitCallback( | 705 test_util::CreateQuitCallback( |
| 706 &run_loop, | 706 &run_loop, |
| 707 test_util::CreateCopyResultCallback(&error, &about_resource))); | 707 test_util::CreateCopyResultCallback(&error, &about_resource))); |
| 708 request_sender_->StartRequestWithRetry(request); | 708 request_sender_->StartRequestWithAuthRetry(request); |
| 709 run_loop.Run(); | 709 run_loop.Run(); |
| 710 } | 710 } |
| 711 | 711 |
| 712 // "parse error" should be returned, and the about resource should be NULL. | 712 // "parse error" should be returned, and the about resource should be NULL. |
| 713 EXPECT_EQ(DRIVE_PARSE_ERROR, error); | 713 EXPECT_EQ(DRIVE_PARSE_ERROR, error); |
| 714 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 714 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 715 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); | 715 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); |
| 716 EXPECT_FALSE(about_resource); | 716 EXPECT_FALSE(about_resource); |
| 717 } | 717 } |
| 718 | 718 |
| 719 TEST_F(DriveApiRequestsTest, AppsListRequest) { | 719 TEST_F(DriveApiRequestsTest, AppsListRequest) { |
| 720 // Set an expected data file containing valid result. | 720 // Set an expected data file containing valid result. |
| 721 expected_data_file_path_ = test_util::GetTestFilePath( | 721 expected_data_file_path_ = test_util::GetTestFilePath( |
| 722 "drive/applist.json"); | 722 "drive/applist.json"); |
| 723 | 723 |
| 724 DriveApiErrorCode error = DRIVE_OTHER_ERROR; | 724 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 725 scoped_ptr<AppList> app_list; | 725 scoped_ptr<AppList> app_list; |
| 726 | 726 |
| 727 { | 727 { |
| 728 base::RunLoop run_loop; | 728 base::RunLoop run_loop; |
| 729 drive::AppsListRequest* request = new drive::AppsListRequest( | 729 drive::AppsListRequest* request = new drive::AppsListRequest( |
| 730 request_sender_.get(), | 730 request_sender_.get(), |
| 731 *url_generator_, | 731 *url_generator_, |
| 732 false, // use_internal_endpoint | 732 false, // use_internal_endpoint |
| 733 test_util::CreateQuitCallback( | 733 test_util::CreateQuitCallback( |
| 734 &run_loop, | 734 &run_loop, |
| 735 test_util::CreateCopyResultCallback(&error, &app_list))); | 735 test_util::CreateCopyResultCallback(&error, &app_list))); |
| 736 request_sender_->StartRequestWithRetry(request); | 736 request_sender_->StartRequestWithAuthRetry(request); |
| 737 run_loop.Run(); | 737 run_loop.Run(); |
| 738 } | 738 } |
| 739 | 739 |
| 740 EXPECT_EQ(HTTP_SUCCESS, error); | 740 EXPECT_EQ(HTTP_SUCCESS, error); |
| 741 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 741 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 742 EXPECT_EQ("/drive/v2/apps", http_request_.relative_url); | 742 EXPECT_EQ("/drive/v2/apps", http_request_.relative_url); |
| 743 EXPECT_TRUE(app_list); | 743 EXPECT_TRUE(app_list); |
| 744 } | 744 } |
| 745 | 745 |
| 746 TEST_F(DriveApiRequestsTest, ChangesListRequest) { | 746 TEST_F(DriveApiRequestsTest, ChangesListRequest) { |
| 747 // Set an expected data file containing valid result. | 747 // Set an expected data file containing valid result. |
| 748 expected_data_file_path_ = test_util::GetTestFilePath( | 748 expected_data_file_path_ = test_util::GetTestFilePath( |
| 749 "drive/changelist.json"); | 749 "drive/changelist.json"); |
| 750 | 750 |
| 751 DriveApiErrorCode error = DRIVE_OTHER_ERROR; | 751 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 752 scoped_ptr<ChangeList> result; | 752 scoped_ptr<ChangeList> result; |
| 753 | 753 |
| 754 { | 754 { |
| 755 base::RunLoop run_loop; | 755 base::RunLoop run_loop; |
| 756 drive::ChangesListRequest* request = new drive::ChangesListRequest( | 756 drive::ChangesListRequest* request = new drive::ChangesListRequest( |
| 757 request_sender_.get(), *url_generator_, | 757 request_sender_.get(), *url_generator_, |
| 758 test_util::CreateQuitCallback( | 758 test_util::CreateQuitCallback( |
| 759 &run_loop, | 759 &run_loop, |
| 760 test_util::CreateCopyResultCallback(&error, &result))); | 760 test_util::CreateCopyResultCallback(&error, &result))); |
| 761 request->set_include_deleted(true); | 761 request->set_include_deleted(true); |
| 762 request->set_start_change_id(100); | 762 request->set_start_change_id(100); |
| 763 request->set_max_results(500); | 763 request->set_max_results(500); |
| 764 request_sender_->StartRequestWithRetry(request); | 764 request_sender_->StartRequestWithAuthRetry(request); |
| 765 run_loop.Run(); | 765 run_loop.Run(); |
| 766 } | 766 } |
| 767 | 767 |
| 768 EXPECT_EQ(HTTP_SUCCESS, error); | 768 EXPECT_EQ(HTTP_SUCCESS, error); |
| 769 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 769 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 770 EXPECT_EQ("/drive/v2/changes?maxResults=500&startChangeId=100", | 770 EXPECT_EQ("/drive/v2/changes?maxResults=500&startChangeId=100", |
| 771 http_request_.relative_url); | 771 http_request_.relative_url); |
| 772 EXPECT_TRUE(result); | 772 EXPECT_TRUE(result); |
| 773 } | 773 } |
| 774 | 774 |
| 775 TEST_F(DriveApiRequestsTest, ChangesListNextPageRequest) { | 775 TEST_F(DriveApiRequestsTest, ChangesListNextPageRequest) { |
| 776 // Set an expected data file containing valid result. | 776 // Set an expected data file containing valid result. |
| 777 expected_data_file_path_ = test_util::GetTestFilePath( | 777 expected_data_file_path_ = test_util::GetTestFilePath( |
| 778 "drive/changelist.json"); | 778 "drive/changelist.json"); |
| 779 | 779 |
| 780 DriveApiErrorCode error = DRIVE_OTHER_ERROR; | 780 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 781 scoped_ptr<ChangeList> result; | 781 scoped_ptr<ChangeList> result; |
| 782 | 782 |
| 783 { | 783 { |
| 784 base::RunLoop run_loop; | 784 base::RunLoop run_loop; |
| 785 drive::ChangesListNextPageRequest* request = | 785 drive::ChangesListNextPageRequest* request = |
| 786 new drive::ChangesListNextPageRequest( | 786 new drive::ChangesListNextPageRequest( |
| 787 request_sender_.get(), | 787 request_sender_.get(), |
| 788 test_util::CreateQuitCallback( | 788 test_util::CreateQuitCallback( |
| 789 &run_loop, | 789 &run_loop, |
| 790 test_util::CreateCopyResultCallback(&error, &result))); | 790 test_util::CreateCopyResultCallback(&error, &result))); |
| 791 request->set_next_link(test_server_.GetURL("/continue/get/change/list")); | 791 request->set_next_link(test_server_.GetURL("/continue/get/change/list")); |
| 792 request_sender_->StartRequestWithRetry(request); | 792 request_sender_->StartRequestWithAuthRetry(request); |
| 793 run_loop.Run(); | 793 run_loop.Run(); |
| 794 } | 794 } |
| 795 | 795 |
| 796 EXPECT_EQ(HTTP_SUCCESS, error); | 796 EXPECT_EQ(HTTP_SUCCESS, error); |
| 797 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 797 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 798 EXPECT_EQ("/continue/get/change/list", http_request_.relative_url); | 798 EXPECT_EQ("/continue/get/change/list", http_request_.relative_url); |
| 799 EXPECT_TRUE(result); | 799 EXPECT_TRUE(result); |
| 800 } | 800 } |
| 801 | 801 |
| 802 TEST_F(DriveApiRequestsTest, FilesCopyRequest) { | 802 TEST_F(DriveApiRequestsTest, FilesCopyRequest) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 816 drive::FilesCopyRequest* request = new drive::FilesCopyRequest( | 816 drive::FilesCopyRequest* request = new drive::FilesCopyRequest( |
| 817 request_sender_.get(), | 817 request_sender_.get(), |
| 818 *url_generator_, | 818 *url_generator_, |
| 819 test_util::CreateQuitCallback( | 819 test_util::CreateQuitCallback( |
| 820 &run_loop, | 820 &run_loop, |
| 821 test_util::CreateCopyResultCallback(&error, &file_resource))); | 821 test_util::CreateCopyResultCallback(&error, &file_resource))); |
| 822 request->set_file_id("resource_id"); | 822 request->set_file_id("resource_id"); |
| 823 request->set_modified_date(base::Time::FromUTCExploded(kModifiedDate)); | 823 request->set_modified_date(base::Time::FromUTCExploded(kModifiedDate)); |
| 824 request->add_parent("parent_resource_id"); | 824 request->add_parent("parent_resource_id"); |
| 825 request->set_title("new title"); | 825 request->set_title("new title"); |
| 826 request_sender_->StartRequestWithRetry(request); | 826 request_sender_->StartRequestWithAuthRetry(request); |
| 827 run_loop.Run(); | 827 run_loop.Run(); |
| 828 } | 828 } |
| 829 | 829 |
| 830 EXPECT_EQ(HTTP_SUCCESS, error); | 830 EXPECT_EQ(HTTP_SUCCESS, error); |
| 831 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 831 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 832 EXPECT_EQ("/drive/v2/files/resource_id/copy", http_request_.relative_url); | 832 EXPECT_EQ("/drive/v2/files/resource_id/copy", http_request_.relative_url); |
| 833 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 833 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| 834 | 834 |
| 835 EXPECT_TRUE(http_request_.has_content); | 835 EXPECT_TRUE(http_request_.has_content); |
| 836 EXPECT_EQ( | 836 EXPECT_EQ( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 853 { | 853 { |
| 854 base::RunLoop run_loop; | 854 base::RunLoop run_loop; |
| 855 drive::FilesCopyRequest* request = new drive::FilesCopyRequest( | 855 drive::FilesCopyRequest* request = new drive::FilesCopyRequest( |
| 856 request_sender_.get(), | 856 request_sender_.get(), |
| 857 *url_generator_, | 857 *url_generator_, |
| 858 test_util::CreateQuitCallback( | 858 test_util::CreateQuitCallback( |
| 859 &run_loop, | 859 &run_loop, |
| 860 test_util::CreateCopyResultCallback(&error, &file_resource))); | 860 test_util::CreateCopyResultCallback(&error, &file_resource))); |
| 861 request->set_file_id("resource_id"); | 861 request->set_file_id("resource_id"); |
| 862 request->set_title("new title"); | 862 request->set_title("new title"); |
| 863 request_sender_->StartRequestWithRetry(request); | 863 request_sender_->StartRequestWithAuthRetry(request); |
| 864 run_loop.Run(); | 864 run_loop.Run(); |
| 865 } | 865 } |
| 866 | 866 |
| 867 EXPECT_EQ(HTTP_SUCCESS, error); | 867 EXPECT_EQ(HTTP_SUCCESS, error); |
| 868 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 868 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 869 EXPECT_EQ("/drive/v2/files/resource_id/copy", http_request_.relative_url); | 869 EXPECT_EQ("/drive/v2/files/resource_id/copy", http_request_.relative_url); |
| 870 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 870 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| 871 | 871 |
| 872 EXPECT_TRUE(http_request_.has_content); | 872 EXPECT_TRUE(http_request_.has_content); |
| 873 EXPECT_EQ("{\"title\":\"new title\"}", http_request_.content); | 873 EXPECT_EQ("{\"title\":\"new title\"}", http_request_.content); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 884 | 884 |
| 885 { | 885 { |
| 886 base::RunLoop run_loop; | 886 base::RunLoop run_loop; |
| 887 drive::FilesListRequest* request = new drive::FilesListRequest( | 887 drive::FilesListRequest* request = new drive::FilesListRequest( |
| 888 request_sender_.get(), *url_generator_, | 888 request_sender_.get(), *url_generator_, |
| 889 test_util::CreateQuitCallback( | 889 test_util::CreateQuitCallback( |
| 890 &run_loop, | 890 &run_loop, |
| 891 test_util::CreateCopyResultCallback(&error, &result))); | 891 test_util::CreateCopyResultCallback(&error, &result))); |
| 892 request->set_max_results(50); | 892 request->set_max_results(50); |
| 893 request->set_q("\"abcde\" in parents"); | 893 request->set_q("\"abcde\" in parents"); |
| 894 request_sender_->StartRequestWithRetry(request); | 894 request_sender_->StartRequestWithAuthRetry(request); |
| 895 run_loop.Run(); | 895 run_loop.Run(); |
| 896 } | 896 } |
| 897 | 897 |
| 898 EXPECT_EQ(HTTP_SUCCESS, error); | 898 EXPECT_EQ(HTTP_SUCCESS, error); |
| 899 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 899 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 900 EXPECT_EQ("/drive/v2/files?maxResults=50&q=%22abcde%22+in+parents", | 900 EXPECT_EQ("/drive/v2/files?maxResults=50&q=%22abcde%22+in+parents", |
| 901 http_request_.relative_url); | 901 http_request_.relative_url); |
| 902 EXPECT_TRUE(result); | 902 EXPECT_TRUE(result); |
| 903 } | 903 } |
| 904 | 904 |
| 905 TEST_F(DriveApiRequestsTest, FilesListNextPageRequest) { | 905 TEST_F(DriveApiRequestsTest, FilesListNextPageRequest) { |
| 906 // Set an expected data file containing valid result. | 906 // Set an expected data file containing valid result. |
| 907 expected_data_file_path_ = test_util::GetTestFilePath( | 907 expected_data_file_path_ = test_util::GetTestFilePath( |
| 908 "drive/filelist.json"); | 908 "drive/filelist.json"); |
| 909 | 909 |
| 910 DriveApiErrorCode error = DRIVE_OTHER_ERROR; | 910 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 911 scoped_ptr<FileList> result; | 911 scoped_ptr<FileList> result; |
| 912 | 912 |
| 913 { | 913 { |
| 914 base::RunLoop run_loop; | 914 base::RunLoop run_loop; |
| 915 drive::FilesListNextPageRequest* request = | 915 drive::FilesListNextPageRequest* request = |
| 916 new drive::FilesListNextPageRequest( | 916 new drive::FilesListNextPageRequest( |
| 917 request_sender_.get(), | 917 request_sender_.get(), |
| 918 test_util::CreateQuitCallback( | 918 test_util::CreateQuitCallback( |
| 919 &run_loop, | 919 &run_loop, |
| 920 test_util::CreateCopyResultCallback(&error, &result))); | 920 test_util::CreateCopyResultCallback(&error, &result))); |
| 921 request->set_next_link(test_server_.GetURL("/continue/get/file/list")); | 921 request->set_next_link(test_server_.GetURL("/continue/get/file/list")); |
| 922 request_sender_->StartRequestWithRetry(request); | 922 request_sender_->StartRequestWithAuthRetry(request); |
| 923 run_loop.Run(); | 923 run_loop.Run(); |
| 924 } | 924 } |
| 925 | 925 |
| 926 EXPECT_EQ(HTTP_SUCCESS, error); | 926 EXPECT_EQ(HTTP_SUCCESS, error); |
| 927 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 927 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 928 EXPECT_EQ("/continue/get/file/list", http_request_.relative_url); | 928 EXPECT_EQ("/continue/get/file/list", http_request_.relative_url); |
| 929 EXPECT_TRUE(result); | 929 EXPECT_TRUE(result); |
| 930 } | 930 } |
| 931 | 931 |
| 932 TEST_F(DriveApiRequestsTest, FilesDeleteRequest) { | 932 TEST_F(DriveApiRequestsTest, FilesDeleteRequest) { |
| 933 DriveApiErrorCode error = DRIVE_OTHER_ERROR; | 933 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 934 | 934 |
| 935 // Delete a resource with the given resource id. | 935 // Delete a resource with the given resource id. |
| 936 { | 936 { |
| 937 base::RunLoop run_loop; | 937 base::RunLoop run_loop; |
| 938 drive::FilesDeleteRequest* request = new drive::FilesDeleteRequest( | 938 drive::FilesDeleteRequest* request = new drive::FilesDeleteRequest( |
| 939 request_sender_.get(), | 939 request_sender_.get(), |
| 940 *url_generator_, | 940 *url_generator_, |
| 941 test_util::CreateQuitCallback( | 941 test_util::CreateQuitCallback( |
| 942 &run_loop, test_util::CreateCopyResultCallback(&error))); | 942 &run_loop, test_util::CreateCopyResultCallback(&error))); |
| 943 request->set_file_id("resource_id"); | 943 request->set_file_id("resource_id"); |
| 944 request->set_etag(kTestETag); | 944 request->set_etag(kTestETag); |
| 945 request_sender_->StartRequestWithRetry(request); | 945 request_sender_->StartRequestWithAuthRetry(request); |
| 946 run_loop.Run(); | 946 run_loop.Run(); |
| 947 } | 947 } |
| 948 | 948 |
| 949 EXPECT_EQ(HTTP_NO_CONTENT, error); | 949 EXPECT_EQ(HTTP_NO_CONTENT, error); |
| 950 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); | 950 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); |
| 951 EXPECT_EQ(kTestETag, http_request_.headers["If-Match"]); | 951 EXPECT_EQ(kTestETag, http_request_.headers["If-Match"]); |
| 952 EXPECT_EQ("/drive/v2/files/resource_id", http_request_.relative_url); | 952 EXPECT_EQ("/drive/v2/files/resource_id", http_request_.relative_url); |
| 953 EXPECT_FALSE(http_request_.has_content); | 953 EXPECT_FALSE(http_request_.has_content); |
| 954 } | 954 } |
| 955 | 955 |
| 956 TEST_F(DriveApiRequestsTest, FilesTrashRequest) { | 956 TEST_F(DriveApiRequestsTest, FilesTrashRequest) { |
| 957 // Set data for the expected result. Directory entry should be returned | 957 // Set data for the expected result. Directory entry should be returned |
| 958 // if the trashing entry is a directory, so using it here should be fine. | 958 // if the trashing entry is a directory, so using it here should be fine. |
| 959 expected_data_file_path_ = | 959 expected_data_file_path_ = |
| 960 test_util::GetTestFilePath("drive/directory_entry.json"); | 960 test_util::GetTestFilePath("drive/directory_entry.json"); |
| 961 | 961 |
| 962 DriveApiErrorCode error = DRIVE_OTHER_ERROR; | 962 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 963 scoped_ptr<FileResource> file_resource; | 963 scoped_ptr<FileResource> file_resource; |
| 964 | 964 |
| 965 // Trash a resource with the given resource id. | 965 // Trash a resource with the given resource id. |
| 966 { | 966 { |
| 967 base::RunLoop run_loop; | 967 base::RunLoop run_loop; |
| 968 drive::FilesTrashRequest* request = new drive::FilesTrashRequest( | 968 drive::FilesTrashRequest* request = new drive::FilesTrashRequest( |
| 969 request_sender_.get(), | 969 request_sender_.get(), |
| 970 *url_generator_, | 970 *url_generator_, |
| 971 test_util::CreateQuitCallback( | 971 test_util::CreateQuitCallback( |
| 972 &run_loop, | 972 &run_loop, |
| 973 test_util::CreateCopyResultCallback(&error, &file_resource))); | 973 test_util::CreateCopyResultCallback(&error, &file_resource))); |
| 974 request->set_file_id("resource_id"); | 974 request->set_file_id("resource_id"); |
| 975 request_sender_->StartRequestWithRetry(request); | 975 request_sender_->StartRequestWithAuthRetry(request); |
| 976 run_loop.Run(); | 976 run_loop.Run(); |
| 977 } | 977 } |
| 978 | 978 |
| 979 EXPECT_EQ(HTTP_SUCCESS, error); | 979 EXPECT_EQ(HTTP_SUCCESS, error); |
| 980 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 980 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 981 EXPECT_EQ("/drive/v2/files/resource_id/trash", http_request_.relative_url); | 981 EXPECT_EQ("/drive/v2/files/resource_id/trash", http_request_.relative_url); |
| 982 EXPECT_TRUE(http_request_.has_content); | 982 EXPECT_TRUE(http_request_.has_content); |
| 983 EXPECT_TRUE(http_request_.content.empty()); | 983 EXPECT_TRUE(http_request_.content.empty()); |
| 984 } | 984 } |
| 985 | 985 |
| 986 TEST_F(DriveApiRequestsTest, ChildrenInsertRequest) { | 986 TEST_F(DriveApiRequestsTest, ChildrenInsertRequest) { |
| 987 // Set an expected data file containing the children entry. | 987 // Set an expected data file containing the children entry. |
| 988 expected_content_type_ = "application/json"; | 988 expected_content_type_ = "application/json"; |
| 989 expected_content_ = kTestChildrenResponse; | 989 expected_content_ = kTestChildrenResponse; |
| 990 | 990 |
| 991 DriveApiErrorCode error = DRIVE_OTHER_ERROR; | 991 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 992 | 992 |
| 993 // Add a resource with "resource_id" to a directory with | 993 // Add a resource with "resource_id" to a directory with |
| 994 // "parent_resource_id". | 994 // "parent_resource_id". |
| 995 { | 995 { |
| 996 base::RunLoop run_loop; | 996 base::RunLoop run_loop; |
| 997 drive::ChildrenInsertRequest* request = new drive::ChildrenInsertRequest( | 997 drive::ChildrenInsertRequest* request = new drive::ChildrenInsertRequest( |
| 998 request_sender_.get(), | 998 request_sender_.get(), |
| 999 *url_generator_, | 999 *url_generator_, |
| 1000 test_util::CreateQuitCallback( | 1000 test_util::CreateQuitCallback( |
| 1001 &run_loop, | 1001 &run_loop, |
| 1002 test_util::CreateCopyResultCallback(&error))); | 1002 test_util::CreateCopyResultCallback(&error))); |
| 1003 request->set_folder_id("parent_resource_id"); | 1003 request->set_folder_id("parent_resource_id"); |
| 1004 request->set_id("resource_id"); | 1004 request->set_id("resource_id"); |
| 1005 request_sender_->StartRequestWithRetry(request); | 1005 request_sender_->StartRequestWithAuthRetry(request); |
| 1006 run_loop.Run(); | 1006 run_loop.Run(); |
| 1007 } | 1007 } |
| 1008 | 1008 |
| 1009 EXPECT_EQ(HTTP_SUCCESS, error); | 1009 EXPECT_EQ(HTTP_SUCCESS, error); |
| 1010 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 1010 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 1011 EXPECT_EQ("/drive/v2/files/parent_resource_id/children", | 1011 EXPECT_EQ("/drive/v2/files/parent_resource_id/children", |
| 1012 http_request_.relative_url); | 1012 http_request_.relative_url); |
| 1013 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 1013 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| 1014 | 1014 |
| 1015 EXPECT_TRUE(http_request_.has_content); | 1015 EXPECT_TRUE(http_request_.has_content); |
| 1016 EXPECT_EQ("{\"id\":\"resource_id\"}", http_request_.content); | 1016 EXPECT_EQ("{\"id\":\"resource_id\"}", http_request_.content); |
| 1017 } | 1017 } |
| 1018 | 1018 |
| 1019 TEST_F(DriveApiRequestsTest, ChildrenDeleteRequest) { | 1019 TEST_F(DriveApiRequestsTest, ChildrenDeleteRequest) { |
| 1020 DriveApiErrorCode error = DRIVE_OTHER_ERROR; | 1020 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 1021 | 1021 |
| 1022 // Remove a resource with "resource_id" from a directory with | 1022 // Remove a resource with "resource_id" from a directory with |
| 1023 // "parent_resource_id". | 1023 // "parent_resource_id". |
| 1024 { | 1024 { |
| 1025 base::RunLoop run_loop; | 1025 base::RunLoop run_loop; |
| 1026 drive::ChildrenDeleteRequest* request = new drive::ChildrenDeleteRequest( | 1026 drive::ChildrenDeleteRequest* request = new drive::ChildrenDeleteRequest( |
| 1027 request_sender_.get(), | 1027 request_sender_.get(), |
| 1028 *url_generator_, | 1028 *url_generator_, |
| 1029 test_util::CreateQuitCallback( | 1029 test_util::CreateQuitCallback( |
| 1030 &run_loop, | 1030 &run_loop, |
| 1031 test_util::CreateCopyResultCallback(&error))); | 1031 test_util::CreateCopyResultCallback(&error))); |
| 1032 request->set_child_id("resource_id"); | 1032 request->set_child_id("resource_id"); |
| 1033 request->set_folder_id("parent_resource_id"); | 1033 request->set_folder_id("parent_resource_id"); |
| 1034 request_sender_->StartRequestWithRetry(request); | 1034 request_sender_->StartRequestWithAuthRetry(request); |
| 1035 run_loop.Run(); | 1035 run_loop.Run(); |
| 1036 } | 1036 } |
| 1037 | 1037 |
| 1038 EXPECT_EQ(HTTP_NO_CONTENT, error); | 1038 EXPECT_EQ(HTTP_NO_CONTENT, error); |
| 1039 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); | 1039 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); |
| 1040 EXPECT_EQ("/drive/v2/files/parent_resource_id/children/resource_id", | 1040 EXPECT_EQ("/drive/v2/files/parent_resource_id/children/resource_id", |
| 1041 http_request_.relative_url); | 1041 http_request_.relative_url); |
| 1042 EXPECT_FALSE(http_request_.has_content); | 1042 EXPECT_FALSE(http_request_.has_content); |
| 1043 } | 1043 } |
| 1044 | 1044 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1064 request_sender_.get(), | 1064 request_sender_.get(), |
| 1065 *url_generator_, | 1065 *url_generator_, |
| 1066 kTestContentType, | 1066 kTestContentType, |
| 1067 kTestContent.size(), | 1067 kTestContent.size(), |
| 1068 "parent_resource_id", // The resource id of the parent directory. | 1068 "parent_resource_id", // The resource id of the parent directory. |
| 1069 "new file title", // The title of the file being uploaded. | 1069 "new file title", // The title of the file being uploaded. |
| 1070 test_util::CreateQuitCallback( | 1070 test_util::CreateQuitCallback( |
| 1071 &run_loop, | 1071 &run_loop, |
| 1072 test_util::CreateCopyResultCallback(&error, &upload_url))); | 1072 test_util::CreateCopyResultCallback(&error, &upload_url))); |
| 1073 request->set_properties(testing_properties_); | 1073 request->set_properties(testing_properties_); |
| 1074 request_sender_->StartRequestWithRetry(request); | 1074 request_sender_->StartRequestWithAuthRetry(request); |
| 1075 run_loop.Run(); | 1075 run_loop.Run(); |
| 1076 } | 1076 } |
| 1077 | 1077 |
| 1078 EXPECT_EQ(HTTP_SUCCESS, error); | 1078 EXPECT_EQ(HTTP_SUCCESS, error); |
| 1079 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); | 1079 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); |
| 1080 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 1080 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
| 1081 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 1081 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
| 1082 http_request_.headers["X-Upload-Content-Length"]); | 1082 http_request_.headers["X-Upload-Content-Length"]); |
| 1083 | 1083 |
| 1084 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 1084 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1109 upload_url, | 1109 upload_url, |
| 1110 0, // start_position | 1110 0, // start_position |
| 1111 kTestContent.size(), // end_position (exclusive) | 1111 kTestContent.size(), // end_position (exclusive) |
| 1112 kTestContent.size(), // content_length, | 1112 kTestContent.size(), // content_length, |
| 1113 kTestContentType, | 1113 kTestContentType, |
| 1114 kTestFilePath, | 1114 kTestFilePath, |
| 1115 test_util::CreateQuitCallback( | 1115 test_util::CreateQuitCallback( |
| 1116 &run_loop, | 1116 &run_loop, |
| 1117 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1117 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 1118 ProgressCallback()); | 1118 ProgressCallback()); |
| 1119 request_sender_->StartRequestWithRetry(resume_request); | 1119 request_sender_->StartRequestWithAuthRetry(resume_request); |
| 1120 run_loop.Run(); | 1120 run_loop.Run(); |
| 1121 } | 1121 } |
| 1122 | 1122 |
| 1123 // METHOD_PUT should be used to upload data. | 1123 // METHOD_PUT should be used to upload data. |
| 1124 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1124 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1125 // Request should go to the upload URL. | 1125 // Request should go to the upload URL. |
| 1126 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1126 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1127 // Content-Range header should be added. | 1127 // Content-Range header should be added. |
| 1128 EXPECT_EQ("bytes 0-" + | 1128 EXPECT_EQ("bytes 0-" + |
| 1129 base::Int64ToString(kTestContent.size() - 1) + "/" + | 1129 base::Int64ToString(kTestContent.size() - 1) + "/" + |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1160 new drive::InitiateUploadNewFileRequest( | 1160 new drive::InitiateUploadNewFileRequest( |
| 1161 request_sender_.get(), | 1161 request_sender_.get(), |
| 1162 *url_generator_, | 1162 *url_generator_, |
| 1163 kTestContentType, | 1163 kTestContentType, |
| 1164 0, | 1164 0, |
| 1165 "parent_resource_id", // The resource id of the parent directory. | 1165 "parent_resource_id", // The resource id of the parent directory. |
| 1166 "new file title", // The title of the file being uploaded. | 1166 "new file title", // The title of the file being uploaded. |
| 1167 test_util::CreateQuitCallback( | 1167 test_util::CreateQuitCallback( |
| 1168 &run_loop, | 1168 &run_loop, |
| 1169 test_util::CreateCopyResultCallback(&error, &upload_url))); | 1169 test_util::CreateCopyResultCallback(&error, &upload_url))); |
| 1170 request_sender_->StartRequestWithRetry(request); | 1170 request_sender_->StartRequestWithAuthRetry(request); |
| 1171 run_loop.Run(); | 1171 run_loop.Run(); |
| 1172 } | 1172 } |
| 1173 | 1173 |
| 1174 EXPECT_EQ(HTTP_SUCCESS, error); | 1174 EXPECT_EQ(HTTP_SUCCESS, error); |
| 1175 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); | 1175 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); |
| 1176 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 1176 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
| 1177 EXPECT_EQ("0", http_request_.headers["X-Upload-Content-Length"]); | 1177 EXPECT_EQ("0", http_request_.headers["X-Upload-Content-Length"]); |
| 1178 | 1178 |
| 1179 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 1179 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 1180 EXPECT_EQ("/upload/drive/v2/files?uploadType=resumable", | 1180 EXPECT_EQ("/upload/drive/v2/files?uploadType=resumable", |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1200 upload_url, | 1200 upload_url, |
| 1201 0, // start_position | 1201 0, // start_position |
| 1202 0, // end_position (exclusive) | 1202 0, // end_position (exclusive) |
| 1203 0, // content_length, | 1203 0, // content_length, |
| 1204 kTestContentType, | 1204 kTestContentType, |
| 1205 kTestFilePath, | 1205 kTestFilePath, |
| 1206 test_util::CreateQuitCallback( | 1206 test_util::CreateQuitCallback( |
| 1207 &run_loop, | 1207 &run_loop, |
| 1208 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1208 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 1209 ProgressCallback()); | 1209 ProgressCallback()); |
| 1210 request_sender_->StartRequestWithRetry(resume_request); | 1210 request_sender_->StartRequestWithAuthRetry(resume_request); |
| 1211 run_loop.Run(); | 1211 run_loop.Run(); |
| 1212 } | 1212 } |
| 1213 | 1213 |
| 1214 // METHOD_PUT should be used to upload data. | 1214 // METHOD_PUT should be used to upload data. |
| 1215 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1215 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1216 // Request should go to the upload URL. | 1216 // Request should go to the upload URL. |
| 1217 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1217 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1218 // Content-Range header should NOT be added. | 1218 // Content-Range header should NOT be added. |
| 1219 EXPECT_EQ(0U, http_request_.headers.count("Content-Range")); | 1219 EXPECT_EQ(0U, http_request_.headers.count("Content-Range")); |
| 1220 // The upload content should be set in the HTTP request. | 1220 // The upload content should be set in the HTTP request. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1249 new drive::InitiateUploadNewFileRequest( | 1249 new drive::InitiateUploadNewFileRequest( |
| 1250 request_sender_.get(), | 1250 request_sender_.get(), |
| 1251 *url_generator_, | 1251 *url_generator_, |
| 1252 kTestContentType, | 1252 kTestContentType, |
| 1253 kTestContent.size(), | 1253 kTestContent.size(), |
| 1254 "parent_resource_id", // The resource id of the parent directory. | 1254 "parent_resource_id", // The resource id of the parent directory. |
| 1255 "new file title", // The title of the file being uploaded. | 1255 "new file title", // The title of the file being uploaded. |
| 1256 test_util::CreateQuitCallback( | 1256 test_util::CreateQuitCallback( |
| 1257 &run_loop, | 1257 &run_loop, |
| 1258 test_util::CreateCopyResultCallback(&error, &upload_url))); | 1258 test_util::CreateCopyResultCallback(&error, &upload_url))); |
| 1259 request_sender_->StartRequestWithRetry(request); | 1259 request_sender_->StartRequestWithAuthRetry(request); |
| 1260 run_loop.Run(); | 1260 run_loop.Run(); |
| 1261 } | 1261 } |
| 1262 | 1262 |
| 1263 EXPECT_EQ(HTTP_SUCCESS, error); | 1263 EXPECT_EQ(HTTP_SUCCESS, error); |
| 1264 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); | 1264 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); |
| 1265 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 1265 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
| 1266 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 1266 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
| 1267 http_request_.headers["X-Upload-Content-Length"]); | 1267 http_request_.headers["X-Upload-Content-Length"]); |
| 1268 | 1268 |
| 1269 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 1269 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1288 { | 1288 { |
| 1289 base::RunLoop run_loop; | 1289 base::RunLoop run_loop; |
| 1290 drive::GetUploadStatusRequest* get_upload_status_request = | 1290 drive::GetUploadStatusRequest* get_upload_status_request = |
| 1291 new drive::GetUploadStatusRequest( | 1291 new drive::GetUploadStatusRequest( |
| 1292 request_sender_.get(), | 1292 request_sender_.get(), |
| 1293 upload_url, | 1293 upload_url, |
| 1294 kTestContent.size(), | 1294 kTestContent.size(), |
| 1295 test_util::CreateQuitCallback( | 1295 test_util::CreateQuitCallback( |
| 1296 &run_loop, | 1296 &run_loop, |
| 1297 test_util::CreateCopyResultCallback(&response, &new_entry))); | 1297 test_util::CreateCopyResultCallback(&response, &new_entry))); |
| 1298 request_sender_->StartRequestWithRetry(get_upload_status_request); | 1298 request_sender_->StartRequestWithAuthRetry(get_upload_status_request); |
| 1299 run_loop.Run(); | 1299 run_loop.Run(); |
| 1300 } | 1300 } |
| 1301 | 1301 |
| 1302 // METHOD_PUT should be used to upload data. | 1302 // METHOD_PUT should be used to upload data. |
| 1303 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1303 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1304 // Request should go to the upload URL. | 1304 // Request should go to the upload URL. |
| 1305 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1305 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1306 // Content-Range header should be added. | 1306 // Content-Range header should be added. |
| 1307 EXPECT_EQ("bytes */" + base::Int64ToString(kTestContent.size()), | 1307 EXPECT_EQ("bytes */" + base::Int64ToString(kTestContent.size()), |
| 1308 http_request_.headers["Content-Range"]); | 1308 http_request_.headers["Content-Range"]); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1334 upload_url, | 1334 upload_url, |
| 1335 start_position, | 1335 start_position, |
| 1336 end_position, | 1336 end_position, |
| 1337 kTestContent.size(), // content_length, | 1337 kTestContent.size(), // content_length, |
| 1338 kTestContentType, | 1338 kTestContentType, |
| 1339 kTestFilePath, | 1339 kTestFilePath, |
| 1340 test_util::CreateQuitCallback( | 1340 test_util::CreateQuitCallback( |
| 1341 &run_loop, | 1341 &run_loop, |
| 1342 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1342 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 1343 ProgressCallback()); | 1343 ProgressCallback()); |
| 1344 request_sender_->StartRequestWithRetry(resume_request); | 1344 request_sender_->StartRequestWithAuthRetry(resume_request); |
| 1345 run_loop.Run(); | 1345 run_loop.Run(); |
| 1346 } | 1346 } |
| 1347 | 1347 |
| 1348 // METHOD_PUT should be used to upload data. | 1348 // METHOD_PUT should be used to upload data. |
| 1349 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1349 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1350 // Request should go to the upload URL. | 1350 // Request should go to the upload URL. |
| 1351 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1351 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1352 // Content-Range header should be added. | 1352 // Content-Range header should be added. |
| 1353 EXPECT_EQ("bytes " + | 1353 EXPECT_EQ("bytes " + |
| 1354 base::Int64ToString(start_position) + "-" + | 1354 base::Int64ToString(start_position) + "-" + |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1378 { | 1378 { |
| 1379 base::RunLoop run_loop; | 1379 base::RunLoop run_loop; |
| 1380 drive::GetUploadStatusRequest* get_upload_status_request = | 1380 drive::GetUploadStatusRequest* get_upload_status_request = |
| 1381 new drive::GetUploadStatusRequest( | 1381 new drive::GetUploadStatusRequest( |
| 1382 request_sender_.get(), | 1382 request_sender_.get(), |
| 1383 upload_url, | 1383 upload_url, |
| 1384 kTestContent.size(), | 1384 kTestContent.size(), |
| 1385 test_util::CreateQuitCallback( | 1385 test_util::CreateQuitCallback( |
| 1386 &run_loop, | 1386 &run_loop, |
| 1387 test_util::CreateCopyResultCallback(&response, &new_entry))); | 1387 test_util::CreateCopyResultCallback(&response, &new_entry))); |
| 1388 request_sender_->StartRequestWithRetry(get_upload_status_request); | 1388 request_sender_->StartRequestWithAuthRetry(get_upload_status_request); |
| 1389 run_loop.Run(); | 1389 run_loop.Run(); |
| 1390 } | 1390 } |
| 1391 | 1391 |
| 1392 // METHOD_PUT should be used to upload data. | 1392 // METHOD_PUT should be used to upload data. |
| 1393 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1393 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1394 // Request should go to the upload URL. | 1394 // Request should go to the upload URL. |
| 1395 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1395 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1396 // Content-Range header should be added. | 1396 // Content-Range header should be added. |
| 1397 EXPECT_EQ("bytes */" + base::Int64ToString(kTestContent.size()), | 1397 EXPECT_EQ("bytes */" + base::Int64ToString(kTestContent.size()), |
| 1398 http_request_.headers["Content-Range"]); | 1398 http_request_.headers["Content-Range"]); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 kTestContentType, | 1431 kTestContentType, |
| 1432 kTestContent.size(), | 1432 kTestContent.size(), |
| 1433 "parent_resource_id", // The resource id of the parent directory. | 1433 "parent_resource_id", // The resource id of the parent directory. |
| 1434 "new file title", // The title of the file being uploaded. | 1434 "new file title", // The title of the file being uploaded. |
| 1435 test_util::CreateQuitCallback( | 1435 test_util::CreateQuitCallback( |
| 1436 &run_loop, | 1436 &run_loop, |
| 1437 test_util::CreateCopyResultCallback(&error, &upload_url))); | 1437 test_util::CreateCopyResultCallback(&error, &upload_url))); |
| 1438 request->set_modified_date(base::Time::FromUTCExploded(kModifiedDate)); | 1438 request->set_modified_date(base::Time::FromUTCExploded(kModifiedDate)); |
| 1439 request->set_last_viewed_by_me_date( | 1439 request->set_last_viewed_by_me_date( |
| 1440 base::Time::FromUTCExploded(kLastViewedByMeDate)); | 1440 base::Time::FromUTCExploded(kLastViewedByMeDate)); |
| 1441 request_sender_->StartRequestWithRetry(request); | 1441 request_sender_->StartRequestWithAuthRetry(request); |
| 1442 run_loop.Run(); | 1442 run_loop.Run(); |
| 1443 } | 1443 } |
| 1444 | 1444 |
| 1445 EXPECT_EQ(HTTP_SUCCESS, error); | 1445 EXPECT_EQ(HTTP_SUCCESS, error); |
| 1446 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); | 1446 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); |
| 1447 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 1447 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
| 1448 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 1448 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
| 1449 http_request_.headers["X-Upload-Content-Length"]); | 1449 http_request_.headers["X-Upload-Content-Length"]); |
| 1450 | 1450 |
| 1451 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 1451 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1482 request_sender_.get(), | 1482 request_sender_.get(), |
| 1483 *url_generator_, | 1483 *url_generator_, |
| 1484 kTestContentType, | 1484 kTestContentType, |
| 1485 kTestContent.size(), | 1485 kTestContent.size(), |
| 1486 "resource_id", // The resource id of the file to be overwritten. | 1486 "resource_id", // The resource id of the file to be overwritten. |
| 1487 std::string(), // No etag. | 1487 std::string(), // No etag. |
| 1488 test_util::CreateQuitCallback( | 1488 test_util::CreateQuitCallback( |
| 1489 &run_loop, | 1489 &run_loop, |
| 1490 test_util::CreateCopyResultCallback(&error, &upload_url))); | 1490 test_util::CreateCopyResultCallback(&error, &upload_url))); |
| 1491 request->set_properties(testing_properties_); | 1491 request->set_properties(testing_properties_); |
| 1492 request_sender_->StartRequestWithRetry(request); | 1492 request_sender_->StartRequestWithAuthRetry(request); |
| 1493 run_loop.Run(); | 1493 run_loop.Run(); |
| 1494 } | 1494 } |
| 1495 | 1495 |
| 1496 EXPECT_EQ(HTTP_SUCCESS, error); | 1496 EXPECT_EQ(HTTP_SUCCESS, error); |
| 1497 EXPECT_EQ(kTestUploadExistingFilePath, upload_url.path()); | 1497 EXPECT_EQ(kTestUploadExistingFilePath, upload_url.path()); |
| 1498 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 1498 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
| 1499 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 1499 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
| 1500 http_request_.headers["X-Upload-Content-Length"]); | 1500 http_request_.headers["X-Upload-Content-Length"]); |
| 1501 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 1501 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
| 1502 | 1502 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1522 upload_url, | 1522 upload_url, |
| 1523 0, // start_position | 1523 0, // start_position |
| 1524 kTestContent.size(), // end_position (exclusive) | 1524 kTestContent.size(), // end_position (exclusive) |
| 1525 kTestContent.size(), // content_length, | 1525 kTestContent.size(), // content_length, |
| 1526 kTestContentType, | 1526 kTestContentType, |
| 1527 kTestFilePath, | 1527 kTestFilePath, |
| 1528 test_util::CreateQuitCallback( | 1528 test_util::CreateQuitCallback( |
| 1529 &run_loop, | 1529 &run_loop, |
| 1530 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1530 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 1531 ProgressCallback()); | 1531 ProgressCallback()); |
| 1532 request_sender_->StartRequestWithRetry(resume_request); | 1532 request_sender_->StartRequestWithAuthRetry(resume_request); |
| 1533 run_loop.Run(); | 1533 run_loop.Run(); |
| 1534 } | 1534 } |
| 1535 | 1535 |
| 1536 // METHOD_PUT should be used to upload data. | 1536 // METHOD_PUT should be used to upload data. |
| 1537 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1537 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1538 // Request should go to the upload URL. | 1538 // Request should go to the upload URL. |
| 1539 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1539 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1540 // Content-Range header should be added. | 1540 // Content-Range header should be added. |
| 1541 EXPECT_EQ("bytes 0-" + | 1541 EXPECT_EQ("bytes 0-" + |
| 1542 base::Int64ToString(kTestContent.size() - 1) + "/" + | 1542 base::Int64ToString(kTestContent.size() - 1) + "/" + |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1573 new drive::InitiateUploadExistingFileRequest( | 1573 new drive::InitiateUploadExistingFileRequest( |
| 1574 request_sender_.get(), | 1574 request_sender_.get(), |
| 1575 *url_generator_, | 1575 *url_generator_, |
| 1576 kTestContentType, | 1576 kTestContentType, |
| 1577 kTestContent.size(), | 1577 kTestContent.size(), |
| 1578 "resource_id", // The resource id of the file to be overwritten. | 1578 "resource_id", // The resource id of the file to be overwritten. |
| 1579 kTestETag, | 1579 kTestETag, |
| 1580 test_util::CreateQuitCallback( | 1580 test_util::CreateQuitCallback( |
| 1581 &run_loop, | 1581 &run_loop, |
| 1582 test_util::CreateCopyResultCallback(&error, &upload_url))); | 1582 test_util::CreateCopyResultCallback(&error, &upload_url))); |
| 1583 request_sender_->StartRequestWithRetry(request); | 1583 request_sender_->StartRequestWithAuthRetry(request); |
| 1584 run_loop.Run(); | 1584 run_loop.Run(); |
| 1585 } | 1585 } |
| 1586 | 1586 |
| 1587 EXPECT_EQ(HTTP_SUCCESS, error); | 1587 EXPECT_EQ(HTTP_SUCCESS, error); |
| 1588 EXPECT_EQ(kTestUploadExistingFilePath, upload_url.path()); | 1588 EXPECT_EQ(kTestUploadExistingFilePath, upload_url.path()); |
| 1589 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 1589 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
| 1590 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 1590 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
| 1591 http_request_.headers["X-Upload-Content-Length"]); | 1591 http_request_.headers["X-Upload-Content-Length"]); |
| 1592 EXPECT_EQ(kTestETag, http_request_.headers["If-Match"]); | 1592 EXPECT_EQ(kTestETag, http_request_.headers["If-Match"]); |
| 1593 | 1593 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1609 upload_url, | 1609 upload_url, |
| 1610 0, // start_position | 1610 0, // start_position |
| 1611 kTestContent.size(), // end_position (exclusive) | 1611 kTestContent.size(), // end_position (exclusive) |
| 1612 kTestContent.size(), // content_length, | 1612 kTestContent.size(), // content_length, |
| 1613 kTestContentType, | 1613 kTestContentType, |
| 1614 kTestFilePath, | 1614 kTestFilePath, |
| 1615 test_util::CreateQuitCallback( | 1615 test_util::CreateQuitCallback( |
| 1616 &run_loop, | 1616 &run_loop, |
| 1617 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1617 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 1618 ProgressCallback()); | 1618 ProgressCallback()); |
| 1619 request_sender_->StartRequestWithRetry(resume_request); | 1619 request_sender_->StartRequestWithAuthRetry(resume_request); |
| 1620 run_loop.Run(); | 1620 run_loop.Run(); |
| 1621 } | 1621 } |
| 1622 | 1622 |
| 1623 // METHOD_PUT should be used to upload data. | 1623 // METHOD_PUT should be used to upload data. |
| 1624 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1624 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1625 // Request should go to the upload URL. | 1625 // Request should go to the upload URL. |
| 1626 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1626 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1627 // Content-Range header should be added. | 1627 // Content-Range header should be added. |
| 1628 EXPECT_EQ("bytes 0-" + | 1628 EXPECT_EQ("bytes 0-" + |
| 1629 base::Int64ToString(kTestContent.size() - 1) + "/" + | 1629 base::Int64ToString(kTestContent.size() - 1) + "/" + |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1662 new drive::InitiateUploadExistingFileRequest( | 1662 new drive::InitiateUploadExistingFileRequest( |
| 1663 request_sender_.get(), | 1663 request_sender_.get(), |
| 1664 *url_generator_, | 1664 *url_generator_, |
| 1665 kTestContentType, | 1665 kTestContentType, |
| 1666 kTestContent.size(), | 1666 kTestContent.size(), |
| 1667 "resource_id", // The resource id of the file to be overwritten. | 1667 "resource_id", // The resource id of the file to be overwritten. |
| 1668 "Conflicting-etag", | 1668 "Conflicting-etag", |
| 1669 test_util::CreateQuitCallback( | 1669 test_util::CreateQuitCallback( |
| 1670 &run_loop, | 1670 &run_loop, |
| 1671 test_util::CreateCopyResultCallback(&error, &upload_url))); | 1671 test_util::CreateCopyResultCallback(&error, &upload_url))); |
| 1672 request_sender_->StartRequestWithRetry(request); | 1672 request_sender_->StartRequestWithAuthRetry(request); |
| 1673 run_loop.Run(); | 1673 run_loop.Run(); |
| 1674 } | 1674 } |
| 1675 | 1675 |
| 1676 EXPECT_EQ(HTTP_PRECONDITION, error); | 1676 EXPECT_EQ(HTTP_PRECONDITION, error); |
| 1677 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 1677 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
| 1678 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 1678 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
| 1679 http_request_.headers["X-Upload-Content-Length"]); | 1679 http_request_.headers["X-Upload-Content-Length"]); |
| 1680 EXPECT_EQ("Conflicting-etag", http_request_.headers["If-Match"]); | 1680 EXPECT_EQ("Conflicting-etag", http_request_.headers["If-Match"]); |
| 1681 | 1681 |
| 1682 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1682 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1707 new drive::InitiateUploadExistingFileRequest( | 1707 new drive::InitiateUploadExistingFileRequest( |
| 1708 request_sender_.get(), | 1708 request_sender_.get(), |
| 1709 *url_generator_, | 1709 *url_generator_, |
| 1710 kTestContentType, | 1710 kTestContentType, |
| 1711 kTestContent.size(), | 1711 kTestContent.size(), |
| 1712 "resource_id", // The resource id of the file to be overwritten. | 1712 "resource_id", // The resource id of the file to be overwritten. |
| 1713 kTestETag, | 1713 kTestETag, |
| 1714 test_util::CreateQuitCallback( | 1714 test_util::CreateQuitCallback( |
| 1715 &run_loop, | 1715 &run_loop, |
| 1716 test_util::CreateCopyResultCallback(&error, &upload_url))); | 1716 test_util::CreateCopyResultCallback(&error, &upload_url))); |
| 1717 request_sender_->StartRequestWithRetry(request); | 1717 request_sender_->StartRequestWithAuthRetry(request); |
| 1718 run_loop.Run(); | 1718 run_loop.Run(); |
| 1719 } | 1719 } |
| 1720 | 1720 |
| 1721 EXPECT_EQ(HTTP_SUCCESS, error); | 1721 EXPECT_EQ(HTTP_SUCCESS, error); |
| 1722 EXPECT_EQ(kTestUploadExistingFilePath, upload_url.path()); | 1722 EXPECT_EQ(kTestUploadExistingFilePath, upload_url.path()); |
| 1723 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 1723 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
| 1724 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 1724 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
| 1725 http_request_.headers["X-Upload-Content-Length"]); | 1725 http_request_.headers["X-Upload-Content-Length"]); |
| 1726 EXPECT_EQ(kTestETag, http_request_.headers["If-Match"]); | 1726 EXPECT_EQ(kTestETag, http_request_.headers["If-Match"]); |
| 1727 | 1727 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1748 upload_url, | 1748 upload_url, |
| 1749 0, // start_position | 1749 0, // start_position |
| 1750 kTestContent.size(), // end_position (exclusive) | 1750 kTestContent.size(), // end_position (exclusive) |
| 1751 kTestContent.size(), // content_length, | 1751 kTestContent.size(), // content_length, |
| 1752 kTestContentType, | 1752 kTestContentType, |
| 1753 kTestFilePath, | 1753 kTestFilePath, |
| 1754 test_util::CreateQuitCallback( | 1754 test_util::CreateQuitCallback( |
| 1755 &run_loop, | 1755 &run_loop, |
| 1756 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1756 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 1757 ProgressCallback()); | 1757 ProgressCallback()); |
| 1758 request_sender_->StartRequestWithRetry(resume_request); | 1758 request_sender_->StartRequestWithAuthRetry(resume_request); |
| 1759 run_loop.Run(); | 1759 run_loop.Run(); |
| 1760 } | 1760 } |
| 1761 | 1761 |
| 1762 // METHOD_PUT should be used to upload data. | 1762 // METHOD_PUT should be used to upload data. |
| 1763 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1763 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1764 // Request should go to the upload URL. | 1764 // Request should go to the upload URL. |
| 1765 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1765 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1766 // Content-Range header should be added. | 1766 // Content-Range header should be added. |
| 1767 EXPECT_EQ("bytes 0-" + | 1767 EXPECT_EQ("bytes 0-" + |
| 1768 base::Int64ToString(kTestContent.size() - 1) + "/" + | 1768 base::Int64ToString(kTestContent.size() - 1) + "/" + |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1809 kTestETag, | 1809 kTestETag, |
| 1810 test_util::CreateQuitCallback( | 1810 test_util::CreateQuitCallback( |
| 1811 &run_loop, | 1811 &run_loop, |
| 1812 test_util::CreateCopyResultCallback(&error, &upload_url))); | 1812 test_util::CreateCopyResultCallback(&error, &upload_url))); |
| 1813 request->set_parent_resource_id("new_parent_resource_id"); | 1813 request->set_parent_resource_id("new_parent_resource_id"); |
| 1814 request->set_title("new file title"); | 1814 request->set_title("new file title"); |
| 1815 request->set_modified_date(base::Time::FromUTCExploded(kModifiedDate)); | 1815 request->set_modified_date(base::Time::FromUTCExploded(kModifiedDate)); |
| 1816 request->set_last_viewed_by_me_date( | 1816 request->set_last_viewed_by_me_date( |
| 1817 base::Time::FromUTCExploded(kLastViewedByMeDate)); | 1817 base::Time::FromUTCExploded(kLastViewedByMeDate)); |
| 1818 | 1818 |
| 1819 request_sender_->StartRequestWithRetry(request); | 1819 request_sender_->StartRequestWithAuthRetry(request); |
| 1820 run_loop.Run(); | 1820 run_loop.Run(); |
| 1821 } | 1821 } |
| 1822 | 1822 |
| 1823 EXPECT_EQ(HTTP_SUCCESS, error); | 1823 EXPECT_EQ(HTTP_SUCCESS, error); |
| 1824 EXPECT_EQ(kTestUploadExistingFilePath, upload_url.path()); | 1824 EXPECT_EQ(kTestUploadExistingFilePath, upload_url.path()); |
| 1825 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 1825 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
| 1826 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 1826 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
| 1827 http_request_.headers["X-Upload-Content-Length"]); | 1827 http_request_.headers["X-Upload-Content-Length"]); |
| 1828 EXPECT_EQ(kTestETag, http_request_.headers["If-Match"]); | 1828 EXPECT_EQ(kTestETag, http_request_.headers["If-Match"]); |
| 1829 | 1829 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1853 drive::DownloadFileRequest* request = new drive::DownloadFileRequest( | 1853 drive::DownloadFileRequest* request = new drive::DownloadFileRequest( |
| 1854 request_sender_.get(), | 1854 request_sender_.get(), |
| 1855 *url_generator_, | 1855 *url_generator_, |
| 1856 kTestId, | 1856 kTestId, |
| 1857 kDownloadedFilePath, | 1857 kDownloadedFilePath, |
| 1858 test_util::CreateQuitCallback( | 1858 test_util::CreateQuitCallback( |
| 1859 &run_loop, | 1859 &run_loop, |
| 1860 test_util::CreateCopyResultCallback(&result_code, &temp_file)), | 1860 test_util::CreateCopyResultCallback(&result_code, &temp_file)), |
| 1861 GetContentCallback(), | 1861 GetContentCallback(), |
| 1862 ProgressCallback()); | 1862 ProgressCallback()); |
| 1863 request_sender_->StartRequestWithRetry(request); | 1863 request_sender_->StartRequestWithAuthRetry(request); |
| 1864 run_loop.Run(); | 1864 run_loop.Run(); |
| 1865 } | 1865 } |
| 1866 | 1866 |
| 1867 std::string contents; | 1867 std::string contents; |
| 1868 base::ReadFileToString(temp_file, &contents); | 1868 base::ReadFileToString(temp_file, &contents); |
| 1869 base::DeleteFile(temp_file, false); | 1869 base::DeleteFile(temp_file, false); |
| 1870 | 1870 |
| 1871 EXPECT_EQ(HTTP_SUCCESS, result_code); | 1871 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 1872 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 1872 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 1873 EXPECT_EQ(kTestDownloadPathPrefix + kTestId, http_request_.relative_url); | 1873 EXPECT_EQ(kTestDownloadPathPrefix + kTestId, http_request_.relative_url); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1890 drive::DownloadFileRequest* request = new drive::DownloadFileRequest( | 1890 drive::DownloadFileRequest* request = new drive::DownloadFileRequest( |
| 1891 request_sender_.get(), | 1891 request_sender_.get(), |
| 1892 *url_generator_, | 1892 *url_generator_, |
| 1893 kTestId, | 1893 kTestId, |
| 1894 kDownloadedFilePath, | 1894 kDownloadedFilePath, |
| 1895 test_util::CreateQuitCallback( | 1895 test_util::CreateQuitCallback( |
| 1896 &run_loop, | 1896 &run_loop, |
| 1897 test_util::CreateCopyResultCallback(&result_code, &temp_file)), | 1897 test_util::CreateCopyResultCallback(&result_code, &temp_file)), |
| 1898 base::Bind(&AppendContent, &contents), | 1898 base::Bind(&AppendContent, &contents), |
| 1899 ProgressCallback()); | 1899 ProgressCallback()); |
| 1900 request_sender_->StartRequestWithRetry(request); | 1900 request_sender_->StartRequestWithAuthRetry(request); |
| 1901 run_loop.Run(); | 1901 run_loop.Run(); |
| 1902 } | 1902 } |
| 1903 | 1903 |
| 1904 base::DeleteFile(temp_file, false); | 1904 base::DeleteFile(temp_file, false); |
| 1905 | 1905 |
| 1906 EXPECT_EQ(HTTP_SUCCESS, result_code); | 1906 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 1907 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 1907 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 1908 EXPECT_EQ(kTestDownloadPathPrefix + kTestId, http_request_.relative_url); | 1908 EXPECT_EQ(kTestDownloadPathPrefix + kTestId, http_request_.relative_url); |
| 1909 EXPECT_EQ(kDownloadedFilePath, temp_file); | 1909 EXPECT_EQ(kDownloadedFilePath, temp_file); |
| 1910 | 1910 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1925 new drive::PermissionsInsertRequest( | 1925 new drive::PermissionsInsertRequest( |
| 1926 request_sender_.get(), | 1926 request_sender_.get(), |
| 1927 *url_generator_, | 1927 *url_generator_, |
| 1928 test_util::CreateQuitCallback( | 1928 test_util::CreateQuitCallback( |
| 1929 &run_loop, | 1929 &run_loop, |
| 1930 test_util::CreateCopyResultCallback(&error))); | 1930 test_util::CreateCopyResultCallback(&error))); |
| 1931 request->set_id("resource_id"); | 1931 request->set_id("resource_id"); |
| 1932 request->set_role(drive::PERMISSION_ROLE_COMMENTER); | 1932 request->set_role(drive::PERMISSION_ROLE_COMMENTER); |
| 1933 request->set_type(drive::PERMISSION_TYPE_USER); | 1933 request->set_type(drive::PERMISSION_TYPE_USER); |
| 1934 request->set_value("user@example.com"); | 1934 request->set_value("user@example.com"); |
| 1935 request_sender_->StartRequestWithRetry(request); | 1935 request_sender_->StartRequestWithAuthRetry(request); |
| 1936 run_loop.Run(); | 1936 run_loop.Run(); |
| 1937 } | 1937 } |
| 1938 | 1938 |
| 1939 EXPECT_EQ(HTTP_SUCCESS, error); | 1939 EXPECT_EQ(HTTP_SUCCESS, error); |
| 1940 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 1940 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 1941 EXPECT_EQ("/drive/v2/files/resource_id/permissions", | 1941 EXPECT_EQ("/drive/v2/files/resource_id/permissions", |
| 1942 http_request_.relative_url); | 1942 http_request_.relative_url); |
| 1943 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 1943 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| 1944 | 1944 |
| 1945 scoped_ptr<base::Value> expected(base::JSONReader::DeprecatedRead( | 1945 scoped_ptr<base::Value> expected(base::JSONReader::DeprecatedRead( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1960 new drive::PermissionsInsertRequest( | 1960 new drive::PermissionsInsertRequest( |
| 1961 request_sender_.get(), | 1961 request_sender_.get(), |
| 1962 *url_generator_, | 1962 *url_generator_, |
| 1963 test_util::CreateQuitCallback( | 1963 test_util::CreateQuitCallback( |
| 1964 &run_loop, | 1964 &run_loop, |
| 1965 test_util::CreateCopyResultCallback(&error))); | 1965 test_util::CreateCopyResultCallback(&error))); |
| 1966 request->set_id("resource_id2"); | 1966 request->set_id("resource_id2"); |
| 1967 request->set_role(drive::PERMISSION_ROLE_WRITER); | 1967 request->set_role(drive::PERMISSION_ROLE_WRITER); |
| 1968 request->set_type(drive::PERMISSION_TYPE_DOMAIN); | 1968 request->set_type(drive::PERMISSION_TYPE_DOMAIN); |
| 1969 request->set_value("example.com"); | 1969 request->set_value("example.com"); |
| 1970 request_sender_->StartRequestWithRetry(request); | 1970 request_sender_->StartRequestWithAuthRetry(request); |
| 1971 run_loop.Run(); | 1971 run_loop.Run(); |
| 1972 } | 1972 } |
| 1973 | 1973 |
| 1974 EXPECT_EQ(HTTP_SUCCESS, error); | 1974 EXPECT_EQ(HTTP_SUCCESS, error); |
| 1975 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 1975 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 1976 EXPECT_EQ("/drive/v2/files/resource_id2/permissions", | 1976 EXPECT_EQ("/drive/v2/files/resource_id2/permissions", |
| 1977 http_request_.relative_url); | 1977 http_request_.relative_url); |
| 1978 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 1978 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| 1979 | 1979 |
| 1980 expected.reset(base::JSONReader::DeprecatedRead( | 1980 expected.reset(base::JSONReader::DeprecatedRead( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1991 const char kTestContentType[] = "text/plain"; | 1991 const char kTestContentType[] = "text/plain"; |
| 1992 const std::string kTestContent(10, 'a'); | 1992 const std::string kTestContent(10, 'a'); |
| 1993 const base::FilePath kTestFilePath = | 1993 const base::FilePath kTestFilePath = |
| 1994 temp_dir_.path().AppendASCII("upload_file.txt"); | 1994 temp_dir_.path().AppendASCII("upload_file.txt"); |
| 1995 ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent)); | 1995 ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent)); |
| 1996 | 1996 |
| 1997 // Create batch request. | 1997 // Create batch request. |
| 1998 drive::BatchUploadRequest* const request = | 1998 drive::BatchUploadRequest* const request = |
| 1999 new drive::BatchUploadRequest(request_sender_.get(), *url_generator_); | 1999 new drive::BatchUploadRequest(request_sender_.get(), *url_generator_); |
| 2000 request->SetBoundaryForTesting("OUTERBOUNDARY"); | 2000 request->SetBoundaryForTesting("OUTERBOUNDARY"); |
| 2001 request_sender_->StartRequestWithRetry(request); | 2001 request_sender_->StartRequestWithAuthRetry(request); |
| 2002 | 2002 |
| 2003 // Create child request. | 2003 // Create child request. |
| 2004 DriveApiErrorCode errors[] = {DRIVE_OTHER_ERROR, DRIVE_OTHER_ERROR}; | 2004 DriveApiErrorCode errors[] = {DRIVE_OTHER_ERROR, DRIVE_OTHER_ERROR}; |
| 2005 scoped_ptr<FileResource> file_resources[2]; | 2005 scoped_ptr<FileResource> file_resources[2]; |
| 2006 base::RunLoop run_loop[2]; | 2006 base::RunLoop run_loop[2]; |
| 2007 for (int i = 0; i < 2; ++i) { | 2007 for (int i = 0; i < 2; ++i) { |
| 2008 const FileResourceCallback callback = test_util::CreateQuitCallback( | 2008 const FileResourceCallback callback = test_util::CreateQuitCallback( |
| 2009 &run_loop[i], | 2009 &run_loop[i], |
| 2010 test_util::CreateCopyResultCallback(&errors[i], &file_resources[i])); | 2010 test_util::CreateCopyResultCallback(&errors[i], &file_resources[i])); |
| 2011 drive::MultipartUploadNewFileDelegate* const child_request = | 2011 drive::MultipartUploadNewFileDelegate* const child_request = |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2079 request->GetWeakPtrAsBatchUploadRequest(); | 2079 request->GetWeakPtrAsBatchUploadRequest(); |
| 2080 request->Commit(); | 2080 request->Commit(); |
| 2081 ASSERT_FALSE(weak_ptr.get()); | 2081 ASSERT_FALSE(weak_ptr.get()); |
| 2082 } | 2082 } |
| 2083 | 2083 |
| 2084 TEST_F(DriveApiRequestsTest, BatchUploadRequestWithBodyIncludingZero) { | 2084 TEST_F(DriveApiRequestsTest, BatchUploadRequestWithBodyIncludingZero) { |
| 2085 // Create batch request. | 2085 // Create batch request. |
| 2086 drive::BatchUploadRequest* const request = | 2086 drive::BatchUploadRequest* const request = |
| 2087 new drive::BatchUploadRequest(request_sender_.get(), *url_generator_); | 2087 new drive::BatchUploadRequest(request_sender_.get(), *url_generator_); |
| 2088 request->SetBoundaryForTesting("OUTERBOUNDARY"); | 2088 request->SetBoundaryForTesting("OUTERBOUNDARY"); |
| 2089 request_sender_->StartRequestWithRetry(request); | 2089 request_sender_->StartRequestWithAuthRetry(request); |
| 2090 | 2090 |
| 2091 // Create child request. | 2091 // Create child request. |
| 2092 { | 2092 { |
| 2093 base::RunLoop loop; | 2093 base::RunLoop loop; |
| 2094 TestBatchableDelegate* const child_request = new TestBatchableDelegate( | 2094 TestBatchableDelegate* const child_request = new TestBatchableDelegate( |
| 2095 GURL("http://example.com/test"), "application/binary", | 2095 GURL("http://example.com/test"), "application/binary", |
| 2096 std::string("Apple\0Orange\0", 13), loop.QuitClosure()); | 2096 std::string("Apple\0Orange\0", 13), loop.QuitClosure()); |
| 2097 request->AddRequest(child_request); | 2097 request->AddRequest(child_request); |
| 2098 request->Commit(); | 2098 request->Commit(); |
| 2099 loop.Run(); | 2099 loop.Run(); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2281 "Header: value\r\n" | 2281 "Header: value\r\n" |
| 2282 "\r\n" | 2282 "\r\n" |
| 2283 "BODY\r\n" | 2283 "BODY\r\n" |
| 2284 "--BOUNDARY-- \t", | 2284 "--BOUNDARY-- \t", |
| 2285 &parts)); | 2285 &parts)); |
| 2286 ASSERT_EQ(1u, parts.size()); | 2286 ASSERT_EQ(1u, parts.size()); |
| 2287 EXPECT_EQ(HTTP_SUCCESS, parts[0].code); | 2287 EXPECT_EQ(HTTP_SUCCESS, parts[0].code); |
| 2288 EXPECT_EQ("BODY", parts[0].body); | 2288 EXPECT_EQ("BODY", parts[0].body); |
| 2289 } | 2289 } |
| 2290 } // namespace google_apis | 2290 } // namespace google_apis |
| OLD | NEW |