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

Unified Diff: chrome/browser/chromeos/drive/sync/entry_update_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 | « no previous file | chrome/browser/chromeos/drive/sync/remove_performer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/drive/sync/entry_update_performer_unittest.cc
diff --git a/chrome/browser/chromeos/drive/sync/entry_update_performer_unittest.cc b/chrome/browser/chromeos/drive/sync/entry_update_performer_unittest.cc
index 54d77ddbc7cb0e22ae0c6c7e311df1b3962190f6..bcb3d5e969087f86e75d744eba80f65b62f84b53 100644
--- a/chrome/browser/chromeos/drive/sync/entry_update_performer_unittest.cc
+++ b/chrome/browser/chromeos/drive/sync/entry_update_performer_unittest.cc
@@ -551,5 +551,48 @@ TEST_F(EntryUpdatePerformerTest, UpdateEntry_CreateDirectory) {
EXPECT_TRUE(server_entry->IsDirectory());
}
+TEST_F(EntryUpdatePerformerTest, UpdateEntry_InsufficientPermission) {
+ base::FilePath src_path(
+ FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt"));
+
+ ResourceEntry src_entry;
+ EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &src_entry));
+
+ // Update local entry.
+ ResourceEntry updated_entry(src_entry);
+ updated_entry.set_title("Moved" + src_entry.title());
+ updated_entry.set_metadata_edit_state(ResourceEntry::DIRTY);
+
+ 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 update.
+ error = FILE_ERROR_FAILED;
+ performer_->UpdateEntry(
+ 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.title(), result_entry.title());
+}
+
} // namespace internal
} // namespace drive
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/sync/remove_performer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698