Chromium Code Reviews| Index: google_apis/drive/drive_api_requests_unittest.cc |
| diff --git a/google_apis/drive/drive_api_requests_unittest.cc b/google_apis/drive/drive_api_requests_unittest.cc |
| index deb2845536a9bb142b9add983c7a00847f423f57..eb9502c77b1ecb1e610ba66d741b3be1e9b8fe42 100644 |
| --- a/google_apis/drive/drive_api_requests_unittest.cc |
| +++ b/google_apis/drive/drive_api_requests_unittest.cc |
| @@ -62,6 +62,18 @@ void AppendContent(std::string* out, |
| class DriveApiRequestsTest : public testing::Test { |
| public: |
| DriveApiRequestsTest() { |
| + // Testing properties used by multiple test cases. |
| + drive::Property private_property; |
| + private_property.set_key("key1"); |
| + private_property.set_value("value1"); |
| + |
| + drive::Property public_property; |
| + public_property.set_visibility(drive::Property::VISIBILITY_PUBLIC); |
| + public_property.set_key("key2"); |
| + public_property.set_value("value2"); |
| + |
| + testing_properties_.push_back(private_property); |
| + testing_properties_.push_back(public_property); |
|
hashimoto
2015/02/23 10:16:20
nit: Initialization order and declaration order sh
mtomasz
2015/02/24 02:30:38
Done.
|
| } |
| void SetUp() override { |
| @@ -140,6 +152,9 @@ class DriveApiRequestsTest : public testing::Test { |
| // instead of GET). |
| net::test_server::HttpRequest http_request_; |
| + // Testing properties used by multiple test cases. |
| + drive::Properties testing_properties_; |
| + |
| private: |
| void ResetExpectedResponse() { |
| expected_data_file_path_.clear(); |
| @@ -451,6 +466,7 @@ TEST_F(DriveApiRequestsTest, FilesInsertRequest) { |
| request->set_modified_date(base::Time::FromUTCExploded(kModifiedDate)); |
| request->add_parent("root"); |
| request->set_title("new directory"); |
| + request->set_properties(testing_properties_); |
| request_sender_->StartRequestWithRetry(request); |
| run_loop.Run(); |
| } |
| @@ -461,12 +477,16 @@ TEST_F(DriveApiRequestsTest, FilesInsertRequest) { |
| EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| EXPECT_TRUE(http_request_.has_content); |
| - EXPECT_EQ("{\"lastViewedByMeDate\":\"2013-07-19T15:59:13.123Z\"," |
| - "\"mimeType\":\"application/vnd.google-apps.folder\"," |
| - "\"modifiedDate\":\"2012-07-19T15:59:13.123Z\"," |
| - "\"parents\":[{\"id\":\"root\"}]," |
| - "\"title\":\"new directory\"}", |
| - http_request_.content); |
| + EXPECT_EQ( |
| + "{\"lastViewedByMeDate\":\"2013-07-19T15:59:13.123Z\"," |
| + "\"mimeType\":\"application/vnd.google-apps.folder\"," |
| + "\"modifiedDate\":\"2012-07-19T15:59:13.123Z\"," |
| + "\"parents\":[{\"id\":\"root\"}]," |
| + "\"properties\":[" |
| + "{\"key\":\"key1\",\"value\":\"value1\",\"visibility\":\"PRIVATE\"}," |
| + "{\"key\":\"key2\",\"value\":\"value2\",\"visibility\":\"PUBLIC\"}]," |
| + "\"title\":\"new directory\"}", |
| + http_request_.content); |
| scoped_ptr<FileResource> expected( |
| FileResource::CreateFrom( |
| @@ -511,20 +531,7 @@ TEST_F(DriveApiRequestsTest, FilesPatchRequest) { |
| base::Time::FromUTCExploded(kLastViewedByMeDate)); |
| request->add_parent("parent_resource_id"); |
| - drive::Property private_property; |
| - private_property.set_key("key1"); |
| - private_property.set_value("value1"); |
| - |
| - drive::Property public_property; |
| - public_property.set_visibility(drive::Property::VISIBILITY_PUBLIC); |
| - public_property.set_key("key2"); |
| - public_property.set_value("value2"); |
| - |
| - drive::Properties properties; |
| - properties.push_back(private_property); |
| - properties.push_back(public_property); |
| - request->set_properties(properties); |
| - |
| + request->set_properties(testing_properties_); |
| request_sender_->StartRequestWithRetry(request); |
| run_loop.Run(); |
| } |
| @@ -964,6 +971,7 @@ TEST_F(DriveApiRequestsTest, UploadNewFileRequest) { |
| test_util::CreateQuitCallback( |
| &run_loop, |
| test_util::CreateCopyResultCallback(&error, &upload_url))); |
| + request->set_properties(testing_properties_); |
| request_sender_->StartRequestWithRetry(request); |
| run_loop.Run(); |
| } |
| @@ -979,12 +987,16 @@ TEST_F(DriveApiRequestsTest, UploadNewFileRequest) { |
| http_request_.relative_url); |
| EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| EXPECT_TRUE(http_request_.has_content); |
| - EXPECT_EQ("{\"parents\":[{" |
| - "\"id\":\"parent_resource_id\"," |
| - "\"kind\":\"drive#fileLink\"" |
| - "}]," |
| - "\"title\":\"new file title\"}", |
| - http_request_.content); |
| + EXPECT_EQ( |
| + "{\"parents\":[{" |
| + "\"id\":\"parent_resource_id\"," |
| + "\"kind\":\"drive#fileLink\"" |
| + "}]," |
| + "\"properties\":[" |
| + "{\"key\":\"key1\",\"value\":\"value1\",\"visibility\":\"PRIVATE\"}," |
| + "{\"key\":\"key2\",\"value\":\"value2\",\"visibility\":\"PUBLIC\"}]," |
| + "\"title\":\"new file title\"}", |
| + http_request_.content); |
| // Upload the content to the upload URL. |
| UploadRangeResponse response; |
| @@ -1377,6 +1389,7 @@ TEST_F(DriveApiRequestsTest, UploadExistingFileRequest) { |
| test_util::CreateQuitCallback( |
| &run_loop, |
| test_util::CreateCopyResultCallback(&error, &upload_url))); |
| + request->set_properties(testing_properties_); |
| request_sender_->StartRequestWithRetry(request); |
| run_loop.Run(); |
| } |
| @@ -1392,7 +1405,11 @@ TEST_F(DriveApiRequestsTest, UploadExistingFileRequest) { |
| EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", |
| http_request_.relative_url); |
| EXPECT_TRUE(http_request_.has_content); |
| - EXPECT_TRUE(http_request_.content.empty()); |
| + EXPECT_EQ( |
| + "{\"properties\":[" |
| + "{\"key\":\"key1\",\"value\":\"value1\",\"visibility\":\"PRIVATE\"}," |
| + "{\"key\":\"key2\",\"value\":\"value2\",\"visibility\":\"PUBLIC\"}]}", |
| + http_request_.content); |
| // Upload the content to the upload URL. |
| UploadRangeResponse response; |