OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 // Syncer unit tests. Unfortunately a lot of these tests | 5 // Syncer unit tests. Unfortunately a lot of these tests |
6 // are outdated and need to be reworked and updated. | 6 // are outdated and need to be reworked and updated. |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <limits> | 9 #include <limits> |
10 #include <list> | 10 #include <list> |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 EnableDatatype(PREFERENCES); | 213 EnableDatatype(PREFERENCES); |
214 EnableDatatype(NIGORI); | 214 EnableDatatype(NIGORI); |
215 workers_.push_back(scoped_refptr<ModelSafeWorker>( | 215 workers_.push_back(scoped_refptr<ModelSafeWorker>( |
216 new FakeModelWorker(GROUP_PASSIVE))); | 216 new FakeModelWorker(GROUP_PASSIVE))); |
217 std::vector<SyncEngineEventListener*> listeners; | 217 std::vector<SyncEngineEventListener*> listeners; |
218 listeners.push_back(this); | 218 listeners.push_back(this); |
219 | 219 |
220 ModelSafeRoutingInfo routing_info; | 220 ModelSafeRoutingInfo routing_info; |
221 GetModelSafeRoutingInfo(&routing_info); | 221 GetModelSafeRoutingInfo(&routing_info); |
222 | 222 |
| 223 model_type_registry_.reset(new ModelTypeRegistry(workers_, directory())); |
| 224 |
223 context_.reset( | 225 context_.reset( |
224 new SyncSessionContext( | 226 new SyncSessionContext( |
225 mock_server_.get(), directory(), workers_, | 227 mock_server_.get(), directory(), |
226 extensions_activity_, | 228 extensions_activity_, |
227 listeners, debug_info_getter_.get(), &traffic_recorder_, | 229 listeners, debug_info_getter_.get(), &traffic_recorder_, |
| 230 model_type_registry_.get(), |
228 true, // enable keystore encryption | 231 true, // enable keystore encryption |
229 false, // force enable pre-commit GU avoidance experiment | 232 false, // force enable pre-commit GU avoidance experiment |
230 "fake_invalidator_client_id")); | 233 "fake_invalidator_client_id")); |
231 context_->set_routing_info(routing_info); | 234 context_->SetRoutingInfo(routing_info); |
232 syncer_ = new Syncer(&cancelation_signal_); | 235 syncer_ = new Syncer(&cancelation_signal_); |
233 | 236 |
234 syncable::ReadTransaction trans(FROM_HERE, directory()); | 237 syncable::ReadTransaction trans(FROM_HERE, directory()); |
235 syncable::Directory::Metahandles children; | 238 syncable::Directory::Metahandles children; |
236 directory()->GetChildHandlesById(&trans, trans.root_id(), &children); | 239 directory()->GetChildHandlesById(&trans, trans.root_id(), &children); |
237 ASSERT_EQ(0u, children.size()); | 240 ASSERT_EQ(0u, children.size()); |
238 saw_syncer_event_ = false; | 241 saw_syncer_event_ = false; |
239 root_id_ = TestIdFactory::root(); | 242 root_id_ = TestIdFactory::root(); |
240 parent_id_ = ids_.MakeServer("parent id"); | 243 parent_id_ = ids_.MakeServer("parent id"); |
241 child_id_ = ids_.MakeServer("child id"); | 244 child_id_ = ids_.MakeServer("child id"); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 return entry.GetMetahandle(); | 433 return entry.GetMetahandle(); |
431 } | 434 } |
432 | 435 |
433 void EnableDatatype(ModelType model_type) { | 436 void EnableDatatype(ModelType model_type) { |
434 enabled_datatypes_.Put(model_type); | 437 enabled_datatypes_.Put(model_type); |
435 | 438 |
436 ModelSafeRoutingInfo routing_info; | 439 ModelSafeRoutingInfo routing_info; |
437 GetModelSafeRoutingInfo(&routing_info); | 440 GetModelSafeRoutingInfo(&routing_info); |
438 | 441 |
439 if (context_) { | 442 if (context_) { |
440 context_->set_routing_info(routing_info); | 443 context_->SetRoutingInfo(routing_info); |
441 } | 444 } |
442 | 445 |
443 mock_server_->ExpectGetUpdatesRequestTypes(enabled_datatypes_); | 446 mock_server_->ExpectGetUpdatesRequestTypes(enabled_datatypes_); |
444 } | 447 } |
445 | 448 |
446 void DisableDatatype(ModelType model_type) { | 449 void DisableDatatype(ModelType model_type) { |
447 enabled_datatypes_.Remove(model_type); | 450 enabled_datatypes_.Remove(model_type); |
448 | 451 |
449 ModelSafeRoutingInfo routing_info; | 452 ModelSafeRoutingInfo routing_info; |
450 GetModelSafeRoutingInfo(&routing_info); | 453 GetModelSafeRoutingInfo(&routing_info); |
451 | 454 |
452 if (context_) { | 455 if (context_) { |
453 context_->set_routing_info(routing_info); | 456 context_->SetRoutingInfo(routing_info); |
454 } | 457 } |
455 | 458 |
456 mock_server_->ExpectGetUpdatesRequestTypes(enabled_datatypes_); | 459 mock_server_->ExpectGetUpdatesRequestTypes(enabled_datatypes_); |
457 } | 460 } |
458 | 461 |
459 Cryptographer* GetCryptographer(syncable::BaseTransaction* trans) { | 462 Cryptographer* GetCryptographer(syncable::BaseTransaction* trans) { |
460 return directory()->GetCryptographer(trans); | 463 return directory()->GetCryptographer(trans); |
461 } | 464 } |
462 | 465 |
463 // Configures SyncSessionContext and NudgeTracker so Syncer won't call | 466 // Configures SyncSessionContext and NudgeTracker so Syncer won't call |
(...skipping 22 matching lines...) Expand all Loading... |
486 | 489 |
487 TestDirectorySetterUpper dir_maker_; | 490 TestDirectorySetterUpper dir_maker_; |
488 FakeEncryptor encryptor_; | 491 FakeEncryptor encryptor_; |
489 scoped_refptr<ExtensionsActivity> extensions_activity_; | 492 scoped_refptr<ExtensionsActivity> extensions_activity_; |
490 scoped_ptr<MockConnectionManager> mock_server_; | 493 scoped_ptr<MockConnectionManager> mock_server_; |
491 CancelationSignal cancelation_signal_; | 494 CancelationSignal cancelation_signal_; |
492 | 495 |
493 Syncer* syncer_; | 496 Syncer* syncer_; |
494 | 497 |
495 scoped_ptr<SyncSession> session_; | 498 scoped_ptr<SyncSession> session_; |
| 499 scoped_ptr<ModelTypeRegistry> model_type_registry_; |
496 scoped_ptr<SyncSessionContext> context_; | 500 scoped_ptr<SyncSessionContext> context_; |
497 bool saw_syncer_event_; | 501 bool saw_syncer_event_; |
498 base::TimeDelta last_short_poll_interval_received_; | 502 base::TimeDelta last_short_poll_interval_received_; |
499 base::TimeDelta last_long_poll_interval_received_; | 503 base::TimeDelta last_long_poll_interval_received_; |
500 base::TimeDelta last_sessions_commit_delay_seconds_; | 504 base::TimeDelta last_sessions_commit_delay_seconds_; |
501 int last_client_invalidation_hint_buffer_size_; | 505 int last_client_invalidation_hint_buffer_size_; |
502 std::vector<scoped_refptr<ModelSafeWorker> > workers_; | 506 std::vector<scoped_refptr<ModelSafeWorker> > workers_; |
503 | 507 |
504 ModelTypeSet enabled_datatypes_; | 508 ModelTypeSet enabled_datatypes_; |
505 TrafficRecorder traffic_recorder_; | 509 TrafficRecorder traffic_recorder_; |
(...skipping 4291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4797 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); | 4801 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); |
4798 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); | 4802 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); |
4799 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); | 4803 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); |
4800 } else { | 4804 } else { |
4801 EXPECT_TRUE(final_monitor_records.empty()) | 4805 EXPECT_TRUE(final_monitor_records.empty()) |
4802 << "Should not restore records after successful bookmark commit."; | 4806 << "Should not restore records after successful bookmark commit."; |
4803 } | 4807 } |
4804 } | 4808 } |
4805 | 4809 |
4806 } // namespace syncer | 4810 } // namespace syncer |
OLD | NEW |