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

Side by Side Diff: google_apis/drive/drive_api_requests_unittest.cc

Issue 140513008: drive: Allow setting modified/accessed date with AddNewDirectory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « google_apis/drive/drive_api_requests.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 AboutResource::CreateFrom( 411 AboutResource::CreateFrom(
412 *test_util::LoadJSONFile("drive/about.json"))); 412 *test_util::LoadJSONFile("drive/about.json")));
413 ASSERT_TRUE(about_resource.get()); 413 ASSERT_TRUE(about_resource.get());
414 EXPECT_EQ(expected->largest_change_id(), about_resource->largest_change_id()); 414 EXPECT_EQ(expected->largest_change_id(), about_resource->largest_change_id());
415 EXPECT_EQ(expected->quota_bytes_total(), about_resource->quota_bytes_total()); 415 EXPECT_EQ(expected->quota_bytes_total(), about_resource->quota_bytes_total());
416 EXPECT_EQ(expected->quota_bytes_used(), about_resource->quota_bytes_used()); 416 EXPECT_EQ(expected->quota_bytes_used(), about_resource->quota_bytes_used());
417 EXPECT_EQ(expected->root_folder_id(), about_resource->root_folder_id()); 417 EXPECT_EQ(expected->root_folder_id(), about_resource->root_folder_id());
418 } 418 }
419 419
420 TEST_F(DriveApiRequestsTest, FilesInsertRequest) { 420 TEST_F(DriveApiRequestsTest, FilesInsertRequest) {
421 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123};
422 const base::Time::Exploded kLastViewedByMeDate =
423 {2013, 7, 0, 19, 15, 59, 13, 123};
424
421 // Set an expected data file containing the directory's entry data. 425 // Set an expected data file containing the directory's entry data.
422 expected_data_file_path_ = 426 expected_data_file_path_ =
423 test_util::GetTestFilePath("drive/directory_entry.json"); 427 test_util::GetTestFilePath("drive/directory_entry.json");
424 428
425 GDataErrorCode error = GDATA_OTHER_ERROR; 429 GDataErrorCode error = GDATA_OTHER_ERROR;
426 scoped_ptr<FileResource> file_resource; 430 scoped_ptr<FileResource> file_resource;
427 431
428 // Create "new directory" in the root directory. 432 // Create "new directory" in the root directory.
429 { 433 {
430 base::RunLoop run_loop; 434 base::RunLoop run_loop;
431 drive::FilesInsertRequest* request = new drive::FilesInsertRequest( 435 drive::FilesInsertRequest* request = new drive::FilesInsertRequest(
432 request_sender_.get(), 436 request_sender_.get(),
433 *url_generator_, 437 *url_generator_,
434 test_util::CreateQuitCallback( 438 test_util::CreateQuitCallback(
435 &run_loop, 439 &run_loop,
436 test_util::CreateCopyResultCallback(&error, &file_resource))); 440 test_util::CreateCopyResultCallback(&error, &file_resource)));
441 request->set_last_viewed_by_me_date(
442 base::Time::FromUTCExploded(kLastViewedByMeDate));
437 request->set_mime_type("application/vnd.google-apps.folder"); 443 request->set_mime_type("application/vnd.google-apps.folder");
444 request->set_modified_date(base::Time::FromUTCExploded(kModifiedDate));
438 request->add_parent("root"); 445 request->add_parent("root");
439 request->set_title("new directory"); 446 request->set_title("new directory");
440 request_sender_->StartRequestWithRetry(request); 447 request_sender_->StartRequestWithRetry(request);
441 run_loop.Run(); 448 run_loop.Run();
442 } 449 }
443 450
444 EXPECT_EQ(HTTP_SUCCESS, error); 451 EXPECT_EQ(HTTP_SUCCESS, error);
445 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); 452 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method);
446 EXPECT_EQ("/drive/v2/files", http_request_.relative_url); 453 EXPECT_EQ("/drive/v2/files", http_request_.relative_url);
447 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); 454 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]);
448 455
449 EXPECT_TRUE(http_request_.has_content); 456 EXPECT_TRUE(http_request_.has_content);
457 EXPECT_EQ("{\"lastViewedByMeDate\":\"2013-07-19T15:59:13.123Z\","
458 "\"mimeType\":\"application/vnd.google-apps.folder\","
459 "\"modifiedDate\":\"2012-07-19T15:59:13.123Z\","
460 "\"parents\":[{\"id\":\"root\"}],"
461 "\"title\":\"new directory\"}",
462 http_request_.content);
450 463
451 scoped_ptr<FileResource> expected( 464 scoped_ptr<FileResource> expected(
452 FileResource::CreateFrom( 465 FileResource::CreateFrom(
453 *test_util::LoadJSONFile("drive/directory_entry.json"))); 466 *test_util::LoadJSONFile("drive/directory_entry.json")));
454 467
455 // Sanity check. 468 // Sanity check.
456 ASSERT_TRUE(file_resource.get()); 469 ASSERT_TRUE(file_resource.get());
457 470
458 EXPECT_EQ(expected->file_id(), file_resource->file_id()); 471 EXPECT_EQ(expected->file_id(), file_resource->file_id());
459 EXPECT_EQ(expected->title(), file_resource->title()); 472 EXPECT_EQ(expected->title(), file_resource->title());
(...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1751 EXPECT_EQ(HTTP_SUCCESS, result_code); 1764 EXPECT_EQ(HTTP_SUCCESS, result_code);
1752 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); 1765 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method);
1753 EXPECT_EQ(kTestDownloadPathPrefix + kTestId, http_request_.relative_url); 1766 EXPECT_EQ(kTestDownloadPathPrefix + kTestId, http_request_.relative_url);
1754 EXPECT_EQ(kDownloadedFilePath, temp_file); 1767 EXPECT_EQ(kDownloadedFilePath, temp_file);
1755 1768
1756 const std::string expected_contents = kTestId + kTestId + kTestId; 1769 const std::string expected_contents = kTestId + kTestId + kTestId;
1757 EXPECT_EQ(expected_contents, contents); 1770 EXPECT_EQ(expected_contents, contents);
1758 } 1771 }
1759 1772
1760 } // namespace google_apis 1773 } // namespace google_apis
OLDNEW
« no previous file with comments | « google_apis/drive/drive_api_requests.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698