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

Unified Diff: chrome/browser/chromeos/drive/sync_client_unittest.cc

Issue 372713004: Wait for parent directory sync before performing server-side copy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add operation_observer.cc 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
« no previous file with comments | « chrome/browser/chromeos/drive/sync_client.cc ('k') | chrome/chrome_browser_chromeos.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/drive/sync_client_unittest.cc
diff --git a/chrome/browser/chromeos/drive/sync_client_unittest.cc b/chrome/browser/chromeos/drive/sync_client_unittest.cc
index cb56dd2863d83657b2cb0f990acc8afc8804ca58..310008141b939ec956fcd451eaa2cef7ff7cd6f7 100644
--- a/chrome/browser/chromeos/drive/sync_client_unittest.cc
+++ b/chrome/browser/chromeos/drive/sync_client_unittest.cc
@@ -489,5 +489,38 @@ TEST_F(SyncClientTest, Dependencies) {
EXPECT_EQ(ResourceEntry::CLEAN, entry2.metadata_edit_state());
}
+TEST_F(SyncClientTest, WaitForUpdateTaskToComplete) {
+ // Create a directory locally.
+ const base::FilePath kPath(FILE_PATH_LITERAL("drive/root/dir1"));
+
+ ResourceEntry parent;
+ EXPECT_EQ(FILE_ERROR_OK,
+ metadata_->GetResourceEntryByPath(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);
+ std::string local_id;
+ EXPECT_EQ(FILE_ERROR_OK, metadata_->AddEntry(entry, &local_id));
+
+ // Sync task is not yet avialable.
+ FileError error = FILE_ERROR_FAILED;
+ EXPECT_FALSE(sync_client_->WaitForUpdateTaskToComplete(
+ local_id, google_apis::test_util::CreateCopyResultCallback(&error)));
+
+ // Start syncing the directory and wait for it to complete.
+ sync_client_->AddUpdateTask(ClientContext(USER_INITIATED), local_id);
+
+ EXPECT_TRUE(sync_client_->WaitForUpdateTaskToComplete(
+ local_id, google_apis::test_util::CreateCopyResultCallback(&error)));
+
+ base::RunLoop().RunUntilIdle();
+
+ // The callback is called.
+ EXPECT_EQ(FILE_ERROR_OK, error);
+}
+
} // namespace internal
} // namespace drive
« no previous file with comments | « chrome/browser/chromeos/drive/sync_client.cc ('k') | chrome/chrome_browser_chromeos.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698