OLD | NEW |
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/chromeos/drive/job_scheduler.h" | 5 #include "chrome/browser/chromeos/drive/job_scheduler.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 | 651 |
652 // Switch to a Wifi connection | 652 // Switch to a Wifi connection |
653 ConnectToWifi(); | 653 ConnectToWifi(); |
654 | 654 |
655 base::RunLoop().RunUntilIdle(); | 655 base::RunLoop().RunUntilIdle(); |
656 | 656 |
657 // Check the download again | 657 // Check the download again |
658 EXPECT_EQ(google_apis::HTTP_SUCCESS, download_error); | 658 EXPECT_EQ(google_apis::HTTP_SUCCESS, download_error); |
659 std::string content; | 659 std::string content; |
660 EXPECT_EQ(output_file_path, kOutputFilePath); | 660 EXPECT_EQ(output_file_path, kOutputFilePath); |
661 ASSERT_TRUE(file_util::ReadFileToString(output_file_path, &content)); | 661 ASSERT_TRUE(base::ReadFileToString(output_file_path, &content)); |
662 EXPECT_EQ("This is some test content.", content); | 662 EXPECT_EQ("This is some test content.", content); |
663 } | 663 } |
664 | 664 |
665 TEST_F(JobSchedulerTest, DownloadFileWimaxDisabled) { | 665 TEST_F(JobSchedulerTest, DownloadFileWimaxDisabled) { |
666 ConnectToWimax(); | 666 ConnectToWimax(); |
667 | 667 |
668 // Disable fetching over cellular network. | 668 // Disable fetching over cellular network. |
669 pref_service_->SetBoolean(prefs::kDisableDriveOverCellular, true); | 669 pref_service_->SetBoolean(prefs::kDisableDriveOverCellular, true); |
670 | 670 |
671 // Try to get a file in the background | 671 // Try to get a file in the background |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 | 704 |
705 // Switch to a Wifi connection | 705 // Switch to a Wifi connection |
706 ConnectToWifi(); | 706 ConnectToWifi(); |
707 | 707 |
708 base::RunLoop().RunUntilIdle(); | 708 base::RunLoop().RunUntilIdle(); |
709 | 709 |
710 // Check the download again | 710 // Check the download again |
711 EXPECT_EQ(google_apis::HTTP_SUCCESS, download_error); | 711 EXPECT_EQ(google_apis::HTTP_SUCCESS, download_error); |
712 std::string content; | 712 std::string content; |
713 EXPECT_EQ(output_file_path, kOutputFilePath); | 713 EXPECT_EQ(output_file_path, kOutputFilePath); |
714 ASSERT_TRUE(file_util::ReadFileToString(output_file_path, &content)); | 714 ASSERT_TRUE(base::ReadFileToString(output_file_path, &content)); |
715 EXPECT_EQ("This is some test content.", content); | 715 EXPECT_EQ("This is some test content.", content); |
716 } | 716 } |
717 | 717 |
718 TEST_F(JobSchedulerTest, DownloadFileCellularEnabled) { | 718 TEST_F(JobSchedulerTest, DownloadFileCellularEnabled) { |
719 ConnectToCellular(); | 719 ConnectToCellular(); |
720 | 720 |
721 // Enable fetching over cellular network. | 721 // Enable fetching over cellular network. |
722 pref_service_->SetBoolean(prefs::kDisableDriveOverCellular, false); | 722 pref_service_->SetBoolean(prefs::kDisableDriveOverCellular, false); |
723 | 723 |
724 // Try to get a file in the background | 724 // Try to get a file in the background |
(...skipping 24 matching lines...) Expand all Loading... |
749 base::RunLoop().RunUntilIdle(); | 749 base::RunLoop().RunUntilIdle(); |
750 | 750 |
751 // Check the metadata | 751 // Check the metadata |
752 ASSERT_EQ(google_apis::HTTP_SUCCESS, metadata_error); | 752 ASSERT_EQ(google_apis::HTTP_SUCCESS, metadata_error); |
753 ASSERT_TRUE(about_resource); | 753 ASSERT_TRUE(about_resource); |
754 | 754 |
755 // Check the download | 755 // Check the download |
756 EXPECT_EQ(google_apis::HTTP_SUCCESS, download_error); | 756 EXPECT_EQ(google_apis::HTTP_SUCCESS, download_error); |
757 std::string content; | 757 std::string content; |
758 EXPECT_EQ(output_file_path, kOutputFilePath); | 758 EXPECT_EQ(output_file_path, kOutputFilePath); |
759 ASSERT_TRUE(file_util::ReadFileToString(output_file_path, &content)); | 759 ASSERT_TRUE(base::ReadFileToString(output_file_path, &content)); |
760 EXPECT_EQ("This is some test content.", content); | 760 EXPECT_EQ("This is some test content.", content); |
761 } | 761 } |
762 | 762 |
763 TEST_F(JobSchedulerTest, DownloadFileWimaxEnabled) { | 763 TEST_F(JobSchedulerTest, DownloadFileWimaxEnabled) { |
764 ConnectToWimax(); | 764 ConnectToWimax(); |
765 | 765 |
766 // Enable fetching over cellular network. | 766 // Enable fetching over cellular network. |
767 pref_service_->SetBoolean(prefs::kDisableDriveOverCellular, false); | 767 pref_service_->SetBoolean(prefs::kDisableDriveOverCellular, false); |
768 | 768 |
769 // Try to get a file in the background | 769 // Try to get a file in the background |
(...skipping 24 matching lines...) Expand all Loading... |
794 base::RunLoop().RunUntilIdle(); | 794 base::RunLoop().RunUntilIdle(); |
795 | 795 |
796 // Check the metadata | 796 // Check the metadata |
797 ASSERT_EQ(google_apis::HTTP_SUCCESS, metadata_error); | 797 ASSERT_EQ(google_apis::HTTP_SUCCESS, metadata_error); |
798 ASSERT_TRUE(about_resource); | 798 ASSERT_TRUE(about_resource); |
799 | 799 |
800 // Check the download | 800 // Check the download |
801 EXPECT_EQ(google_apis::HTTP_SUCCESS, download_error); | 801 EXPECT_EQ(google_apis::HTTP_SUCCESS, download_error); |
802 std::string content; | 802 std::string content; |
803 EXPECT_EQ(output_file_path, kOutputFilePath); | 803 EXPECT_EQ(output_file_path, kOutputFilePath); |
804 ASSERT_TRUE(file_util::ReadFileToString(output_file_path, &content)); | 804 ASSERT_TRUE(base::ReadFileToString(output_file_path, &content)); |
805 EXPECT_EQ("This is some test content.", content); | 805 EXPECT_EQ("This is some test content.", content); |
806 } | 806 } |
807 | 807 |
808 TEST_F(JobSchedulerTest, JobInfo) { | 808 TEST_F(JobSchedulerTest, JobInfo) { |
809 JobListLogger logger; | 809 JobListLogger logger; |
810 scheduler_->AddObserver(&logger); | 810 scheduler_->AddObserver(&logger); |
811 | 811 |
812 // Disable background upload/download. | 812 // Disable background upload/download. |
813 ConnectToWimax(); | 813 ConnectToWimax(); |
814 pref_service_->SetBoolean(prefs::kDisableDriveOverCellular, true); | 814 pref_service_->SetBoolean(prefs::kDisableDriveOverCellular, true); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 | 971 |
972 std::vector<int64> upload_progress; | 972 std::vector<int64> upload_progress; |
973 logger.GetProgressInfo(TYPE_UPLOAD_NEW_FILE, &upload_progress); | 973 logger.GetProgressInfo(TYPE_UPLOAD_NEW_FILE, &upload_progress); |
974 ASSERT_TRUE(!upload_progress.empty()); | 974 ASSERT_TRUE(!upload_progress.empty()); |
975 EXPECT_TRUE(base::STLIsSorted(upload_progress)); | 975 EXPECT_TRUE(base::STLIsSorted(upload_progress)); |
976 EXPECT_GE(upload_progress.front(), 0); | 976 EXPECT_GE(upload_progress.front(), 0); |
977 EXPECT_LE(upload_progress.back(), 13); | 977 EXPECT_LE(upload_progress.back(), 13); |
978 } | 978 } |
979 | 979 |
980 } // namespace drive | 980 } // namespace drive |
OLD | NEW |