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

Side by Side Diff: chrome/browser/google_apis/fake_drive_service_unittest.cc

Issue 12500008: Eliminate CopyResultsFromDownloadActionCallback(AndQuit). (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase Created 7 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/google_apis/fake_drive_service.h" 5 #include "chrome/browser/google_apis/fake_drive_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 578
579 const GURL kContentUrl("https://file_content_url/"); 579 const GURL kContentUrl("https://file_content_url/");
580 const base::FilePath kOutputFilePath = 580 const base::FilePath kOutputFilePath =
581 temp_dir.path().AppendASCII("whatever.txt"); 581 temp_dir.path().AppendASCII("whatever.txt");
582 GDataErrorCode error = GDATA_OTHER_ERROR; 582 GDataErrorCode error = GDATA_OTHER_ERROR;
583 base::FilePath output_file_path; 583 base::FilePath output_file_path;
584 fake_service_.DownloadFile( 584 fake_service_.DownloadFile(
585 base::FilePath::FromUTF8Unsafe("/drive/whatever.txt"), // virtual path 585 base::FilePath::FromUTF8Unsafe("/drive/whatever.txt"), // virtual path
586 kOutputFilePath, 586 kOutputFilePath,
587 kContentUrl, 587 kContentUrl,
588 base::Bind(&test_util::CopyResultsFromDownloadActionCallback, 588 test_util::CreateCopyResultCallback(&error, &output_file_path),
589 &error,
590 &output_file_path),
591 GetContentCallback()); 589 GetContentCallback());
592 message_loop_.RunUntilIdle(); 590 message_loop_.RunUntilIdle();
593 591
594 EXPECT_EQ(HTTP_SUCCESS, error); 592 EXPECT_EQ(HTTP_SUCCESS, error);
595 EXPECT_EQ(output_file_path, kOutputFilePath); 593 EXPECT_EQ(output_file_path, kOutputFilePath);
596 std::string content; 594 std::string content;
597 ASSERT_TRUE(file_util::ReadFileToString(output_file_path, &content)); 595 ASSERT_TRUE(file_util::ReadFileToString(output_file_path, &content));
598 // The content is "x"s of the file size specified in root_feed.json. 596 // The content is "x"s of the file size specified in root_feed.json.
599 EXPECT_EQ("xxxxxxxxxx", content); 597 EXPECT_EQ("xxxxxxxxxx", content);
600 } 598 }
601 599
602 TEST_F(FakeDriveServiceTest, DownloadFile_NonexistingFile) { 600 TEST_F(FakeDriveServiceTest, DownloadFile_NonexistingFile) {
603 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( 601 ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
604 "chromeos/gdata/root_feed.json")); 602 "chromeos/gdata/root_feed.json"));
605 603
606 base::ScopedTempDir temp_dir; 604 base::ScopedTempDir temp_dir;
607 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 605 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
608 606
609 const GURL kContentUrl("https://non_existing_content_url/"); 607 const GURL kContentUrl("https://non_existing_content_url/");
610 const base::FilePath kOutputFilePath = 608 const base::FilePath kOutputFilePath =
611 temp_dir.path().AppendASCII("whatever.txt"); 609 temp_dir.path().AppendASCII("whatever.txt");
612 GDataErrorCode error = GDATA_OTHER_ERROR; 610 GDataErrorCode error = GDATA_OTHER_ERROR;
613 base::FilePath output_file_path; 611 base::FilePath output_file_path;
614 fake_service_.DownloadFile( 612 fake_service_.DownloadFile(
615 base::FilePath::FromUTF8Unsafe("/drive/whatever.txt"), // virtual path 613 base::FilePath::FromUTF8Unsafe("/drive/whatever.txt"), // virtual path
616 kOutputFilePath, 614 kOutputFilePath,
617 kContentUrl, 615 kContentUrl,
618 base::Bind(&test_util::CopyResultsFromDownloadActionCallback, 616 test_util::CreateCopyResultCallback(&error, &output_file_path),
619 &error,
620 &output_file_path),
621 GetContentCallback()); 617 GetContentCallback());
622 message_loop_.RunUntilIdle(); 618 message_loop_.RunUntilIdle();
623 619
624 EXPECT_EQ(HTTP_NOT_FOUND, error); 620 EXPECT_EQ(HTTP_NOT_FOUND, error);
625 } 621 }
626 622
627 TEST_F(FakeDriveServiceTest, DownloadFile_Offline) { 623 TEST_F(FakeDriveServiceTest, DownloadFile_Offline) {
628 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( 624 ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
629 "chromeos/gdata/root_feed.json")); 625 "chromeos/gdata/root_feed.json"));
630 fake_service_.set_offline(true); 626 fake_service_.set_offline(true);
631 627
632 base::ScopedTempDir temp_dir; 628 base::ScopedTempDir temp_dir;
633 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 629 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
634 630
635 const GURL kContentUrl("https://file_content_url/"); 631 const GURL kContentUrl("https://file_content_url/");
636 const base::FilePath kOutputFilePath = 632 const base::FilePath kOutputFilePath =
637 temp_dir.path().AppendASCII("whatever.txt"); 633 temp_dir.path().AppendASCII("whatever.txt");
638 GDataErrorCode error = GDATA_OTHER_ERROR; 634 GDataErrorCode error = GDATA_OTHER_ERROR;
639 base::FilePath output_file_path; 635 base::FilePath output_file_path;
640 fake_service_.DownloadFile( 636 fake_service_.DownloadFile(
641 base::FilePath::FromUTF8Unsafe("/drive/whatever.txt"), // virtual path 637 base::FilePath::FromUTF8Unsafe("/drive/whatever.txt"), // virtual path
642 kOutputFilePath, 638 kOutputFilePath,
643 kContentUrl, 639 kContentUrl,
644 base::Bind(&test_util::CopyResultsFromDownloadActionCallback, 640 test_util::CreateCopyResultCallback(&error, &output_file_path),
645 &error,
646 &output_file_path),
647 GetContentCallback()); 641 GetContentCallback());
648 message_loop_.RunUntilIdle(); 642 message_loop_.RunUntilIdle();
649 643
650 EXPECT_EQ(GDATA_NO_CONNECTION, error); 644 EXPECT_EQ(GDATA_NO_CONNECTION, error);
651 } 645 }
652 646
653 TEST_F(FakeDriveServiceTest, CopyHostedDocument_ExistingHostedDocument) { 647 TEST_F(FakeDriveServiceTest, CopyHostedDocument_ExistingHostedDocument) {
654 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( 648 ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
655 "chromeos/gdata/root_feed.json")); 649 "chromeos/gdata/root_feed.json"));
656 ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi( 650 ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi(
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 1445
1452 EXPECT_EQ(HTTP_CREATED, response.code); 1446 EXPECT_EQ(HTTP_CREATED, response.code);
1453 EXPECT_TRUE(entry.get()); 1447 EXPECT_TRUE(entry.get());
1454 EXPECT_EQ(15L, entry->file_size()); 1448 EXPECT_EQ(15L, entry->file_size());
1455 EXPECT_TRUE(Exists(entry->resource_id())); 1449 EXPECT_TRUE(Exists(entry->resource_id()));
1456 } 1450 }
1457 1451
1458 } // namespace 1452 } // namespace
1459 1453
1460 } // namespace google_apis 1454 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/base_operations_server_unittest.cc ('k') | chrome/browser/google_apis/test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698