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

Side by Side Diff: sync/engine/syncer_unittest.cc

Issue 10523003: Refactor following sync commit loop change (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another rebase Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « sync/engine/syncer.cc ('k') | sync/internal_api/public/sessions/error_counters.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 // Syncer unit tests. Unfortunately a lot of these tests 5 // Syncer unit tests. Unfortunately a lot of these tests
6 // are outdated and need to be reworked and updated. 6 // are outdated and need to be reworked and updated.
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <limits> 9 #include <limits>
10 #include <list> 10 #include <list>
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 C.Put(NON_UNIQUE_NAME, kEncryptedString); 785 C.Put(NON_UNIQUE_NAME, kEncryptedString);
786 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4)); 786 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4));
787 ASSERT_TRUE(D.good()); 787 ASSERT_TRUE(D.good());
788 D.Put(SPECIFICS, encrypted_bookmark); 788 D.Put(SPECIFICS, encrypted_bookmark);
789 D.Put(NON_UNIQUE_NAME, kEncryptedString); 789 D.Put(NON_UNIQUE_NAME, kEncryptedString);
790 } 790 }
791 SyncShareNudge(); 791 SyncShareNudge();
792 { 792 {
793 const StatusController& status_controller = session_->status_controller(); 793 const StatusController& status_controller = session_->status_controller();
794 // Expect success. 794 // Expect success.
795 EXPECT_EQ(status_controller.last_post_commit_result(), SYNCER_OK); 795 EXPECT_EQ(status_controller.error().commit_result, SYNCER_OK);
796 // None should be unsynced anymore. 796 // None should be unsynced anymore.
797 ReadTransaction rtrans(FROM_HERE, directory()); 797 ReadTransaction rtrans(FROM_HERE, directory());
798 VERIFY_ENTRY(1, false, false, false, 0, 21, 21, ids_, &rtrans); 798 VERIFY_ENTRY(1, false, false, false, 0, 21, 21, ids_, &rtrans);
799 VERIFY_ENTRY(2, false, false, false, 0, 11, 11, ids_, &rtrans); 799 VERIFY_ENTRY(2, false, false, false, 0, 11, 11, ids_, &rtrans);
800 VERIFY_ENTRY(3, false, false, false, 0, 11, 11, ids_, &rtrans); 800 VERIFY_ENTRY(3, false, false, false, 0, 11, 11, ids_, &rtrans);
801 VERIFY_ENTRY(4, false, false, false, 0, 11, 11, ids_, &rtrans); 801 VERIFY_ENTRY(4, false, false, false, 0, 11, 11, ids_, &rtrans);
802 } 802 }
803 } 803 }
804 804
805 TEST_F(SyncerTest, EncryptionAwareConflicts) { 805 TEST_F(SyncerTest, EncryptionAwareConflicts) {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 { 946 {
947 ReadTransaction rtrans(FROM_HERE, directory()); 947 ReadTransaction rtrans(FROM_HERE, directory());
948 // Resolve the pending keys. 948 // Resolve the pending keys.
949 cryptographer(&rtrans)->DecryptPendingKeys(key_params); 949 cryptographer(&rtrans)->DecryptPendingKeys(key_params);
950 } 950 }
951 // First cycle resolves conflicts, second cycle commits changes. 951 // First cycle resolves conflicts, second cycle commits changes.
952 SyncShareNudge(); 952 SyncShareNudge();
953 EXPECT_EQ(2, status().syncer_status().num_server_overwrites); 953 EXPECT_EQ(2, status().syncer_status().num_server_overwrites);
954 EXPECT_EQ(1, status().syncer_status().num_local_overwrites); 954 EXPECT_EQ(1, status().syncer_status().num_local_overwrites);
955 // We successfully commited item(s). 955 // We successfully commited item(s).
956 EXPECT_EQ(status().last_post_commit_result(), SYNCER_OK); 956 EXPECT_EQ(status().error().commit_result, SYNCER_OK);
957 SyncShareNudge(); 957 SyncShareNudge();
958 958
959 // Everything should be resolved now. The local changes should have 959 // Everything should be resolved now. The local changes should have
960 // overwritten the server changes for 2 and 4, while the server changes 960 // overwritten the server changes for 2 and 4, while the server changes
961 // overwrote the local for entry 3. 961 // overwrote the local for entry 3.
962 EXPECT_EQ(0, status().syncer_status().num_server_overwrites); 962 EXPECT_EQ(0, status().syncer_status().num_server_overwrites);
963 EXPECT_EQ(0, status().syncer_status().num_local_overwrites); 963 EXPECT_EQ(0, status().syncer_status().num_local_overwrites);
964 EXPECT_EQ(status().last_post_commit_result(), SYNCER_OK); 964 EXPECT_EQ(status().error().commit_result, SYNCER_OK);
965 ReadTransaction rtrans(FROM_HERE, directory()); 965 ReadTransaction rtrans(FROM_HERE, directory());
966 VERIFY_ENTRY(1, false, false, false, 0, 41, 41, ids_, &rtrans); 966 VERIFY_ENTRY(1, false, false, false, 0, 41, 41, ids_, &rtrans);
967 VERIFY_ENTRY(2, false, false, false, 1, 31, 31, ids_, &rtrans); 967 VERIFY_ENTRY(2, false, false, false, 1, 31, 31, ids_, &rtrans);
968 VERIFY_ENTRY(3, false, false, false, 1, 30, 30, ids_, &rtrans); 968 VERIFY_ENTRY(3, false, false, false, 1, 30, 30, ids_, &rtrans);
969 VERIFY_ENTRY(4, false, false, false, 0, 31, 31, ids_, &rtrans); 969 VERIFY_ENTRY(4, false, false, false, 0, 31, 31, ids_, &rtrans);
970 } 970 }
971 971
972 #undef VERIFY_ENTRY 972 #undef VERIFY_ENTRY
973 973
974 // Receive an old nigori with old encryption keys and encrypted types. We should 974 // Receive an old nigori with old encryption keys and encrypted types. We should
(...skipping 1746 matching lines...) Expand 10 before | Expand all | Expand 10 after
2721 ASSERT_EQ(items_to_commit, directory()->unsynced_entity_count()); 2721 ASSERT_EQ(items_to_commit, directory()->unsynced_entity_count());
2722 2722
2723 // The second commit should fail. It will be preceded by one successful 2723 // The second commit should fail. It will be preceded by one successful
2724 // GetUpdate and one succesful commit. 2724 // GetUpdate and one succesful commit.
2725 mock_server_->FailNthPostBufferToPathCall(3); 2725 mock_server_->FailNthPostBufferToPathCall(3);
2726 SyncShareNudge(); 2726 SyncShareNudge();
2727 2727
2728 EXPECT_EQ(1U, mock_server_->commit_messages().size()); 2728 EXPECT_EQ(1U, mock_server_->commit_messages().size());
2729 EXPECT_FALSE(session_->Succeeded()); 2729 EXPECT_FALSE(session_->Succeeded());
2730 EXPECT_EQ(SYNC_SERVER_ERROR, 2730 EXPECT_EQ(SYNC_SERVER_ERROR,
2731 session_->status_controller().error().last_post_commit_result); 2731 session_->status_controller().error().commit_result);
2732 EXPECT_EQ(items_to_commit - kDefaultMaxCommitBatchSize, 2732 EXPECT_EQ(items_to_commit - kDefaultMaxCommitBatchSize,
2733 directory()->unsynced_entity_count()); 2733 directory()->unsynced_entity_count());
2734 } 2734 }
2735 2735
2736 // Test that a single conflict response from the server will cause us to exit 2736 // Test that a single conflict response from the server will cause us to exit
2737 // the commit loop immediately. 2737 // the commit loop immediately.
2738 TEST_F(SyncerTest, CommitManyItemsInOneGo_CommitConflict) { 2738 TEST_F(SyncerTest, CommitManyItemsInOneGo_CommitConflict) {
2739 uint32 num_batches = 2; 2739 uint32 num_batches = 2;
2740 uint32 items_to_commit = kDefaultMaxCommitBatchSize * num_batches; 2740 uint32 items_to_commit = kDefaultMaxCommitBatchSize * num_batches;
2741 { 2741 {
(...skipping 2080 matching lines...) Expand 10 before | Expand all | Expand 10 after
4822 4822
4823 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { 4823 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) {
4824 Add(mid_id_); 4824 Add(mid_id_);
4825 Add(low_id_); 4825 Add(low_id_);
4826 Add(high_id_); 4826 Add(high_id_);
4827 SyncShareNudge(); 4827 SyncShareNudge();
4828 ExpectLocalOrderIsByServerId(); 4828 ExpectLocalOrderIsByServerId();
4829 } 4829 }
4830 4830
4831 } // namespace browser_sync 4831 } // namespace browser_sync
OLDNEW
« no previous file with comments | « sync/engine/syncer.cc ('k') | sync/internal_api/public/sessions/error_counters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698