summaryrefslogtreecommitdiffstats
path: root/google_apis
diff options
context:
space:
mode:
authormtomasz <mtomasz@chromium.org>2015-02-23 19:59:23 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-24 04:00:13 +0000
commitf2b838038376370a64ab3e284e83a1979db4b392 (patch)
tree125a3c9141c329cf104f6ba3d33d1bcc22d0e92e /google_apis
parentc9316d484825c72d4a87171d94fc74b78a889bfb (diff)
downloadchromium_src-f2b838038376370a64ab3e284e83a1979db4b392.zip
chromium_src-f2b838038376370a64ab3e284e83a1979db4b392.tar.gz
chromium_src-f2b838038376370a64ab3e284e83a1979db4b392.tar.bz2
Add support for setting properties to requests uploading contents.
This CL adds support to setting properties to all requests which are used by EntryUpdatePerformer. TEST=google_apis_unittests BUG=451113 Review URL: https://codereview.chromium.org/944413003 Cr-Commit-Position: refs/heads/master@{#317753}
Diffstat (limited to 'google_apis')
-rw-r--r--google_apis/drive/base_requests.cc45
-rw-r--r--google_apis/drive/base_requests.h22
-rw-r--r--google_apis/drive/base_requests_unittest.cc16
-rw-r--r--google_apis/drive/drive_api_requests.cc156
-rw-r--r--google_apis/drive/drive_api_requests.h20
-rw-r--r--google_apis/drive/drive_api_requests_unittest.cc73
6 files changed, 185 insertions, 147 deletions
diff --git a/google_apis/drive/base_requests.cc b/google_apis/drive/base_requests.cc
index 8e625cd..37a49e3 100644
--- a/google_apis/drive/base_requests.cc
+++ b/google_apis/drive/base_requests.cc
@@ -105,40 +105,6 @@ bool IsSuccessfulResponseCode(int response_code) {
return 200 <= response_code && response_code <= 299;
}
-// Creates metadata JSON string for multipart uploading.
-// All the values are optional. If the value is empty or null, the value does
-// not appear in the metadata.
-std::string CreateMultipartUploadMetadataJson(
- const std::string& title,
- const std::string& parent_resource_id,
- const base::Time& modified_date,
- const base::Time& last_viewed_by_me_date) {
- base::DictionaryValue root;
- if (!title.empty())
- root.SetString("title", title);
-
- // Fill parent link.
- if (!parent_resource_id.empty()) {
- scoped_ptr<base::ListValue> parents(new base::ListValue);
- parents->Append(
- google_apis::util::CreateParentValue(parent_resource_id).release());
- root.Set("parents", parents.release());
- }
-
- if (!modified_date.is_null())
- root.SetString("modifiedDate",
- google_apis::util::FormatTimeAsString(modified_date));
-
- if (!last_viewed_by_me_date.is_null()) {
- root.SetString("lastViewedByMeDate", google_apis::util::FormatTimeAsString(
- last_viewed_by_me_date));
- }
-
- std::string json_string;
- base::JSONWriter::Write(&root, &json_string);
- return json_string;
-}
-
// Obtains the multipart body for the metadata string and file contents. If
// predetermined_boundary is empty, the function generates the boundary string.
bool GetMultipartContent(const std::string& predetermined_boundary,
@@ -787,23 +753,16 @@ GetUploadStatusRequestBase::GetExtraRequestHeaders() const {
MultipartUploadRequestBase::MultipartUploadRequestBase(
RequestSender* sender,
- const std::string& title,
- const std::string& parent_resource_id,
+ const std::string& metadata_json,
const std::string& content_type,
int64 content_length,
- const base::Time& modified_date,
- const base::Time& last_viewed_by_me_date,
const base::FilePath& local_file_path,
const FileResourceCallback& callback,
const ProgressCallback& progress_callback)
: UrlFetchRequestBase(sender),
- metadata_json_(CreateMultipartUploadMetadataJson(title,
- parent_resource_id,
- modified_date,
- last_viewed_by_me_date)),
+ metadata_json_(metadata_json),
content_type_(content_type),
local_path_(local_file_path),
- has_modified_date_(!modified_date.is_null()),
callback_(callback),
progress_callback_(progress_callback),
weak_ptr_factory_(this) {
diff --git a/google_apis/drive/base_requests.h b/google_apis/drive/base_requests.h
index 59e50c8..d7f46ab 100644
--- a/google_apis/drive/base_requests.h
+++ b/google_apis/drive/base_requests.h
@@ -449,17 +449,13 @@ class MultipartUploadRequestBase : public UrlFetchRequestBase {
// |content_type| and |content_length| should be the attributes of the
// uploading file. Other parameters are optional and can be empty or null
// depending on Upload URL provided by the subclasses.
- MultipartUploadRequestBase(
- RequestSender* sender,
- const std::string& title,
- const std::string& parent_resource_id,
- const std::string& content_type,
- int64 content_length,
- const base::Time& modified_date,
- const base::Time& last_viewed_by_me_date,
- const base::FilePath& local_file_path,
- const FileResourceCallback& callback,
- const google_apis::ProgressCallback& progress_callback);
+ MultipartUploadRequestBase(RequestSender* sender,
+ const std::string& metadata_json,
+ const std::string& content_type,
+ int64 content_length,
+ const base::FilePath& local_file_path,
+ const FileResourceCallback& callback,
+ const ProgressCallback& progress_callback);
~MultipartUploadRequestBase() override;
// Overridden from AuthenticatedRequestInterface.
@@ -481,9 +477,6 @@ class MultipartUploadRequestBase : public UrlFetchRequestBase {
// Parses the response value and invokes |callback_| with |FileResource|.
void OnDataParsed(DriveApiErrorCode code, scoped_ptr<base::Value> value);
- // Whether to the request has modified date information or not.
- bool has_modified_date() const { return has_modified_date_; }
-
private:
// Continues to rest part of |Start| method after determining boundary string
// of multipart/related.
@@ -497,7 +490,6 @@ class MultipartUploadRequestBase : public UrlFetchRequestBase {
const std::string metadata_json_;
const std::string content_type_;
const base::FilePath local_path_;
- const bool has_modified_date_;
const FileResourceCallback callback_;
const ProgressCallback progress_callback_;
diff --git a/google_apis/drive/base_requests_unittest.cc b/google_apis/drive/base_requests_unittest.cc
index 92ae948..2b780d1 100644
--- a/google_apis/drive/base_requests_unittest.cc
+++ b/google_apis/drive/base_requests_unittest.cc
@@ -55,12 +55,9 @@ class FakeMultipartUploadRequest : public MultipartUploadRequestBase {
public:
FakeMultipartUploadRequest(
RequestSender* sender,
- const std::string& title,
- const std::string& parent_resource_id,
+ const std::string& metadata_json,
const std::string& content_type,
int64 content_length,
- const base::Time& modified_date,
- const base::Time& last_viewed_by_me_date,
const base::FilePath& local_file_path,
const FileResourceCallback& callback,
const google_apis::ProgressCallback& progress_callback,
@@ -68,12 +65,9 @@ class FakeMultipartUploadRequest : public MultipartUploadRequestBase {
std::string* upload_content_type,
std::string* upload_content_data)
: MultipartUploadRequestBase(sender,
- title,
- parent_resource_id,
+ metadata_json,
content_type,
content_length,
- modified_date,
- last_viewed_by_me_date,
local_file_path,
callback,
progress_callback),
@@ -203,8 +197,7 @@ TEST_F(MultipartUploadRequestBaseTest, Basic) {
std::string upload_content_type;
std::string upload_content_data;
scoped_ptr<FakeMultipartUploadRequest> request(new FakeMultipartUploadRequest(
- sender_.get(), "test.txt", "parent_id", "text/plain", 10, base::Time(),
- base::Time(), source_path,
+ sender_.get(), "{json:\"test\"}", "text/plain", 10, source_path,
test_util::CreateQuitCallback(
&run_loop, test_util::CreateCopyResultCallback(&error, &file)),
ProgressCallback(), test_server_.base_url(), &upload_content_type,
@@ -217,8 +210,7 @@ TEST_F(MultipartUploadRequestBaseTest, Basic) {
"--TESTBOUNDARY\n"
"Content-Type: application/json\n"
"\n"
- "{\"parents\":[{\"id\":\"parent_id\",\"kind\":\"drive#fileLink\"}],"
- "\"title\":\"test.txt\"}\n"
+ "{json:\"test\"}\n"
"--TESTBOUNDARY\n"
"Content-Type: text/plain\n"
"\n"
diff --git a/google_apis/drive/drive_api_requests.cc b/google_apis/drive/drive_api_requests.cc
index 8e32915..a1c6d8a 100644
--- a/google_apis/drive/drive_api_requests.cc
+++ b/google_apis/drive/drive_api_requests.cc
@@ -17,16 +17,16 @@
#include "net/base/url_util.h"
namespace google_apis {
+namespace drive {
namespace {
// Parses the JSON value to FileResource instance and runs |callback| on the
// UI thread once parsing is done.
// This is customized version of ParseJsonAndRun defined above to adapt the
// remaining response type.
-void ParseFileResourceWithUploadRangeAndRun(
- const drive::UploadRangeCallback& callback,
- const UploadRangeResponse& response,
- scoped_ptr<base::Value> value) {
+void ParseFileResourceWithUploadRangeAndRun(const UploadRangeCallback& callback,
+ const UploadRangeResponse& response,
+ scoped_ptr<base::Value> value) {
DCHECK(!callback.is_null());
scoped_ptr<FileResource> file_resource;
@@ -45,9 +45,72 @@ void ParseFileResourceWithUploadRangeAndRun(
callback.Run(response, file_resource.Pass());
}
-} // namespace
+// Attaches |properties| to the |request_body| if |properties| is not empty.
+// |request_body| must not be NULL.
+void AttachProperties(const Properties& properties,
+ base::DictionaryValue* request_body) {
+ DCHECK(request_body);
+ if (properties.empty())
+ return;
+
+ base::ListValue* const properties_value = new base::ListValue;
+ for (const auto& property : properties) {
+ base::DictionaryValue* const property_value = new base::DictionaryValue;
+ std::string visibility_as_string;
+ switch (property.visibility()) {
+ case Property::VISIBILITY_PRIVATE:
+ visibility_as_string = "PRIVATE";
+ break;
+ case Property::VISIBILITY_PUBLIC:
+ visibility_as_string = "PUBLIC";
+ break;
+ }
+ property_value->SetString("visibility", visibility_as_string);
+ property_value->SetString("key", property.key());
+ property_value->SetString("value", property.value());
+ properties_value->Append(property_value);
+ }
+ request_body->Set("properties", properties_value);
+}
-namespace drive {
+// Creates metadata JSON string for multipart uploading.
+// All the values are optional. If the value is empty or null, the value does
+// not appear in the metadata.
+std::string CreateMultipartUploadMetadataJson(
+ const std::string& title,
+ const std::string& parent_resource_id,
+ const base::Time& modified_date,
+ const base::Time& last_viewed_by_me_date,
+ const Properties& properties) {
+ base::DictionaryValue root;
+ if (!title.empty())
+ root.SetString("title", title);
+
+ // Fill parent link.
+ if (!parent_resource_id.empty()) {
+ scoped_ptr<base::ListValue> parents(new base::ListValue);
+ parents->Append(
+ google_apis::util::CreateParentValue(parent_resource_id).release());
+ root.Set("parents", parents.release());
+ }
+
+ if (!modified_date.is_null()) {
+ root.SetString("modifiedDate",
+ google_apis::util::FormatTimeAsString(modified_date));
+ }
+
+ if (!last_viewed_by_me_date.is_null()) {
+ root.SetString("lastViewedByMeDate", google_apis::util::FormatTimeAsString(
+ last_viewed_by_me_date));
+ }
+
+ AttachProperties(properties, &root);
+ std::string json_string;
+ base::JSONWriter::Write(&root, &json_string);
+ return json_string;
+}
+
+} // namespace
Property::Property() : visibility_(VISIBILITY_PRIVATE) {
}
@@ -160,7 +223,9 @@ bool FilesInsertRequest::GetContentData(std::string* upload_content_type,
if (!title_.empty())
root.SetString("title", title_);
+ AttachProperties(properties_, &root);
base::JSONWriter::Write(&root, upload_content);
+
DVLOG(1) << "FilesInsert data: " << *upload_content_type << ", ["
<< *upload_content << "]";
return true;
@@ -232,28 +297,9 @@ bool FilesPatchRequest::GetContentData(std::string* upload_content_type,
root.Set("parents", parents_value);
}
- if (!properties_.empty()) {
- base::ListValue* properties_value = new base::ListValue;
- for (const auto& property : properties_) {
- base::DictionaryValue* const property_value = new base::DictionaryValue;
- std::string visibility_as_string;
- switch (property.visibility()) {
- case Property::VISIBILITY_PRIVATE:
- visibility_as_string = "PRIVATE";
- break;
- case Property::VISIBILITY_PUBLIC:
- visibility_as_string = "PUBLIC";
- break;
- }
- property_value->SetString("visibility", visibility_as_string);
- property_value->SetString("key", property.key());
- property_value->SetString("value", property.value());
- properties_value->Append(property_value);
- }
- root.Set("properties", properties_value);
- }
-
+ AttachProperties(properties_, &root);
base::JSONWriter::Write(&root, upload_content);
+
DVLOG(1) << "FilesPatch data: " << *upload_content_type << ", ["
<< *upload_content << "]";
return true;
@@ -594,6 +640,7 @@ bool InitiateUploadNewFileRequest::GetContentData(
util::FormatTimeAsString(last_viewed_by_me_date_));
}
+ AttachProperties(properties_, &root);
base::JSONWriter::Write(&root, upload_content);
DVLOG(1) << "InitiateUploadNewFile data: " << *upload_content_type << ", ["
@@ -661,6 +708,7 @@ bool InitiateUploadExistingFileRequest::GetContentData(
util::FormatTimeAsString(last_viewed_by_me_date_));
}
+ AttachProperties(properties_, &root);
if (root.empty())
return false;
@@ -744,19 +792,23 @@ MultipartUploadNewFileRequest::MultipartUploadNewFileRequest(
const base::Time& modified_date,
const base::Time& last_viewed_by_me_date,
const base::FilePath& local_file_path,
+ const Properties& properties,
const DriveApiUrlGenerator& url_generator,
const FileResourceCallback& callback,
const ProgressCallback& progress_callback)
- : MultipartUploadRequestBase(sender,
- title,
- parent_resource_id,
- content_type,
- content_length,
- modified_date,
- last_viewed_by_me_date,
- local_file_path,
- callback,
- progress_callback),
+ : MultipartUploadRequestBase(
+ sender,
+ CreateMultipartUploadMetadataJson(title,
+ parent_resource_id,
+ modified_date,
+ last_viewed_by_me_date,
+ properties),
+ content_type,
+ content_length,
+ local_file_path,
+ callback,
+ progress_callback),
+ has_modified_date_(!modified_date.is_null()),
url_generator_(url_generator) {
}
@@ -764,7 +816,7 @@ MultipartUploadNewFileRequest::~MultipartUploadNewFileRequest() {
}
GURL MultipartUploadNewFileRequest::GetURL() const {
- return url_generator_.GetMultipartUploadNewFileUrl(has_modified_date());
+ return url_generator_.GetMultipartUploadNewFileUrl(has_modified_date_);
}
net::URLFetcher::RequestType MultipartUploadNewFileRequest::GetRequestType()
@@ -785,21 +837,25 @@ MultipartUploadExistingFileRequest::MultipartUploadExistingFileRequest(
const base::Time& last_viewed_by_me_date,
const base::FilePath& local_file_path,
const std::string& etag,
+ const Properties& properties,
const DriveApiUrlGenerator& url_generator,
const FileResourceCallback& callback,
const ProgressCallback& progress_callback)
- : MultipartUploadRequestBase(sender,
- title,
- parent_resource_id,
- content_type,
- content_length,
- modified_date,
- last_viewed_by_me_date,
- local_file_path,
- callback,
- progress_callback),
+ : MultipartUploadRequestBase(
+ sender,
+ CreateMultipartUploadMetadataJson(title,
+ parent_resource_id,
+ modified_date,
+ last_viewed_by_me_date,
+ properties),
+ content_type,
+ content_length,
+ local_file_path,
+ callback,
+ progress_callback),
resource_id_(resource_id),
etag_(etag),
+ has_modified_date_(!modified_date.is_null()),
url_generator_(url_generator) {
}
@@ -815,8 +871,8 @@ MultipartUploadExistingFileRequest::GetExtraRequestHeaders() const {
}
GURL MultipartUploadExistingFileRequest::GetURL() const {
- return url_generator_.GetMultipartUploadExistingFileUrl(
- resource_id_, has_modified_date());
+ return url_generator_.GetMultipartUploadExistingFileUrl(resource_id_,
+ has_modified_date_);
}
net::URLFetcher::RequestType
diff --git a/google_apis/drive/drive_api_requests.h b/google_apis/drive/drive_api_requests.h
index 33f74a8..00f310a 100644
--- a/google_apis/drive/drive_api_requests.h
+++ b/google_apis/drive/drive_api_requests.h
@@ -269,6 +269,11 @@ class FilesInsertRequest : public DriveApiDataRequest<FileResource> {
const std::string& title() const { return title_; }
void set_title(const std::string& title) { title_ = title; }
+ const Properties& properties() const { return properties_; }
+ void set_properties(const Properties& properties) {
+ properties_ = properties;
+ }
+
protected:
// Overridden from GetDataRequest.
net::URLFetcher::RequestType GetRequestType() const override;
@@ -286,6 +291,7 @@ class FilesInsertRequest : public DriveApiDataRequest<FileResource> {
base::Time modified_date_;
std::vector<std::string> parents_;
std::string title_;
+ Properties properties_;
DISALLOW_COPY_AND_ASSIGN(FilesInsertRequest);
};
@@ -795,6 +801,10 @@ class InitiateUploadNewFileRequest : public InitiateUploadRequestBase {
void set_last_viewed_by_me_date(const base::Time& last_viewed_by_me_date) {
last_viewed_by_me_date_ = last_viewed_by_me_date;
}
+ const Properties& properties() const { return properties_; }
+ void set_properties(const Properties& properties) {
+ properties_ = properties;
+ }
protected:
// UrlFetchRequestBase overrides.
@@ -810,6 +820,7 @@ class InitiateUploadNewFileRequest : public InitiateUploadRequestBase {
base::Time modified_date_;
base::Time last_viewed_by_me_date_;
+ Properties properties_;
DISALLOW_COPY_AND_ASSIGN(InitiateUploadNewFileRequest);
};
@@ -851,6 +862,10 @@ class InitiateUploadExistingFileRequest : public InitiateUploadRequestBase {
void set_last_viewed_by_me_date(const base::Time& last_viewed_by_me_date) {
last_viewed_by_me_date_ = last_viewed_by_me_date;
}
+ const Properties& properties() const { return properties_; }
+ void set_properties(const Properties& properties) {
+ properties_ = properties;
+ }
protected:
// UrlFetchRequestBase overrides.
@@ -869,6 +884,7 @@ class InitiateUploadExistingFileRequest : public InitiateUploadRequestBase {
std::string title_;
base::Time modified_date_;
base::Time last_viewed_by_me_date_;
+ Properties properties_;
DISALLOW_COPY_AND_ASSIGN(InitiateUploadExistingFileRequest);
};
@@ -953,6 +969,7 @@ class MultipartUploadNewFileRequest : public MultipartUploadRequestBase {
const base::Time& modified_date,
const base::Time& last_viewed_by_me_date,
const base::FilePath& local_file_path,
+ const Properties& properties,
const DriveApiUrlGenerator& url_generator,
const FileResourceCallback& callback,
const ProgressCallback& progress_callback);
@@ -964,6 +981,7 @@ class MultipartUploadNewFileRequest : public MultipartUploadRequestBase {
net::URLFetcher::RequestType GetRequestType() const override;
private:
+ const bool has_modified_date_;
const DriveApiUrlGenerator url_generator_;
DISALLOW_COPY_AND_ASSIGN(MultipartUploadNewFileRequest);
@@ -988,6 +1006,7 @@ class MultipartUploadExistingFileRequest : public MultipartUploadRequestBase {
const base::Time& last_viewed_by_me_date,
const base::FilePath& local_file_path,
const std::string& etag,
+ const Properties& properties,
const DriveApiUrlGenerator& url_generator,
const FileResourceCallback& callback,
const ProgressCallback& progress_callback);
@@ -1002,6 +1021,7 @@ class MultipartUploadExistingFileRequest : public MultipartUploadRequestBase {
private:
const std::string resource_id_;
const std::string etag_;
+ const bool has_modified_date_;
const DriveApiUrlGenerator url_generator_;
DISALLOW_COPY_AND_ASSIGN(MultipartUploadExistingFileRequest);
diff --git a/google_apis/drive/drive_api_requests_unittest.cc b/google_apis/drive/drive_api_requests_unittest.cc
index deb2845..3f56e4e 100644
--- a/google_apis/drive/drive_api_requests_unittest.cc
+++ b/google_apis/drive/drive_api_requests_unittest.cc
@@ -109,6 +109,20 @@ class DriveApiRequestsTest : public testing::Test {
ResetExpectedResponse();
received_bytes_ = 0;
content_length_ = 0;
+
+ // 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_.clear();
+ testing_properties_.push_back(private_property);
+ testing_properties_.push_back(public_property);
}
base::MessageLoopForIO message_loop_; // Test server needs IO thread.
@@ -140,6 +154,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 +468,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 +479,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 +533,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 +973,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 +989,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 +1391,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 +1407,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;