Index: chrome/browser/chromeos/drive/file_system/remove_operation_unittest.cc |
diff --git a/chrome/browser/chromeos/drive/file_system/remove_operation_unittest.cc b/chrome/browser/chromeos/drive/file_system/remove_operation_unittest.cc |
index 8916267068029f193855a2437f0d5f67a548a456..ce23874203e55a48af0a08b28e6d9ea79a32041e 100644 |
--- a/chrome/browser/chromeos/drive/file_system/remove_operation_unittest.cc |
+++ b/chrome/browser/chromeos/drive/file_system/remove_operation_unittest.cc |
@@ -5,8 +5,7 @@ |
#include "chrome/browser/chromeos/drive/file_system/remove_operation.h" |
#include "chrome/browser/chromeos/drive/file_system/operation_test_base.h" |
-#include "chrome/browser/drive/fake_drive_service.h" |
-#include "chrome/browser/google_apis/gdata_wapi_parser.h" |
+#include "chrome/browser/chromeos/drive/file_system_util.h" |
#include "chrome/browser/google_apis/test_util.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -16,10 +15,9 @@ namespace file_system { |
typedef OperationTestBase RemoveOperationTest; |
TEST_F(RemoveOperationTest, RemoveFile) { |
- RemoveOperation operation(blocking_task_runner(), observer(), scheduler(), |
- metadata(), cache()); |
+ RemoveOperation operation(blocking_task_runner(), observer(), metadata(), |
+ cache()); |
- base::FilePath my_drive(FILE_PATH_LITERAL("drive/root")); |
base::FilePath nonexisting_file( |
FILE_PATH_LITERAL("drive/root/Dummy file.txt")); |
base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
@@ -37,6 +35,10 @@ TEST_F(RemoveOperationTest, RemoveFile) { |
EXPECT_EQ(FILE_ERROR_OK, error); |
EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(file_in_root, &entry)); |
+ const std::string id_file_in_root = entry.local_id(); |
+ EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntryById(id_file_in_root, &entry)); |
+ EXPECT_EQ(util::kDriveTrashDirLocalId, entry.parent_local_id()); |
+ |
// Remove a file in subdirectory. |
error = FILE_ERROR_FAILED; |
ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(file_in_subdir, &entry)); |
@@ -50,22 +52,16 @@ TEST_F(RemoveOperationTest, RemoveFile) { |
EXPECT_EQ(FILE_ERROR_NOT_FOUND, |
GetLocalResourceEntry(file_in_subdir, &entry)); |
- // Verify the file is indeed removed in the server. |
- google_apis::GDataErrorCode gdata_error = google_apis::GDATA_OTHER_ERROR; |
- scoped_ptr<google_apis::ResourceEntry> gdata_entry; |
- fake_service()->GetResourceEntry( |
- resource_id, |
- google_apis::test_util::CreateCopyResultCallback(&gdata_error, |
- &gdata_entry)); |
- test_util::RunBlockingPoolTask(); |
- ASSERT_EQ(google_apis::HTTP_SUCCESS, gdata_error); |
- EXPECT_TRUE(gdata_entry->deleted()); |
+ const std::string id_file_in_subdir = entry.local_id(); |
+ EXPECT_EQ(FILE_ERROR_OK, |
+ GetLocalResourceEntryById(id_file_in_subdir, &entry)); |
+ EXPECT_EQ(util::kDriveTrashDirLocalId, entry.parent_local_id()); |
// Try removing non-existing file. |
error = FILE_ERROR_FAILED; |
ASSERT_EQ(FILE_ERROR_NOT_FOUND, |
GetLocalResourceEntry(nonexisting_file, &entry)); |
- operation.Remove(base::FilePath::FromUTF8Unsafe("drive/root/Dummy file.txt"), |
+ operation.Remove(nonexisting_file, |
false, // is_recursive |
google_apis::test_util::CreateCopyResultCallback(&error)); |
test_util::RunBlockingPoolTask(); |
@@ -75,11 +71,15 @@ TEST_F(RemoveOperationTest, RemoveFile) { |
EXPECT_EQ(2U, observer()->get_changed_paths().size()); |
EXPECT_TRUE(observer()->get_changed_paths().count(file_in_root.DirName())); |
EXPECT_TRUE(observer()->get_changed_paths().count(file_in_subdir.DirName())); |
+ |
+ EXPECT_EQ(2U, observer()->removed_local_ids().size()); |
+ EXPECT_TRUE(observer()->removed_local_ids().count(id_file_in_root)); |
+ EXPECT_TRUE(observer()->removed_local_ids().count(id_file_in_subdir)); |
} |
TEST_F(RemoveOperationTest, RemoveDirectory) { |
- RemoveOperation operation(blocking_task_runner(), observer(), scheduler(), |
- metadata(), cache()); |
+ RemoveOperation operation(blocking_task_runner(), observer(), metadata(), |
+ cache()); |
base::FilePath empty_dir(FILE_PATH_LITERAL( |
"drive/root/Directory 1/Sub Directory Folder/Sub Sub Directory Folder")); |
@@ -126,54 +126,5 @@ TEST_F(RemoveOperationTest, RemoveDirectory) { |
GetLocalResourceEntry(file_in_non_empty_dir, &entry)); |
} |
-TEST_F(RemoveOperationTest, RemoveShared) { |
- RemoveOperation operation(blocking_task_runner(), observer(), scheduler(), |
- metadata(), cache()); |
- |
- const base::FilePath kPathInMyDrive(FILE_PATH_LITERAL( |
- "drive/root/shared.txt")); |
- const base::FilePath kPathInOther(FILE_PATH_LITERAL( |
- "drive/other/shared.txt")); |
- |
- // Prepare a shared file to the root folder. |
- google_apis::GDataErrorCode gdata_error = google_apis::GDATA_OTHER_ERROR; |
- scoped_ptr<google_apis::ResourceEntry> gdata_entry; |
- fake_service()->AddNewFile( |
- "text/plain", |
- "dummy content", |
- fake_service()->GetRootResourceId(), |
- kPathInMyDrive.BaseName().AsUTF8Unsafe(), |
- true, // shared_with_me, |
- google_apis::test_util::CreateCopyResultCallback(&gdata_error, |
- &gdata_entry)); |
- test_util::RunBlockingPoolTask(); |
- ASSERT_EQ(google_apis::HTTP_CREATED, gdata_error); |
- CheckForUpdates(); |
- |
- // Remove it. Locally, the file should be moved to drive/other. |
- FileError error = FILE_ERROR_FAILED; |
- ResourceEntry entry; |
- operation.Remove(kPathInMyDrive, |
- false, // is_recursive |
- google_apis::test_util::CreateCopyResultCallback(&error)); |
- test_util::RunBlockingPoolTask(); |
- EXPECT_EQ(FILE_ERROR_OK, error); |
- EXPECT_EQ(FILE_ERROR_NOT_FOUND, |
- GetLocalResourceEntry(kPathInMyDrive, &entry)); |
- EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(kPathInOther, &entry)); |
- |
- // Remotely, the entry should have lost its parent. |
- gdata_error = google_apis::GDATA_OTHER_ERROR; |
- const std::string resource_id = gdata_entry->resource_id(); |
- fake_service()->GetResourceEntry( |
- resource_id, |
- google_apis::test_util::CreateCopyResultCallback(&gdata_error, |
- &gdata_entry)); |
- test_util::RunBlockingPoolTask(); |
- ASSERT_EQ(google_apis::HTTP_SUCCESS, gdata_error); |
- EXPECT_FALSE(gdata_entry->deleted()); // It's not deleted. |
- EXPECT_FALSE(gdata_entry->GetLinkByType(google_apis::Link::LINK_PARENT)); |
-} |
- |
} // namespace file_system |
} // namespace drive |