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

Unified Diff: sync/syncable/parent_child_index_unittest.cc

Issue 1139883007: Sync: ParentChildIndex fix for out of order deletion of entries by PurgeEntriesWithTypeIn. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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/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 6362242f2481c9a933c6da01d3817fc7327d9b41..f94c5b95b4215e17b2c7877d59a0eded7f089ff5 100644
--- a/sync/syncable/parent_child_index_unittest.cc
+++ b/sync/syncable/parent_child_index_unittest.cc
@@ -409,9 +409,45 @@ TEST_F(ParentChildIndexTest, NodesWithImplicitParentId) {
EXPECT_FALSE(index_.Contains(p2));
children = index_.GetChildren(type_root);
ASSERT_EQ(nullptr, children);
+}
+
+// Test that the removal isn't sensitive to the order (PurgeEntriesWithTypeIn
+// removes items in arbitrary order).
+TEST_F(ParentChildIndexTest, RemoveOutOfOrder) {
+ // Insert a type root and two items (with implicit parent ID).
+ syncable::Id type_root_id = syncable::Id::CreateFromServerId("type_root");
+ EntryKernel* type_root = MakeTypeRoot(PREFERENCES, type_root_id);
+ index_.Insert(type_root);
+ EntryKernel* p1 = MakeUniqueClientItem(PREFERENCES, 1);
+ EntryKernel* p2 = MakeUniqueClientItem(PREFERENCES, 2);
+ index_.Insert(p1);
+ index_.Insert(p2);
+ // Two items expected under the type root.
+ const OrderedChildSet* children = index_.GetChildren(type_root);
+ ASSERT_TRUE(children);
+ EXPECT_EQ(2UL, children->size());
+
+ // Remove all 3 items in arbitrary order.
+ index_.Remove(p2);
index_.Remove(type_root);
- EXPECT_EQ(Id(), IndexKnownModelTypeRootId(PREFERENCES));
+ index_.Remove(p1);
+
+ EXPECT_EQ(nullptr, index_.GetChildren(type_root));
+
+ // Add a new root and another two items again.
+ type_root = MakeTypeRoot(PREFERENCES, type_root_id);
+ index_.Insert(type_root);
+
+ index_.Insert(MakeUniqueClientItem(PREFERENCES, 3));
+ index_.Insert(MakeUniqueClientItem(PREFERENCES, 4));
+
+ children = index_.GetChildren(type_root);
+ ASSERT_TRUE(children);
+ // Should have 2 items. If the out of order removal cleared the implicit
+ // parent folder ID prematurely, the collection would have 3 items including
+ // p1.
+ EXPECT_EQ(2UL, children->size());
}
} // namespace syncable
« no previous file with comments | « sync/syncable/parent_child_index.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698