| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/sync/remove_performer.h" | 5 #include "chrome/browser/chromeos/drive/sync/remove_performer.h" |
| 6 | 6 |
| 7 #include "base/task_runner_util.h" | 7 #include "base/task_runner_util.h" |
| 8 #include "chrome/browser/chromeos/drive/file_system/operation_test_base.h" | 8 #include "chrome/browser/chromeos/drive/file_system/operation_test_base.h" |
| 9 #include "chrome/browser/chromeos/drive/file_system_util.h" | 9 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 10 #include "chrome/browser/chromeos/drive/job_scheduler.h" | 10 #include "chrome/browser/chromeos/drive/job_scheduler.h" |
| 11 #include "chrome/browser/chromeos/drive/resource_metadata.h" | 11 #include "chrome/browser/chromeos/drive/resource_metadata.h" |
| 12 #include "chrome/browser/drive/fake_drive_service.h" | 12 #include "chrome/browser/drive/fake_drive_service.h" |
| 13 #include "content/public/test/test_utils.h" | 13 #include "content/public/test/test_utils.h" |
| 14 #include "google_apis/drive/drive_api_parser.h" | 14 #include "google_apis/drive/drive_api_parser.h" |
| 15 #include "google_apis/drive/test_util.h" | 15 #include "google_apis/drive/test_util.h" |
| 16 | 16 |
| 17 namespace drive { | 17 namespace drive { |
| 18 namespace internal { | 18 namespace internal { |
| 19 | 19 |
| 20 typedef file_system::OperationTestBase RemovePerformerTest; | 20 typedef file_system::OperationTestBase RemovePerformerTest; |
| 21 | 21 |
| 22 TEST_F(RemovePerformerTest, RemoveFile) { | 22 TEST_F(RemovePerformerTest, RemoveFile) { |
| 23 RemovePerformer performer(blocking_task_runner(), observer(), scheduler(), | 23 RemovePerformer performer(blocking_task_runner(), delegate(), scheduler(), |
| 24 metadata()); | 24 metadata()); |
| 25 | 25 |
| 26 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); | 26 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 27 base::FilePath file_in_subdir( | 27 base::FilePath file_in_subdir( |
| 28 FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")); | 28 FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")); |
| 29 | 29 |
| 30 // Remove a file in root. | 30 // Remove a file in root. |
| 31 ResourceEntry entry; | 31 ResourceEntry entry; |
| 32 FileError error = FILE_ERROR_FAILED; | 32 FileError error = FILE_ERROR_FAILED; |
| 33 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(file_in_root, &entry)); | 33 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(file_in_root, &entry)); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 62 // Try removing non-existing file. | 62 // Try removing non-existing file. |
| 63 error = FILE_ERROR_FAILED; | 63 error = FILE_ERROR_FAILED; |
| 64 performer.Remove("non-existing-id", | 64 performer.Remove("non-existing-id", |
| 65 ClientContext(USER_INITIATED), | 65 ClientContext(USER_INITIATED), |
| 66 google_apis::test_util::CreateCopyResultCallback(&error)); | 66 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 67 content::RunAllBlockingPoolTasksUntilIdle(); | 67 content::RunAllBlockingPoolTasksUntilIdle(); |
| 68 EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); | 68 EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); |
| 69 } | 69 } |
| 70 | 70 |
| 71 TEST_F(RemovePerformerTest, RemoveShared) { | 71 TEST_F(RemovePerformerTest, RemoveShared) { |
| 72 RemovePerformer performer(blocking_task_runner(), observer(), scheduler(), | 72 RemovePerformer performer(blocking_task_runner(), delegate(), scheduler(), |
| 73 metadata()); | 73 metadata()); |
| 74 | 74 |
| 75 const base::FilePath kPathInMyDrive(FILE_PATH_LITERAL( | 75 const base::FilePath kPathInMyDrive(FILE_PATH_LITERAL( |
| 76 "drive/root/shared.txt")); | 76 "drive/root/shared.txt")); |
| 77 const base::FilePath kPathInOther(FILE_PATH_LITERAL( | 77 const base::FilePath kPathInOther(FILE_PATH_LITERAL( |
| 78 "drive/other/shared.txt")); | 78 "drive/other/shared.txt")); |
| 79 | 79 |
| 80 // Prepare a shared file to the root folder. | 80 // Prepare a shared file to the root folder. |
| 81 google_apis::GDataErrorCode gdata_error = google_apis::GDATA_OTHER_ERROR; | 81 google_apis::GDataErrorCode gdata_error = google_apis::GDATA_OTHER_ERROR; |
| 82 scoped_ptr<google_apis::FileResource> gdata_entry; | 82 scoped_ptr<google_apis::FileResource> gdata_entry; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 112 resource_id, | 112 resource_id, |
| 113 google_apis::test_util::CreateCopyResultCallback(&gdata_error, | 113 google_apis::test_util::CreateCopyResultCallback(&gdata_error, |
| 114 &gdata_entry)); | 114 &gdata_entry)); |
| 115 content::RunAllBlockingPoolTasksUntilIdle(); | 115 content::RunAllBlockingPoolTasksUntilIdle(); |
| 116 ASSERT_EQ(google_apis::HTTP_SUCCESS, gdata_error); | 116 ASSERT_EQ(google_apis::HTTP_SUCCESS, gdata_error); |
| 117 EXPECT_FALSE(gdata_entry->labels().is_trashed()); // It's not deleted. | 117 EXPECT_FALSE(gdata_entry->labels().is_trashed()); // It's not deleted. |
| 118 EXPECT_TRUE(gdata_entry->parents().empty()); | 118 EXPECT_TRUE(gdata_entry->parents().empty()); |
| 119 } | 119 } |
| 120 | 120 |
| 121 TEST_F(RemovePerformerTest, RemoveLocallyCreatedFile) { | 121 TEST_F(RemovePerformerTest, RemoveLocallyCreatedFile) { |
| 122 RemovePerformer performer(blocking_task_runner(), observer(), scheduler(), | 122 RemovePerformer performer(blocking_task_runner(), delegate(), scheduler(), |
| 123 metadata()); | 123 metadata()); |
| 124 | 124 |
| 125 // Add an entry without resource ID. | 125 // Add an entry without resource ID. |
| 126 ResourceEntry entry; | 126 ResourceEntry entry; |
| 127 entry.set_title("New File.txt"); | 127 entry.set_title("New File.txt"); |
| 128 entry.set_parent_local_id(util::kDriveTrashDirLocalId); | 128 entry.set_parent_local_id(util::kDriveTrashDirLocalId); |
| 129 | 129 |
| 130 FileError error = FILE_ERROR_FAILED; | 130 FileError error = FILE_ERROR_FAILED; |
| 131 std::string local_id; | 131 std::string local_id; |
| 132 base::PostTaskAndReplyWithResult( | 132 base::PostTaskAndReplyWithResult( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 143 // Remove the entry. | 143 // Remove the entry. |
| 144 performer.Remove(local_id, ClientContext(USER_INITIATED), | 144 performer.Remove(local_id, ClientContext(USER_INITIATED), |
| 145 google_apis::test_util::CreateCopyResultCallback(&error)); | 145 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 146 content::RunAllBlockingPoolTasksUntilIdle(); | 146 content::RunAllBlockingPoolTasksUntilIdle(); |
| 147 EXPECT_EQ(FILE_ERROR_OK, error); | 147 EXPECT_EQ(FILE_ERROR_OK, error); |
| 148 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntryById(local_id, &entry)); | 148 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntryById(local_id, &entry)); |
| 149 } | 149 } |
| 150 | 150 |
| 151 } // namespace internal | 151 } // namespace internal |
| 152 } // namespace drive | 152 } // namespace drive |
| OLD | NEW |