| OLD | NEW |
| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 public: | 45 public: |
| 46 MockSyncer(); | 46 MockSyncer(); |
| 47 MOCK_METHOD3(NormalSyncShare, bool(ModelTypeSet, | 47 MOCK_METHOD3(NormalSyncShare, bool(ModelTypeSet, |
| 48 const sessions::NudgeTracker&, | 48 const sessions::NudgeTracker&, |
| 49 sessions::SyncSession*)); | 49 sessions::SyncSession*)); |
| 50 MOCK_METHOD3(ConfigureSyncShare, | 50 MOCK_METHOD3(ConfigureSyncShare, |
| 51 bool(ModelTypeSet, | 51 bool(ModelTypeSet, |
| 52 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource, | 52 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource, |
| 53 SyncSession*)); | 53 SyncSession*)); |
| 54 MOCK_METHOD2(PollSyncShare, bool(ModelTypeSet, sessions::SyncSession*)); | 54 MOCK_METHOD2(PollSyncShare, bool(ModelTypeSet, sessions::SyncSession*)); |
| 55 MOCK_METHOD2(RetrySyncShare, bool(ModelTypeSet, sessions::SyncSession*)); | |
| 56 }; | 55 }; |
| 57 | 56 |
| 58 MockSyncer::MockSyncer() | 57 MockSyncer::MockSyncer() |
| 59 : Syncer(NULL) {} | 58 : Syncer(NULL) {} |
| 60 | 59 |
| 61 typedef std::vector<TimeTicks> SyncShareTimes; | 60 typedef std::vector<TimeTicks> SyncShareTimes; |
| 62 | 61 |
| 63 void QuitLoopNow() { | 62 void QuitLoopNow() { |
| 64 // We use QuitNow() instead of Quit() as the latter may get stalled | 63 // We use QuitNow() instead of Quit() as the latter may get stalled |
| 65 // indefinitely in the presence of repeated timers with low delays | 64 // indefinitely in the presence of repeated timers with low delays |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 scheduler()->ScheduleInvalidationNudge(zero(), invalidations2, FROM_HERE); | 544 scheduler()->ScheduleInvalidationNudge(zero(), invalidations2, FROM_HERE); |
| 546 RunLoop(); | 545 RunLoop(); |
| 547 } | 546 } |
| 548 | 547 |
| 549 // Test that polling works as expected. | 548 // Test that polling works as expected. |
| 550 TEST_F(SyncSchedulerTest, Polling) { | 549 TEST_F(SyncSchedulerTest, Polling) { |
| 551 SyncShareTimes times; | 550 SyncShareTimes times; |
| 552 TimeDelta poll_interval(TimeDelta::FromMilliseconds(30)); | 551 TimeDelta poll_interval(TimeDelta::FromMilliseconds(30)); |
| 553 EXPECT_CALL(*syncer(), PollSyncShare(_,_)).Times(AtLeast(kMinNumSamples)) | 552 EXPECT_CALL(*syncer(), PollSyncShare(_,_)).Times(AtLeast(kMinNumSamples)) |
| 554 .WillRepeatedly( | 553 .WillRepeatedly( |
| 555 DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess), | 554 DoAll(Invoke(sessions::test_util::SimulatePollSuccess), |
| 556 RecordSyncShareMultiple(×, kMinNumSamples))); | 555 RecordSyncShareMultiple(×, kMinNumSamples))); |
| 557 | 556 |
| 558 scheduler()->OnReceivedLongPollIntervalUpdate(poll_interval); | 557 scheduler()->OnReceivedLongPollIntervalUpdate(poll_interval); |
| 559 | 558 |
| 560 TimeTicks optimal_start = TimeTicks::Now() + poll_interval; | 559 TimeTicks optimal_start = TimeTicks::Now() + poll_interval; |
| 561 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 560 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 562 | 561 |
| 563 // Run again to wait for polling. | 562 // Run again to wait for polling. |
| 564 RunLoop(); | 563 RunLoop(); |
| 565 | 564 |
| 566 StopSyncScheduler(); | 565 StopSyncScheduler(); |
| 567 AnalyzePollRun(times, kMinNumSamples, optimal_start, poll_interval); | 566 AnalyzePollRun(times, kMinNumSamples, optimal_start, poll_interval); |
| 568 } | 567 } |
| 569 | 568 |
| 570 // Test that the short poll interval is used. | 569 // Test that the short poll interval is used. |
| 571 TEST_F(SyncSchedulerTest, PollNotificationsDisabled) { | 570 TEST_F(SyncSchedulerTest, PollNotificationsDisabled) { |
| 572 SyncShareTimes times; | 571 SyncShareTimes times; |
| 573 TimeDelta poll_interval(TimeDelta::FromMilliseconds(30)); | 572 TimeDelta poll_interval(TimeDelta::FromMilliseconds(30)); |
| 574 EXPECT_CALL(*syncer(), PollSyncShare(_,_)).Times(AtLeast(kMinNumSamples)) | 573 EXPECT_CALL(*syncer(), PollSyncShare(_,_)).Times(AtLeast(kMinNumSamples)) |
| 575 .WillRepeatedly( | 574 .WillRepeatedly( |
| 576 DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess), | 575 DoAll(Invoke(sessions::test_util::SimulatePollSuccess), |
| 577 RecordSyncShareMultiple(×, kMinNumSamples))); | 576 RecordSyncShareMultiple(×, kMinNumSamples))); |
| 578 | 577 |
| 579 scheduler()->OnReceivedShortPollIntervalUpdate(poll_interval); | 578 scheduler()->OnReceivedShortPollIntervalUpdate(poll_interval); |
| 580 scheduler()->SetNotificationsEnabled(false); | 579 scheduler()->SetNotificationsEnabled(false); |
| 581 | 580 |
| 582 TimeTicks optimal_start = TimeTicks::Now() + poll_interval; | 581 TimeTicks optimal_start = TimeTicks::Now() + poll_interval; |
| 583 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 582 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 584 | 583 |
| 585 // Run again to wait for polling. | 584 // Run again to wait for polling. |
| 586 RunLoop(); | 585 RunLoop(); |
| 587 | 586 |
| 588 StopSyncScheduler(); | 587 StopSyncScheduler(); |
| 589 AnalyzePollRun(times, kMinNumSamples, optimal_start, poll_interval); | 588 AnalyzePollRun(times, kMinNumSamples, optimal_start, poll_interval); |
| 590 } | 589 } |
| 591 | 590 |
| 592 // Test that polling intervals are updated when needed. | 591 // Test that polling intervals are updated when needed. |
| 593 TEST_F(SyncSchedulerTest, PollIntervalUpdate) { | 592 TEST_F(SyncSchedulerTest, PollIntervalUpdate) { |
| 594 SyncShareTimes times; | 593 SyncShareTimes times; |
| 595 TimeDelta poll1(TimeDelta::FromMilliseconds(120)); | 594 TimeDelta poll1(TimeDelta::FromMilliseconds(120)); |
| 596 TimeDelta poll2(TimeDelta::FromMilliseconds(30)); | 595 TimeDelta poll2(TimeDelta::FromMilliseconds(30)); |
| 597 scheduler()->OnReceivedLongPollIntervalUpdate(poll1); | 596 scheduler()->OnReceivedLongPollIntervalUpdate(poll1); |
| 598 EXPECT_CALL(*syncer(), PollSyncShare(_,_)).Times(AtLeast(kMinNumSamples)) | 597 EXPECT_CALL(*syncer(), PollSyncShare(_,_)).Times(AtLeast(kMinNumSamples)) |
| 599 .WillOnce(DoAll( | 598 .WillOnce(DoAll( |
| 600 WithArgs<0,1>( | 599 WithArgs<0,1>( |
| 601 sessions::test_util::SimulatePollIntervalUpdate(poll2)), | 600 sessions::test_util::SimulatePollIntervalUpdate(poll2)), |
| 602 Return(true))) | 601 Return(true))) |
| 603 .WillRepeatedly( | 602 .WillRepeatedly( |
| 604 DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess), | 603 DoAll(Invoke(sessions::test_util::SimulatePollSuccess), |
| 605 WithArg<1>( | 604 WithArg<1>( |
| 606 RecordSyncShareMultiple(×, kMinNumSamples)))); | 605 RecordSyncShareMultiple(×, kMinNumSamples)))); |
| 607 | 606 |
| 608 TimeTicks optimal_start = TimeTicks::Now() + poll1 + poll2; | 607 TimeTicks optimal_start = TimeTicks::Now() + poll1 + poll2; |
| 609 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 608 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 610 | 609 |
| 611 // Run again to wait for polling. | 610 // Run again to wait for polling. |
| 612 RunLoop(); | 611 RunLoop(); |
| 613 | 612 |
| 614 StopSyncScheduler(); | 613 StopSyncScheduler(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 scheduler()->OnReceivedLongPollIntervalUpdate(poll); | 685 scheduler()->OnReceivedLongPollIntervalUpdate(poll); |
| 687 | 686 |
| 688 ::testing::InSequence seq; | 687 ::testing::InSequence seq; |
| 689 EXPECT_CALL(*syncer(), PollSyncShare(_,_)) | 688 EXPECT_CALL(*syncer(), PollSyncShare(_,_)) |
| 690 .WillOnce(DoAll( | 689 .WillOnce(DoAll( |
| 691 WithArg<1>(sessions::test_util::SimulateThrottled(throttle1)), | 690 WithArg<1>(sessions::test_util::SimulateThrottled(throttle1)), |
| 692 Return(true))) | 691 Return(true))) |
| 693 .RetiresOnSaturation(); | 692 .RetiresOnSaturation(); |
| 694 EXPECT_CALL(*syncer(), PollSyncShare(_,_)) | 693 EXPECT_CALL(*syncer(), PollSyncShare(_,_)) |
| 695 .WillRepeatedly( | 694 .WillRepeatedly( |
| 696 DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess), | 695 DoAll(Invoke(sessions::test_util::SimulatePollSuccess), |
| 697 RecordSyncShareMultiple(×, kMinNumSamples))); | 696 RecordSyncShareMultiple(×, kMinNumSamples))); |
| 698 | 697 |
| 699 TimeTicks optimal_start = TimeTicks::Now() + poll + throttle1; | 698 TimeTicks optimal_start = TimeTicks::Now() + poll + throttle1; |
| 700 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 699 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 701 | 700 |
| 702 // Run again to wait for polling. | 701 // Run again to wait for polling. |
| 703 RunLoop(); | 702 RunLoop(); |
| 704 | 703 |
| 705 StopSyncScheduler(); | 704 StopSyncScheduler(); |
| 706 AnalyzePollRun(times, kMinNumSamples, optimal_start, poll); | 705 AnalyzePollRun(times, kMinNumSamples, optimal_start, poll); |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 RecordSyncShare(×))); | 1118 RecordSyncShare(×))); |
| 1120 RunLoop(); | 1119 RunLoop(); |
| 1121 Mock::VerifyAndClearExpectations(syncer()); | 1120 Mock::VerifyAndClearExpectations(syncer()); |
| 1122 optimal_job_time = optimal_job_time + backoff; | 1121 optimal_job_time = optimal_job_time + backoff; |
| 1123 ASSERT_EQ(2U, times.size()); | 1122 ASSERT_EQ(2U, times.size()); |
| 1124 EXPECT_GE(times[1], optimal_job_time); | 1123 EXPECT_GE(times[1], optimal_job_time); |
| 1125 | 1124 |
| 1126 // Now let the Poll timer do its thing. | 1125 // Now let the Poll timer do its thing. |
| 1127 EXPECT_CALL(*syncer(), PollSyncShare(_,_)) | 1126 EXPECT_CALL(*syncer(), PollSyncShare(_,_)) |
| 1128 .WillRepeatedly(DoAll( | 1127 .WillRepeatedly(DoAll( |
| 1129 Invoke(sessions::test_util::SimulatePollRetrySuccess), | 1128 Invoke(sessions::test_util::SimulatePollSuccess), |
| 1130 RecordSyncShareMultiple(×, kMinNumSamples))); | 1129 RecordSyncShareMultiple(×, kMinNumSamples))); |
| 1131 RunLoop(); | 1130 RunLoop(); |
| 1132 Mock::VerifyAndClearExpectations(syncer()); | 1131 Mock::VerifyAndClearExpectations(syncer()); |
| 1133 ASSERT_EQ(kMinNumSamples, times.size()); | 1132 ASSERT_EQ(kMinNumSamples, times.size()); |
| 1134 for (size_t i = 2; i < times.size(); i++) { | 1133 for (size_t i = 2; i < times.size(); i++) { |
| 1135 optimal_job_time = optimal_job_time + poll; | 1134 optimal_job_time = optimal_job_time + poll; |
| 1136 SCOPED_TRACE(testing::Message() << "SyncShare # (" << i << ")"); | 1135 SCOPED_TRACE(testing::Message() << "SyncShare # (" << i << ")"); |
| 1137 EXPECT_GE(times[i], optimal_job_time); | 1136 EXPECT_GE(times[i], optimal_job_time); |
| 1138 } | 1137 } |
| 1139 | 1138 |
| 1140 StopSyncScheduler(); | 1139 StopSyncScheduler(); |
| 1141 } | 1140 } |
| 1142 | 1141 |
| 1143 // Test that poll failures are ignored. They should have no effect on | 1142 // Test that poll failures are ignored. They should have no effect on |
| 1144 // subsequent poll attempts, nor should they trigger a backoff/retry. | 1143 // subsequent poll attempts, nor should they trigger a backoff/retry. |
| 1145 TEST_F(SyncSchedulerTest, TransientPollFailure) { | 1144 TEST_F(SyncSchedulerTest, TransientPollFailure) { |
| 1146 SyncShareTimes times; | 1145 SyncShareTimes times; |
| 1147 const TimeDelta poll_interval(TimeDelta::FromMilliseconds(1)); | 1146 const TimeDelta poll_interval(TimeDelta::FromMilliseconds(1)); |
| 1148 scheduler()->OnReceivedLongPollIntervalUpdate(poll_interval); | 1147 scheduler()->OnReceivedLongPollIntervalUpdate(poll_interval); |
| 1149 UseMockDelayProvider(); // Will cause test failure if backoff is initiated. | 1148 UseMockDelayProvider(); // Will cause test failure if backoff is initiated. |
| 1150 | 1149 |
| 1151 EXPECT_CALL(*syncer(), PollSyncShare(_,_)) | 1150 EXPECT_CALL(*syncer(), PollSyncShare(_,_)) |
| 1152 .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollRetryFailed), | 1151 .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollFailed), |
| 1153 RecordSyncShare(×))) | 1152 RecordSyncShare(×))) |
| 1154 .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess), | 1153 .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollSuccess), |
| 1155 RecordSyncShare(×))); | 1154 RecordSyncShare(×))); |
| 1156 | 1155 |
| 1157 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 1156 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 1158 | 1157 |
| 1159 // Run the unsucessful poll. The failed poll should not trigger backoff. | 1158 // Run the unsucessful poll. The failed poll should not trigger backoff. |
| 1160 RunLoop(); | 1159 RunLoop(); |
| 1161 EXPECT_FALSE(scheduler()->IsBackingOff()); | 1160 EXPECT_FALSE(scheduler()->IsBackingOff()); |
| 1162 | 1161 |
| 1163 // Run the successful poll. | 1162 // Run the successful poll. |
| 1164 RunLoop(); | 1163 RunLoop(); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1278 } | 1277 } |
| 1279 | 1278 |
| 1280 TEST_F(SyncSchedulerTest, PollFromCanaryAfterAuthError) { | 1279 TEST_F(SyncSchedulerTest, PollFromCanaryAfterAuthError) { |
| 1281 SyncShareTimes times; | 1280 SyncShareTimes times; |
| 1282 TimeDelta poll(TimeDelta::FromMilliseconds(15)); | 1281 TimeDelta poll(TimeDelta::FromMilliseconds(15)); |
| 1283 scheduler()->OnReceivedLongPollIntervalUpdate(poll); | 1282 scheduler()->OnReceivedLongPollIntervalUpdate(poll); |
| 1284 | 1283 |
| 1285 ::testing::InSequence seq; | 1284 ::testing::InSequence seq; |
| 1286 EXPECT_CALL(*syncer(), PollSyncShare(_,_)) | 1285 EXPECT_CALL(*syncer(), PollSyncShare(_,_)) |
| 1287 .WillRepeatedly( | 1286 .WillRepeatedly( |
| 1288 DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess), | 1287 DoAll(Invoke(sessions::test_util::SimulatePollSuccess), |
| 1289 RecordSyncShareMultiple(×, kMinNumSamples))); | 1288 RecordSyncShareMultiple(×, kMinNumSamples))); |
| 1290 | 1289 |
| 1291 connection()->SetServerStatus(HttpResponse::SYNC_AUTH_ERROR); | 1290 connection()->SetServerStatus(HttpResponse::SYNC_AUTH_ERROR); |
| 1292 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 1291 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 1293 | 1292 |
| 1294 // Run to wait for polling. | 1293 // Run to wait for polling. |
| 1295 RunLoop(); | 1294 RunLoop(); |
| 1296 | 1295 |
| 1297 // Normally OnCredentialsUpdated calls TryCanaryJob that doesn't run Poll, | 1296 // Normally OnCredentialsUpdated calls TryCanaryJob that doesn't run Poll, |
| 1298 // but after poll finished with auth error from poll timer it should retry | 1297 // but after poll finished with auth error from poll timer it should retry |
| 1299 // poll once more | 1298 // poll once more |
| 1300 EXPECT_CALL(*syncer(), PollSyncShare(_,_)) | 1299 EXPECT_CALL(*syncer(), PollSyncShare(_,_)) |
| 1301 .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess), | 1300 .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollSuccess), |
| 1302 RecordSyncShare(×))); | 1301 RecordSyncShare(×))); |
| 1303 scheduler()->OnCredentialsUpdated(); | 1302 scheduler()->OnCredentialsUpdated(); |
| 1304 connection()->SetServerStatus(HttpResponse::SERVER_CONNECTION_OK); | 1303 connection()->SetServerStatus(HttpResponse::SERVER_CONNECTION_OK); |
| 1305 RunLoop(); | 1304 RunLoop(); |
| 1306 StopSyncScheduler(); | 1305 StopSyncScheduler(); |
| 1307 } | 1306 } |
| 1308 | 1307 |
| 1309 TEST_F(SyncSchedulerTest, SuccessfulRetry) { | 1308 TEST_F(SyncSchedulerTest, SuccessfulRetry) { |
| 1310 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 1309 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 1311 | 1310 |
| 1312 SyncShareTimes times; | 1311 SyncShareTimes times; |
| 1313 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(1); | 1312 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(1); |
| 1314 scheduler()->OnReceivedGuRetryDelay(delay); | 1313 scheduler()->OnReceivedGuRetryDelay(delay); |
| 1315 EXPECT_EQ(delay, GetRetryTimerDelay()); | 1314 EXPECT_EQ(delay, GetRetryTimerDelay()); |
| 1316 | 1315 |
| 1317 EXPECT_CALL(*syncer(), RetrySyncShare(_,_)) | 1316 EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_)) |
| 1318 .WillOnce( | 1317 .WillOnce( |
| 1319 DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess), | 1318 DoAll(Invoke(sessions::test_util::SimulateNormalSuccess), |
| 1320 RecordSyncShare(×))); | 1319 RecordSyncShare(×))); |
| 1321 | 1320 |
| 1322 // Run to wait for retrying. | 1321 // Run to wait for retrying. |
| 1323 RunLoop(); | 1322 RunLoop(); |
| 1324 | 1323 |
| 1325 StopSyncScheduler(); | 1324 StopSyncScheduler(); |
| 1326 } | 1325 } |
| 1327 | 1326 |
| 1328 TEST_F(SyncSchedulerTest, FailedRetry) { | 1327 TEST_F(SyncSchedulerTest, FailedRetry) { |
| 1329 UseMockDelayProvider(); | 1328 UseMockDelayProvider(); |
| 1330 EXPECT_CALL(*delay(), GetDelay(_)) | 1329 EXPECT_CALL(*delay(), GetDelay(_)) |
| 1331 .WillRepeatedly(Return(TimeDelta::FromMilliseconds(1))); | 1330 .WillRepeatedly(Return(TimeDelta::FromMilliseconds(1))); |
| 1332 | 1331 |
| 1333 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 1332 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 1334 | 1333 |
| 1335 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(1); | 1334 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(1); |
| 1336 scheduler()->OnReceivedGuRetryDelay(delay); | 1335 scheduler()->OnReceivedGuRetryDelay(delay); |
| 1337 | 1336 |
| 1338 EXPECT_CALL(*syncer(), RetrySyncShare(_,_)) | 1337 EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_)) |
| 1339 .WillOnce( | 1338 .WillOnce( |
| 1340 DoAll(Invoke(sessions::test_util::SimulatePollRetryFailed), | 1339 DoAll(Invoke(sessions::test_util::SimulateDownloadUpdatesFailed), |
| 1341 QuitLoopNowAction())); | 1340 QuitLoopNowAction())); |
| 1342 | 1341 |
| 1343 // Run to wait for retrying. | 1342 // Run to wait for retrying. |
| 1344 RunLoop(); | 1343 RunLoop(); |
| 1345 | 1344 |
| 1346 EXPECT_TRUE(scheduler()->IsBackingOff()); | 1345 EXPECT_TRUE(scheduler()->IsBackingOff()); |
| 1347 EXPECT_CALL(*syncer(), RetrySyncShare(_,_)) | 1346 EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_)) |
| 1348 .WillOnce( | 1347 .WillOnce( |
| 1349 DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess), | 1348 DoAll(Invoke(sessions::test_util::SimulateNormalSuccess), |
| 1350 QuitLoopNowAction())); | 1349 QuitLoopNowAction())); |
| 1351 | 1350 |
| 1352 // Run to wait for second retrying. | 1351 // Run to wait for second retrying. |
| 1353 RunLoop(); | 1352 RunLoop(); |
| 1354 | 1353 |
| 1355 StopSyncScheduler(); | 1354 StopSyncScheduler(); |
| 1356 } | 1355 } |
| 1357 | 1356 |
| 1358 ACTION_P2(VerifyRetryTimerDelay, scheduler_test, expected_delay) { | 1357 ACTION_P2(VerifyRetryTimerDelay, scheduler_test, expected_delay) { |
| 1359 EXPECT_EQ(expected_delay, scheduler_test->GetRetryTimerDelay()); | 1358 EXPECT_EQ(expected_delay, scheduler_test->GetRetryTimerDelay()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1374 EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_)) | 1373 EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_)) |
| 1375 .WillOnce(DoAll( | 1374 .WillOnce(DoAll( |
| 1376 WithoutArgs(VerifyRetryTimerDelay(this, delay1)), | 1375 WithoutArgs(VerifyRetryTimerDelay(this, delay1)), |
| 1377 WithArg<2>(sessions::test_util::SimulateGuRetryDelayCommand(delay2)), | 1376 WithArg<2>(sessions::test_util::SimulateGuRetryDelayCommand(delay2)), |
| 1378 RecordSyncShare(×))); | 1377 RecordSyncShare(×))); |
| 1379 | 1378 |
| 1380 // Run nudge GU. | 1379 // Run nudge GU. |
| 1381 RunLoop(); | 1380 RunLoop(); |
| 1382 EXPECT_EQ(delay2, GetRetryTimerDelay()); | 1381 EXPECT_EQ(delay2, GetRetryTimerDelay()); |
| 1383 | 1382 |
| 1384 EXPECT_CALL(*syncer(), RetrySyncShare(_,_)) | 1383 EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_)) |
| 1385 .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess), | 1384 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess), |
| 1386 RecordSyncShare(×))); | 1385 RecordSyncShare(×))); |
| 1387 | 1386 |
| 1388 // Run to wait for retrying. | 1387 // Run to wait for retrying. |
| 1389 RunLoop(); | 1388 RunLoop(); |
| 1390 | 1389 |
| 1391 StopSyncScheduler(); | 1390 StopSyncScheduler(); |
| 1392 } | 1391 } |
| 1393 | 1392 |
| 1394 } // namespace syncer | 1393 } // namespace syncer |
| OLD | NEW |