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

Side by Side Diff: chrome/browser/chromeos/drive/job_scheduler_unittest.cc

Issue 148233006: drive: Use UploadNewFile from EntryUpdatePerformer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits 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
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/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 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 google_apis::GDataErrorCode upload_error = 964 google_apis::GDataErrorCode upload_error =
965 google_apis::GDATA_OTHER_ERROR; 965 google_apis::GDATA_OTHER_ERROR;
966 scoped_ptr<google_apis::ResourceEntry> entry; 966 scoped_ptr<google_apis::ResourceEntry> entry;
967 967
968 scheduler_->UploadNewFile( 968 scheduler_->UploadNewFile(
969 fake_drive_service_->GetRootResourceId(), 969 fake_drive_service_->GetRootResourceId(),
970 base::FilePath::FromUTF8Unsafe("drive/new_file.txt"), 970 base::FilePath::FromUTF8Unsafe("drive/new_file.txt"),
971 path, 971 path,
972 "dummy title", 972 "dummy title",
973 "plain/plain", 973 "plain/plain",
974 DriveUploader::UploadNewFileOptions(),
974 ClientContext(BACKGROUND), 975 ClientContext(BACKGROUND),
975 google_apis::test_util::CreateCopyResultCallback(&upload_error, &entry)); 976 google_apis::test_util::CreateCopyResultCallback(&upload_error, &entry));
976 base::RunLoop().RunUntilIdle(); 977 base::RunLoop().RunUntilIdle();
977 978
978 std::vector<int64> upload_progress; 979 std::vector<int64> upload_progress;
979 logger.GetProgressInfo(TYPE_UPLOAD_NEW_FILE, &upload_progress); 980 logger.GetProgressInfo(TYPE_UPLOAD_NEW_FILE, &upload_progress);
980 ASSERT_TRUE(!upload_progress.empty()); 981 ASSERT_TRUE(!upload_progress.empty());
981 EXPECT_TRUE(base::STLIsSorted(upload_progress)); 982 EXPECT_TRUE(base::STLIsSorted(upload_progress));
982 EXPECT_GE(upload_progress.front(), 0); 983 EXPECT_GE(upload_progress.front(), 0);
983 EXPECT_LE(upload_progress.back(), 13); 984 EXPECT_LE(upload_progress.back(), 13);
(...skipping 12 matching lines...) Expand all
996 997
997 // Start the first job and record its job ID. 998 // Start the first job and record its job ID.
998 google_apis::GDataErrorCode error1 = google_apis::GDATA_OTHER_ERROR; 999 google_apis::GDataErrorCode error1 = google_apis::GDATA_OTHER_ERROR;
999 scoped_ptr<google_apis::ResourceEntry> entry; 1000 scoped_ptr<google_apis::ResourceEntry> entry;
1000 scheduler_->UploadNewFile( 1001 scheduler_->UploadNewFile(
1001 fake_drive_service_->GetRootResourceId(), 1002 fake_drive_service_->GetRootResourceId(),
1002 base::FilePath::FromUTF8Unsafe("dummy/path"), 1003 base::FilePath::FromUTF8Unsafe("dummy/path"),
1003 upload_path, 1004 upload_path,
1004 "dummy title 1", 1005 "dummy title 1",
1005 "text/plain", 1006 "text/plain",
1007 DriveUploader::UploadNewFileOptions(),
1006 ClientContext(BACKGROUND), 1008 ClientContext(BACKGROUND),
1007 google_apis::test_util::CreateCopyResultCallback(&error1, &entry)); 1009 google_apis::test_util::CreateCopyResultCallback(&error1, &entry));
1008 1010
1009 const std::vector<JobInfo>& jobs = scheduler_->GetJobInfoList(); 1011 const std::vector<JobInfo>& jobs = scheduler_->GetJobInfoList();
1010 ASSERT_EQ(1u, jobs.size()); 1012 ASSERT_EQ(1u, jobs.size());
1011 ASSERT_EQ(STATE_NONE, jobs[0].state); // Not started yet. 1013 ASSERT_EQ(STATE_NONE, jobs[0].state); // Not started yet.
1012 JobID first_job_id = jobs[0].job_id; 1014 JobID first_job_id = jobs[0].job_id;
1013 1015
1014 // Start the second job. 1016 // Start the second job.
1015 google_apis::GDataErrorCode error2 = google_apis::GDATA_OTHER_ERROR; 1017 google_apis::GDataErrorCode error2 = google_apis::GDATA_OTHER_ERROR;
1016 scheduler_->UploadNewFile( 1018 scheduler_->UploadNewFile(
1017 fake_drive_service_->GetRootResourceId(), 1019 fake_drive_service_->GetRootResourceId(),
1018 base::FilePath::FromUTF8Unsafe("dummy/path"), 1020 base::FilePath::FromUTF8Unsafe("dummy/path"),
1019 upload_path, 1021 upload_path,
1020 "dummy title 2", 1022 "dummy title 2",
1021 "text/plain", 1023 "text/plain",
1024 DriveUploader::UploadNewFileOptions(),
1022 ClientContext(BACKGROUND), 1025 ClientContext(BACKGROUND),
1023 google_apis::test_util::CreateCopyResultCallback(&error2, &entry)); 1026 google_apis::test_util::CreateCopyResultCallback(&error2, &entry));
1024 1027
1025 // Cancel the first one. 1028 // Cancel the first one.
1026 scheduler_->CancelJob(first_job_id); 1029 scheduler_->CancelJob(first_job_id);
1027 1030
1028 // Only the first job should be cancelled. 1031 // Only the first job should be cancelled.
1029 ConnectToWifi(); 1032 ConnectToWifi();
1030 base::RunLoop().RunUntilIdle(); 1033 base::RunLoop().RunUntilIdle();
1031 EXPECT_EQ(google_apis::GDATA_CANCELLED, error1); 1034 EXPECT_EQ(google_apis::GDATA_CANCELLED, error1);
(...skipping 12 matching lines...) Expand all
1044 // Run as a cancelable task. 1047 // Run as a cancelable task.
1045 fake_drive_service_->set_upload_new_file_cancelable(true); 1048 fake_drive_service_->set_upload_new_file_cancelable(true);
1046 google_apis::GDataErrorCode error1 = google_apis::GDATA_OTHER_ERROR; 1049 google_apis::GDataErrorCode error1 = google_apis::GDATA_OTHER_ERROR;
1047 scoped_ptr<google_apis::ResourceEntry> entry; 1050 scoped_ptr<google_apis::ResourceEntry> entry;
1048 scheduler_->UploadNewFile( 1051 scheduler_->UploadNewFile(
1049 fake_drive_service_->GetRootResourceId(), 1052 fake_drive_service_->GetRootResourceId(),
1050 base::FilePath::FromUTF8Unsafe("dummy/path"), 1053 base::FilePath::FromUTF8Unsafe("dummy/path"),
1051 upload_path, 1054 upload_path,
1052 "dummy title 1", 1055 "dummy title 1",
1053 "text/plain", 1056 "text/plain",
1057 DriveUploader::UploadNewFileOptions(),
1054 ClientContext(USER_INITIATED), 1058 ClientContext(USER_INITIATED),
1055 google_apis::test_util::CreateCopyResultCallback(&error1, &entry)); 1059 google_apis::test_util::CreateCopyResultCallback(&error1, &entry));
1056 1060
1057 const std::vector<JobInfo>& jobs = scheduler_->GetJobInfoList(); 1061 const std::vector<JobInfo>& jobs = scheduler_->GetJobInfoList();
1058 ASSERT_EQ(1u, jobs.size()); 1062 ASSERT_EQ(1u, jobs.size());
1059 ASSERT_EQ(STATE_RUNNING, jobs[0].state); // It's running. 1063 ASSERT_EQ(STATE_RUNNING, jobs[0].state); // It's running.
1060 JobID first_job_id = jobs[0].job_id; 1064 JobID first_job_id = jobs[0].job_id;
1061 1065
1062 // Start the second job normally. 1066 // Start the second job normally.
1063 fake_drive_service_->set_upload_new_file_cancelable(false); 1067 fake_drive_service_->set_upload_new_file_cancelable(false);
1064 google_apis::GDataErrorCode error2 = google_apis::GDATA_OTHER_ERROR; 1068 google_apis::GDataErrorCode error2 = google_apis::GDATA_OTHER_ERROR;
1065 scheduler_->UploadNewFile( 1069 scheduler_->UploadNewFile(
1066 fake_drive_service_->GetRootResourceId(), 1070 fake_drive_service_->GetRootResourceId(),
1067 base::FilePath::FromUTF8Unsafe("dummy/path"), 1071 base::FilePath::FromUTF8Unsafe("dummy/path"),
1068 upload_path, 1072 upload_path,
1069 "dummy title 2", 1073 "dummy title 2",
1070 "text/plain", 1074 "text/plain",
1075 DriveUploader::UploadNewFileOptions(),
1071 ClientContext(USER_INITIATED), 1076 ClientContext(USER_INITIATED),
1072 google_apis::test_util::CreateCopyResultCallback(&error2, &entry)); 1077 google_apis::test_util::CreateCopyResultCallback(&error2, &entry));
1073 1078
1074 // Cancel the first one. 1079 // Cancel the first one.
1075 scheduler_->CancelJob(first_job_id); 1080 scheduler_->CancelJob(first_job_id);
1076 1081
1077 // Only the first job should be cancelled. 1082 // Only the first job should be cancelled.
1078 base::RunLoop().RunUntilIdle(); 1083 base::RunLoop().RunUntilIdle();
1079 EXPECT_EQ(google_apis::GDATA_CANCELLED, error1); 1084 EXPECT_EQ(google_apis::GDATA_CANCELLED, error1);
1080 EXPECT_EQ(google_apis::HTTP_SUCCESS, error2); 1085 EXPECT_EQ(google_apis::HTTP_SUCCESS, error2);
1081 EXPECT_TRUE(scheduler_->GetJobInfoList().empty()); 1086 EXPECT_TRUE(scheduler_->GetJobInfoList().empty());
1082 } 1087 }
1083 1088
1084 } // namespace drive 1089 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/job_scheduler.cc ('k') | chrome/browser/chromeos/drive/sync/entry_update_performer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698