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

Unified Diff: sync/syncable/parent_child_index_unittest.cc

Issue 1226213002: Sync: Support nodes with implicit permanent folders: Node Browser and out-of-order loading from DB (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed CR feedback Created 5 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
« sync/syncable/parent_child_index.cc ('K') | « sync/syncable/parent_child_index.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/syncable/parent_child_index_unittest.cc
diff --git a/sync/syncable/parent_child_index_unittest.cc b/sync/syncable/parent_child_index_unittest.cc
index f94c5b95b4215e17b2c7877d59a0eded7f089ff5..26ccb52148d5ea38e0aa8e7d4ad511855873ee23 100644
--- a/sync/syncable/parent_child_index_unittest.cc
+++ b/sync/syncable/parent_child_index_unittest.cc
@@ -158,9 +158,10 @@ TEST_F(ParentChildIndexTest, TestBookmarkRootFolder) {
EntryKernel* bm_folder = MakeBookmarkRoot();
EXPECT_TRUE(ParentChildIndex::ShouldInclude(bm_folder));
- EXPECT_EQ(Id(), IndexKnownModelTypeRootId(BOOKMARKS));
index_.Insert(bm_folder);
- EXPECT_EQ(GetBookmarkRootId(), IndexKnownModelTypeRootId(BOOKMARKS));
+ // Since BOOKMARKS is a hierarchical type, its type root folder shouldn't be
+ // tracked by ParentChildIndex.
+ EXPECT_EQ(Id(), IndexKnownModelTypeRootId(BOOKMARKS));
}
// Tests iteration over a set of siblings.
@@ -450,6 +451,24 @@ TEST_F(ParentChildIndexTest, RemoveOutOfOrder) {
EXPECT_EQ(2UL, children->size());
}
+// Test that the insert isn't sensitive to the order (Loading entries from
+// Sync DB is done in arbitrary order).
+TEST_F(ParentChildIndexTest, InsertOutOfOrder) {
+ // Insert two Preferences entries with implicit parent first
+ index_.Insert(MakeUniqueClientItem(PREFERENCES, 1));
+ index_.Insert(MakeUniqueClientItem(PREFERENCES, 2));
+
+ // Then insert the Preferences type root
+ syncable::Id type_root_id = syncable::Id::CreateFromServerId("type_root");
+ index_.Insert(MakeTypeRoot(PREFERENCES, type_root_id));
+
+ // The index should still be able to associate Preferences entries
+ // with the root.
+ const OrderedChildSet* children = index_.GetChildren(type_root_id);
+ ASSERT_TRUE(children);
+ EXPECT_EQ(2UL, children->size());
+}
+
} // namespace syncable
} // namespace syncer
« sync/syncable/parent_child_index.cc ('K') | « sync/syncable/parent_child_index.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698