Chromium Code Reviews| 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 50aeca151d362e0c3bd716d7229c4b495ba3bbcd..4c2a5b6ed0efbd621ebdb764627673e393678fcb 100644 |
| --- a/sync/syncable/parent_child_index_unittest.cc |
| +++ b/sync/syncable/parent_child_index_unittest.cc |
| @@ -470,6 +470,57 @@ TEST_F(ParentChildIndexTest, InsertOutOfOrder) { |
| EXPECT_EQ(2UL, children->size()); |
| } |
| +// Test that the if for some reason we wind up with multiple type roots, we |
|
stanisc
2016/07/22 23:50:25
"Test that the if"
Nicolas Zea
2016/07/25 18:20:38
Done.
|
| +// gracefully handle it and don't allow any new entities to become invisible. |
| +TEST_F(ParentChildIndexTest, MultipleTypeRoots) { |
| + // Create the good Preferences type root. |
| + syncable::Id type_root_id = syncable::Id::CreateFromClientString("type_root"); |
| + index_.Insert(MakeTypeRoot(PREFERENCES, type_root_id)); |
| + |
| + // Then insert the bad Preferences type root |
| + syncable::Id bad_type_root_id = syncable::Id::CreateFromServerId("bad"); |
| + index_.Insert(MakeTypeRoot(PREFERENCES, bad_type_root_id)); |
| + |
| + // Insert two Preferences entries with implicit parent. |
| + index_.Insert(MakeUniqueClientItem(PREFERENCES, 1)); |
| + index_.Insert(MakeUniqueClientItem(PREFERENCES, 2)); |
| + |
| + // The index should still be able to associate Preferences entries |
| + // with the good and bad roots. |
| + const OrderedChildSet* children = index_.GetChildren(type_root_id); |
| + ASSERT_TRUE(children); |
| + EXPECT_EQ(2UL, children->size()); |
| + const OrderedChildSet* children_bad = index_.GetChildren(bad_type_root_id); |
| + ASSERT_TRUE(children_bad); |
| + EXPECT_EQ(2UL, children_bad->size()); |
| +} |
| + |
| +// Test that the if for some reason we wind up with multiple type roots, we |
|
stanisc
2016/07/22 23:50:25
"Test that the if"
Nicolas Zea
2016/07/25 18:20:38
Done.
|
| +// gracefully handle it and don't allow any new entities to become invisible. |
| +// Same as above but with the roots created in inverse order. |
| +TEST_F(ParentChildIndexTest, MultipleTypeRootsInverse) { |
| + // Create the bad Preferences type root |
| + syncable::Id bad_type_root_id = syncable::Id::CreateFromServerId("bad"); |
| + index_.Insert(MakeTypeRoot(PREFERENCES, bad_type_root_id)); |
| + |
| + // Then insert the good Preferences type root. |
| + syncable::Id type_root_id = syncable::Id::CreateFromClientString("type_root"); |
| + index_.Insert(MakeTypeRoot(PREFERENCES, type_root_id)); |
| + |
| + // Insert two Preferences entries with implicit parent. |
| + index_.Insert(MakeUniqueClientItem(PREFERENCES, 1)); |
| + index_.Insert(MakeUniqueClientItem(PREFERENCES, 2)); |
| + |
| + // The index should still be able to associate Preferences entries |
| + // with the good root and bad roots. |
| + const OrderedChildSet* children = index_.GetChildren(type_root_id); |
| + ASSERT_TRUE(children); |
| + EXPECT_EQ(2UL, children->size()); |
| + const OrderedChildSet* children_bad = index_.GetChildren(bad_type_root_id); |
| + ASSERT_TRUE(children_bad); |
| + EXPECT_EQ(2UL, children_bad->size()); |
| +} |
| + |
| } // namespace syncable |
| } // namespace syncer |