Index: chrome/browser/chromeos/drive/sync/remove_performer_unittest.cc |
diff --git a/chrome/browser/chromeos/drive/sync/remove_performer_unittest.cc b/chrome/browser/chromeos/drive/sync/remove_performer_unittest.cc |
index a24f0b25b5bd33c870fb4e935150a073fd4e4e6f..bb8e7f30fc829e7f4e1d2c9553986c4c837878bc 100644 |
--- a/chrome/browser/chromeos/drive/sync/remove_performer_unittest.cc |
+++ b/chrome/browser/chromeos/drive/sync/remove_performer_unittest.cc |
@@ -4,7 +4,10 @@ |
#include "chrome/browser/chromeos/drive/sync/remove_performer.h" |
+#include "base/task_runner_util.h" |
#include "chrome/browser/chromeos/drive/file_system/operation_test_base.h" |
+#include "chrome/browser/chromeos/drive/file_system_util.h" |
+#include "chrome/browser/chromeos/drive/resource_metadata.h" |
#include "chrome/browser/drive/fake_drive_service.h" |
#include "chrome/browser/google_apis/gdata_wapi_parser.h" |
#include "chrome/browser/google_apis/test_util.h" |
@@ -18,36 +21,35 @@ TEST_F(RemovePerformerTest, RemoveFile) { |
RemovePerformer performer(blocking_task_runner(), scheduler(), metadata()); |
base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
- base::FilePath file_in_subdir( |
- FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")); |
- // Remove a file in root. |
- ResourceEntry entry; |
+ // Mark the file as deleted. |
FileError error = FILE_ERROR_FAILED; |
+ ResourceEntry entry; |
ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(file_in_root, &entry)); |
- performer.Remove(entry.local_id(), |
- google_apis::test_util::CreateCopyResultCallback(&error)); |
+ entry.set_parent_local_id(util::kDriveOtherDirLocalId); |
+ entry.set_deleted(true); |
+ base::PostTaskAndReplyWithResult( |
+ blocking_task_runner(), |
+ FROM_HERE, |
+ base::Bind(&ResourceMetadata::RefreshEntry, |
+ base::Unretained(metadata()), |
+ entry), |
+ google_apis::test_util::CreateCopyResultCallback(&error)); |
test_util::RunBlockingPoolTask(); |
EXPECT_EQ(FILE_ERROR_OK, error); |
- EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(file_in_root, &entry)); |
- |
- // Remove a file in subdirectory. |
- error = FILE_ERROR_FAILED; |
- ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(file_in_subdir, &entry)); |
- const std::string resource_id = entry.resource_id(); |
+ // Remove the file. |
performer.Remove(entry.local_id(), |
google_apis::test_util::CreateCopyResultCallback(&error)); |
test_util::RunBlockingPoolTask(); |
EXPECT_EQ(FILE_ERROR_OK, error); |
- EXPECT_EQ(FILE_ERROR_NOT_FOUND, |
- GetLocalResourceEntry(file_in_subdir, &entry)); |
+ EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(file_in_root, &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, |
+ entry.resource_id(), |
google_apis::test_util::CreateCopyResultCallback(&gdata_error, |
&gdata_entry)); |
test_util::RunBlockingPoolTask(); |
@@ -85,10 +87,23 @@ TEST_F(RemovePerformerTest, RemoveShared) { |
ASSERT_EQ(google_apis::HTTP_CREATED, gdata_error); |
CheckForUpdates(); |
- // Remove it. Locally, the file should be moved to drive/other. |
+ // Mark the file as deleted. |
+ FileError error = FILE_ERROR_FAILED; |
ResourceEntry entry; |
ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(kPathInMyDrive, &entry)); |
- FileError error = FILE_ERROR_FAILED; |
+ entry.set_parent_local_id(util::kDriveOtherDirLocalId); |
+ entry.set_deleted(true); |
+ base::PostTaskAndReplyWithResult( |
+ blocking_task_runner(), |
+ FROM_HERE, |
+ base::Bind(&ResourceMetadata::RefreshEntry, |
+ base::Unretained(metadata()), |
+ entry), |
+ google_apis::test_util::CreateCopyResultCallback(&error)); |
+ test_util::RunBlockingPoolTask(); |
+ EXPECT_EQ(FILE_ERROR_OK, error); |
+ |
+ // Remove it. Locally, the file should be moved to drive/other. |
performer.Remove(entry.local_id(), |
google_apis::test_util::CreateCopyResultCallback(&error)); |
test_util::RunBlockingPoolTask(); |