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/util/extensions_activity.h" | 24 #include "sync/util/extensions_activity.h" |
24 #include "testing/gmock/include/gmock/gmock.h" | 25 #include "testing/gmock/include/gmock/gmock.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
26 | 27 |
27 using base::TimeDelta; | 28 using base::TimeDelta; |
28 using base::TimeTicks; | 29 using base::TimeTicks; |
29 using testing::_; | 30 using testing::_; |
30 using testing::AtLeast; | 31 using testing::AtLeast; |
31 using testing::DoAll; | 32 using testing::DoAll; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 124 |
124 workers_.clear(); | 125 workers_.clear(); |
125 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_UI))); | 126 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_UI))); |
126 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_DB))); | 127 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_DB))); |
127 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_PASSIVE))); | 128 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_PASSIVE))); |
128 | 129 |
129 connection_.reset(new MockConnectionManager(directory(), | 130 connection_.reset(new MockConnectionManager(directory(), |
130 &cancelation_signal_)); | 131 &cancelation_signal_)); |
131 connection_->SetServerReachable(); | 132 connection_->SetServerReachable(); |
132 | 133 |
133 model_type_registry_.reset(new ModelTypeRegistry(workers_, directory())); | 134 model_type_registry_.reset( |
| 135 new ModelTypeRegistry(workers_, directory(), &mock_nudge_handler_)); |
134 | 136 |
135 context_.reset(new SyncSessionContext( | 137 context_.reset(new SyncSessionContext( |
136 connection_.get(), directory(), | 138 connection_.get(), directory(), |
137 extensions_activity_.get(), | 139 extensions_activity_.get(), |
138 std::vector<SyncEngineEventListener*>(), NULL, | 140 std::vector<SyncEngineEventListener*>(), NULL, |
139 model_type_registry_.get(), | 141 model_type_registry_.get(), |
140 true, // enable keystore encryption | 142 true, // enable keystore encryption |
141 false, // force enable pre-commit GU avoidance | 143 false, // force enable pre-commit GU avoidance |
142 "fake_invalidator_client_id")); | 144 "fake_invalidator_client_id")); |
143 context_->SetRoutingInfo(routing_info_); | 145 context_->SetRoutingInfo(routing_info_); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 return dir_maker_.directory(); | 227 return dir_maker_.directory(); |
226 } | 228 } |
227 | 229 |
228 base::MessageLoop loop_; | 230 base::MessageLoop loop_; |
229 TestDirectorySetterUpper dir_maker_; | 231 TestDirectorySetterUpper dir_maker_; |
230 CancelationSignal cancelation_signal_; | 232 CancelationSignal cancelation_signal_; |
231 scoped_ptr<MockConnectionManager> connection_; | 233 scoped_ptr<MockConnectionManager> connection_; |
232 scoped_ptr<ModelTypeRegistry> model_type_registry_; | 234 scoped_ptr<ModelTypeRegistry> model_type_registry_; |
233 scoped_ptr<SyncSessionContext> context_; | 235 scoped_ptr<SyncSessionContext> context_; |
234 scoped_ptr<SyncSchedulerImpl> scheduler_; | 236 scoped_ptr<SyncSchedulerImpl> scheduler_; |
| 237 MockNudgeHandler mock_nudge_handler_; |
235 MockSyncer* syncer_; | 238 MockSyncer* syncer_; |
236 MockDelayProvider* delay_; | 239 MockDelayProvider* delay_; |
237 std::vector<scoped_refptr<ModelSafeWorker> > workers_; | 240 std::vector<scoped_refptr<ModelSafeWorker> > workers_; |
238 scoped_refptr<ExtensionsActivity> extensions_activity_; | 241 scoped_refptr<ExtensionsActivity> extensions_activity_; |
239 ModelSafeRoutingInfo routing_info_; | 242 ModelSafeRoutingInfo routing_info_; |
240 base::WeakPtrFactory<SyncSchedulerTest> weak_ptr_factory_; | 243 base::WeakPtrFactory<SyncSchedulerTest> weak_ptr_factory_; |
241 }; | 244 }; |
242 | 245 |
243 void RecordSyncShareImpl(SyncShareTimes* times) { | 246 void RecordSyncShareImpl(SyncShareTimes* times) { |
244 times->push_back(TimeTicks::Now()); | 247 times->push_back(TimeTicks::Now()); |
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1384 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess), | 1387 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess), |
1385 RecordSyncShare(×))); | 1388 RecordSyncShare(×))); |
1386 | 1389 |
1387 // Run to wait for retrying. | 1390 // Run to wait for retrying. |
1388 RunLoop(); | 1391 RunLoop(); |
1389 | 1392 |
1390 StopSyncScheduler(); | 1393 StopSyncScheduler(); |
1391 } | 1394 } |
1392 | 1395 |
1393 } // namespace syncer | 1396 } // namespace syncer |
OLD | NEW |