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

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

Issue 891123003: Revert of Sync commit errors should temporarily re-enable trigger pre-commit getupdates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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/engine/syncer.cc ('k') | sync/protocol/sync.proto » ('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 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 // 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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 void ResetSession() { 255 void ResetSession() {
256 session_.reset(SyncSession::Build(context_.get(), this)); 256 session_.reset(SyncSession::Build(context_.get(), this));
257 } 257 }
258 258
259 void SyncShareNudge() { 259 void SyncShareNudge() {
260 ResetSession(); 260 ResetSession();
261 261
262 // Pretend we've seen a local change, to make the nudge_tracker look normal. 262 // Pretend we've seen a local change, to make the nudge_tracker look normal.
263 nudge_tracker_.RecordLocalChange(ModelTypeSet(BOOKMARKS)); 263 nudge_tracker_.RecordLocalChange(ModelTypeSet(BOOKMARKS));
264 264
265 EXPECT_TRUE(syncer_->NormalSyncShare(context_->GetEnabledTypes(), 265 EXPECT_TRUE(
266 &nudge_tracker_, session_.get())); 266 syncer_->NormalSyncShare(
267 context_->GetEnabledTypes(),
268 nudge_tracker_,
269 session_.get()));
267 } 270 }
268 271
269 void SyncShareConfigure() { 272 void SyncShareConfigure() {
270 ResetSession(); 273 ResetSession();
271 EXPECT_TRUE(syncer_->ConfigureSyncShare( 274 EXPECT_TRUE(syncer_->ConfigureSyncShare(
272 context_->GetEnabledTypes(), 275 context_->GetEnabledTypes(),
273 sync_pb::GetUpdatesCallerInfo::RECONFIGURATION, 276 sync_pb::GetUpdatesCallerInfo::RECONFIGURATION,
274 session_.get())); 277 session_.get()));
275 } 278 }
276 279
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 A.PutSpecifics(bookmark_data); 635 A.PutSpecifics(bookmark_data);
633 A.PutNonUniqueName("bookmark"); 636 A.PutNonUniqueName("bookmark");
634 } 637 }
635 638
636 // Now sync without enabling bookmarks. 639 // Now sync without enabling bookmarks.
637 mock_server_->ExpectGetUpdatesRequestTypes( 640 mock_server_->ExpectGetUpdatesRequestTypes(
638 Difference(context_->GetEnabledTypes(), ModelTypeSet(BOOKMARKS))); 641 Difference(context_->GetEnabledTypes(), ModelTypeSet(BOOKMARKS)));
639 ResetSession(); 642 ResetSession();
640 syncer_->NormalSyncShare( 643 syncer_->NormalSyncShare(
641 Difference(context_->GetEnabledTypes(), ModelTypeSet(BOOKMARKS)), 644 Difference(context_->GetEnabledTypes(), ModelTypeSet(BOOKMARKS)),
642 &nudge_tracker_, session_.get()); 645 nudge_tracker_,
646 session_.get());
643 647
644 { 648 {
645 // Nothing should have been committed as bookmarks is throttled. 649 // Nothing should have been committed as bookmarks is throttled.
646 syncable::ReadTransaction rtrans(FROM_HERE, directory()); 650 syncable::ReadTransaction rtrans(FROM_HERE, directory());
647 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); 651 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1));
648 ASSERT_TRUE(entryA.good()); 652 ASSERT_TRUE(entryA.good());
649 EXPECT_TRUE(entryA.GetIsUnsynced()); 653 EXPECT_TRUE(entryA.GetIsUnsynced());
650 } 654 }
651 655
652 // Sync again with bookmarks enabled. 656 // Sync again with bookmarks enabled.
(...skipping 2203 matching lines...) Expand 10 before | Expand all | Expand 10 after
2856 EXPECT_EQ(2, mock_server_->last_request().debug_info().events_size()); 2860 EXPECT_EQ(2, mock_server_->last_request().debug_info().events_size());
2857 2861
2858 // The previous send was successful so this next one shouldn't generate any 2862 // The previous send was successful so this next one shouldn't generate any
2859 // debug info events. 2863 // debug info events.
2860 SyncShareNudge(); 2864 SyncShareNudge();
2861 EXPECT_EQ(3U, mock_server_->requests().size()); 2865 EXPECT_EQ(3U, mock_server_->requests().size());
2862 ASSERT_TRUE(mock_server_->last_request().has_get_updates()); 2866 ASSERT_TRUE(mock_server_->last_request().has_get_updates());
2863 EXPECT_EQ(0, mock_server_->last_request().debug_info().events_size()); 2867 EXPECT_EQ(0, mock_server_->last_request().debug_info().events_size());
2864 } 2868 }
2865 2869
2866 // Tests that commit failure with conflict will trigger GetUpdates for next
2867 // sycle of sync
2868 TEST_F(SyncerTest, CommitFailureWithConflict) {
2869 ConfigureNoGetUpdatesRequired();
2870 CreateUnsyncedDirectory("X", "id_X");
2871 EXPECT_FALSE(nudge_tracker_.IsGetUpdatesRequired());
2872
2873 SyncShareNudge();
2874 EXPECT_FALSE(nudge_tracker_.IsGetUpdatesRequired());
2875
2876 CreateUnsyncedDirectory("Y", "id_Y");
2877 mock_server_->set_conflict_n_commits(1);
2878 SyncShareNudge();
2879 EXPECT_TRUE(nudge_tracker_.IsGetUpdatesRequired());
2880
2881 nudge_tracker_.RecordSuccessfulSyncCycle();
2882 EXPECT_FALSE(nudge_tracker_.IsGetUpdatesRequired());
2883 }
2884
2885 // Tests that sending debug info events on Commit works. 2870 // Tests that sending debug info events on Commit works.
2886 TEST_F(SyncerTest, SendDebugInfoEventsOnCommit_HappyCase) { 2871 TEST_F(SyncerTest, SendDebugInfoEventsOnCommit_HappyCase) {
2887 // Make sure GetUpdate isn't call as it would "steal" debug info events before 2872 // Make sure GetUpdate isn't call as it would "steal" debug info events before
2888 // Commit has a chance to send them. 2873 // Commit has a chance to send them.
2889 ConfigureNoGetUpdatesRequired(); 2874 ConfigureNoGetUpdatesRequired();
2890 2875
2891 // Generate a debug info event and trigger a commit. 2876 // Generate a debug info event and trigger a commit.
2892 debug_info_getter_->AddDebugEvent(); 2877 debug_info_getter_->AddDebugEvent();
2893 CreateUnsyncedDirectory("X", "id_X"); 2878 CreateUnsyncedDirectory("X", "id_X");
2894 SyncShareNudge(); 2879 SyncShareNudge();
(...skipping 2465 matching lines...) Expand 10 before | Expand all | Expand 10 after
5360 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); 5345 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id);
5361 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); 5346 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count);
5362 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); 5347 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count);
5363 } else { 5348 } else {
5364 EXPECT_TRUE(final_monitor_records.empty()) 5349 EXPECT_TRUE(final_monitor_records.empty())
5365 << "Should not restore records after successful bookmark commit."; 5350 << "Should not restore records after successful bookmark commit.";
5366 } 5351 }
5367 } 5352 }
5368 5353
5369 } // namespace syncer 5354 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/syncer.cc ('k') | sync/protocol/sync.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698