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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 scoped_ptr<AboutResource> about_resource; | 452 scoped_ptr<AboutResource> about_resource; |
453 | 453 |
454 { | 454 { |
455 base::RunLoop run_loop; | 455 base::RunLoop run_loop; |
456 drive::AboutGetRequest* request = new drive::AboutGetRequest( | 456 drive::AboutGetRequest* request = new drive::AboutGetRequest( |
457 request_sender_.get(), | 457 request_sender_.get(), |
458 *url_generator_, | 458 *url_generator_, |
459 test_util::CreateQuitCallback( | 459 test_util::CreateQuitCallback( |
460 &run_loop, | 460 &run_loop, |
461 test_util::CreateCopyResultCallback(&error, &about_resource))); | 461 test_util::CreateCopyResultCallback(&error, &about_resource))); |
462 request->set_fields( | 462 request->set_fields("kind,quotaBytesTotal,quotaBytesUsedAggregate," |
463 "kind,quotaBytesTotal,quotaBytesUsed,largestChangeId,rootFolderId"); | 463 "largestChangeId,rootFolderId"); |
464 request_sender_->StartRequestWithRetry(request); | 464 request_sender_->StartRequestWithRetry(request); |
465 run_loop.Run(); | 465 run_loop.Run(); |
466 } | 466 } |
467 | 467 |
468 EXPECT_EQ(HTTP_SUCCESS, error); | 468 EXPECT_EQ(HTTP_SUCCESS, error); |
469 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 469 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
470 EXPECT_EQ("/drive/v2/about?" | 470 EXPECT_EQ("/drive/v2/about?" |
471 "fields=kind%2CquotaBytesTotal%2CquotaBytesUsed%2C" | 471 "fields=kind%2CquotaBytesTotal%2CquotaBytesUsedAggregate%2C" |
472 "largestChangeId%2CrootFolderId", | 472 "largestChangeId%2CrootFolderId", |
473 http_request_.relative_url); | 473 http_request_.relative_url); |
474 | 474 |
475 scoped_ptr<AboutResource> expected( | 475 scoped_ptr<AboutResource> expected( |
476 AboutResource::CreateFrom( | 476 AboutResource::CreateFrom( |
477 *test_util::LoadJSONFile("drive/about.json"))); | 477 *test_util::LoadJSONFile("drive/about.json"))); |
478 ASSERT_TRUE(about_resource.get()); | 478 ASSERT_TRUE(about_resource.get()); |
479 EXPECT_EQ(expected->largest_change_id(), about_resource->largest_change_id()); | 479 EXPECT_EQ(expected->largest_change_id(), about_resource->largest_change_id()); |
480 EXPECT_EQ(expected->quota_bytes_total(), about_resource->quota_bytes_total()); | 480 EXPECT_EQ(expected->quota_bytes_total(), about_resource->quota_bytes_total()); |
481 EXPECT_EQ(expected->quota_bytes_used(), about_resource->quota_bytes_used()); | 481 EXPECT_EQ(expected->quota_bytes_used_aggregate(), |
| 482 about_resource->quota_bytes_used_aggregate()); |
482 EXPECT_EQ(expected->root_folder_id(), about_resource->root_folder_id()); | 483 EXPECT_EQ(expected->root_folder_id(), about_resource->root_folder_id()); |
483 } | 484 } |
484 | 485 |
485 TEST_F(DriveApiRequestsTest, FilesInsertRequest) { | 486 TEST_F(DriveApiRequestsTest, FilesInsertRequest) { |
486 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; | 487 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; |
487 const base::Time::Exploded kLastViewedByMeDate = | 488 const base::Time::Exploded kLastViewedByMeDate = |
488 {2013, 7, 0, 19, 15, 59, 13, 123}; | 489 {2013, 7, 0, 19, 15, 59, 13, 123}; |
489 | 490 |
490 // Set an expected data file containing the directory's entry data. | 491 // Set an expected data file containing the directory's entry data. |
491 expected_data_file_path_ = | 492 expected_data_file_path_ = |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 EXPECT_EQ(HTTP_SUCCESS, error); | 623 EXPECT_EQ(HTTP_SUCCESS, error); |
623 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 624 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
624 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); | 625 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); |
625 | 626 |
626 scoped_ptr<AboutResource> expected( | 627 scoped_ptr<AboutResource> expected( |
627 AboutResource::CreateFrom( | 628 AboutResource::CreateFrom( |
628 *test_util::LoadJSONFile("drive/about.json"))); | 629 *test_util::LoadJSONFile("drive/about.json"))); |
629 ASSERT_TRUE(about_resource.get()); | 630 ASSERT_TRUE(about_resource.get()); |
630 EXPECT_EQ(expected->largest_change_id(), about_resource->largest_change_id()); | 631 EXPECT_EQ(expected->largest_change_id(), about_resource->largest_change_id()); |
631 EXPECT_EQ(expected->quota_bytes_total(), about_resource->quota_bytes_total()); | 632 EXPECT_EQ(expected->quota_bytes_total(), about_resource->quota_bytes_total()); |
632 EXPECT_EQ(expected->quota_bytes_used(), about_resource->quota_bytes_used()); | 633 EXPECT_EQ(expected->quota_bytes_used_aggregate(), |
| 634 about_resource->quota_bytes_used_aggregate()); |
633 EXPECT_EQ(expected->root_folder_id(), about_resource->root_folder_id()); | 635 EXPECT_EQ(expected->root_folder_id(), about_resource->root_folder_id()); |
634 } | 636 } |
635 | 637 |
636 TEST_F(DriveApiRequestsTest, AboutGetRequest_InvalidJson) { | 638 TEST_F(DriveApiRequestsTest, AboutGetRequest_InvalidJson) { |
637 // Set an expected data file containing invalid result. | 639 // Set an expected data file containing invalid result. |
638 expected_data_file_path_ = test_util::GetTestFilePath( | 640 expected_data_file_path_ = test_util::GetTestFilePath( |
639 "drive/testfile.txt"); | 641 "drive/testfile.txt"); |
640 | 642 |
641 DriveApiErrorCode error = DRIVE_OTHER_ERROR; | 643 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
642 scoped_ptr<AboutResource> about_resource; | 644 scoped_ptr<AboutResource> about_resource; |
(...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2121 "Header: value\r\n" | 2123 "Header: value\r\n" |
2122 "\r\n" | 2124 "\r\n" |
2123 "BODY\r\n" | 2125 "BODY\r\n" |
2124 "--BOUNDARY-- \t", | 2126 "--BOUNDARY-- \t", |
2125 &parts)); | 2127 &parts)); |
2126 ASSERT_EQ(1u, parts.size()); | 2128 ASSERT_EQ(1u, parts.size()); |
2127 EXPECT_EQ(HTTP_SUCCESS, parts[0].code); | 2129 EXPECT_EQ(HTTP_SUCCESS, parts[0].code); |
2128 EXPECT_EQ("BODY", parts[0].body); | 2130 EXPECT_EQ("BODY", parts[0].body); |
2129 } | 2131 } |
2130 } // namespace google_apis | 2132 } // namespace google_apis |
OLD | NEW |