| 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 "google_apis/drive/drive_api_requests.h" | 5 #include "google_apis/drive/drive_api_requests.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 drive::Property public_property; | 187 drive::Property public_property; |
| 188 public_property.set_visibility(drive::Property::VISIBILITY_PUBLIC); | 188 public_property.set_visibility(drive::Property::VISIBILITY_PUBLIC); |
| 189 public_property.set_key("key2"); | 189 public_property.set_key("key2"); |
| 190 public_property.set_value("value2"); | 190 public_property.set_value("value2"); |
| 191 | 191 |
| 192 testing_properties_.clear(); | 192 testing_properties_.clear(); |
| 193 testing_properties_.push_back(private_property); | 193 testing_properties_.push_back(private_property); |
| 194 testing_properties_.push_back(public_property); | 194 testing_properties_.push_back(public_property); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void EnableTeamDrivesIntegration() { |
| 198 GURL test_base_url = test_util::GetBaseUrlForTesting(test_server_.port()); |
| 199 url_generator_.reset(new DriveApiUrlGenerator( |
| 200 test_base_url, test_base_url, TEAM_DRIVES_INTEGRATION_ENABLED)); |
| 201 } |
| 202 |
| 197 base::MessageLoopForIO message_loop_; // Test server needs IO thread. | 203 base::MessageLoopForIO message_loop_; // Test server needs IO thread. |
| 198 net::EmbeddedTestServer test_server_; | 204 net::EmbeddedTestServer test_server_; |
| 199 std::unique_ptr<RequestSender> request_sender_; | 205 std::unique_ptr<RequestSender> request_sender_; |
| 200 std::unique_ptr<DriveApiUrlGenerator> url_generator_; | 206 std::unique_ptr<DriveApiUrlGenerator> url_generator_; |
| 201 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; | 207 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; |
| 202 base::ScopedTempDir temp_dir_; | 208 base::ScopedTempDir temp_dir_; |
| 203 | 209 |
| 204 // This is a path to the file which contains expected response from | 210 // This is a path to the file which contains expected response from |
| 205 // the server. See also HandleDataFileRequest below. | 211 // the server. See also HandleDataFileRequest below. |
| 206 base::FilePath expected_data_file_path_; | 212 base::FilePath expected_data_file_path_; |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 run_loop.Run(); | 763 run_loop.Run(); |
| 758 } | 764 } |
| 759 | 765 |
| 760 EXPECT_EQ(HTTP_SUCCESS, error); | 766 EXPECT_EQ(HTTP_SUCCESS, error); |
| 761 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 767 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 762 EXPECT_EQ("/drive/v2/apps", http_request_.relative_url); | 768 EXPECT_EQ("/drive/v2/apps", http_request_.relative_url); |
| 763 EXPECT_TRUE(app_list); | 769 EXPECT_TRUE(app_list); |
| 764 } | 770 } |
| 765 | 771 |
| 766 TEST_F(DriveApiRequestsTest, ChangesListRequest) { | 772 TEST_F(DriveApiRequestsTest, ChangesListRequest) { |
| 773 EnableTeamDrivesIntegration(); |
| 767 // Set an expected data file containing valid result. | 774 // Set an expected data file containing valid result. |
| 768 expected_data_file_path_ = test_util::GetTestFilePath( | 775 expected_data_file_path_ = test_util::GetTestFilePath( |
| 769 "drive/changelist.json"); | 776 "drive/changelist.json"); |
| 770 | 777 |
| 771 DriveApiErrorCode error = DRIVE_OTHER_ERROR; | 778 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 772 std::unique_ptr<ChangeList> result; | 779 std::unique_ptr<ChangeList> result; |
| 773 | 780 |
| 774 { | 781 { |
| 775 base::RunLoop run_loop; | 782 base::RunLoop run_loop; |
| 776 std::unique_ptr<drive::ChangesListRequest> request = | 783 std::unique_ptr<drive::ChangesListRequest> request = |
| 777 base::MakeUnique<drive::ChangesListRequest>( | 784 base::MakeUnique<drive::ChangesListRequest>( |
| 778 request_sender_.get(), *url_generator_, | 785 request_sender_.get(), *url_generator_, |
| 779 test_util::CreateQuitCallback( | 786 test_util::CreateQuitCallback( |
| 780 &run_loop, | 787 &run_loop, |
| 781 test_util::CreateCopyResultCallback(&error, &result))); | 788 test_util::CreateCopyResultCallback(&error, &result))); |
| 782 request->set_include_deleted(true); | 789 request->set_include_deleted(true); |
| 783 request->set_start_change_id(100); | 790 request->set_start_change_id(100); |
| 784 request->set_max_results(500); | 791 request->set_max_results(500); |
| 792 request->set_team_drive_id("TEAM_DRIVE_ID"); |
| 785 request_sender_->StartRequestWithAuthRetry(std::move(request)); | 793 request_sender_->StartRequestWithAuthRetry(std::move(request)); |
| 786 run_loop.Run(); | 794 run_loop.Run(); |
| 787 } | 795 } |
| 788 | 796 |
| 789 EXPECT_EQ(HTTP_SUCCESS, error); | 797 EXPECT_EQ(HTTP_SUCCESS, error); |
| 790 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 798 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 791 EXPECT_EQ("/drive/v2/changes?maxResults=500&startChangeId=100", | 799 EXPECT_EQ( |
| 792 http_request_.relative_url); | 800 "/drive/v2/changes?supportsTeamDrives=true&" |
| 801 "includeTeamDriveItems=true&teamDriveId=TEAM_DRIVE_ID&" |
| 802 "maxResults=500&startChangeId=100", |
| 803 http_request_.relative_url); |
| 793 EXPECT_TRUE(result); | 804 EXPECT_TRUE(result); |
| 794 } | 805 } |
| 795 | 806 |
| 796 TEST_F(DriveApiRequestsTest, ChangesListNextPageRequest) { | 807 TEST_F(DriveApiRequestsTest, ChangesListNextPageRequest) { |
| 797 // Set an expected data file containing valid result. | 808 // Set an expected data file containing valid result. |
| 798 expected_data_file_path_ = test_util::GetTestFilePath( | 809 expected_data_file_path_ = test_util::GetTestFilePath( |
| 799 "drive/changelist.json"); | 810 "drive/changelist.json"); |
| 800 | 811 |
| 801 DriveApiErrorCode error = DRIVE_OTHER_ERROR; | 812 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 802 std::unique_ptr<ChangeList> result; | 813 std::unique_ptr<ChangeList> result; |
| (...skipping 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2298 "Header: value\r\n" | 2309 "Header: value\r\n" |
| 2299 "\r\n" | 2310 "\r\n" |
| 2300 "BODY\r\n" | 2311 "BODY\r\n" |
| 2301 "--BOUNDARY-- \t", | 2312 "--BOUNDARY-- \t", |
| 2302 &parts)); | 2313 &parts)); |
| 2303 ASSERT_EQ(1u, parts.size()); | 2314 ASSERT_EQ(1u, parts.size()); |
| 2304 EXPECT_EQ(HTTP_SUCCESS, parts[0].code); | 2315 EXPECT_EQ(HTTP_SUCCESS, parts[0].code); |
| 2305 EXPECT_EQ("BODY", parts[0].body); | 2316 EXPECT_EQ("BODY", parts[0].body); |
| 2306 } | 2317 } |
| 2307 } // namespace google_apis | 2318 } // namespace google_apis |
| OLD | NEW |