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

Unified Diff: sync/syncable/directory_unittest.cc

Issue 1008993004: Sync: Handle empty (implicit) ParentId in GetPredecessorId and GetSuccessorId (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added extra unit test. Created 5 years, 9 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.cc ('k') | sync/syncable/parent_child_index.h » ('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 5f8cbed23c2225e3827f09a905586f6f8e4eaa5a..4c8531cf1a269cf3680b5532bcfb74ac230a8e94 100644
--- a/sync/syncable/directory_unittest.cc
+++ b/sync/syncable/directory_unittest.cc
@@ -1880,6 +1880,51 @@ TEST_F(SyncableDirectoryTest, MutableEntry_ImplicitParentId) {
}
}
+// Verify that the successor / predecessor navigation still works for
+// directory entries with unset Parent IDs.
+TEST_F(SyncableDirectoryTest, MutableEntry_ImplicitParentId_Siblings) {
+ TestIdFactory id_factory;
+ const Id root_id = TestIdFactory::root();
+ const Id p_root_id = id_factory.NewServerId();
+ const Id item1_id = id_factory.FromNumber(1);
+ const Id item2_id = id_factory.FromNumber(2);
+
+ // Create type root folder for PREFERENCES.
+ {
+ WriteTransaction trans(FROM_HERE, UNITTEST, dir().get());
+ MutableEntry p_root(&trans, CREATE, PREFERENCES, root_id, "P");
+ ASSERT_TRUE(p_root.good());
+ p_root.PutIsDir(true);
+ p_root.PutId(p_root_id);
+ p_root.PutBaseVersion(1);
+ }
+
+ // Create two PREFERENCES entries with implicit parent nodes.
+ {
+ WriteTransaction trans(FROM_HERE, UNITTEST, dir().get());
+ MutableEntry item1(&trans, CREATE, PREFERENCES, "P1");
+ item1.PutBaseVersion(1);
+ item1.PutId(item1_id);
+ MutableEntry item2(&trans, CREATE, PREFERENCES, "P2");
+ item2.PutBaseVersion(1);
+ item2.PutId(item2_id);
+ }
+
+ // Verify GetSuccessorId and GetPredecessorId calls for these items.
+ // Please note that items are sorted according to their ID, e.g.
+ // item1 first, then item2.
+ {
+ ReadTransaction trans(FROM_HERE, dir().get());
+ Entry item1(&trans, GET_BY_ID, item1_id);
+ EXPECT_EQ(Id(), item1.GetPredecessorId());
+ EXPECT_EQ(item2_id, item1.GetSuccessorId());
+
+ Entry item2(&trans, GET_BY_ID, item2_id);
+ EXPECT_EQ(item1_id, item2.GetPredecessorId());
+ EXPECT_EQ(Id(), item2.GetSuccessorId());
+ }
+}
+
} // namespace syncable
} // namespace syncer
« no previous file with comments | « sync/syncable/directory.cc ('k') | sync/syncable/parent_child_index.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698