Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / sync_file_system / drive_backend / fake_drive_service_helper.cc
index 0772f09..76d5d5a 100644 (file)
@@ -11,7 +11,6 @@
 #include "base/threading/sequenced_worker_pool.h"
 #include "chrome/browser/sync_file_system/sync_file_system_test_util.h"
 #include "chrome/browser/sync_file_system/sync_status_code.h"
-#include "content/public/test/test_browser_thread.h"
 #include "google_apis/drive/drive_api_parser.h"
 #include "google_apis/drive/gdata_wapi_parser.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -65,8 +64,6 @@ FakeDriveServiceHelper::~FakeDriveServiceHelper() {
 GDataErrorCode FakeDriveServiceHelper::AddOrphanedFolder(
     const std::string& title,
     std::string* folder_id) {
-  EXPECT_TRUE(folder_id);
-
   std::string root_folder_id = fake_drive_service_->GetRootResourceId();
   GDataErrorCode error = AddFolder(root_folder_id, title, folder_id);
   if (error != google_apis::HTTP_CREATED)
@@ -78,7 +75,7 @@ GDataErrorCode FakeDriveServiceHelper::AddOrphanedFolder(
       CreateResultReceiver(&error));
   base::RunLoop().RunUntilIdle();
 
-  if (error != google_apis::HTTP_NO_CONTENT)
+  if (error != google_apis::HTTP_NO_CONTENT && folder_id)
     return error;
   return google_apis::HTTP_CREATED;
 }
@@ -87,16 +84,15 @@ GDataErrorCode FakeDriveServiceHelper::AddFolder(
     const std::string& parent_folder_id,
     const std::string& title,
     std::string* folder_id) {
-  EXPECT_TRUE(folder_id);
-
   GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
   scoped_ptr<ResourceEntry> folder;
   fake_drive_service_->AddNewDirectory(
       parent_folder_id, title,
+      drive::DriveServiceInterface::AddNewDirectoryOptions(),
       CreateResultReceiver(&error, &folder));
   base::RunLoop().RunUntilIdle();
 
-  if (error == google_apis::HTTP_CREATED)
+  if (error == google_apis::HTTP_CREATED && folder_id)
     *folder_id = folder->resource_id();
   return error;
 }
@@ -106,7 +102,6 @@ GDataErrorCode FakeDriveServiceHelper::AddFile(
     const std::string& title,
     const std::string& content,
     std::string* file_id) {
-  EXPECT_TRUE(file_id);
   base::FilePath temp_file = WriteToTempFile(content);
 
   GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
@@ -119,7 +114,7 @@ GDataErrorCode FakeDriveServiceHelper::AddFile(
       google_apis::ProgressCallback());
   base::RunLoop().RunUntilIdle();
 
-  if (error == google_apis::HTTP_SUCCESS)
+  if (error == google_apis::HTTP_SUCCESS && file_id)
     *file_id = file->resource_id();
   return error;
 }
@@ -161,6 +156,23 @@ GDataErrorCode FakeDriveServiceHelper::TrashResource(
   return error;
 }
 
+GDataErrorCode FakeDriveServiceHelper::UpdateModificationTime(
+    const std::string& file_id,
+    const base::Time& modification_time) {
+  GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
+  scoped_ptr<ResourceEntry> entry;
+  error = GetResourceEntry(file_id, &entry);
+  if (error != google_apis::HTTP_SUCCESS)
+    return error;
+
+  fake_drive_service_->UpdateResource(
+      file_id, std::string(), entry->title(),
+      modification_time, entry->last_viewed_time(),
+      CreateResultReceiver(&error, &entry));
+  base::RunLoop().RunUntilIdle();
+  return error;
+}
+
 GDataErrorCode FakeDriveServiceHelper::RenameResource(
     const std::string& file_id,
     const std::string& new_title) {