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

Unified Diff: chrome/browser/sync/profile_sync_service_bookmark_unittest.cc

Issue 277033002: [Sync] Make BookmarkChangeProcessor resilient against updates before add (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CreateOrUpdate Created 6 years, 7 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/sync/glue/bookmark_change_processor.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/profile_sync_service_bookmark_unittest.cc
diff --git a/chrome/browser/sync/profile_sync_service_bookmark_unittest.cc b/chrome/browser/sync/profile_sync_service_bookmark_unittest.cc
index 44a493fba95f82b1622f991fc0670fb40e1576a7..290f5405a6d6019e703585409bc5191317df5331 100644
--- a/chrome/browser/sync/profile_sync_service_bookmark_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_bookmark_unittest.cc
@@ -725,6 +725,7 @@ class ProfileSyncServiceBookmarkTest : public testing::Test {
}
protected:
+ TestingProfile profile_;
BookmarkModel* model_;
syncer::TestUserShare test_user_share_;
scoped_ptr<BookmarkChangeProcessor> change_processor_;
@@ -740,8 +741,6 @@ class ProfileSyncServiceBookmarkTest : public testing::Test {
syncer::SyncMergeResult local_merge_result_;
syncer::SyncMergeResult syncer_merge_result_;
-
- TestingProfile profile_;
};
TEST_F(ProfileSyncServiceBookmarkTest, InitialState) {
@@ -2136,6 +2135,39 @@ TEST_F(ProfileSyncServiceBookmarkTestWithData, PersistenceError) {
EXPECT_FALSE(AssociateModels());
}
+// It's possible for update/add calls from the bookmark model to be out of
+// order, or asynchronous. Handle that without triggering an error.
+TEST_F(ProfileSyncServiceBookmarkTest, UpdateThenAdd) {
+ LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE);
+ StartSync();
+
+ EXPECT_TRUE(other_bookmarks_id());
+ EXPECT_TRUE(bookmark_bar_id());
+ EXPECT_TRUE(mobile_bookmarks_id());
+
+ ExpectModelMatch();
+
+ // Now destroy the change processor then add a bookmark, to simulate
+ // missing the Update call.
+ change_processor_.reset();
+ const BookmarkNode* node = model_->AddURL(model_->bookmark_bar_node(),
+ 0,
+ base::ASCIIToUTF16("title"),
+ GURL("http://www.url.com"));
+
+ // Recreate the change processor then update that bookmark. Sync should
+ // receive the update call and gracefully treat that as if it were an add.
+ change_processor_.reset(new BookmarkChangeProcessor(
+ &profile_, model_associator_.get(), &mock_error_handler_));
+ change_processor_->Start(test_user_share_.user_share());
+ model_->SetTitle(node, base::ASCIIToUTF16("title2"));
+ ExpectModelMatch();
+
+ // Then simulate the add call arriving late.
+ change_processor_->BookmarkNodeAdded(model_, model_->bookmark_bar_node(), 0);
+ ExpectModelMatch();
+}
+
} // namespace
} // namespace browser_sync
« no previous file with comments | « chrome/browser/sync/glue/bookmark_change_processor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698