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

Unified Diff: sync/syncable/directory_unittest.cc

Issue 283143002: sync: Improve handling of bad UniquePos (retry) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | « sync/syncable/directory_backing_store.cc ('k') | sync/syncable/syncable_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/syncable/directory_unittest.cc
diff --git a/sync/syncable/directory_unittest.cc b/sync/syncable/directory_unittest.cc
index f58f54f9b9ba09ed0b57cab55d0b2612c3449f81..6b6b8a2699c27a9fe2343d09aaa2a0dddf1f5cd0 100644
--- a/sync/syncable/directory_unittest.cc
+++ b/sync/syncable/directory_unittest.cc
@@ -81,6 +81,11 @@ DirOpenResult SyncableDirectoryTest::ReopenDirectory() {
DirOpenResult open_result =
dir_->Open(kDirectoryName, &delegate_, NullTransactionObserver());
+
+ if (open_result != OPENED) {
+ dir_.reset();
+ }
+
return open_result;
}
@@ -1221,6 +1226,38 @@ TEST_F(SyncableDirectoryTest, PositionWithNullSurvivesSaveAndReload) {
}
}
+// Any item with BOOKMARKS in their local specifics should have a valid local
+// unique position. If there is an item in the loaded DB that does not match
+// this criteria, we consider the whole DB to be corrupt.
+TEST_F(SyncableDirectoryTest, BadPositionCountsAsCorruption) {
+ TestIdFactory id_factory;
+
+ {
+ WriteTransaction trans(FROM_HERE, UNITTEST, dir().get());
+
+ MutableEntry parent(&trans, CREATE, BOOKMARKS, id_factory.root(), "parent");
+ parent.PutIsDir(true);
+ parent.PutIsUnsynced(true);
+
+ // The code is littered with DCHECKs that try to stop us from doing what
+ // we're about to do. Our work-around is to create a bookmark based on
+ // a server update, then update its local specifics without updating its
+ // local unique position.
+
+ MutableEntry child(
+ &trans, CREATE_NEW_UPDATE_ITEM, id_factory.MakeServer("child"));
+ sync_pb::EntitySpecifics specifics;
+ AddDefaultFieldValue(BOOKMARKS, &specifics);
+ child.PutIsUnappliedUpdate(true);
+ child.PutSpecifics(specifics);
+
+ EXPECT_TRUE(child.ShouldMaintainPosition());
+ EXPECT_TRUE(!child.GetUniquePosition().IsValid());
+ }
+
+ EXPECT_EQ(FAILED_DATABASE_CORRUPT, SimulateSaveAndReloadDir());
+}
+
TEST_F(SyncableDirectoryTest, General) {
int64 written_metahandle;
const Id id = TestIdFactory::FromNumber(99);
« no previous file with comments | « sync/syncable/directory_backing_store.cc ('k') | sync/syncable/syncable_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698