| 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" |
| 11 #include "sync/engine/backoff_delay_provider.h" | 11 #include "sync/engine/backoff_delay_provider.h" |
| 12 #include "sync/engine/sync_scheduler_impl.h" | 12 #include "sync/engine/sync_scheduler_impl.h" |
| 13 #include "sync/engine/syncer.h" | 13 #include "sync/engine/syncer.h" |
| 14 #include "sync/internal_api/public/base/cancelation_signal.h" | 14 #include "sync/internal_api/public/base/cancelation_signal.h" |
| 15 #include "sync/internal_api/public/base/model_type_test_util.h" | 15 #include "sync/internal_api/public/base/model_type_test_util.h" |
| 16 #include "sync/notifier/invalidation_util.h" | 16 #include "sync/notifier/invalidation_util.h" |
| 17 #include "sync/notifier/object_id_invalidation_map.h" | 17 #include "sync/notifier/object_id_invalidation_map.h" |
| 18 #include "sync/sessions/test_util.h" | 18 #include "sync/sessions/test_util.h" |
| 19 #include "sync/test/callback_counter.h" | 19 #include "sync/test/callback_counter.h" |
| 20 #include "sync/test/engine/fake_model_worker.h" | 20 #include "sync/test/engine/fake_model_worker.h" |
| 21 #include "sync/test/engine/mock_connection_manager.h" | 21 #include "sync/test/engine/mock_connection_manager.h" |
| 22 #include "sync/test/engine/mock_nudge_handler.h" |
| 22 #include "sync/test/engine/test_directory_setter_upper.h" | 23 #include "sync/test/engine/test_directory_setter_upper.h" |
| 23 #include "sync/test/mock_invalidation.h" | 24 #include "sync/test/mock_invalidation.h" |
| 24 #include "sync/util/extensions_activity.h" | 25 #include "sync/util/extensions_activity.h" |
| 25 #include "testing/gmock/include/gmock/gmock.h" | 26 #include "testing/gmock/include/gmock/gmock.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 27 | 28 |
| 28 using base::TimeDelta; | 29 using base::TimeDelta; |
| 29 using base::TimeTicks; | 30 using base::TimeTicks; |
| 30 using testing::_; | 31 using testing::_; |
| 31 using testing::AtLeast; | 32 using testing::AtLeast; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 125 |
| 125 workers_.clear(); | 126 workers_.clear(); |
| 126 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_UI))); | 127 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_UI))); |
| 127 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_DB))); | 128 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_DB))); |
| 128 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_PASSIVE))); | 129 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_PASSIVE))); |
| 129 | 130 |
| 130 connection_.reset(new MockConnectionManager(directory(), | 131 connection_.reset(new MockConnectionManager(directory(), |
| 131 &cancelation_signal_)); | 132 &cancelation_signal_)); |
| 132 connection_->SetServerReachable(); | 133 connection_->SetServerReachable(); |
| 133 | 134 |
| 134 model_type_registry_.reset(new ModelTypeRegistry(workers_, directory())); | 135 model_type_registry_.reset( |
| 136 new ModelTypeRegistry(workers_, directory(), &mock_nudge_handler_)); |
| 135 | 137 |
| 136 context_.reset(new SyncSessionContext( | 138 context_.reset(new SyncSessionContext( |
| 137 connection_.get(), directory(), | 139 connection_.get(), directory(), |
| 138 extensions_activity_.get(), | 140 extensions_activity_.get(), |
| 139 std::vector<SyncEngineEventListener*>(), NULL, | 141 std::vector<SyncEngineEventListener*>(), NULL, |
| 140 model_type_registry_.get(), | 142 model_type_registry_.get(), |
| 141 true, // enable keystore encryption | 143 true, // enable keystore encryption |
| 142 false, // force enable pre-commit GU avoidance | 144 false, // force enable pre-commit GU avoidance |
| 143 "fake_invalidator_client_id")); | 145 "fake_invalidator_client_id")); |
| 144 context_->SetRoutingInfo(routing_info_); | 146 context_->SetRoutingInfo(routing_info_); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 return dir_maker_.directory(); | 235 return dir_maker_.directory(); |
| 234 } | 236 } |
| 235 | 237 |
| 236 base::MessageLoop loop_; | 238 base::MessageLoop loop_; |
| 237 TestDirectorySetterUpper dir_maker_; | 239 TestDirectorySetterUpper dir_maker_; |
| 238 CancelationSignal cancelation_signal_; | 240 CancelationSignal cancelation_signal_; |
| 239 scoped_ptr<MockConnectionManager> connection_; | 241 scoped_ptr<MockConnectionManager> connection_; |
| 240 scoped_ptr<ModelTypeRegistry> model_type_registry_; | 242 scoped_ptr<ModelTypeRegistry> model_type_registry_; |
| 241 scoped_ptr<SyncSessionContext> context_; | 243 scoped_ptr<SyncSessionContext> context_; |
| 242 scoped_ptr<SyncSchedulerImpl> scheduler_; | 244 scoped_ptr<SyncSchedulerImpl> scheduler_; |
| 245 MockNudgeHandler mock_nudge_handler_; |
| 243 MockSyncer* syncer_; | 246 MockSyncer* syncer_; |
| 244 MockDelayProvider* delay_; | 247 MockDelayProvider* delay_; |
| 245 std::vector<scoped_refptr<ModelSafeWorker> > workers_; | 248 std::vector<scoped_refptr<ModelSafeWorker> > workers_; |
| 246 scoped_refptr<ExtensionsActivity> extensions_activity_; | 249 scoped_refptr<ExtensionsActivity> extensions_activity_; |
| 247 ModelSafeRoutingInfo routing_info_; | 250 ModelSafeRoutingInfo routing_info_; |
| 248 base::WeakPtrFactory<SyncSchedulerTest> weak_ptr_factory_; | 251 base::WeakPtrFactory<SyncSchedulerTest> weak_ptr_factory_; |
| 249 }; | 252 }; |
| 250 | 253 |
| 251 void RecordSyncShareImpl(SyncShareTimes* times) { | 254 void RecordSyncShareImpl(SyncShareTimes* times) { |
| 252 times->push_back(TimeTicks::Now()); | 255 times->push_back(TimeTicks::Now()); |
| (...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1389 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess), | 1392 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess), |
| 1390 RecordSyncShare(×))); | 1393 RecordSyncShare(×))); |
| 1391 | 1394 |
| 1392 // Run to wait for retrying. | 1395 // Run to wait for retrying. |
| 1393 RunLoop(); | 1396 RunLoop(); |
| 1394 | 1397 |
| 1395 StopSyncScheduler(); | 1398 StopSyncScheduler(); |
| 1396 } | 1399 } |
| 1397 | 1400 |
| 1398 } // namespace syncer | 1401 } // namespace syncer |
| OLD | NEW |