Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(763)

Unified Diff: chrome/browser/chromeos/drive/sync/remove_performer_unittest.cc

Issue 453843002: Add tests for sync performes about HTTP_FORBIDDEN handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/drive/sync/entry_update_performer_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1d6ed00938f3303a6bc9ea5cf06179632434e1f2..dc98b11d69936dbb658e72d90afd0770b4f69e0a 100644
--- a/chrome/browser/chromeos/drive/sync/remove_performer_unittest.cc
+++ b/chrome/browser/chromeos/drive/sync/remove_performer_unittest.cc
@@ -148,5 +148,52 @@ TEST_F(RemovePerformerTest, RemoveLocallyCreatedFile) {
EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntryById(local_id, &entry));
}
+TEST_F(RemovePerformerTest, Remove_InsufficientPermission) {
+ RemovePerformer performer(blocking_task_runner(), delegate(), scheduler(),
+ metadata());
+
+ base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt"));
+
+ ResourceEntry src_entry;
+ ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(file_in_root, &src_entry));
+
+ // Remove locally.
+ ResourceEntry updated_entry(src_entry);
+ updated_entry.set_parent_local_id(util::kDriveTrashDirLocalId);
+
+ FileError error = FILE_ERROR_FAILED;
+ base::PostTaskAndReplyWithResult(
+ blocking_task_runner(),
+ FROM_HERE,
+ base::Bind(&ResourceMetadata::RefreshEntry,
+ base::Unretained(metadata()),
+ updated_entry),
+ google_apis::test_util::CreateCopyResultCallback(&error));
+ content::RunAllBlockingPoolTasksUntilIdle();
+ EXPECT_EQ(FILE_ERROR_OK, error);
+
+ // Set user permission to forbid server side update.
+ EXPECT_EQ(google_apis::HTTP_SUCCESS, fake_service()->SetUserPermission(
+ src_entry.resource_id(), google_apis::drive::PERMISSION_ROLE_READER));
+
+ // Try to perform remove.
+ error = FILE_ERROR_FAILED;
+ performer.Remove(src_entry.local_id(),
+ ClientContext(USER_INITIATED),
+ google_apis::test_util::CreateCopyResultCallback(&error));
+ content::RunAllBlockingPoolTasksUntilIdle();
+ EXPECT_EQ(FILE_ERROR_OK, error);
+
+ // This should result in reverting the local change.
+ ResourceEntry result_entry;
+ EXPECT_EQ(FILE_ERROR_OK,
+ GetLocalResourceEntryById(src_entry.local_id(), &result_entry));
+ EXPECT_EQ(src_entry.parent_local_id(), result_entry.parent_local_id());
+
+ ASSERT_EQ(1U, delegate()->drive_sync_errors().size());
+ EXPECT_EQ(file_system::DRIVE_SYNC_ERROR_DELETE_WITHOUT_PERMISSION,
+ delegate()->drive_sync_errors()[0]);
+}
+
} // namespace internal
} // namespace drive
« no previous file with comments | « chrome/browser/chromeos/drive/sync/entry_update_performer_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698