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

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

Issue 391343002: Keep sync tasks alive as long as it's not finished (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
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 678e7ce158e870f382ff64fa5ca707f759829959..5718f8f143aba9403d2bc50fa55ffb6f69480246 100644
--- a/chrome/browser/chromeos/drive/sync/entry_update_performer_unittest.cc
+++ b/chrome/browser/chromeos/drive/sync/entry_update_performer_unittest.cc
@@ -550,5 +550,62 @@ TEST_F(EntryUpdatePerformerTest, UpdateEntry_CreateDirectory) {
EXPECT_TRUE(server_entry->IsDirectory());
}
+TEST_F(EntryUpdatePerformerTest, ParentNeedsToBeSynced) {
+ // Create new directories locally.
+ const base::FilePath kPath(FILE_PATH_LITERAL("drive/root/New Directory"));
+ const base::FilePath kChildPath(
+ FILE_PATH_LITERAL("drive/root/New Directory/Sub Directory"));
+
+ ResourceEntry parent;
+ EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(kPath.DirName(), &parent));
+
+ ResourceEntry entry;
+ entry.set_parent_local_id(parent.local_id());
+ entry.set_title(kPath.BaseName().AsUTF8Unsafe());
+ entry.mutable_file_info()->set_is_directory(true);
+ entry.set_metadata_edit_state(ResourceEntry::DIRTY);
+
+ FileError error = FILE_ERROR_FAILED;
+ std::string local_id;
+ base::PostTaskAndReplyWithResult(
+ blocking_task_runner(),
+ FROM_HERE,
+ base::Bind(&internal::ResourceMetadata::AddEntry,
+ base::Unretained(metadata()),
+ entry,
+ &local_id),
+ google_apis::test_util::CreateCopyResultCallback(&error));
+ test_util::RunBlockingPoolTask();
+ EXPECT_EQ(FILE_ERROR_OK, error);
+
+ ResourceEntry child;
+ child.set_parent_local_id(local_id);
+ child.set_title(kChildPath.BaseName().AsUTF8Unsafe());
+ child.mutable_file_info()->set_is_directory(true);
+ child.set_metadata_edit_state(ResourceEntry::DIRTY);
+
+ error = FILE_ERROR_FAILED;
+ std::string child_local_id;
+ base::PostTaskAndReplyWithResult(
+ blocking_task_runner(),
+ FROM_HERE,
+ base::Bind(&internal::ResourceMetadata::AddEntry,
+ base::Unretained(metadata()),
+ child,
+ &child_local_id),
+ google_apis::test_util::CreateCopyResultCallback(&error));
+ test_util::RunBlockingPoolTask();
+ EXPECT_EQ(FILE_ERROR_OK, error);
+
+ // Update the child. This should return a specific error code.
+ error = FILE_ERROR_FAILED;
+ performer_->UpdateEntry(
+ child_local_id,
+ ClientContext(USER_INITIATED),
+ google_apis::test_util::CreateCopyResultCallback(&error));
+ test_util::RunBlockingPoolTask();
+ EXPECT_EQ(FILE_ERROR_PARENT_NEEDS_TO_BE_SYNCED, error);
+}
+
} // namespace internal
} // namespace drive

Powered by Google App Engine
This is Rietveld 408576698