OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/scoped_callback_factory.h" | 8 #include "base/memory/scoped_callback_factory.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/task.h" | 10 #include "base/task.h" |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 622 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
623 RunLoop(); | 623 RunLoop(); |
624 | 624 |
625 // Run again to wait for polling. | 625 // Run again to wait for polling. |
626 RunLoop(); | 626 RunLoop(); |
627 | 627 |
628 scheduler()->Stop(); | 628 scheduler()->Stop(); |
629 AnalyzePollRun(records, kMinNumSamples, optimal_start, poll2); | 629 AnalyzePollRun(records, kMinNumSamples, optimal_start, poll2); |
630 } | 630 } |
631 | 631 |
| 632 // Test that the sessions commit delay is updated when needed. |
| 633 TEST_F(SyncSchedulerTest, SessionsCommitDelay) { |
| 634 SyncShareRecords records; |
| 635 TimeDelta delay1(TimeDelta::FromMilliseconds(120)); |
| 636 TimeDelta delay2(TimeDelta::FromMilliseconds(30)); |
| 637 scheduler()->OnReceivedSessionsCommitDelay(delay1); |
| 638 |
| 639 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) |
| 640 .WillOnce( |
| 641 DoAll( |
| 642 WithArg<0>( |
| 643 sessions::test_util::SimulateSessionsCommitDelayUpdate( |
| 644 delay2)), |
| 645 Invoke(sessions::test_util::SimulateSuccess), |
| 646 QuitLoopNowAction())); |
| 647 |
| 648 EXPECT_EQ(delay1, scheduler()->sessions_commit_delay()); |
| 649 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 650 RunLoop(); |
| 651 |
| 652 EXPECT_EQ(delay1, scheduler()->sessions_commit_delay()); |
| 653 syncable::ModelTypeBitSet model_types; |
| 654 model_types[syncable::BOOKMARKS] = true; |
| 655 scheduler()->ScheduleNudge( |
| 656 zero(), NUDGE_SOURCE_LOCAL, model_types, FROM_HERE); |
| 657 RunLoop(); |
| 658 |
| 659 EXPECT_EQ(delay2, scheduler()->sessions_commit_delay()); |
| 660 scheduler()->Stop(); |
| 661 } |
| 662 |
632 // Test that a sync session is run through to completion. | 663 // Test that a sync session is run through to completion. |
633 TEST_F(SyncSchedulerTest, HasMoreToSync) { | 664 TEST_F(SyncSchedulerTest, HasMoreToSync) { |
634 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) | 665 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) |
635 .WillOnce(Invoke(sessions::test_util::SimulateHasMoreToSync)) | 666 .WillOnce(Invoke(sessions::test_util::SimulateHasMoreToSync)) |
636 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), | 667 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), |
637 QuitLoopNowAction())); | 668 QuitLoopNowAction())); |
638 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 669 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
639 RunLoop(); | 670 RunLoop(); |
640 | 671 |
641 scheduler()->ScheduleNudge( | 672 scheduler()->ScheduleNudge( |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 PumpLoop(); | 1070 PumpLoop(); |
1040 // Pump again to run job. | 1071 // Pump again to run job. |
1041 PumpLoop(); | 1072 PumpLoop(); |
1042 | 1073 |
1043 scheduler()->Stop(); | 1074 scheduler()->Stop(); |
1044 | 1075 |
1045 EXPECT_TRUE(expected == context()->previous_session_routing_info()); | 1076 EXPECT_TRUE(expected == context()->previous_session_routing_info()); |
1046 } | 1077 } |
1047 | 1078 |
1048 } // namespace browser_sync | 1079 } // namespace browser_sync |
OLD | NEW |