Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / drive / job_scheduler_unittest.cc
index fb58dce..0d8c317 100644 (file)
@@ -14,6 +14,7 @@
 #include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "chrome/browser/chromeos/drive/test_util.h"
+#include "chrome/browser/drive/event_logger.h"
 #include "chrome/browser/drive/fake_drive_service.h"
 #include "chrome/common/pref_names.h"
 #include "content/public/test/test_browser_thread_bundle.h"
@@ -135,6 +136,8 @@ class JobSchedulerTest : public testing::Test {
     fake_network_change_notifier_.reset(
         new test_util::FakeNetworkChangeNotifier);
 
+    logger_.reset(new EventLogger);
+
     fake_drive_service_.reset(new CancelTestableFakeDriveService);
     fake_drive_service_->LoadResourceListForWapi(
         "gdata/root_feed.json");
@@ -144,6 +147,7 @@ class JobSchedulerTest : public testing::Test {
         "drive/applist.json");
 
     scheduler_.reset(new JobScheduler(pref_service_.get(),
+                                      logger_.get(),
                                       fake_drive_service_.get(),
                                       base::MessageLoopProxy::current().get()));
     scheduler_->SetDisableThrottling(true);
@@ -184,6 +188,7 @@ class JobSchedulerTest : public testing::Test {
   scoped_ptr<TestingPrefServiceSimple> pref_service_;
   scoped_ptr<test_util::FakeNetworkChangeNotifier>
       fake_network_change_notifier_;
+  scoped_ptr<EventLogger> logger_;
   scoped_ptr<CancelTestableFakeDriveService> fake_drive_service_;
   scoped_ptr<JobScheduler> scheduler_;
 };
@@ -275,6 +280,7 @@ TEST_F(JobSchedulerTest, GetChangeList) {
     fake_drive_service_->AddNewDirectory(
         fake_drive_service_->GetRootResourceId(),
         "new directory",
+        DriveServiceInterface::AddNewDirectoryOptions(),
         google_apis::test_util::CreateCopyResultCallback(
             &error, &resource_entry));
     base::RunLoop().RunUntilIdle();
@@ -499,6 +505,8 @@ TEST_F(JobSchedulerTest, AddNewDirectory) {
   scheduler_->AddNewDirectory(
       fake_drive_service_->GetRootResourceId(),  // Root directory.
       "New Directory",
+      DriveServiceInterface::AddNewDirectoryOptions(),
+      ClientContext(USER_INITIATED),
       google_apis::test_util::CreateCopyResultCallback(&error, &entry));
   base::RunLoop().RunUntilIdle();
 
@@ -507,18 +515,14 @@ TEST_F(JobSchedulerTest, AddNewDirectory) {
 }
 
 TEST_F(JobSchedulerTest, PriorityHandling) {
-  const base::FilePath kDummyFilePath(FILE_PATH_LITERAL("dummy"));
-
   // Saturate the metadata job queue with uninteresting jobs to prevent
   // following jobs from starting.
   google_apis::GDataErrorCode error_dontcare = google_apis::GDATA_OTHER_ERROR;
   scoped_ptr<google_apis::ResourceEntry> entry_dontcare;
   for (int i = 0; i < GetMetadataQueueMaxJobCount(); ++i) {
-    scheduler_->CreateFile(
-        fake_drive_service_->GetRootResourceId(),
-        kDummyFilePath,
-        base::StringPrintf("uninteresting file %d", i),
-        "text/plain",
+    std::string resource_id("file:2_file_resource_id");
+    scheduler_->GetResourceEntry(
+        resource_id,
         ClientContext(USER_INITIATED),
         google_apis::test_util::CreateCopyResultCallback(&error_dontcare,
                                                          &entry_dontcare));
@@ -531,32 +535,28 @@ TEST_F(JobSchedulerTest, PriorityHandling) {
   std::string title_4("new file 4");
   std::vector<std::string> titles;
 
-  scheduler_->CreateFile(
+  scheduler_->AddNewDirectory(
       fake_drive_service_->GetRootResourceId(),
-      kDummyFilePath,
       title_1,
-      "text/plain",
+      DriveServiceInterface::AddNewDirectoryOptions(),
       ClientContext(USER_INITIATED),
       base::Bind(&CopyTitleFromGetResourceEntryCallback, &titles));
-  scheduler_->CreateFile(
+  scheduler_->AddNewDirectory(
       fake_drive_service_->GetRootResourceId(),
-      kDummyFilePath,
       title_2,
-      "text/plain",
+      DriveServiceInterface::AddNewDirectoryOptions(),
       ClientContext(BACKGROUND),
       base::Bind(&CopyTitleFromGetResourceEntryCallback, &titles));
-  scheduler_->CreateFile(
+  scheduler_->AddNewDirectory(
       fake_drive_service_->GetRootResourceId(),
-      kDummyFilePath,
       title_3,
-      "text/plain",
+      DriveServiceInterface::AddNewDirectoryOptions(),
       ClientContext(BACKGROUND),
       base::Bind(&CopyTitleFromGetResourceEntryCallback, &titles));
-  scheduler_->CreateFile(
+  scheduler_->AddNewDirectory(
       fake_drive_service_->GetRootResourceId(),
-      kDummyFilePath,
       title_4,
-      "text/plain",
+      DriveServiceInterface::AddNewDirectoryOptions(),
       ClientContext(USER_INITIATED),
       base::Bind(&CopyTitleFromGetResourceEntryCallback, &titles));
 
@@ -572,13 +572,12 @@ TEST_F(JobSchedulerTest, PriorityHandling) {
 TEST_F(JobSchedulerTest, NoConnectionUserInitiated) {
   ConnectToNone();
 
+  std::string resource_id("file:2_file_resource_id");
+
   google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
   scoped_ptr<google_apis::ResourceEntry> entry;
-  scheduler_->CreateFile(
-      fake_drive_service_->GetRootResourceId(),
-      base::FilePath(FILE_PATH_LITERAL("dummy")),
-      "title",
-      "text/plain",
+  scheduler_->GetResourceEntry(
+      resource_id,
       ClientContext(USER_INITIATED),
       google_apis::test_util::CreateCopyResultCallback(&error, &entry));
   base::RunLoop().RunUntilIdle();
@@ -593,11 +592,8 @@ TEST_F(JobSchedulerTest, NoConnectionBackground) {
 
   google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
   scoped_ptr<google_apis::ResourceEntry> entry;
-  scheduler_->CreateFile(
-      fake_drive_service_->GetRootResourceId(),
-      base::FilePath(FILE_PATH_LITERAL("dummy")),
-      "title",
-      "text/plain",
+  scheduler_->GetResourceEntry(
+      resource_id,
       ClientContext(BACKGROUND),
       google_apis::test_util::CreateCopyResultCallback(&error, &entry));
   base::RunLoop().RunUntilIdle();
@@ -611,7 +607,6 @@ TEST_F(JobSchedulerTest, NoConnectionBackground) {
 
   EXPECT_EQ(google_apis::HTTP_SUCCESS, error);
   ASSERT_TRUE(entry);
-  EXPECT_EQ("title", entry->title());
 }
 
 TEST_F(JobSchedulerTest, DownloadFileCellularDisabled) {
@@ -833,6 +828,8 @@ TEST_F(JobSchedulerTest, JobInfo) {
   scheduler_->AddNewDirectory(
       fake_drive_service_->GetRootResourceId(),
       "New Directory",
+      DriveServiceInterface::AddNewDirectoryOptions(),
+      ClientContext(USER_INITIATED),
       google_apis::test_util::CreateCopyResultCallback(&error, &entry));
   expected_types.insert(TYPE_GET_ABOUT_RESOURCE);
   scheduler_->GetAboutResource(
@@ -971,6 +968,7 @@ TEST_F(JobSchedulerTest, JobInfoProgress) {
       path,
       "dummy title",
       "plain/plain",
+      DriveUploader::UploadNewFileOptions(),
       ClientContext(BACKGROUND),
       google_apis::test_util::CreateCopyResultCallback(&upload_error, &entry));
   base::RunLoop().RunUntilIdle();
@@ -1003,6 +1001,7 @@ TEST_F(JobSchedulerTest, CancelPendingJob) {
       upload_path,
       "dummy title 1",
       "text/plain",
+      DriveUploader::UploadNewFileOptions(),
       ClientContext(BACKGROUND),
       google_apis::test_util::CreateCopyResultCallback(&error1, &entry));
 
@@ -1019,6 +1018,7 @@ TEST_F(JobSchedulerTest, CancelPendingJob) {
       upload_path,
       "dummy title 2",
       "text/plain",
+      DriveUploader::UploadNewFileOptions(),
       ClientContext(BACKGROUND),
       google_apis::test_util::CreateCopyResultCallback(&error2, &entry));
 
@@ -1051,6 +1051,7 @@ TEST_F(JobSchedulerTest, CancelRunningJob) {
       upload_path,
       "dummy title 1",
       "text/plain",
+      DriveUploader::UploadNewFileOptions(),
       ClientContext(USER_INITIATED),
       google_apis::test_util::CreateCopyResultCallback(&error1, &entry));
 
@@ -1068,6 +1069,7 @@ TEST_F(JobSchedulerTest, CancelRunningJob) {
       upload_path,
       "dummy title 2",
       "text/plain",
+      DriveUploader::UploadNewFileOptions(),
       ClientContext(USER_INITIATED),
       google_apis::test_util::CreateCopyResultCallback(&error2, &entry));