| 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.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
| 11 #include "sync/engine/sync_scheduler.h" | 11 #include "sync/engine/sync_scheduler.h" |
| 12 #include "sync/engine/syncer.h" | 12 #include "sync/engine/syncer.h" |
| 13 #include "sync/engine/throttled_data_type_tracker.h" |
| 13 #include "sync/sessions/test_util.h" | 14 #include "sync/sessions/test_util.h" |
| 14 #include "sync/test/engine/fake_model_worker.h" | 15 #include "sync/test/engine/fake_model_worker.h" |
| 15 #include "sync/test/engine/mock_connection_manager.h" | 16 #include "sync/test/engine/mock_connection_manager.h" |
| 16 #include "sync/test/engine/test_directory_setter_upper.h" | 17 #include "sync/test/engine/test_directory_setter_upper.h" |
| 17 #include "sync/test/fake_extensions_activity_monitor.h" | 18 #include "sync/test/fake_extensions_activity_monitor.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 21 |
| 21 using base::TimeDelta; | 22 using base::TimeDelta; |
| 22 using base::TimeTicks; | 23 using base::TimeTicks; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_PASSIVE))); | 100 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_PASSIVE))); |
| 100 | 101 |
| 101 std::vector<ModelSafeWorker*> workers; | 102 std::vector<ModelSafeWorker*> workers; |
| 102 for (std::vector<scoped_refptr<FakeModelWorker> >::iterator it = | 103 for (std::vector<scoped_refptr<FakeModelWorker> >::iterator it = |
| 103 workers_.begin(); it != workers_.end(); ++it) { | 104 workers_.begin(); it != workers_.end(); ++it) { |
| 104 workers.push_back(it->get()); | 105 workers.push_back(it->get()); |
| 105 } | 106 } |
| 106 | 107 |
| 107 connection_.reset(new MockConnectionManager(directory())); | 108 connection_.reset(new MockConnectionManager(directory())); |
| 108 connection_->SetServerReachable(); | 109 connection_->SetServerReachable(); |
| 110 throttled_data_type_tracker_.reset(new ThrottledDataTypeTracker(NULL)); |
| 109 context_.reset(new SyncSessionContext( | 111 context_.reset(new SyncSessionContext( |
| 110 connection_.get(), directory(), routing_info, workers, | 112 connection_.get(), directory(), routing_info, workers, |
| 111 &extensions_activity_monitor_, | 113 &extensions_activity_monitor_, throttled_data_type_tracker_.get(), |
| 112 std::vector<SyncEngineEventListener*>(), NULL, NULL)); | 114 std::vector<SyncEngineEventListener*>(), NULL, NULL)); |
| 113 context_->set_notifications_enabled(true); | 115 context_->set_notifications_enabled(true); |
| 114 context_->set_account_name("Test"); | 116 context_->set_account_name("Test"); |
| 115 scheduler_.reset( | 117 scheduler_.reset( |
| 116 new SyncScheduler("TestSyncScheduler", context(), syncer_)); | 118 new SyncScheduler("TestSyncScheduler", context(), syncer_)); |
| 117 } | 119 } |
| 118 | 120 |
| 119 SyncScheduler* scheduler() { return scheduler_.get(); } | 121 SyncScheduler* scheduler() { return scheduler_.get(); } |
| 120 MockSyncer* syncer() { return syncer_; } | 122 MockSyncer* syncer() { return syncer_; } |
| 121 MockDelayProvider* delay() { return delay_; } | 123 MockDelayProvider* delay() { return delay_; } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 base::WeakPtrFactory<SyncSchedulerTest> weak_ptr_factory_; | 208 base::WeakPtrFactory<SyncSchedulerTest> weak_ptr_factory_; |
| 207 MessageLoop message_loop_; | 209 MessageLoop message_loop_; |
| 208 TestDirectorySetterUpper dir_maker_; | 210 TestDirectorySetterUpper dir_maker_; |
| 209 scoped_ptr<MockConnectionManager> connection_; | 211 scoped_ptr<MockConnectionManager> connection_; |
| 210 scoped_ptr<SyncSessionContext> context_; | 212 scoped_ptr<SyncSessionContext> context_; |
| 211 scoped_ptr<SyncScheduler> scheduler_; | 213 scoped_ptr<SyncScheduler> scheduler_; |
| 212 MockSyncer* syncer_; | 214 MockSyncer* syncer_; |
| 213 MockDelayProvider* delay_; | 215 MockDelayProvider* delay_; |
| 214 std::vector<scoped_refptr<FakeModelWorker> > workers_; | 216 std::vector<scoped_refptr<FakeModelWorker> > workers_; |
| 215 FakeExtensionsActivityMonitor extensions_activity_monitor_; | 217 FakeExtensionsActivityMonitor extensions_activity_monitor_; |
| 218 scoped_ptr<ThrottledDataTypeTracker> throttled_data_type_tracker_; |
| 216 }; | 219 }; |
| 217 | 220 |
| 218 class BackoffTriggersSyncSchedulerTest : public SyncSchedulerTest { | 221 class BackoffTriggersSyncSchedulerTest : public SyncSchedulerTest { |
| 219 void SetUp() { | 222 void SetUp() { |
| 220 SyncSchedulerTest::SetUp(); | 223 SyncSchedulerTest::SetUp(); |
| 221 UseMockDelayProvider(); | 224 UseMockDelayProvider(); |
| 222 EXPECT_CALL(*delay(), GetDelay(_)) | 225 EXPECT_CALL(*delay(), GetDelay(_)) |
| 223 .WillRepeatedly(Return(TimeDelta::FromMilliseconds(1))); | 226 .WillRepeatedly(Return(TimeDelta::FromMilliseconds(1))); |
| 224 } | 227 } |
| 225 | 228 |
| (...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 PumpLoop(); | 1191 PumpLoop(); |
| 1189 // Pump again to run job. | 1192 // Pump again to run job. |
| 1190 PumpLoop(); | 1193 PumpLoop(); |
| 1191 | 1194 |
| 1192 StopSyncScheduler(); | 1195 StopSyncScheduler(); |
| 1193 | 1196 |
| 1194 EXPECT_TRUE(expected == context()->previous_session_routing_info()); | 1197 EXPECT_TRUE(expected == context()->previous_session_routing_info()); |
| 1195 } | 1198 } |
| 1196 | 1199 |
| 1197 } // namespace browser_sync | 1200 } // namespace browser_sync |
| OLD | NEW |