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

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

Issue 133763007: [Recommit] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 16 matching lines...) Expand all
27 using base::TimeDelta; 27 using base::TimeDelta;
28 using base::TimeTicks; 28 using base::TimeTicks;
29 using testing::_; 29 using testing::_;
30 using testing::AtLeast; 30 using testing::AtLeast;
31 using testing::DoAll; 31 using testing::DoAll;
32 using testing::Invoke; 32 using testing::Invoke;
33 using testing::Mock; 33 using testing::Mock;
34 using testing::Return; 34 using testing::Return;
35 using testing::WithArg; 35 using testing::WithArg;
36 using testing::WithArgs; 36 using testing::WithArgs;
37 using testing::WithoutArgs;
37 38
38 namespace syncer { 39 namespace syncer {
39 using sessions::SyncSession; 40 using sessions::SyncSession;
40 using sessions::SyncSessionContext; 41 using sessions::SyncSessionContext;
41 using sync_pb::GetUpdatesCallerInfo; 42 using sync_pb::GetUpdatesCallerInfo;
42 43
43 class MockSyncer : public Syncer { 44 class MockSyncer : public Syncer {
44 public: 45 public:
45 MockSyncer(); 46 MockSyncer();
46 MOCK_METHOD3(NormalSyncShare, bool(ModelTypeSet, 47 MOCK_METHOD3(NormalSyncShare, bool(ModelTypeSet,
47 const sessions::NudgeTracker&, 48 const sessions::NudgeTracker&,
48 sessions::SyncSession*)); 49 sessions::SyncSession*));
49 MOCK_METHOD3(ConfigureSyncShare, 50 MOCK_METHOD3(ConfigureSyncShare,
50 bool(ModelTypeSet, 51 bool(ModelTypeSet,
51 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource, 52 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource,
52 SyncSession*)); 53 SyncSession*));
53 MOCK_METHOD2(PollSyncShare, bool(ModelTypeSet, sessions::SyncSession*)); 54 MOCK_METHOD2(PollSyncShare, bool(ModelTypeSet, sessions::SyncSession*));
55 MOCK_METHOD2(RetrySyncShare, bool(ModelTypeSet, sessions::SyncSession*));
54 }; 56 };
55 57
56 MockSyncer::MockSyncer() 58 MockSyncer::MockSyncer()
57 : Syncer(NULL) {} 59 : Syncer(NULL) {}
58 60
59 typedef std::vector<TimeTicks> SyncShareTimes; 61 typedef std::vector<TimeTicks> SyncShareTimes;
60 62
61 void QuitLoopNow() { 63 void QuitLoopNow() {
62 // We use QuitNow() instead of Quit() as the latter may get stalled 64 // We use QuitNow() instead of Quit() as the latter may get stalled
63 // indefinitely in the presence of repeated timers with low delays 65 // indefinitely in the presence of repeated timers with low delays
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 delay_ = new MockDelayProvider(); 205 delay_ = new MockDelayProvider();
204 scheduler_->delay_provider_.reset(delay_); 206 scheduler_->delay_provider_.reset(delay_);
205 } 207 }
206 208
207 SyncSessionContext* context() { return context_.get(); } 209 SyncSessionContext* context() { return context_.get(); }
208 210
209 ModelTypeSet GetThrottledTypes() { 211 ModelTypeSet GetThrottledTypes() {
210 return scheduler_->nudge_tracker_.GetThrottledTypes(); 212 return scheduler_->nudge_tracker_.GetThrottledTypes();
211 } 213 }
212 214
215 base::TimeDelta GetRetryTimerDelay() {
216 EXPECT_TRUE(scheduler_->retry_timer_.IsRunning());
217 return scheduler_->retry_timer_.GetCurrentDelay();
218 }
219
213 private: 220 private:
214 syncable::Directory* directory() { 221 syncable::Directory* directory() {
215 return dir_maker_.directory(); 222 return dir_maker_.directory();
216 } 223 }
217 224
218 base::MessageLoop loop_; 225 base::MessageLoop loop_;
219 TestDirectorySetterUpper dir_maker_; 226 TestDirectorySetterUpper dir_maker_;
220 CancelationSignal cancelation_signal_; 227 CancelationSignal cancelation_signal_;
221 scoped_ptr<MockConnectionManager> connection_; 228 scoped_ptr<MockConnectionManager> connection_;
222 scoped_ptr<SyncSessionContext> context_; 229 scoped_ptr<SyncSessionContext> context_;
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 RecordSyncShare(&times2))); 539 RecordSyncShare(&times2)));
533 scheduler()->ScheduleInvalidationNudge(zero(), invalidations2, FROM_HERE); 540 scheduler()->ScheduleInvalidationNudge(zero(), invalidations2, FROM_HERE);
534 RunLoop(); 541 RunLoop();
535 } 542 }
536 543
537 // Test that polling works as expected. 544 // Test that polling works as expected.
538 TEST_F(SyncSchedulerTest, Polling) { 545 TEST_F(SyncSchedulerTest, Polling) {
539 SyncShareTimes times; 546 SyncShareTimes times;
540 TimeDelta poll_interval(TimeDelta::FromMilliseconds(30)); 547 TimeDelta poll_interval(TimeDelta::FromMilliseconds(30));
541 EXPECT_CALL(*syncer(), PollSyncShare(_,_)).Times(AtLeast(kMinNumSamples)) 548 EXPECT_CALL(*syncer(), PollSyncShare(_,_)).Times(AtLeast(kMinNumSamples))
542 .WillRepeatedly(DoAll(Invoke(sessions::test_util::SimulatePollSuccess), 549 .WillRepeatedly(
543 RecordSyncShareMultiple(&times, kMinNumSamples))); 550 DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess),
551 RecordSyncShareMultiple(&times, kMinNumSamples)));
544 552
545 scheduler()->OnReceivedLongPollIntervalUpdate(poll_interval); 553 scheduler()->OnReceivedLongPollIntervalUpdate(poll_interval);
546 554
547 TimeTicks optimal_start = TimeTicks::Now() + poll_interval; 555 TimeTicks optimal_start = TimeTicks::Now() + poll_interval;
548 StartSyncScheduler(SyncScheduler::NORMAL_MODE); 556 StartSyncScheduler(SyncScheduler::NORMAL_MODE);
549 557
550 // Run again to wait for polling. 558 // Run again to wait for polling.
551 RunLoop(); 559 RunLoop();
552 560
553 StopSyncScheduler(); 561 StopSyncScheduler();
554 AnalyzePollRun(times, kMinNumSamples, optimal_start, poll_interval); 562 AnalyzePollRun(times, kMinNumSamples, optimal_start, poll_interval);
555 } 563 }
556 564
557 // Test that the short poll interval is used. 565 // Test that the short poll interval is used.
558 TEST_F(SyncSchedulerTest, PollNotificationsDisabled) { 566 TEST_F(SyncSchedulerTest, PollNotificationsDisabled) {
559 SyncShareTimes times; 567 SyncShareTimes times;
560 TimeDelta poll_interval(TimeDelta::FromMilliseconds(30)); 568 TimeDelta poll_interval(TimeDelta::FromMilliseconds(30));
561 EXPECT_CALL(*syncer(), PollSyncShare(_,_)).Times(AtLeast(kMinNumSamples)) 569 EXPECT_CALL(*syncer(), PollSyncShare(_,_)).Times(AtLeast(kMinNumSamples))
562 .WillRepeatedly(DoAll(Invoke(sessions::test_util::SimulatePollSuccess), 570 .WillRepeatedly(
563 RecordSyncShareMultiple(&times, kMinNumSamples))); 571 DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess),
572 RecordSyncShareMultiple(&times, kMinNumSamples)));
564 573
565 scheduler()->OnReceivedShortPollIntervalUpdate(poll_interval); 574 scheduler()->OnReceivedShortPollIntervalUpdate(poll_interval);
566 scheduler()->SetNotificationsEnabled(false); 575 scheduler()->SetNotificationsEnabled(false);
567 576
568 TimeTicks optimal_start = TimeTicks::Now() + poll_interval; 577 TimeTicks optimal_start = TimeTicks::Now() + poll_interval;
569 StartSyncScheduler(SyncScheduler::NORMAL_MODE); 578 StartSyncScheduler(SyncScheduler::NORMAL_MODE);
570 579
571 // Run again to wait for polling. 580 // Run again to wait for polling.
572 RunLoop(); 581 RunLoop();
573 582
574 StopSyncScheduler(); 583 StopSyncScheduler();
575 AnalyzePollRun(times, kMinNumSamples, optimal_start, poll_interval); 584 AnalyzePollRun(times, kMinNumSamples, optimal_start, poll_interval);
576 } 585 }
577 586
578 // Test that polling intervals are updated when needed. 587 // Test that polling intervals are updated when needed.
579 TEST_F(SyncSchedulerTest, PollIntervalUpdate) { 588 TEST_F(SyncSchedulerTest, PollIntervalUpdate) {
580 SyncShareTimes times; 589 SyncShareTimes times;
581 TimeDelta poll1(TimeDelta::FromMilliseconds(120)); 590 TimeDelta poll1(TimeDelta::FromMilliseconds(120));
582 TimeDelta poll2(TimeDelta::FromMilliseconds(30)); 591 TimeDelta poll2(TimeDelta::FromMilliseconds(30));
583 scheduler()->OnReceivedLongPollIntervalUpdate(poll1); 592 scheduler()->OnReceivedLongPollIntervalUpdate(poll1);
584 EXPECT_CALL(*syncer(), PollSyncShare(_,_)).Times(AtLeast(kMinNumSamples)) 593 EXPECT_CALL(*syncer(), PollSyncShare(_,_)).Times(AtLeast(kMinNumSamples))
585 .WillOnce(DoAll( 594 .WillOnce(DoAll(
586 WithArgs<0,1>( 595 WithArgs<0,1>(
587 sessions::test_util::SimulatePollIntervalUpdate(poll2)), 596 sessions::test_util::SimulatePollIntervalUpdate(poll2)),
588 Return(true))) 597 Return(true)))
589 .WillRepeatedly( 598 .WillRepeatedly(
590 DoAll(Invoke(sessions::test_util::SimulatePollSuccess), 599 DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess),
591 WithArg<1>( 600 WithArg<1>(
592 RecordSyncShareMultiple(&times, kMinNumSamples)))); 601 RecordSyncShareMultiple(&times, kMinNumSamples))));
593 602
594 TimeTicks optimal_start = TimeTicks::Now() + poll1 + poll2; 603 TimeTicks optimal_start = TimeTicks::Now() + poll1 + poll2;
595 StartSyncScheduler(SyncScheduler::NORMAL_MODE); 604 StartSyncScheduler(SyncScheduler::NORMAL_MODE);
596 605
597 // Run again to wait for polling. 606 // Run again to wait for polling.
598 RunLoop(); 607 RunLoop();
599 608
600 StopSyncScheduler(); 609 StopSyncScheduler();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 TimeDelta throttle1(TimeDelta::FromMilliseconds(150)); 680 TimeDelta throttle1(TimeDelta::FromMilliseconds(150));
672 scheduler()->OnReceivedLongPollIntervalUpdate(poll); 681 scheduler()->OnReceivedLongPollIntervalUpdate(poll);
673 682
674 ::testing::InSequence seq; 683 ::testing::InSequence seq;
675 EXPECT_CALL(*syncer(), PollSyncShare(_,_)) 684 EXPECT_CALL(*syncer(), PollSyncShare(_,_))
676 .WillOnce(DoAll( 685 .WillOnce(DoAll(
677 WithArg<1>(sessions::test_util::SimulateThrottled(throttle1)), 686 WithArg<1>(sessions::test_util::SimulateThrottled(throttle1)),
678 Return(true))) 687 Return(true)))
679 .RetiresOnSaturation(); 688 .RetiresOnSaturation();
680 EXPECT_CALL(*syncer(), PollSyncShare(_,_)) 689 EXPECT_CALL(*syncer(), PollSyncShare(_,_))
681 .WillRepeatedly(DoAll(Invoke(sessions::test_util::SimulatePollSuccess), 690 .WillRepeatedly(
682 RecordSyncShareMultiple(&times, kMinNumSamples))); 691 DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess),
692 RecordSyncShareMultiple(&times, kMinNumSamples)));
683 693
684 TimeTicks optimal_start = TimeTicks::Now() + poll + throttle1; 694 TimeTicks optimal_start = TimeTicks::Now() + poll + throttle1;
685 StartSyncScheduler(SyncScheduler::NORMAL_MODE); 695 StartSyncScheduler(SyncScheduler::NORMAL_MODE);
686 696
687 // Run again to wait for polling. 697 // Run again to wait for polling.
688 RunLoop(); 698 RunLoop();
689 699
690 StopSyncScheduler(); 700 StopSyncScheduler();
691 AnalyzePollRun(times, kMinNumSamples, optimal_start, poll); 701 AnalyzePollRun(times, kMinNumSamples, optimal_start, poll);
692 } 702 }
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 RecordSyncShare(&times))); 1114 RecordSyncShare(&times)));
1105 RunLoop(); 1115 RunLoop();
1106 Mock::VerifyAndClearExpectations(syncer()); 1116 Mock::VerifyAndClearExpectations(syncer());
1107 optimal_job_time = optimal_job_time + backoff; 1117 optimal_job_time = optimal_job_time + backoff;
1108 ASSERT_EQ(2U, times.size()); 1118 ASSERT_EQ(2U, times.size());
1109 EXPECT_GE(times[1], optimal_job_time); 1119 EXPECT_GE(times[1], optimal_job_time);
1110 1120
1111 // Now let the Poll timer do its thing. 1121 // Now let the Poll timer do its thing.
1112 EXPECT_CALL(*syncer(), PollSyncShare(_,_)) 1122 EXPECT_CALL(*syncer(), PollSyncShare(_,_))
1113 .WillRepeatedly(DoAll( 1123 .WillRepeatedly(DoAll(
1114 Invoke(sessions::test_util::SimulatePollSuccess), 1124 Invoke(sessions::test_util::SimulatePollRetrySuccess),
1115 RecordSyncShareMultiple(&times, kMinNumSamples))); 1125 RecordSyncShareMultiple(&times, kMinNumSamples)));
1116 RunLoop(); 1126 RunLoop();
1117 Mock::VerifyAndClearExpectations(syncer()); 1127 Mock::VerifyAndClearExpectations(syncer());
1118 ASSERT_EQ(kMinNumSamples, times.size()); 1128 ASSERT_EQ(kMinNumSamples, times.size());
1119 for (size_t i = 2; i < times.size(); i++) { 1129 for (size_t i = 2; i < times.size(); i++) {
1120 optimal_job_time = optimal_job_time + poll; 1130 optimal_job_time = optimal_job_time + poll;
1121 SCOPED_TRACE(testing::Message() << "SyncShare # (" << i << ")"); 1131 SCOPED_TRACE(testing::Message() << "SyncShare # (" << i << ")");
1122 EXPECT_GE(times[i], optimal_job_time); 1132 EXPECT_GE(times[i], optimal_job_time);
1123 } 1133 }
1124 1134
1125 StopSyncScheduler(); 1135 StopSyncScheduler();
1126 } 1136 }
1127 1137
1128 // Test that poll failures are ignored. They should have no effect on 1138 // Test that poll failures are ignored. They should have no effect on
1129 // subsequent poll attempts, nor should they trigger a backoff/retry. 1139 // subsequent poll attempts, nor should they trigger a backoff/retry.
1130 TEST_F(SyncSchedulerTest, TransientPollFailure) { 1140 TEST_F(SyncSchedulerTest, TransientPollFailure) {
1131 SyncShareTimes times; 1141 SyncShareTimes times;
1132 const TimeDelta poll_interval(TimeDelta::FromMilliseconds(1)); 1142 const TimeDelta poll_interval(TimeDelta::FromMilliseconds(1));
1133 scheduler()->OnReceivedLongPollIntervalUpdate(poll_interval); 1143 scheduler()->OnReceivedLongPollIntervalUpdate(poll_interval);
1134 UseMockDelayProvider(); // Will cause test failure if backoff is initiated. 1144 UseMockDelayProvider(); // Will cause test failure if backoff is initiated.
1135 1145
1136 EXPECT_CALL(*syncer(), PollSyncShare(_,_)) 1146 EXPECT_CALL(*syncer(), PollSyncShare(_,_))
1137 .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollFailed), 1147 .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollRetryFailed),
1138 RecordSyncShare(&times))) 1148 RecordSyncShare(&times)))
1139 .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollSuccess), 1149 .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess),
1140 RecordSyncShare(&times))); 1150 RecordSyncShare(&times)));
1141 1151
1142 StartSyncScheduler(SyncScheduler::NORMAL_MODE); 1152 StartSyncScheduler(SyncScheduler::NORMAL_MODE);
1143 1153
1144 // Run the unsucessful poll. The failed poll should not trigger backoff. 1154 // Run the unsucessful poll. The failed poll should not trigger backoff.
1145 RunLoop(); 1155 RunLoop();
1146 EXPECT_FALSE(scheduler()->IsBackingOff()); 1156 EXPECT_FALSE(scheduler()->IsBackingOff());
1147 1157
1148 // Run the successful poll. 1158 // Run the successful poll.
1149 RunLoop(); 1159 RunLoop();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 PumpLoop(); // Run the nudge, that will fail and schedule a quick retry. 1272 PumpLoop(); // Run the nudge, that will fail and schedule a quick retry.
1263 } 1273 }
1264 1274
1265 TEST_F(SyncSchedulerTest, PollFromCanaryAfterAuthError) { 1275 TEST_F(SyncSchedulerTest, PollFromCanaryAfterAuthError) {
1266 SyncShareTimes times; 1276 SyncShareTimes times;
1267 TimeDelta poll(TimeDelta::FromMilliseconds(15)); 1277 TimeDelta poll(TimeDelta::FromMilliseconds(15));
1268 scheduler()->OnReceivedLongPollIntervalUpdate(poll); 1278 scheduler()->OnReceivedLongPollIntervalUpdate(poll);
1269 1279
1270 ::testing::InSequence seq; 1280 ::testing::InSequence seq;
1271 EXPECT_CALL(*syncer(), PollSyncShare(_,_)) 1281 EXPECT_CALL(*syncer(), PollSyncShare(_,_))
1272 .WillRepeatedly(DoAll(Invoke(sessions::test_util::SimulatePollSuccess), 1282 .WillRepeatedly(
1273 RecordSyncShareMultiple(&times, kMinNumSamples))); 1283 DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess),
1284 RecordSyncShareMultiple(&times, kMinNumSamples)));
1274 1285
1275 connection()->SetServerStatus(HttpResponse::SYNC_AUTH_ERROR); 1286 connection()->SetServerStatus(HttpResponse::SYNC_AUTH_ERROR);
1276 StartSyncScheduler(SyncScheduler::NORMAL_MODE); 1287 StartSyncScheduler(SyncScheduler::NORMAL_MODE);
1277 1288
1278 // Run to wait for polling. 1289 // Run to wait for polling.
1279 RunLoop(); 1290 RunLoop();
1280 1291
1281 // Normally OnCredentialsUpdated calls TryCanaryJob that doesn't run Poll, 1292 // Normally OnCredentialsUpdated calls TryCanaryJob that doesn't run Poll,
1282 // but after poll finished with auth error from poll timer it should retry 1293 // but after poll finished with auth error from poll timer it should retry
1283 // poll once more 1294 // poll once more
1284 EXPECT_CALL(*syncer(), PollSyncShare(_,_)) 1295 EXPECT_CALL(*syncer(), PollSyncShare(_,_))
1285 .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollSuccess), 1296 .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess),
1286 RecordSyncShare(&times))); 1297 RecordSyncShare(&times)));
1287 scheduler()->OnCredentialsUpdated(); 1298 scheduler()->OnCredentialsUpdated();
1288 connection()->SetServerStatus(HttpResponse::SERVER_CONNECTION_OK); 1299 connection()->SetServerStatus(HttpResponse::SERVER_CONNECTION_OK);
1289 RunLoop(); 1300 RunLoop();
1290 StopSyncScheduler(); 1301 StopSyncScheduler();
1291 } 1302 }
1292 1303
1304 TEST_F(SyncSchedulerTest, SuccessfulRetry) {
1305 StartSyncScheduler(SyncScheduler::NORMAL_MODE);
1306
1307 SyncShareTimes times;
1308 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(1);
1309 scheduler()->OnReceivedGuRetryDelay(delay);
1310 EXPECT_EQ(delay, GetRetryTimerDelay());
1311
1312 EXPECT_CALL(*syncer(), RetrySyncShare(_,_))
1313 .WillOnce(
1314 DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess),
1315 RecordSyncShare(&times)));
1316
1317 // Run to wait for retrying.
1318 RunLoop();
1319
1320 StopSyncScheduler();
1321 }
1322
1323 TEST_F(SyncSchedulerTest, FailedRetry) {
1324 UseMockDelayProvider();
1325 EXPECT_CALL(*delay(), GetDelay(_))
1326 .WillRepeatedly(Return(TimeDelta::FromMilliseconds(1)));
1327
1328 StartSyncScheduler(SyncScheduler::NORMAL_MODE);
1329
1330 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(1);
1331 scheduler()->OnReceivedGuRetryDelay(delay);
1332
1333 EXPECT_CALL(*syncer(), RetrySyncShare(_,_))
1334 .WillOnce(
1335 DoAll(Invoke(sessions::test_util::SimulatePollRetryFailed),
1336 QuitLoopNowAction()));
1337
1338 // Run to wait for retrying.
1339 RunLoop();
1340
1341 EXPECT_TRUE(scheduler()->IsBackingOff());
1342 EXPECT_CALL(*syncer(), RetrySyncShare(_,_))
1343 .WillOnce(
1344 DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess),
1345 QuitLoopNowAction()));
1346
1347 // Run to wait for second retrying.
1348 RunLoop();
1349
1350 StopSyncScheduler();
1351 }
1352
1353 ACTION_P2(VerifyRetryTimerDelay, scheduler_test, expected_delay) {
1354 EXPECT_EQ(expected_delay, scheduler_test->GetRetryTimerDelay());
1355 }
1356
1357 TEST_F(SyncSchedulerTest, ReceiveNewRetryDelay) {
1358 StartSyncScheduler(SyncScheduler::NORMAL_MODE);
1359
1360 SyncShareTimes times;
1361 base::TimeDelta delay1 = base::TimeDelta::FromMilliseconds(100);
1362 base::TimeDelta delay2 = base::TimeDelta::FromMilliseconds(200);
1363
1364 scheduler()->ScheduleLocalRefreshRequest(zero(), ModelTypeSet(BOOKMARKS),
1365 FROM_HERE);
1366 scheduler()->OnReceivedGuRetryDelay(delay1);
1367
1368 EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_))
1369 .WillOnce(DoAll(
1370 WithoutArgs(VerifyRetryTimerDelay(this, delay1)),
1371 WithArg<2>(sessions::test_util::SimulateGuRetryDelayCommand(delay2)),
1372 WithoutArgs(VerifyRetryTimerDelay(this, delay2)),
1373 RecordSyncShare(&times)));
1374
1375 // Run nudge GU.
1376 RunLoop();
1377
1378 EXPECT_CALL(*syncer(), RetrySyncShare(_,_))
1379 .WillOnce(
1380 DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess),
1381 RecordSyncShare(&times)));
1382
1383 // Run to wait for retrying.
1384 RunLoop();
1385
1386 StopSyncScheduler();
1387 }
1388
1293 } // namespace syncer 1389 } // 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