Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Unified Diff: chrome/browser/google_apis/drive_api_requests_unittest.cc

Issue 23042004: Implement MoveResourceRequest on Drive API v2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/google_apis/drive_api_requests.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/google_apis/drive_api_requests_unittest.cc
diff --git a/chrome/browser/google_apis/drive_api_requests_unittest.cc b/chrome/browser/google_apis/drive_api_requests_unittest.cc
index bdba3d83d92daa227eefe78c61e1e4bd53fa3478..ea71b789fcc456450333223acd460bb8b840319c 100644
--- a/chrome/browser/google_apis/drive_api_requests_unittest.cc
+++ b/chrome/browser/google_apis/drive_api_requests_unittest.cc
@@ -562,39 +562,6 @@ TEST_F(DriveApiRequestsTest, CreateDirectoryRequest) {
EXPECT_EQ(expected->parents().size(), file_resource->parents().size());
}
-TEST_F(DriveApiRequestsTest, RenameResourceRequest) {
- // Set an expected data file containing the directory's entry data.
- // It'd be returned if we rename a directory.
- expected_data_file_path_ =
- test_util::GetTestFilePath("drive/directory_entry.json");
-
- GDataErrorCode error = GDATA_OTHER_ERROR;
-
- // Create "new directory" in the root directory.
- {
- base::RunLoop run_loop;
- drive::RenameResourceRequest* request =
- new drive::RenameResourceRequest(
- request_sender_.get(),
- *url_generator_,
- "resource_id",
- "new title",
- test_util::CreateQuitCallback(
- &run_loop,
- test_util::CreateCopyResultCallback(&error)));
- request_sender_->StartRequestWithRetry(request);
- run_loop.Run();
- }
-
- EXPECT_EQ(HTTP_SUCCESS, error);
- EXPECT_EQ(net::test_server::METHOD_PATCH, http_request_.method);
- EXPECT_EQ("/drive/v2/files/resource_id", http_request_.relative_url);
- EXPECT_EQ("application/json", http_request_.headers["Content-Type"]);
-
- EXPECT_TRUE(http_request_.has_content);
- EXPECT_EQ("{\"title\":\"new title\"}", http_request_.content);
-}
-
TEST_F(DriveApiRequestsTest, TouchResourceRequest) {
// Set an expected data file containing the directory's entry data.
// It'd be returned if we rename a directory.
@@ -710,6 +677,81 @@ TEST_F(DriveApiRequestsTest, CopyResourceRequest_EmptyParentResourceId) {
EXPECT_TRUE(file_resource);
}
+TEST_F(DriveApiRequestsTest, MoveResourceRequest) {
+ // Set an expected data file containing the dummy file entry data.
+ // It'd be returned if we move a file.
+ expected_data_file_path_ =
+ test_util::GetTestFilePath("drive/file_entry.json");
+
+ GDataErrorCode error = GDATA_OTHER_ERROR;
+ scoped_ptr<FileResource> file_resource;
+
+ // Move the file to the directory |parent_resource_id| with new name
+ // "new title".
+ {
+ base::RunLoop run_loop;
+ drive::MoveResourceRequest* request =
+ new drive::MoveResourceRequest(
+ request_sender_.get(),
+ *url_generator_,
+ "resource_id",
+ "parent_resource_id",
+ "new title",
+ test_util::CreateQuitCallback(
+ &run_loop,
+ test_util::CreateCopyResultCallback(&error, &file_resource)));
+ request_sender_->StartRequestWithRetry(request);
+ run_loop.Run();
+ }
+
+ EXPECT_EQ(HTTP_SUCCESS, error);
+ EXPECT_EQ(net::test_server::METHOD_PATCH, http_request_.method);
+ EXPECT_EQ("/drive/v2/files/resource_id", 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\"}],\"title\":\"new title\"}",
+ http_request_.content);
+ EXPECT_TRUE(file_resource);
+}
+
+TEST_F(DriveApiRequestsTest, MoveResourceRequest_EmptyParentResourceId) {
+ // Set an expected data file containing the directory's entry data.
+ // It'd be returned if we rename a directory.
+ expected_data_file_path_ =
+ test_util::GetTestFilePath("drive/file_entry.json");
+
+ GDataErrorCode error = GDATA_OTHER_ERROR;
+ scoped_ptr<FileResource> file_resource;
+
+ // Rename the file to "new title," but keep the parent directory as is.
+ {
+ base::RunLoop run_loop;
+ drive::MoveResourceRequest* request =
+ new drive::MoveResourceRequest(
+ request_sender_.get(),
+ *url_generator_,
+ "resource_id",
+ std::string(),
+ "new title",
+ test_util::CreateQuitCallback(
+ &run_loop,
+ test_util::CreateCopyResultCallback(&error, &file_resource)));
+ request_sender_->StartRequestWithRetry(request);
+ run_loop.Run();
+ }
+
+ EXPECT_EQ(HTTP_SUCCESS, error);
+ EXPECT_EQ(net::test_server::METHOD_PATCH, http_request_.method);
+ EXPECT_EQ("/drive/v2/files/resource_id", http_request_.relative_url);
+ EXPECT_EQ("application/json", http_request_.headers["Content-Type"]);
+
+ EXPECT_TRUE(http_request_.has_content);
+ EXPECT_EQ("{\"title\":\"new title\"}", http_request_.content);
+ EXPECT_TRUE(file_resource);
+}
+
TEST_F(DriveApiRequestsTest, TrashResourceRequest) {
// Set data for the expected result. Directory entry should be returned
// if the trashing entry is a directory, so using it here should be fine.
« no previous file with comments | « chrome/browser/google_apis/drive_api_requests.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698