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

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

Issue 10933075: FYI: Remove PerModelSafeGroupState + move ConflictResolution (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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/sync_scheduler_impl.cc ('k') | sync/engine/syncer.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 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 EXPECT_EQ(delay1, scheduler()->GetSessionsCommitDelay()); 684 EXPECT_EQ(delay1, scheduler()->GetSessionsCommitDelay());
685 const ModelTypeSet model_types(BOOKMARKS); 685 const ModelTypeSet model_types(BOOKMARKS);
686 scheduler()->ScheduleNudgeAsync( 686 scheduler()->ScheduleNudgeAsync(
687 zero(), NUDGE_SOURCE_LOCAL, model_types, FROM_HERE); 687 zero(), NUDGE_SOURCE_LOCAL, model_types, FROM_HERE);
688 RunLoop(); 688 RunLoop();
689 689
690 EXPECT_EQ(delay2, scheduler()->GetSessionsCommitDelay()); 690 EXPECT_EQ(delay2, scheduler()->GetSessionsCommitDelay());
691 StopSyncScheduler(); 691 StopSyncScheduler();
692 } 692 }
693 693
694 // Test that a sync session is run through to completion.
695 TEST_F(SyncSchedulerTest, HasMoreToSync) {
696 EXPECT_CALL(*syncer(), SyncShare(_,_,_))
697 .WillOnce(Invoke(sessions::test_util::SimulateHasMoreToSync))
698 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess),
699 QuitLoopNowAction()));
700 StartSyncScheduler(SyncScheduler::NORMAL_MODE);
701
702 scheduler()->ScheduleNudgeAsync(
703 zero(), NUDGE_SOURCE_LOCAL, ModelTypeSet(BOOKMARKS), FROM_HERE);
704 RunLoop();
705 // If more nudges are scheduled, they'll be waited on by TearDown, and would
706 // cause our expectation to break.
707 }
708
709 // Test that continuations can go into backoff.
710 TEST_F(SyncSchedulerTest, HasMoreToSyncThenFails) {
711 EXPECT_CALL(*syncer(), SyncShare(_,_,_))
712 .WillOnce(Invoke(sessions::test_util::SimulateHasMoreToSync))
713 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateCommitFailed),
714 QuitLoopNowAction()));
715 StartSyncScheduler(SyncScheduler::NORMAL_MODE);
716
717 scheduler()->ScheduleNudgeAsync(
718 zero(), NUDGE_SOURCE_LOCAL, ModelTypeSet(BOOKMARKS), FROM_HERE);
719
720 // We should detect the failure on the second sync share, and go into backoff.
721 EXPECT_TRUE(RunAndGetBackoff());
722 }
723
724 // Test that no syncing occurs when throttled. 694 // Test that no syncing occurs when throttled.
725 TEST_F(SyncSchedulerTest, ThrottlingDoesThrottle) { 695 TEST_F(SyncSchedulerTest, ThrottlingDoesThrottle) {
726 const ModelTypeSet types(BOOKMARKS); 696 const ModelTypeSet types(BOOKMARKS);
727 TimeDelta poll(TimeDelta::FromMilliseconds(5)); 697 TimeDelta poll(TimeDelta::FromMilliseconds(5));
728 TimeDelta throttle(TimeDelta::FromMinutes(10)); 698 TimeDelta throttle(TimeDelta::FromMinutes(10));
729 scheduler()->OnReceivedLongPollIntervalUpdate(poll); 699 scheduler()->OnReceivedLongPollIntervalUpdate(poll);
730 700
731 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) 701 EXPECT_CALL(*syncer(), SyncShare(_,_,_))
732 .WillOnce(WithArg<0>(sessions::test_util::SimulateThrottled(throttle))) 702 .WillOnce(WithArg<0>(sessions::test_util::SimulateThrottled(throttle)))
733 .WillRepeatedly(AddFailureAndQuitLoopNow()); 703 .WillRepeatedly(AddFailureAndQuitLoopNow());
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 // Should save the nudge for until after the server is reachable. 1103 // Should save the nudge for until after the server is reachable.
1134 MessageLoop::current()->RunAllPending(); 1104 MessageLoop::current()->RunAllPending();
1135 1105
1136 connection()->SetServerReachable(); 1106 connection()->SetServerReachable();
1137 connection()->UpdateConnectionStatus(); 1107 connection()->UpdateConnectionStatus();
1138 scheduler()->OnConnectionStatusChange(); 1108 scheduler()->OnConnectionStatusChange();
1139 MessageLoop::current()->RunAllPending(); 1109 MessageLoop::current()->RunAllPending();
1140 } 1110 }
1141 1111
1142 } // namespace syncer 1112 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/sync_scheduler_impl.cc ('k') | sync/engine/syncer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698