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

Side by Side Diff: sync/internal_api/sync_manager_impl_unittest.cc

Issue 993153002: Sync: ChangeReorderBuffer::Traversal should handle nodes with unset Parent ID (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « sync/internal_api/change_reorder_buffer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Unit tests for the SyncApi. Note that a lot of the underlying 5 // Unit tests for the SyncApi. Note that a lot of the underlying
6 // functionality is provided by the Syncable layer, which has its own 6 // functionality is provided by the Syncable layer, which has its own
7 // unit tests. We'll test SyncApi specific things in this harness. 7 // unit tests. We'll test SyncApi specific things in this harness.
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <map> 10 #include <map>
(...skipping 2878 matching lines...) Expand 10 before | Expand all | Expand 10 after
2889 // non-fatal failure if these changes are not found. 2889 // non-fatal failure if these changes are not found.
2890 size_t folder_change_pos = 2890 size_t folder_change_pos =
2891 FindChangeInList(folder_id, ChangeRecord::ACTION_ADD); 2891 FindChangeInList(folder_id, ChangeRecord::ACTION_ADD);
2892 size_t child_change_pos = 2892 size_t child_change_pos =
2893 FindChangeInList(child_id, ChangeRecord::ACTION_ADD); 2893 FindChangeInList(child_id, ChangeRecord::ACTION_ADD);
2894 2894
2895 // Parents are delivered before children. 2895 // Parents are delivered before children.
2896 EXPECT_LT(folder_change_pos, child_change_pos); 2896 EXPECT_LT(folder_change_pos, child_change_pos);
2897 } 2897 }
2898 2898
2899 // Test creation of a preferences (with implicit parent Id)
2900 TEST_F(SyncManagerChangeProcessingTest, AddPreferences) {
2901 int64 item1_id = kInvalidId;
2902 int64 item2_id = kInvalidId;
2903
2904 // Create two preferences.
2905 {
2906 syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER,
2907 share()->directory.get());
2908
2909 syncable::MutableEntry item1(&trans, syncable::CREATE, PREFERENCES,
2910 "test_item_1");
2911 ASSERT_TRUE(item1.good());
2912 SetNodeProperties(&item1);
2913 item1_id = item1.GetMetahandle();
2914
2915 // Need at least two items to ensure hitting all possible codepaths in
2916 // ChangeReorderBuffer::Traversal::ExpandToInclude.
2917 syncable::MutableEntry item2(&trans, syncable::CREATE, PREFERENCES,
2918 "test_item_2");
2919 ASSERT_TRUE(item2.good());
2920 SetNodeProperties(&item2);
2921 item2_id = item2.GetMetahandle();
2922 }
2923
2924 // The closing of the above scope will delete the transaction. Its processed
2925 // changes should be waiting for us in a member of the test harness.
2926 EXPECT_EQ(2UL, GetChangeListSize());
2927
2928 FindChangeInList(item1_id, ChangeRecord::ACTION_ADD);
2929 FindChangeInList(item2_id, ChangeRecord::ACTION_ADD);
2930 }
2931
2899 // Test moving a bookmark into an empty folder. 2932 // Test moving a bookmark into an empty folder.
2900 TEST_F(SyncManagerChangeProcessingTest, MoveBookmarkIntoEmptyFolder) { 2933 TEST_F(SyncManagerChangeProcessingTest, MoveBookmarkIntoEmptyFolder) {
2901 int64 type_root = GetIdForDataType(BOOKMARKS); 2934 int64 type_root = GetIdForDataType(BOOKMARKS);
2902 int64 folder_b_id = kInvalidId; 2935 int64 folder_b_id = kInvalidId;
2903 int64 child_id = kInvalidId; 2936 int64 child_id = kInvalidId;
2904 2937
2905 // Create two folders. Place a child under folder A. 2938 // Create two folders. Place a child under folder A.
2906 { 2939 {
2907 syncable::WriteTransaction trans( 2940 syncable::WriteTransaction trans(
2908 FROM_HERE, syncable::SYNCER, share()->directory.get()); 2941 FROM_HERE, syncable::SYNCER, share()->directory.get());
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
3164 // SyncManagerInitInvalidStorageTest::GetFactory will return 3197 // SyncManagerInitInvalidStorageTest::GetFactory will return
3165 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. 3198 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails.
3166 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's 3199 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's
3167 // task is to ensure that SyncManagerImpl reported initialization failure in 3200 // task is to ensure that SyncManagerImpl reported initialization failure in
3168 // OnInitializationComplete callback. 3201 // OnInitializationComplete callback.
3169 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { 3202 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) {
3170 EXPECT_FALSE(initialization_succeeded_); 3203 EXPECT_FALSE(initialization_succeeded_);
3171 } 3204 }
3172 3205
3173 } // namespace syncer 3206 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/change_reorder_buffer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698