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/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 EXPECT_EQ(HTTP_SUCCESS, error); | 820 EXPECT_EQ(HTTP_SUCCESS, error); |
821 EXPECT_EQ(net::test_server::METHOD_PATCH, http_request_.method); | 821 EXPECT_EQ(net::test_server::METHOD_PATCH, http_request_.method); |
822 EXPECT_EQ("/drive/v2/files/resource_id", http_request_.relative_url); | 822 EXPECT_EQ("/drive/v2/files/resource_id", http_request_.relative_url); |
823 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 823 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
824 | 824 |
825 EXPECT_TRUE(http_request_.has_content); | 825 EXPECT_TRUE(http_request_.has_content); |
826 EXPECT_EQ("{\"title\":\"new title\"}", http_request_.content); | 826 EXPECT_EQ("{\"title\":\"new title\"}", http_request_.content); |
827 EXPECT_TRUE(file_resource); | 827 EXPECT_TRUE(file_resource); |
828 } | 828 } |
829 | 829 |
830 TEST_F(DriveApiRequestsTest, InsertResourceRequest) { | 830 TEST_F(DriveApiRequestsTest, ChildrenInsertRequest) { |
831 // Set an expected data file containing the children entry. | 831 // Set an expected data file containing the children entry. |
832 expected_content_type_ = "application/json"; | 832 expected_content_type_ = "application/json"; |
833 expected_content_ = kTestChildrenResponse; | 833 expected_content_ = kTestChildrenResponse; |
834 | 834 |
835 GDataErrorCode error = GDATA_OTHER_ERROR; | 835 GDataErrorCode error = GDATA_OTHER_ERROR; |
836 | 836 |
837 // Add a resource with "resource_id" to a directory with | 837 // Add a resource with "resource_id" to a directory with |
838 // "parent_resource_id". | 838 // "parent_resource_id". |
839 { | 839 { |
840 base::RunLoop run_loop; | 840 base::RunLoop run_loop; |
841 drive::InsertResourceRequest* request = | 841 drive::ChildrenInsertRequest* request = new drive::ChildrenInsertRequest( |
842 new drive::InsertResourceRequest( | 842 request_sender_.get(), |
843 request_sender_.get(), | 843 *url_generator_, |
844 *url_generator_, | 844 test_util::CreateQuitCallback( |
845 "parent_resource_id", | 845 &run_loop, |
846 "resource_id", | 846 test_util::CreateCopyResultCallback(&error))); |
847 test_util::CreateQuitCallback( | 847 request->set_folder_id("parent_resource_id"); |
848 &run_loop, | 848 request->set_id("resource_id"); |
849 test_util::CreateCopyResultCallback(&error))); | |
850 request_sender_->StartRequestWithRetry(request); | 849 request_sender_->StartRequestWithRetry(request); |
851 run_loop.Run(); | 850 run_loop.Run(); |
852 } | 851 } |
853 | 852 |
854 EXPECT_EQ(HTTP_SUCCESS, error); | 853 EXPECT_EQ(HTTP_SUCCESS, error); |
855 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 854 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
856 EXPECT_EQ("/drive/v2/files/parent_resource_id/children", | 855 EXPECT_EQ("/drive/v2/files/parent_resource_id/children", |
857 http_request_.relative_url); | 856 http_request_.relative_url); |
858 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 857 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
859 | 858 |
860 EXPECT_TRUE(http_request_.has_content); | 859 EXPECT_TRUE(http_request_.has_content); |
861 EXPECT_EQ("{\"id\":\"resource_id\"}", http_request_.content); | 860 EXPECT_EQ("{\"id\":\"resource_id\"}", http_request_.content); |
862 } | 861 } |
863 | 862 |
864 TEST_F(DriveApiRequestsTest, DeleteResourceRequest) { | 863 TEST_F(DriveApiRequestsTest, ChildrenDeleteRequest) { |
865 GDataErrorCode error = GDATA_OTHER_ERROR; | 864 GDataErrorCode error = GDATA_OTHER_ERROR; |
866 | 865 |
867 // Remove a resource with "resource_id" from a directory with | 866 // Remove a resource with "resource_id" from a directory with |
868 // "parent_resource_id". | 867 // "parent_resource_id". |
869 { | 868 { |
870 base::RunLoop run_loop; | 869 base::RunLoop run_loop; |
871 drive::DeleteResourceRequest* request = | 870 drive::ChildrenDeleteRequest* request = new drive::ChildrenDeleteRequest( |
872 new drive::DeleteResourceRequest( | 871 request_sender_.get(), |
873 request_sender_.get(), | 872 *url_generator_, |
874 *url_generator_, | 873 test_util::CreateQuitCallback( |
875 "parent_resource_id", | 874 &run_loop, |
876 "resource_id", | 875 test_util::CreateCopyResultCallback(&error))); |
877 test_util::CreateQuitCallback( | 876 request->set_child_id("resource_id"); |
878 &run_loop, | 877 request->set_folder_id("parent_resource_id"); |
879 test_util::CreateCopyResultCallback(&error))); | |
880 request_sender_->StartRequestWithRetry(request); | 878 request_sender_->StartRequestWithRetry(request); |
881 run_loop.Run(); | 879 run_loop.Run(); |
882 } | 880 } |
883 | 881 |
884 EXPECT_EQ(HTTP_NO_CONTENT, error); | 882 EXPECT_EQ(HTTP_NO_CONTENT, error); |
885 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); | 883 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); |
886 EXPECT_EQ("/drive/v2/files/parent_resource_id/children/resource_id", | 884 EXPECT_EQ("/drive/v2/files/parent_resource_id/children/resource_id", |
887 http_request_.relative_url); | 885 http_request_.relative_url); |
888 EXPECT_FALSE(http_request_.has_content); | 886 EXPECT_FALSE(http_request_.has_content); |
889 } | 887 } |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1594 EXPECT_EQ(HTTP_SUCCESS, result_code); | 1592 EXPECT_EQ(HTTP_SUCCESS, result_code); |
1595 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 1593 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
1596 EXPECT_EQ(kTestDownloadPathPrefix + kTestId, http_request_.relative_url); | 1594 EXPECT_EQ(kTestDownloadPathPrefix + kTestId, http_request_.relative_url); |
1597 EXPECT_EQ(kDownloadedFilePath, temp_file); | 1595 EXPECT_EQ(kDownloadedFilePath, temp_file); |
1598 | 1596 |
1599 const std::string expected_contents = kTestId + kTestId + kTestId; | 1597 const std::string expected_contents = kTestId + kTestId + kTestId; |
1600 EXPECT_EQ(expected_contents, contents); | 1598 EXPECT_EQ(expected_contents, contents); |
1601 } | 1599 } |
1602 | 1600 |
1603 } // namespace google_apis | 1601 } // namespace google_apis |
OLD | NEW |