| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 "\"id\": \"resource_id\",\n" | 44 "\"id\": \"resource_id\",\n" |
| 45 "\"selfLink\": \"self_link\",\n" | 45 "\"selfLink\": \"self_link\",\n" |
| 46 "}\n"; | 46 "}\n"; |
| 47 | 47 |
| 48 const char kTestUploadExistingFilePath[] = "/upload/existingfile/path"; | 48 const char kTestUploadExistingFilePath[] = "/upload/existingfile/path"; |
| 49 const char kTestUploadNewFilePath[] = "/upload/newfile/path"; | 49 const char kTestUploadNewFilePath[] = "/upload/newfile/path"; |
| 50 const char kTestDownloadPathPrefix[] = "/download/"; | 50 const char kTestDownloadPathPrefix[] = "/download/"; |
| 51 | 51 |
| 52 // Used as a GetContentCallback. | 52 // Used as a GetContentCallback. |
| 53 void AppendContent(std::string* out, | 53 void AppendContent(std::string* out, |
| 54 GDataErrorCode error, | 54 DriveApiErrorCode error, |
| 55 scoped_ptr<std::string> content) { | 55 scoped_ptr<std::string> content) { |
| 56 EXPECT_EQ(HTTP_SUCCESS, error); | 56 EXPECT_EQ(HTTP_SUCCESS, error); |
| 57 out->append(*content); | 57 out->append(*content); |
| 58 } | 58 } |
| 59 | 59 |
| 60 } // namespace | 60 } // namespace |
| 61 | 61 |
| 62 class DriveApiRequestsTest : public testing::Test { | 62 class DriveApiRequestsTest : public testing::Test { |
| 63 public: | 63 public: |
| 64 DriveApiRequestsTest() { | 64 DriveApiRequestsTest() { |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 }; | 383 }; |
| 384 | 384 |
| 385 TEST_F(DriveApiRequestsTest, DriveApiDataRequest_Fields) { | 385 TEST_F(DriveApiRequestsTest, DriveApiDataRequest_Fields) { |
| 386 // Make sure that "fields" query param is supported by using its subclass, | 386 // Make sure that "fields" query param is supported by using its subclass, |
| 387 // AboutGetRequest. | 387 // AboutGetRequest. |
| 388 | 388 |
| 389 // Set an expected data file containing valid result. | 389 // Set an expected data file containing valid result. |
| 390 expected_data_file_path_ = test_util::GetTestFilePath( | 390 expected_data_file_path_ = test_util::GetTestFilePath( |
| 391 "drive/about.json"); | 391 "drive/about.json"); |
| 392 | 392 |
| 393 GDataErrorCode error = GDATA_OTHER_ERROR; | 393 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 394 scoped_ptr<AboutResource> about_resource; | 394 scoped_ptr<AboutResource> about_resource; |
| 395 | 395 |
| 396 { | 396 { |
| 397 base::RunLoop run_loop; | 397 base::RunLoop run_loop; |
| 398 drive::AboutGetRequest* request = new drive::AboutGetRequest( | 398 drive::AboutGetRequest* request = new drive::AboutGetRequest( |
| 399 request_sender_.get(), | 399 request_sender_.get(), |
| 400 *url_generator_, | 400 *url_generator_, |
| 401 test_util::CreateQuitCallback( | 401 test_util::CreateQuitCallback( |
| 402 &run_loop, | 402 &run_loop, |
| 403 test_util::CreateCopyResultCallback(&error, &about_resource))); | 403 test_util::CreateCopyResultCallback(&error, &about_resource))); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 426 | 426 |
| 427 TEST_F(DriveApiRequestsTest, FilesInsertRequest) { | 427 TEST_F(DriveApiRequestsTest, FilesInsertRequest) { |
| 428 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; | 428 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; |
| 429 const base::Time::Exploded kLastViewedByMeDate = | 429 const base::Time::Exploded kLastViewedByMeDate = |
| 430 {2013, 7, 0, 19, 15, 59, 13, 123}; | 430 {2013, 7, 0, 19, 15, 59, 13, 123}; |
| 431 | 431 |
| 432 // Set an expected data file containing the directory's entry data. | 432 // Set an expected data file containing the directory's entry data. |
| 433 expected_data_file_path_ = | 433 expected_data_file_path_ = |
| 434 test_util::GetTestFilePath("drive/directory_entry.json"); | 434 test_util::GetTestFilePath("drive/directory_entry.json"); |
| 435 | 435 |
| 436 GDataErrorCode error = GDATA_OTHER_ERROR; | 436 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 437 scoped_ptr<FileResource> file_resource; | 437 scoped_ptr<FileResource> file_resource; |
| 438 | 438 |
| 439 // Create "new directory" in the root directory. | 439 // Create "new directory" in the root directory. |
| 440 { | 440 { |
| 441 base::RunLoop run_loop; | 441 base::RunLoop run_loop; |
| 442 drive::FilesInsertRequest* request = new drive::FilesInsertRequest( | 442 drive::FilesInsertRequest* request = new drive::FilesInsertRequest( |
| 443 request_sender_.get(), | 443 request_sender_.get(), |
| 444 *url_generator_, | 444 *url_generator_, |
| 445 test_util::CreateQuitCallback( | 445 test_util::CreateQuitCallback( |
| 446 &run_loop, | 446 &run_loop, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 | 483 |
| 484 TEST_F(DriveApiRequestsTest, FilesPatchRequest) { | 484 TEST_F(DriveApiRequestsTest, FilesPatchRequest) { |
| 485 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; | 485 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; |
| 486 const base::Time::Exploded kLastViewedByMeDate = | 486 const base::Time::Exploded kLastViewedByMeDate = |
| 487 {2013, 7, 0, 19, 15, 59, 13, 123}; | 487 {2013, 7, 0, 19, 15, 59, 13, 123}; |
| 488 | 488 |
| 489 // Set an expected data file containing valid result. | 489 // Set an expected data file containing valid result. |
| 490 expected_data_file_path_ = | 490 expected_data_file_path_ = |
| 491 test_util::GetTestFilePath("drive/file_entry.json"); | 491 test_util::GetTestFilePath("drive/file_entry.json"); |
| 492 | 492 |
| 493 GDataErrorCode error = GDATA_OTHER_ERROR; | 493 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 494 scoped_ptr<FileResource> file_resource; | 494 scoped_ptr<FileResource> file_resource; |
| 495 | 495 |
| 496 { | 496 { |
| 497 base::RunLoop run_loop; | 497 base::RunLoop run_loop; |
| 498 drive::FilesPatchRequest* request = new drive::FilesPatchRequest( | 498 drive::FilesPatchRequest* request = new drive::FilesPatchRequest( |
| 499 request_sender_.get(), | 499 request_sender_.get(), |
| 500 *url_generator_, | 500 *url_generator_, |
| 501 test_util::CreateQuitCallback( | 501 test_util::CreateQuitCallback( |
| 502 &run_loop, | 502 &run_loop, |
| 503 test_util::CreateCopyResultCallback(&error, &file_resource))); | 503 test_util::CreateCopyResultCallback(&error, &file_resource))); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 529 "\"title\":\"new title\"}", | 529 "\"title\":\"new title\"}", |
| 530 http_request_.content); | 530 http_request_.content); |
| 531 EXPECT_TRUE(file_resource); | 531 EXPECT_TRUE(file_resource); |
| 532 } | 532 } |
| 533 | 533 |
| 534 TEST_F(DriveApiRequestsTest, AboutGetRequest_ValidJson) { | 534 TEST_F(DriveApiRequestsTest, AboutGetRequest_ValidJson) { |
| 535 // Set an expected data file containing valid result. | 535 // Set an expected data file containing valid result. |
| 536 expected_data_file_path_ = test_util::GetTestFilePath( | 536 expected_data_file_path_ = test_util::GetTestFilePath( |
| 537 "drive/about.json"); | 537 "drive/about.json"); |
| 538 | 538 |
| 539 GDataErrorCode error = GDATA_OTHER_ERROR; | 539 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 540 scoped_ptr<AboutResource> about_resource; | 540 scoped_ptr<AboutResource> about_resource; |
| 541 | 541 |
| 542 { | 542 { |
| 543 base::RunLoop run_loop; | 543 base::RunLoop run_loop; |
| 544 drive::AboutGetRequest* request = new drive::AboutGetRequest( | 544 drive::AboutGetRequest* request = new drive::AboutGetRequest( |
| 545 request_sender_.get(), | 545 request_sender_.get(), |
| 546 *url_generator_, | 546 *url_generator_, |
| 547 test_util::CreateQuitCallback( | 547 test_util::CreateQuitCallback( |
| 548 &run_loop, | 548 &run_loop, |
| 549 test_util::CreateCopyResultCallback(&error, &about_resource))); | 549 test_util::CreateCopyResultCallback(&error, &about_resource))); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 563 EXPECT_EQ(expected->quota_bytes_total(), about_resource->quota_bytes_total()); | 563 EXPECT_EQ(expected->quota_bytes_total(), about_resource->quota_bytes_total()); |
| 564 EXPECT_EQ(expected->quota_bytes_used(), about_resource->quota_bytes_used()); | 564 EXPECT_EQ(expected->quota_bytes_used(), about_resource->quota_bytes_used()); |
| 565 EXPECT_EQ(expected->root_folder_id(), about_resource->root_folder_id()); | 565 EXPECT_EQ(expected->root_folder_id(), about_resource->root_folder_id()); |
| 566 } | 566 } |
| 567 | 567 |
| 568 TEST_F(DriveApiRequestsTest, AboutGetRequest_InvalidJson) { | 568 TEST_F(DriveApiRequestsTest, AboutGetRequest_InvalidJson) { |
| 569 // Set an expected data file containing invalid result. | 569 // Set an expected data file containing invalid result. |
| 570 expected_data_file_path_ = test_util::GetTestFilePath( | 570 expected_data_file_path_ = test_util::GetTestFilePath( |
| 571 "drive/testfile.txt"); | 571 "drive/testfile.txt"); |
| 572 | 572 |
| 573 GDataErrorCode error = GDATA_OTHER_ERROR; | 573 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 574 scoped_ptr<AboutResource> about_resource; | 574 scoped_ptr<AboutResource> about_resource; |
| 575 | 575 |
| 576 { | 576 { |
| 577 base::RunLoop run_loop; | 577 base::RunLoop run_loop; |
| 578 drive::AboutGetRequest* request = new drive::AboutGetRequest( | 578 drive::AboutGetRequest* request = new drive::AboutGetRequest( |
| 579 request_sender_.get(), | 579 request_sender_.get(), |
| 580 *url_generator_, | 580 *url_generator_, |
| 581 test_util::CreateQuitCallback( | 581 test_util::CreateQuitCallback( |
| 582 &run_loop, | 582 &run_loop, |
| 583 test_util::CreateCopyResultCallback(&error, &about_resource))); | 583 test_util::CreateCopyResultCallback(&error, &about_resource))); |
| 584 request_sender_->StartRequestWithRetry(request); | 584 request_sender_->StartRequestWithRetry(request); |
| 585 run_loop.Run(); | 585 run_loop.Run(); |
| 586 } | 586 } |
| 587 | 587 |
| 588 // "parse error" should be returned, and the about resource should be NULL. | 588 // "parse error" should be returned, and the about resource should be NULL. |
| 589 EXPECT_EQ(GDATA_PARSE_ERROR, error); | 589 EXPECT_EQ(DRIVE_PARSE_ERROR, error); |
| 590 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 590 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 591 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); | 591 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); |
| 592 EXPECT_FALSE(about_resource); | 592 EXPECT_FALSE(about_resource); |
| 593 } | 593 } |
| 594 | 594 |
| 595 TEST_F(DriveApiRequestsTest, AppsListRequest) { | 595 TEST_F(DriveApiRequestsTest, AppsListRequest) { |
| 596 // Set an expected data file containing valid result. | 596 // Set an expected data file containing valid result. |
| 597 expected_data_file_path_ = test_util::GetTestFilePath( | 597 expected_data_file_path_ = test_util::GetTestFilePath( |
| 598 "drive/applist.json"); | 598 "drive/applist.json"); |
| 599 | 599 |
| 600 GDataErrorCode error = GDATA_OTHER_ERROR; | 600 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 601 scoped_ptr<AppList> app_list; | 601 scoped_ptr<AppList> app_list; |
| 602 | 602 |
| 603 { | 603 { |
| 604 base::RunLoop run_loop; | 604 base::RunLoop run_loop; |
| 605 drive::AppsListRequest* request = new drive::AppsListRequest( | 605 drive::AppsListRequest* request = new drive::AppsListRequest( |
| 606 request_sender_.get(), | 606 request_sender_.get(), |
| 607 *url_generator_, | 607 *url_generator_, |
| 608 false, // use_internal_endpoint | 608 false, // use_internal_endpoint |
| 609 test_util::CreateQuitCallback( | 609 test_util::CreateQuitCallback( |
| 610 &run_loop, | 610 &run_loop, |
| 611 test_util::CreateCopyResultCallback(&error, &app_list))); | 611 test_util::CreateCopyResultCallback(&error, &app_list))); |
| 612 request_sender_->StartRequestWithRetry(request); | 612 request_sender_->StartRequestWithRetry(request); |
| 613 run_loop.Run(); | 613 run_loop.Run(); |
| 614 } | 614 } |
| 615 | 615 |
| 616 EXPECT_EQ(HTTP_SUCCESS, error); | 616 EXPECT_EQ(HTTP_SUCCESS, error); |
| 617 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 617 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 618 EXPECT_EQ("/drive/v2/apps", http_request_.relative_url); | 618 EXPECT_EQ("/drive/v2/apps", http_request_.relative_url); |
| 619 EXPECT_TRUE(app_list); | 619 EXPECT_TRUE(app_list); |
| 620 } | 620 } |
| 621 | 621 |
| 622 TEST_F(DriveApiRequestsTest, ChangesListRequest) { | 622 TEST_F(DriveApiRequestsTest, ChangesListRequest) { |
| 623 // Set an expected data file containing valid result. | 623 // Set an expected data file containing valid result. |
| 624 expected_data_file_path_ = test_util::GetTestFilePath( | 624 expected_data_file_path_ = test_util::GetTestFilePath( |
| 625 "drive/changelist.json"); | 625 "drive/changelist.json"); |
| 626 | 626 |
| 627 GDataErrorCode error = GDATA_OTHER_ERROR; | 627 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 628 scoped_ptr<ChangeList> result; | 628 scoped_ptr<ChangeList> result; |
| 629 | 629 |
| 630 { | 630 { |
| 631 base::RunLoop run_loop; | 631 base::RunLoop run_loop; |
| 632 drive::ChangesListRequest* request = new drive::ChangesListRequest( | 632 drive::ChangesListRequest* request = new drive::ChangesListRequest( |
| 633 request_sender_.get(), *url_generator_, | 633 request_sender_.get(), *url_generator_, |
| 634 test_util::CreateQuitCallback( | 634 test_util::CreateQuitCallback( |
| 635 &run_loop, | 635 &run_loop, |
| 636 test_util::CreateCopyResultCallback(&error, &result))); | 636 test_util::CreateCopyResultCallback(&error, &result))); |
| 637 request->set_include_deleted(true); | 637 request->set_include_deleted(true); |
| 638 request->set_start_change_id(100); | 638 request->set_start_change_id(100); |
| 639 request->set_max_results(500); | 639 request->set_max_results(500); |
| 640 request_sender_->StartRequestWithRetry(request); | 640 request_sender_->StartRequestWithRetry(request); |
| 641 run_loop.Run(); | 641 run_loop.Run(); |
| 642 } | 642 } |
| 643 | 643 |
| 644 EXPECT_EQ(HTTP_SUCCESS, error); | 644 EXPECT_EQ(HTTP_SUCCESS, error); |
| 645 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 645 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 646 EXPECT_EQ("/drive/v2/changes?maxResults=500&startChangeId=100", | 646 EXPECT_EQ("/drive/v2/changes?maxResults=500&startChangeId=100", |
| 647 http_request_.relative_url); | 647 http_request_.relative_url); |
| 648 EXPECT_TRUE(result); | 648 EXPECT_TRUE(result); |
| 649 } | 649 } |
| 650 | 650 |
| 651 TEST_F(DriveApiRequestsTest, ChangesListNextPageRequest) { | 651 TEST_F(DriveApiRequestsTest, ChangesListNextPageRequest) { |
| 652 // Set an expected data file containing valid result. | 652 // Set an expected data file containing valid result. |
| 653 expected_data_file_path_ = test_util::GetTestFilePath( | 653 expected_data_file_path_ = test_util::GetTestFilePath( |
| 654 "drive/changelist.json"); | 654 "drive/changelist.json"); |
| 655 | 655 |
| 656 GDataErrorCode error = GDATA_OTHER_ERROR; | 656 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 657 scoped_ptr<ChangeList> result; | 657 scoped_ptr<ChangeList> result; |
| 658 | 658 |
| 659 { | 659 { |
| 660 base::RunLoop run_loop; | 660 base::RunLoop run_loop; |
| 661 drive::ChangesListNextPageRequest* request = | 661 drive::ChangesListNextPageRequest* request = |
| 662 new drive::ChangesListNextPageRequest( | 662 new drive::ChangesListNextPageRequest( |
| 663 request_sender_.get(), | 663 request_sender_.get(), |
| 664 test_util::CreateQuitCallback( | 664 test_util::CreateQuitCallback( |
| 665 &run_loop, | 665 &run_loop, |
| 666 test_util::CreateCopyResultCallback(&error, &result))); | 666 test_util::CreateCopyResultCallback(&error, &result))); |
| 667 request->set_next_link(test_server_.GetURL("/continue/get/change/list")); | 667 request->set_next_link(test_server_.GetURL("/continue/get/change/list")); |
| 668 request_sender_->StartRequestWithRetry(request); | 668 request_sender_->StartRequestWithRetry(request); |
| 669 run_loop.Run(); | 669 run_loop.Run(); |
| 670 } | 670 } |
| 671 | 671 |
| 672 EXPECT_EQ(HTTP_SUCCESS, error); | 672 EXPECT_EQ(HTTP_SUCCESS, error); |
| 673 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 673 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 674 EXPECT_EQ("/continue/get/change/list", http_request_.relative_url); | 674 EXPECT_EQ("/continue/get/change/list", http_request_.relative_url); |
| 675 EXPECT_TRUE(result); | 675 EXPECT_TRUE(result); |
| 676 } | 676 } |
| 677 | 677 |
| 678 TEST_F(DriveApiRequestsTest, FilesCopyRequest) { | 678 TEST_F(DriveApiRequestsTest, FilesCopyRequest) { |
| 679 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; | 679 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; |
| 680 | 680 |
| 681 // Set an expected data file containing the dummy file entry data. | 681 // Set an expected data file containing the dummy file entry data. |
| 682 // It'd be returned if we copy a file. | 682 // It'd be returned if we copy a file. |
| 683 expected_data_file_path_ = | 683 expected_data_file_path_ = |
| 684 test_util::GetTestFilePath("drive/file_entry.json"); | 684 test_util::GetTestFilePath("drive/file_entry.json"); |
| 685 | 685 |
| 686 GDataErrorCode error = GDATA_OTHER_ERROR; | 686 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 687 scoped_ptr<FileResource> file_resource; | 687 scoped_ptr<FileResource> file_resource; |
| 688 | 688 |
| 689 // Copy the file to a new file named "new title". | 689 // Copy the file to a new file named "new title". |
| 690 { | 690 { |
| 691 base::RunLoop run_loop; | 691 base::RunLoop run_loop; |
| 692 drive::FilesCopyRequest* request = new drive::FilesCopyRequest( | 692 drive::FilesCopyRequest* request = new drive::FilesCopyRequest( |
| 693 request_sender_.get(), | 693 request_sender_.get(), |
| 694 *url_generator_, | 694 *url_generator_, |
| 695 test_util::CreateQuitCallback( | 695 test_util::CreateQuitCallback( |
| 696 &run_loop, | 696 &run_loop, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 715 http_request_.content); | 715 http_request_.content); |
| 716 EXPECT_TRUE(file_resource); | 716 EXPECT_TRUE(file_resource); |
| 717 } | 717 } |
| 718 | 718 |
| 719 TEST_F(DriveApiRequestsTest, FilesCopyRequest_EmptyParentResourceId) { | 719 TEST_F(DriveApiRequestsTest, FilesCopyRequest_EmptyParentResourceId) { |
| 720 // Set an expected data file containing the dummy file entry data. | 720 // Set an expected data file containing the dummy file entry data. |
| 721 // It'd be returned if we copy a file. | 721 // It'd be returned if we copy a file. |
| 722 expected_data_file_path_ = | 722 expected_data_file_path_ = |
| 723 test_util::GetTestFilePath("drive/file_entry.json"); | 723 test_util::GetTestFilePath("drive/file_entry.json"); |
| 724 | 724 |
| 725 GDataErrorCode error = GDATA_OTHER_ERROR; | 725 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 726 scoped_ptr<FileResource> file_resource; | 726 scoped_ptr<FileResource> file_resource; |
| 727 | 727 |
| 728 // Copy the file to a new file named "new title". | 728 // Copy the file to a new file named "new title". |
| 729 { | 729 { |
| 730 base::RunLoop run_loop; | 730 base::RunLoop run_loop; |
| 731 drive::FilesCopyRequest* request = new drive::FilesCopyRequest( | 731 drive::FilesCopyRequest* request = new drive::FilesCopyRequest( |
| 732 request_sender_.get(), | 732 request_sender_.get(), |
| 733 *url_generator_, | 733 *url_generator_, |
| 734 test_util::CreateQuitCallback( | 734 test_util::CreateQuitCallback( |
| 735 &run_loop, | 735 &run_loop, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 748 EXPECT_TRUE(http_request_.has_content); | 748 EXPECT_TRUE(http_request_.has_content); |
| 749 EXPECT_EQ("{\"title\":\"new title\"}", http_request_.content); | 749 EXPECT_EQ("{\"title\":\"new title\"}", http_request_.content); |
| 750 EXPECT_TRUE(file_resource); | 750 EXPECT_TRUE(file_resource); |
| 751 } | 751 } |
| 752 | 752 |
| 753 TEST_F(DriveApiRequestsTest, FilesListRequest) { | 753 TEST_F(DriveApiRequestsTest, FilesListRequest) { |
| 754 // Set an expected data file containing valid result. | 754 // Set an expected data file containing valid result. |
| 755 expected_data_file_path_ = test_util::GetTestFilePath( | 755 expected_data_file_path_ = test_util::GetTestFilePath( |
| 756 "drive/filelist.json"); | 756 "drive/filelist.json"); |
| 757 | 757 |
| 758 GDataErrorCode error = GDATA_OTHER_ERROR; | 758 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 759 scoped_ptr<FileList> result; | 759 scoped_ptr<FileList> result; |
| 760 | 760 |
| 761 { | 761 { |
| 762 base::RunLoop run_loop; | 762 base::RunLoop run_loop; |
| 763 drive::FilesListRequest* request = new drive::FilesListRequest( | 763 drive::FilesListRequest* request = new drive::FilesListRequest( |
| 764 request_sender_.get(), *url_generator_, | 764 request_sender_.get(), *url_generator_, |
| 765 test_util::CreateQuitCallback( | 765 test_util::CreateQuitCallback( |
| 766 &run_loop, | 766 &run_loop, |
| 767 test_util::CreateCopyResultCallback(&error, &result))); | 767 test_util::CreateCopyResultCallback(&error, &result))); |
| 768 request->set_max_results(50); | 768 request->set_max_results(50); |
| 769 request->set_q("\"abcde\" in parents"); | 769 request->set_q("\"abcde\" in parents"); |
| 770 request_sender_->StartRequestWithRetry(request); | 770 request_sender_->StartRequestWithRetry(request); |
| 771 run_loop.Run(); | 771 run_loop.Run(); |
| 772 } | 772 } |
| 773 | 773 |
| 774 EXPECT_EQ(HTTP_SUCCESS, error); | 774 EXPECT_EQ(HTTP_SUCCESS, error); |
| 775 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 775 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 776 EXPECT_EQ("/drive/v2/files?maxResults=50&q=%22abcde%22+in+parents", | 776 EXPECT_EQ("/drive/v2/files?maxResults=50&q=%22abcde%22+in+parents", |
| 777 http_request_.relative_url); | 777 http_request_.relative_url); |
| 778 EXPECT_TRUE(result); | 778 EXPECT_TRUE(result); |
| 779 } | 779 } |
| 780 | 780 |
| 781 TEST_F(DriveApiRequestsTest, FilesListNextPageRequest) { | 781 TEST_F(DriveApiRequestsTest, FilesListNextPageRequest) { |
| 782 // Set an expected data file containing valid result. | 782 // Set an expected data file containing valid result. |
| 783 expected_data_file_path_ = test_util::GetTestFilePath( | 783 expected_data_file_path_ = test_util::GetTestFilePath( |
| 784 "drive/filelist.json"); | 784 "drive/filelist.json"); |
| 785 | 785 |
| 786 GDataErrorCode error = GDATA_OTHER_ERROR; | 786 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 787 scoped_ptr<FileList> result; | 787 scoped_ptr<FileList> result; |
| 788 | 788 |
| 789 { | 789 { |
| 790 base::RunLoop run_loop; | 790 base::RunLoop run_loop; |
| 791 drive::FilesListNextPageRequest* request = | 791 drive::FilesListNextPageRequest* request = |
| 792 new drive::FilesListNextPageRequest( | 792 new drive::FilesListNextPageRequest( |
| 793 request_sender_.get(), | 793 request_sender_.get(), |
| 794 test_util::CreateQuitCallback( | 794 test_util::CreateQuitCallback( |
| 795 &run_loop, | 795 &run_loop, |
| 796 test_util::CreateCopyResultCallback(&error, &result))); | 796 test_util::CreateCopyResultCallback(&error, &result))); |
| 797 request->set_next_link(test_server_.GetURL("/continue/get/file/list")); | 797 request->set_next_link(test_server_.GetURL("/continue/get/file/list")); |
| 798 request_sender_->StartRequestWithRetry(request); | 798 request_sender_->StartRequestWithRetry(request); |
| 799 run_loop.Run(); | 799 run_loop.Run(); |
| 800 } | 800 } |
| 801 | 801 |
| 802 EXPECT_EQ(HTTP_SUCCESS, error); | 802 EXPECT_EQ(HTTP_SUCCESS, error); |
| 803 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 803 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 804 EXPECT_EQ("/continue/get/file/list", http_request_.relative_url); | 804 EXPECT_EQ("/continue/get/file/list", http_request_.relative_url); |
| 805 EXPECT_TRUE(result); | 805 EXPECT_TRUE(result); |
| 806 } | 806 } |
| 807 | 807 |
| 808 TEST_F(DriveApiRequestsTest, FilesDeleteRequest) { | 808 TEST_F(DriveApiRequestsTest, FilesDeleteRequest) { |
| 809 GDataErrorCode error = GDATA_OTHER_ERROR; | 809 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 810 | 810 |
| 811 // Delete a resource with the given resource id. | 811 // Delete a resource with the given resource id. |
| 812 { | 812 { |
| 813 base::RunLoop run_loop; | 813 base::RunLoop run_loop; |
| 814 drive::FilesDeleteRequest* request = new drive::FilesDeleteRequest( | 814 drive::FilesDeleteRequest* request = new drive::FilesDeleteRequest( |
| 815 request_sender_.get(), | 815 request_sender_.get(), |
| 816 *url_generator_, | 816 *url_generator_, |
| 817 test_util::CreateQuitCallback( | 817 test_util::CreateQuitCallback( |
| 818 &run_loop, test_util::CreateCopyResultCallback(&error))); | 818 &run_loop, test_util::CreateCopyResultCallback(&error))); |
| 819 request->set_file_id("resource_id"); | 819 request->set_file_id("resource_id"); |
| 820 request->set_etag(kTestETag); | 820 request->set_etag(kTestETag); |
| 821 request_sender_->StartRequestWithRetry(request); | 821 request_sender_->StartRequestWithRetry(request); |
| 822 run_loop.Run(); | 822 run_loop.Run(); |
| 823 } | 823 } |
| 824 | 824 |
| 825 EXPECT_EQ(HTTP_NO_CONTENT, error); | 825 EXPECT_EQ(HTTP_NO_CONTENT, error); |
| 826 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); | 826 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); |
| 827 EXPECT_EQ(kTestETag, http_request_.headers["If-Match"]); | 827 EXPECT_EQ(kTestETag, http_request_.headers["If-Match"]); |
| 828 EXPECT_EQ("/drive/v2/files/resource_id", http_request_.relative_url); | 828 EXPECT_EQ("/drive/v2/files/resource_id", http_request_.relative_url); |
| 829 EXPECT_FALSE(http_request_.has_content); | 829 EXPECT_FALSE(http_request_.has_content); |
| 830 } | 830 } |
| 831 | 831 |
| 832 TEST_F(DriveApiRequestsTest, FilesTrashRequest) { | 832 TEST_F(DriveApiRequestsTest, FilesTrashRequest) { |
| 833 // Set data for the expected result. Directory entry should be returned | 833 // Set data for the expected result. Directory entry should be returned |
| 834 // if the trashing entry is a directory, so using it here should be fine. | 834 // if the trashing entry is a directory, so using it here should be fine. |
| 835 expected_data_file_path_ = | 835 expected_data_file_path_ = |
| 836 test_util::GetTestFilePath("drive/directory_entry.json"); | 836 test_util::GetTestFilePath("drive/directory_entry.json"); |
| 837 | 837 |
| 838 GDataErrorCode error = GDATA_OTHER_ERROR; | 838 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 839 scoped_ptr<FileResource> file_resource; | 839 scoped_ptr<FileResource> file_resource; |
| 840 | 840 |
| 841 // Trash a resource with the given resource id. | 841 // Trash a resource with the given resource id. |
| 842 { | 842 { |
| 843 base::RunLoop run_loop; | 843 base::RunLoop run_loop; |
| 844 drive::FilesTrashRequest* request = new drive::FilesTrashRequest( | 844 drive::FilesTrashRequest* request = new drive::FilesTrashRequest( |
| 845 request_sender_.get(), | 845 request_sender_.get(), |
| 846 *url_generator_, | 846 *url_generator_, |
| 847 test_util::CreateQuitCallback( | 847 test_util::CreateQuitCallback( |
| 848 &run_loop, | 848 &run_loop, |
| 849 test_util::CreateCopyResultCallback(&error, &file_resource))); | 849 test_util::CreateCopyResultCallback(&error, &file_resource))); |
| 850 request->set_file_id("resource_id"); | 850 request->set_file_id("resource_id"); |
| 851 request_sender_->StartRequestWithRetry(request); | 851 request_sender_->StartRequestWithRetry(request); |
| 852 run_loop.Run(); | 852 run_loop.Run(); |
| 853 } | 853 } |
| 854 | 854 |
| 855 EXPECT_EQ(HTTP_SUCCESS, error); | 855 EXPECT_EQ(HTTP_SUCCESS, error); |
| 856 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 856 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 857 EXPECT_EQ("/drive/v2/files/resource_id/trash", http_request_.relative_url); | 857 EXPECT_EQ("/drive/v2/files/resource_id/trash", http_request_.relative_url); |
| 858 EXPECT_TRUE(http_request_.has_content); | 858 EXPECT_TRUE(http_request_.has_content); |
| 859 EXPECT_TRUE(http_request_.content.empty()); | 859 EXPECT_TRUE(http_request_.content.empty()); |
| 860 } | 860 } |
| 861 | 861 |
| 862 TEST_F(DriveApiRequestsTest, ChildrenInsertRequest) { | 862 TEST_F(DriveApiRequestsTest, ChildrenInsertRequest) { |
| 863 // Set an expected data file containing the children entry. | 863 // Set an expected data file containing the children entry. |
| 864 expected_content_type_ = "application/json"; | 864 expected_content_type_ = "application/json"; |
| 865 expected_content_ = kTestChildrenResponse; | 865 expected_content_ = kTestChildrenResponse; |
| 866 | 866 |
| 867 GDataErrorCode error = GDATA_OTHER_ERROR; | 867 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 868 | 868 |
| 869 // Add a resource with "resource_id" to a directory with | 869 // Add a resource with "resource_id" to a directory with |
| 870 // "parent_resource_id". | 870 // "parent_resource_id". |
| 871 { | 871 { |
| 872 base::RunLoop run_loop; | 872 base::RunLoop run_loop; |
| 873 drive::ChildrenInsertRequest* request = new drive::ChildrenInsertRequest( | 873 drive::ChildrenInsertRequest* request = new drive::ChildrenInsertRequest( |
| 874 request_sender_.get(), | 874 request_sender_.get(), |
| 875 *url_generator_, | 875 *url_generator_, |
| 876 test_util::CreateQuitCallback( | 876 test_util::CreateQuitCallback( |
| 877 &run_loop, | 877 &run_loop, |
| 878 test_util::CreateCopyResultCallback(&error))); | 878 test_util::CreateCopyResultCallback(&error))); |
| 879 request->set_folder_id("parent_resource_id"); | 879 request->set_folder_id("parent_resource_id"); |
| 880 request->set_id("resource_id"); | 880 request->set_id("resource_id"); |
| 881 request_sender_->StartRequestWithRetry(request); | 881 request_sender_->StartRequestWithRetry(request); |
| 882 run_loop.Run(); | 882 run_loop.Run(); |
| 883 } | 883 } |
| 884 | 884 |
| 885 EXPECT_EQ(HTTP_SUCCESS, error); | 885 EXPECT_EQ(HTTP_SUCCESS, error); |
| 886 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 886 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 887 EXPECT_EQ("/drive/v2/files/parent_resource_id/children", | 887 EXPECT_EQ("/drive/v2/files/parent_resource_id/children", |
| 888 http_request_.relative_url); | 888 http_request_.relative_url); |
| 889 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 889 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| 890 | 890 |
| 891 EXPECT_TRUE(http_request_.has_content); | 891 EXPECT_TRUE(http_request_.has_content); |
| 892 EXPECT_EQ("{\"id\":\"resource_id\"}", http_request_.content); | 892 EXPECT_EQ("{\"id\":\"resource_id\"}", http_request_.content); |
| 893 } | 893 } |
| 894 | 894 |
| 895 TEST_F(DriveApiRequestsTest, ChildrenDeleteRequest) { | 895 TEST_F(DriveApiRequestsTest, ChildrenDeleteRequest) { |
| 896 GDataErrorCode error = GDATA_OTHER_ERROR; | 896 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 897 | 897 |
| 898 // Remove a resource with "resource_id" from a directory with | 898 // Remove a resource with "resource_id" from a directory with |
| 899 // "parent_resource_id". | 899 // "parent_resource_id". |
| 900 { | 900 { |
| 901 base::RunLoop run_loop; | 901 base::RunLoop run_loop; |
| 902 drive::ChildrenDeleteRequest* request = new drive::ChildrenDeleteRequest( | 902 drive::ChildrenDeleteRequest* request = new drive::ChildrenDeleteRequest( |
| 903 request_sender_.get(), | 903 request_sender_.get(), |
| 904 *url_generator_, | 904 *url_generator_, |
| 905 test_util::CreateQuitCallback( | 905 test_util::CreateQuitCallback( |
| 906 &run_loop, | 906 &run_loop, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 921 TEST_F(DriveApiRequestsTest, UploadNewFileRequest) { | 921 TEST_F(DriveApiRequestsTest, UploadNewFileRequest) { |
| 922 // Set an expected url for uploading. | 922 // Set an expected url for uploading. |
| 923 expected_upload_path_ = kTestUploadNewFilePath; | 923 expected_upload_path_ = kTestUploadNewFilePath; |
| 924 | 924 |
| 925 const char kTestContentType[] = "text/plain"; | 925 const char kTestContentType[] = "text/plain"; |
| 926 const std::string kTestContent(100, 'a'); | 926 const std::string kTestContent(100, 'a'); |
| 927 const base::FilePath kTestFilePath = | 927 const base::FilePath kTestFilePath = |
| 928 temp_dir_.path().AppendASCII("upload_file.txt"); | 928 temp_dir_.path().AppendASCII("upload_file.txt"); |
| 929 ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent)); | 929 ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent)); |
| 930 | 930 |
| 931 GDataErrorCode error = GDATA_OTHER_ERROR; | 931 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 932 GURL upload_url; | 932 GURL upload_url; |
| 933 | 933 |
| 934 // Initiate uploading a new file to the directory with | 934 // Initiate uploading a new file to the directory with |
| 935 // "parent_resource_id". | 935 // "parent_resource_id". |
| 936 { | 936 { |
| 937 base::RunLoop run_loop; | 937 base::RunLoop run_loop; |
| 938 drive::InitiateUploadNewFileRequest* request = | 938 drive::InitiateUploadNewFileRequest* request = |
| 939 new drive::InitiateUploadNewFileRequest( | 939 new drive::InitiateUploadNewFileRequest( |
| 940 request_sender_.get(), | 940 request_sender_.get(), |
| 941 *url_generator_, | 941 *url_generator_, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 TEST_F(DriveApiRequestsTest, UploadNewEmptyFileRequest) { | 1014 TEST_F(DriveApiRequestsTest, UploadNewEmptyFileRequest) { |
| 1015 // Set an expected url for uploading. | 1015 // Set an expected url for uploading. |
| 1016 expected_upload_path_ = kTestUploadNewFilePath; | 1016 expected_upload_path_ = kTestUploadNewFilePath; |
| 1017 | 1017 |
| 1018 const char kTestContentType[] = "text/plain"; | 1018 const char kTestContentType[] = "text/plain"; |
| 1019 const char kTestContent[] = ""; | 1019 const char kTestContent[] = ""; |
| 1020 const base::FilePath kTestFilePath = | 1020 const base::FilePath kTestFilePath = |
| 1021 temp_dir_.path().AppendASCII("empty_file.txt"); | 1021 temp_dir_.path().AppendASCII("empty_file.txt"); |
| 1022 ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent)); | 1022 ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent)); |
| 1023 | 1023 |
| 1024 GDataErrorCode error = GDATA_OTHER_ERROR; | 1024 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 1025 GURL upload_url; | 1025 GURL upload_url; |
| 1026 | 1026 |
| 1027 // Initiate uploading a new file to the directory with "parent_resource_id". | 1027 // Initiate uploading a new file to the directory with "parent_resource_id". |
| 1028 { | 1028 { |
| 1029 base::RunLoop run_loop; | 1029 base::RunLoop run_loop; |
| 1030 drive::InitiateUploadNewFileRequest* request = | 1030 drive::InitiateUploadNewFileRequest* request = |
| 1031 new drive::InitiateUploadNewFileRequest( | 1031 new drive::InitiateUploadNewFileRequest( |
| 1032 request_sender_.get(), | 1032 request_sender_.get(), |
| 1033 *url_generator_, | 1033 *url_generator_, |
| 1034 kTestContentType, | 1034 kTestContentType, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 // Set an expected url for uploading. | 1103 // Set an expected url for uploading. |
| 1104 expected_upload_path_ = kTestUploadNewFilePath; | 1104 expected_upload_path_ = kTestUploadNewFilePath; |
| 1105 | 1105 |
| 1106 const char kTestContentType[] = "text/plain"; | 1106 const char kTestContentType[] = "text/plain"; |
| 1107 const size_t kNumChunkBytes = 10; // Num bytes in a chunk. | 1107 const size_t kNumChunkBytes = 10; // Num bytes in a chunk. |
| 1108 const std::string kTestContent(100, 'a'); | 1108 const std::string kTestContent(100, 'a'); |
| 1109 const base::FilePath kTestFilePath = | 1109 const base::FilePath kTestFilePath = |
| 1110 temp_dir_.path().AppendASCII("upload_file.txt"); | 1110 temp_dir_.path().AppendASCII("upload_file.txt"); |
| 1111 ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent)); | 1111 ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent)); |
| 1112 | 1112 |
| 1113 GDataErrorCode error = GDATA_OTHER_ERROR; | 1113 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 1114 GURL upload_url; | 1114 GURL upload_url; |
| 1115 | 1115 |
| 1116 // Initiate uploading a new file to the directory with "parent_resource_id". | 1116 // Initiate uploading a new file to the directory with "parent_resource_id". |
| 1117 { | 1117 { |
| 1118 base::RunLoop run_loop; | 1118 base::RunLoop run_loop; |
| 1119 drive::InitiateUploadNewFileRequest* request = | 1119 drive::InitiateUploadNewFileRequest* request = |
| 1120 new drive::InitiateUploadNewFileRequest( | 1120 new drive::InitiateUploadNewFileRequest( |
| 1121 request_sender_.get(), | 1121 request_sender_.get(), |
| 1122 *url_generator_, | 1122 *url_generator_, |
| 1123 kTestContentType, | 1123 kTestContentType, |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1282 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; | 1282 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; |
| 1283 const base::Time::Exploded kLastViewedByMeDate = | 1283 const base::Time::Exploded kLastViewedByMeDate = |
| 1284 {2013, 7, 0, 19, 15, 59, 13, 123}; | 1284 {2013, 7, 0, 19, 15, 59, 13, 123}; |
| 1285 | 1285 |
| 1286 // Set an expected url for uploading. | 1286 // Set an expected url for uploading. |
| 1287 expected_upload_path_ = kTestUploadNewFilePath; | 1287 expected_upload_path_ = kTestUploadNewFilePath; |
| 1288 | 1288 |
| 1289 const char kTestContentType[] = "text/plain"; | 1289 const char kTestContentType[] = "text/plain"; |
| 1290 const std::string kTestContent(100, 'a'); | 1290 const std::string kTestContent(100, 'a'); |
| 1291 | 1291 |
| 1292 GDataErrorCode error = GDATA_OTHER_ERROR; | 1292 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 1293 GURL upload_url; | 1293 GURL upload_url; |
| 1294 | 1294 |
| 1295 // Initiate uploading a new file to the directory with "parent_resource_id". | 1295 // Initiate uploading a new file to the directory with "parent_resource_id". |
| 1296 { | 1296 { |
| 1297 base::RunLoop run_loop; | 1297 base::RunLoop run_loop; |
| 1298 drive::InitiateUploadNewFileRequest* request = | 1298 drive::InitiateUploadNewFileRequest* request = |
| 1299 new drive::InitiateUploadNewFileRequest( | 1299 new drive::InitiateUploadNewFileRequest( |
| 1300 request_sender_.get(), | 1300 request_sender_.get(), |
| 1301 *url_generator_, | 1301 *url_generator_, |
| 1302 kTestContentType, | 1302 kTestContentType, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 TEST_F(DriveApiRequestsTest, UploadExistingFileRequest) { | 1335 TEST_F(DriveApiRequestsTest, UploadExistingFileRequest) { |
| 1336 // Set an expected url for uploading. | 1336 // Set an expected url for uploading. |
| 1337 expected_upload_path_ = kTestUploadExistingFilePath; | 1337 expected_upload_path_ = kTestUploadExistingFilePath; |
| 1338 | 1338 |
| 1339 const char kTestContentType[] = "text/plain"; | 1339 const char kTestContentType[] = "text/plain"; |
| 1340 const std::string kTestContent(100, 'a'); | 1340 const std::string kTestContent(100, 'a'); |
| 1341 const base::FilePath kTestFilePath = | 1341 const base::FilePath kTestFilePath = |
| 1342 temp_dir_.path().AppendASCII("upload_file.txt"); | 1342 temp_dir_.path().AppendASCII("upload_file.txt"); |
| 1343 ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent)); | 1343 ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent)); |
| 1344 | 1344 |
| 1345 GDataErrorCode error = GDATA_OTHER_ERROR; | 1345 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 1346 GURL upload_url; | 1346 GURL upload_url; |
| 1347 | 1347 |
| 1348 // Initiate uploading a new file to the directory with "parent_resource_id". | 1348 // Initiate uploading a new file to the directory with "parent_resource_id". |
| 1349 { | 1349 { |
| 1350 base::RunLoop run_loop; | 1350 base::RunLoop run_loop; |
| 1351 drive::InitiateUploadExistingFileRequest* request = | 1351 drive::InitiateUploadExistingFileRequest* request = |
| 1352 new drive::InitiateUploadExistingFileRequest( | 1352 new drive::InitiateUploadExistingFileRequest( |
| 1353 request_sender_.get(), | 1353 request_sender_.get(), |
| 1354 *url_generator_, | 1354 *url_generator_, |
| 1355 kTestContentType, | 1355 kTestContentType, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1422 TEST_F(DriveApiRequestsTest, UploadExistingFileRequestWithETag) { | 1422 TEST_F(DriveApiRequestsTest, UploadExistingFileRequestWithETag) { |
| 1423 // Set an expected url for uploading. | 1423 // Set an expected url for uploading. |
| 1424 expected_upload_path_ = kTestUploadExistingFilePath; | 1424 expected_upload_path_ = kTestUploadExistingFilePath; |
| 1425 | 1425 |
| 1426 const char kTestContentType[] = "text/plain"; | 1426 const char kTestContentType[] = "text/plain"; |
| 1427 const std::string kTestContent(100, 'a'); | 1427 const std::string kTestContent(100, 'a'); |
| 1428 const base::FilePath kTestFilePath = | 1428 const base::FilePath kTestFilePath = |
| 1429 temp_dir_.path().AppendASCII("upload_file.txt"); | 1429 temp_dir_.path().AppendASCII("upload_file.txt"); |
| 1430 ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent)); | 1430 ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent)); |
| 1431 | 1431 |
| 1432 GDataErrorCode error = GDATA_OTHER_ERROR; | 1432 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 1433 GURL upload_url; | 1433 GURL upload_url; |
| 1434 | 1434 |
| 1435 // Initiate uploading a new file to the directory with "parent_resource_id". | 1435 // Initiate uploading a new file to the directory with "parent_resource_id". |
| 1436 { | 1436 { |
| 1437 base::RunLoop run_loop; | 1437 base::RunLoop run_loop; |
| 1438 drive::InitiateUploadExistingFileRequest* request = | 1438 drive::InitiateUploadExistingFileRequest* request = |
| 1439 new drive::InitiateUploadExistingFileRequest( | 1439 new drive::InitiateUploadExistingFileRequest( |
| 1440 request_sender_.get(), | 1440 request_sender_.get(), |
| 1441 *url_generator_, | 1441 *url_generator_, |
| 1442 kTestContentType, | 1442 kTestContentType, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1511 expected_upload_path_ = kTestUploadExistingFilePath; | 1511 expected_upload_path_ = kTestUploadExistingFilePath; |
| 1512 | 1512 |
| 1513 // If it turned out that the etag is conflicting, PRECONDITION_FAILED should | 1513 // If it turned out that the etag is conflicting, PRECONDITION_FAILED should |
| 1514 // be returned. | 1514 // be returned. |
| 1515 expected_precondition_failed_file_path_ = | 1515 expected_precondition_failed_file_path_ = |
| 1516 test_util::GetTestFilePath("drive/error.json"); | 1516 test_util::GetTestFilePath("drive/error.json"); |
| 1517 | 1517 |
| 1518 const char kTestContentType[] = "text/plain"; | 1518 const char kTestContentType[] = "text/plain"; |
| 1519 const std::string kTestContent(100, 'a'); | 1519 const std::string kTestContent(100, 'a'); |
| 1520 | 1520 |
| 1521 GDataErrorCode error = GDATA_OTHER_ERROR; | 1521 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 1522 GURL upload_url; | 1522 GURL upload_url; |
| 1523 | 1523 |
| 1524 // Initiate uploading a new file to the directory with "parent_resource_id". | 1524 // Initiate uploading a new file to the directory with "parent_resource_id". |
| 1525 { | 1525 { |
| 1526 base::RunLoop run_loop; | 1526 base::RunLoop run_loop; |
| 1527 drive::InitiateUploadExistingFileRequest* request = | 1527 drive::InitiateUploadExistingFileRequest* request = |
| 1528 new drive::InitiateUploadExistingFileRequest( | 1528 new drive::InitiateUploadExistingFileRequest( |
| 1529 request_sender_.get(), | 1529 request_sender_.get(), |
| 1530 *url_generator_, | 1530 *url_generator_, |
| 1531 kTestContentType, | 1531 kTestContentType, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1556 UploadExistingFileRequestWithETagConflictOnResumeUpload) { | 1556 UploadExistingFileRequestWithETagConflictOnResumeUpload) { |
| 1557 // Set an expected url for uploading. | 1557 // Set an expected url for uploading. |
| 1558 expected_upload_path_ = kTestUploadExistingFilePath; | 1558 expected_upload_path_ = kTestUploadExistingFilePath; |
| 1559 | 1559 |
| 1560 const char kTestContentType[] = "text/plain"; | 1560 const char kTestContentType[] = "text/plain"; |
| 1561 const std::string kTestContent(100, 'a'); | 1561 const std::string kTestContent(100, 'a'); |
| 1562 const base::FilePath kTestFilePath = | 1562 const base::FilePath kTestFilePath = |
| 1563 temp_dir_.path().AppendASCII("upload_file.txt"); | 1563 temp_dir_.path().AppendASCII("upload_file.txt"); |
| 1564 ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent)); | 1564 ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent)); |
| 1565 | 1565 |
| 1566 GDataErrorCode error = GDATA_OTHER_ERROR; | 1566 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 1567 GURL upload_url; | 1567 GURL upload_url; |
| 1568 | 1568 |
| 1569 // Initiate uploading a new file to the directory with "parent_resource_id". | 1569 // Initiate uploading a new file to the directory with "parent_resource_id". |
| 1570 { | 1570 { |
| 1571 base::RunLoop run_loop; | 1571 base::RunLoop run_loop; |
| 1572 drive::InitiateUploadExistingFileRequest* request = | 1572 drive::InitiateUploadExistingFileRequest* request = |
| 1573 new drive::InitiateUploadExistingFileRequest( | 1573 new drive::InitiateUploadExistingFileRequest( |
| 1574 request_sender_.get(), | 1574 request_sender_.get(), |
| 1575 *url_generator_, | 1575 *url_generator_, |
| 1576 kTestContentType, | 1576 kTestContentType, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1652 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; | 1652 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; |
| 1653 const base::Time::Exploded kLastViewedByMeDate = | 1653 const base::Time::Exploded kLastViewedByMeDate = |
| 1654 {2013, 7, 0, 19, 15, 59, 13, 123}; | 1654 {2013, 7, 0, 19, 15, 59, 13, 123}; |
| 1655 | 1655 |
| 1656 // Set an expected url for uploading. | 1656 // Set an expected url for uploading. |
| 1657 expected_upload_path_ = kTestUploadExistingFilePath; | 1657 expected_upload_path_ = kTestUploadExistingFilePath; |
| 1658 | 1658 |
| 1659 const char kTestContentType[] = "text/plain"; | 1659 const char kTestContentType[] = "text/plain"; |
| 1660 const std::string kTestContent(100, 'a'); | 1660 const std::string kTestContent(100, 'a'); |
| 1661 | 1661 |
| 1662 GDataErrorCode error = GDATA_OTHER_ERROR; | 1662 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 1663 GURL upload_url; | 1663 GURL upload_url; |
| 1664 | 1664 |
| 1665 // Initiate uploading a new file to the directory with "parent_resource_id". | 1665 // Initiate uploading a new file to the directory with "parent_resource_id". |
| 1666 { | 1666 { |
| 1667 base::RunLoop run_loop; | 1667 base::RunLoop run_loop; |
| 1668 drive::InitiateUploadExistingFileRequest* request = | 1668 drive::InitiateUploadExistingFileRequest* request = |
| 1669 new drive::InitiateUploadExistingFileRequest( | 1669 new drive::InitiateUploadExistingFileRequest( |
| 1670 request_sender_.get(), | 1670 request_sender_.get(), |
| 1671 *url_generator_, | 1671 *url_generator_, |
| 1672 kTestContentType, | 1672 kTestContentType, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1705 "\"kind\":\"drive#fileLink\"}]," | 1705 "\"kind\":\"drive#fileLink\"}]," |
| 1706 "\"title\":\"new file title\"}", | 1706 "\"title\":\"new file title\"}", |
| 1707 http_request_.content); | 1707 http_request_.content); |
| 1708 } | 1708 } |
| 1709 | 1709 |
| 1710 TEST_F(DriveApiRequestsTest, DownloadFileRequest) { | 1710 TEST_F(DriveApiRequestsTest, DownloadFileRequest) { |
| 1711 const base::FilePath kDownloadedFilePath = | 1711 const base::FilePath kDownloadedFilePath = |
| 1712 temp_dir_.path().AppendASCII("cache_file"); | 1712 temp_dir_.path().AppendASCII("cache_file"); |
| 1713 const std::string kTestId("dummyId"); | 1713 const std::string kTestId("dummyId"); |
| 1714 | 1714 |
| 1715 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 1715 DriveApiErrorCode result_code = DRIVE_OTHER_ERROR; |
| 1716 base::FilePath temp_file; | 1716 base::FilePath temp_file; |
| 1717 { | 1717 { |
| 1718 base::RunLoop run_loop; | 1718 base::RunLoop run_loop; |
| 1719 drive::DownloadFileRequest* request = new drive::DownloadFileRequest( | 1719 drive::DownloadFileRequest* request = new drive::DownloadFileRequest( |
| 1720 request_sender_.get(), | 1720 request_sender_.get(), |
| 1721 *url_generator_, | 1721 *url_generator_, |
| 1722 kTestId, | 1722 kTestId, |
| 1723 kDownloadedFilePath, | 1723 kDownloadedFilePath, |
| 1724 test_util::CreateQuitCallback( | 1724 test_util::CreateQuitCallback( |
| 1725 &run_loop, | 1725 &run_loop, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1741 | 1741 |
| 1742 const std::string expected_contents = kTestId + kTestId + kTestId; | 1742 const std::string expected_contents = kTestId + kTestId + kTestId; |
| 1743 EXPECT_EQ(expected_contents, contents); | 1743 EXPECT_EQ(expected_contents, contents); |
| 1744 } | 1744 } |
| 1745 | 1745 |
| 1746 TEST_F(DriveApiRequestsTest, DownloadFileRequest_GetContentCallback) { | 1746 TEST_F(DriveApiRequestsTest, DownloadFileRequest_GetContentCallback) { |
| 1747 const base::FilePath kDownloadedFilePath = | 1747 const base::FilePath kDownloadedFilePath = |
| 1748 temp_dir_.path().AppendASCII("cache_file"); | 1748 temp_dir_.path().AppendASCII("cache_file"); |
| 1749 const std::string kTestId("dummyId"); | 1749 const std::string kTestId("dummyId"); |
| 1750 | 1750 |
| 1751 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 1751 DriveApiErrorCode result_code = DRIVE_OTHER_ERROR; |
| 1752 base::FilePath temp_file; | 1752 base::FilePath temp_file; |
| 1753 std::string contents; | 1753 std::string contents; |
| 1754 { | 1754 { |
| 1755 base::RunLoop run_loop; | 1755 base::RunLoop run_loop; |
| 1756 drive::DownloadFileRequest* request = new drive::DownloadFileRequest( | 1756 drive::DownloadFileRequest* request = new drive::DownloadFileRequest( |
| 1757 request_sender_.get(), | 1757 request_sender_.get(), |
| 1758 *url_generator_, | 1758 *url_generator_, |
| 1759 kTestId, | 1759 kTestId, |
| 1760 kDownloadedFilePath, | 1760 kDownloadedFilePath, |
| 1761 test_util::CreateQuitCallback( | 1761 test_util::CreateQuitCallback( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1775 EXPECT_EQ(kDownloadedFilePath, temp_file); | 1775 EXPECT_EQ(kDownloadedFilePath, temp_file); |
| 1776 | 1776 |
| 1777 const std::string expected_contents = kTestId + kTestId + kTestId; | 1777 const std::string expected_contents = kTestId + kTestId + kTestId; |
| 1778 EXPECT_EQ(expected_contents, contents); | 1778 EXPECT_EQ(expected_contents, contents); |
| 1779 } | 1779 } |
| 1780 | 1780 |
| 1781 TEST_F(DriveApiRequestsTest, PermissionsInsertRequest) { | 1781 TEST_F(DriveApiRequestsTest, PermissionsInsertRequest) { |
| 1782 expected_content_type_ = "application/json"; | 1782 expected_content_type_ = "application/json"; |
| 1783 expected_content_ = kTestPermissionResponse; | 1783 expected_content_ = kTestPermissionResponse; |
| 1784 | 1784 |
| 1785 GDataErrorCode error = GDATA_OTHER_ERROR; | 1785 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 1786 | 1786 |
| 1787 // Add comment permission to the user "user@example.com". | 1787 // Add comment permission to the user "user@example.com". |
| 1788 { | 1788 { |
| 1789 base::RunLoop run_loop; | 1789 base::RunLoop run_loop; |
| 1790 drive::PermissionsInsertRequest* request = | 1790 drive::PermissionsInsertRequest* request = |
| 1791 new drive::PermissionsInsertRequest( | 1791 new drive::PermissionsInsertRequest( |
| 1792 request_sender_.get(), | 1792 request_sender_.get(), |
| 1793 *url_generator_, | 1793 *url_generator_, |
| 1794 test_util::CreateQuitCallback( | 1794 test_util::CreateQuitCallback( |
| 1795 &run_loop, | 1795 &run_loop, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1811 scoped_ptr<base::Value> expected(base::JSONReader::Read( | 1811 scoped_ptr<base::Value> expected(base::JSONReader::Read( |
| 1812 "{\"additionalRoles\":[\"commenter\"], \"role\":\"reader\", " | 1812 "{\"additionalRoles\":[\"commenter\"], \"role\":\"reader\", " |
| 1813 "\"type\":\"user\",\"value\":\"user@example.com\"}")); | 1813 "\"type\":\"user\",\"value\":\"user@example.com\"}")); |
| 1814 ASSERT_TRUE(expected); | 1814 ASSERT_TRUE(expected); |
| 1815 | 1815 |
| 1816 scoped_ptr<base::Value> result(base::JSONReader::Read(http_request_.content)); | 1816 scoped_ptr<base::Value> result(base::JSONReader::Read(http_request_.content)); |
| 1817 EXPECT_TRUE(http_request_.has_content); | 1817 EXPECT_TRUE(http_request_.has_content); |
| 1818 EXPECT_TRUE(base::Value::Equals(expected.get(), result.get())); | 1818 EXPECT_TRUE(base::Value::Equals(expected.get(), result.get())); |
| 1819 | 1819 |
| 1820 // Add "can edit" permission to users in "example.com". | 1820 // Add "can edit" permission to users in "example.com". |
| 1821 error = GDATA_OTHER_ERROR; | 1821 error = DRIVE_OTHER_ERROR; |
| 1822 { | 1822 { |
| 1823 base::RunLoop run_loop; | 1823 base::RunLoop run_loop; |
| 1824 drive::PermissionsInsertRequest* request = | 1824 drive::PermissionsInsertRequest* request = |
| 1825 new drive::PermissionsInsertRequest( | 1825 new drive::PermissionsInsertRequest( |
| 1826 request_sender_.get(), | 1826 request_sender_.get(), |
| 1827 *url_generator_, | 1827 *url_generator_, |
| 1828 test_util::CreateQuitCallback( | 1828 test_util::CreateQuitCallback( |
| 1829 &run_loop, | 1829 &run_loop, |
| 1830 test_util::CreateCopyResultCallback(&error))); | 1830 test_util::CreateCopyResultCallback(&error))); |
| 1831 request->set_id("resource_id2"); | 1831 request->set_id("resource_id2"); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1845 expected.reset(base::JSONReader::Read( | 1845 expected.reset(base::JSONReader::Read( |
| 1846 "{\"role\":\"writer\", \"type\":\"domain\",\"value\":\"example.com\"}")); | 1846 "{\"role\":\"writer\", \"type\":\"domain\",\"value\":\"example.com\"}")); |
| 1847 ASSERT_TRUE(expected); | 1847 ASSERT_TRUE(expected); |
| 1848 | 1848 |
| 1849 result.reset(base::JSONReader::Read(http_request_.content)); | 1849 result.reset(base::JSONReader::Read(http_request_.content)); |
| 1850 EXPECT_TRUE(http_request_.has_content); | 1850 EXPECT_TRUE(http_request_.has_content); |
| 1851 EXPECT_TRUE(base::Value::Equals(expected.get(), result.get())); | 1851 EXPECT_TRUE(base::Value::Equals(expected.get(), result.get())); |
| 1852 } | 1852 } |
| 1853 | 1853 |
| 1854 } // namespace google_apis | 1854 } // namespace google_apis |
| OLD | NEW |