| 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);
|
|
|