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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 worker_ = new FakeModelWorker(GROUP_PASSIVE); | 218 worker_ = new FakeModelWorker(GROUP_PASSIVE); |
219 std::vector<SyncEngineEventListener*> listeners; | 219 std::vector<SyncEngineEventListener*> listeners; |
220 listeners.push_back(this); | 220 listeners.push_back(this); |
221 | 221 |
222 ModelSafeRoutingInfo routing_info; | 222 ModelSafeRoutingInfo routing_info; |
223 std::vector<ModelSafeWorker*> workers; | 223 std::vector<ModelSafeWorker*> workers; |
224 | 224 |
225 GetModelSafeRoutingInfo(&routing_info); | 225 GetModelSafeRoutingInfo(&routing_info); |
226 GetWorkers(&workers); | 226 GetWorkers(&workers); |
227 | 227 |
| 228 model_type_registry_.reset(new ModelTypeRegistry(directory(), workers)); |
| 229 |
228 context_.reset( | 230 context_.reset( |
229 new SyncSessionContext( | 231 new SyncSessionContext( |
230 mock_server_.get(), directory(), workers, | 232 mock_server_.get(), directory(), |
231 extensions_activity_, | 233 extensions_activity_, |
232 listeners, debug_info_getter_.get(), &traffic_recorder_, | 234 listeners, debug_info_getter_.get(), &traffic_recorder_, |
| 235 model_type_registry_.get(), |
233 true, // enable keystore encryption | 236 true, // enable keystore encryption |
234 false, // force enable pre-commit GU avoidance experiment | 237 false, // force enable pre-commit GU avoidance experiment |
235 "fake_invalidator_client_id")); | 238 "fake_invalidator_client_id")); |
236 context_->set_routing_info(routing_info); | 239 context_->SetRoutingInfo(routing_info); |
237 syncer_ = new Syncer(&cancelation_signal_); | 240 syncer_ = new Syncer(&cancelation_signal_); |
238 | 241 |
239 syncable::ReadTransaction trans(FROM_HERE, directory()); | 242 syncable::ReadTransaction trans(FROM_HERE, directory()); |
240 syncable::Directory::Metahandles children; | 243 syncable::Directory::Metahandles children; |
241 directory()->GetChildHandlesById(&trans, trans.root_id(), &children); | 244 directory()->GetChildHandlesById(&trans, trans.root_id(), &children); |
242 ASSERT_EQ(0u, children.size()); | 245 ASSERT_EQ(0u, children.size()); |
243 saw_syncer_event_ = false; | 246 saw_syncer_event_ = false; |
244 root_id_ = TestIdFactory::root(); | 247 root_id_ = TestIdFactory::root(); |
245 parent_id_ = ids_.MakeServer("parent id"); | 248 parent_id_ = ids_.MakeServer("parent id"); |
246 child_id_ = ids_.MakeServer("child id"); | 249 child_id_ = ids_.MakeServer("child id"); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 return entry.GetMetahandle(); | 438 return entry.GetMetahandle(); |
436 } | 439 } |
437 | 440 |
438 void EnableDatatype(ModelType model_type) { | 441 void EnableDatatype(ModelType model_type) { |
439 enabled_datatypes_.Put(model_type); | 442 enabled_datatypes_.Put(model_type); |
440 | 443 |
441 ModelSafeRoutingInfo routing_info; | 444 ModelSafeRoutingInfo routing_info; |
442 GetModelSafeRoutingInfo(&routing_info); | 445 GetModelSafeRoutingInfo(&routing_info); |
443 | 446 |
444 if (context_) { | 447 if (context_) { |
445 context_->set_routing_info(routing_info); | 448 context_->SetRoutingInfo(routing_info); |
446 } | 449 } |
447 | 450 |
448 mock_server_->ExpectGetUpdatesRequestTypes(enabled_datatypes_); | 451 mock_server_->ExpectGetUpdatesRequestTypes(enabled_datatypes_); |
449 } | 452 } |
450 | 453 |
451 void DisableDatatype(ModelType model_type) { | 454 void DisableDatatype(ModelType model_type) { |
452 enabled_datatypes_.Remove(model_type); | 455 enabled_datatypes_.Remove(model_type); |
453 | 456 |
454 ModelSafeRoutingInfo routing_info; | 457 ModelSafeRoutingInfo routing_info; |
455 GetModelSafeRoutingInfo(&routing_info); | 458 GetModelSafeRoutingInfo(&routing_info); |
456 | 459 |
457 if (context_) { | 460 if (context_) { |
458 context_->set_routing_info(routing_info); | 461 context_->SetRoutingInfo(routing_info); |
459 } | 462 } |
460 | 463 |
461 mock_server_->ExpectGetUpdatesRequestTypes(enabled_datatypes_); | 464 mock_server_->ExpectGetUpdatesRequestTypes(enabled_datatypes_); |
462 } | 465 } |
463 | 466 |
464 Cryptographer* GetCryptographer(syncable::BaseTransaction* trans) { | 467 Cryptographer* GetCryptographer(syncable::BaseTransaction* trans) { |
465 return directory()->GetCryptographer(trans); | 468 return directory()->GetCryptographer(trans); |
466 } | 469 } |
467 | 470 |
468 // Configures SyncSessionContext and NudgeTracker so Syncer won't call | 471 // Configures SyncSessionContext and NudgeTracker so Syncer won't call |
(...skipping 22 matching lines...) Expand all Loading... |
491 | 494 |
492 TestDirectorySetterUpper dir_maker_; | 495 TestDirectorySetterUpper dir_maker_; |
493 FakeEncryptor encryptor_; | 496 FakeEncryptor encryptor_; |
494 scoped_refptr<ExtensionsActivity> extensions_activity_; | 497 scoped_refptr<ExtensionsActivity> extensions_activity_; |
495 scoped_ptr<MockConnectionManager> mock_server_; | 498 scoped_ptr<MockConnectionManager> mock_server_; |
496 CancelationSignal cancelation_signal_; | 499 CancelationSignal cancelation_signal_; |
497 | 500 |
498 Syncer* syncer_; | 501 Syncer* syncer_; |
499 | 502 |
500 scoped_ptr<SyncSession> session_; | 503 scoped_ptr<SyncSession> session_; |
| 504 scoped_ptr<ModelTypeRegistry> model_type_registry_; |
501 scoped_ptr<SyncSessionContext> context_; | 505 scoped_ptr<SyncSessionContext> context_; |
502 bool saw_syncer_event_; | 506 bool saw_syncer_event_; |
503 base::TimeDelta last_short_poll_interval_received_; | 507 base::TimeDelta last_short_poll_interval_received_; |
504 base::TimeDelta last_long_poll_interval_received_; | 508 base::TimeDelta last_long_poll_interval_received_; |
505 base::TimeDelta last_sessions_commit_delay_seconds_; | 509 base::TimeDelta last_sessions_commit_delay_seconds_; |
506 int last_client_invalidation_hint_buffer_size_; | 510 int last_client_invalidation_hint_buffer_size_; |
507 scoped_refptr<ModelSafeWorker> worker_; | 511 scoped_refptr<ModelSafeWorker> worker_; |
508 | 512 |
509 ModelTypeSet enabled_datatypes_; | 513 ModelTypeSet enabled_datatypes_; |
510 TrafficRecorder traffic_recorder_; | 514 TrafficRecorder traffic_recorder_; |
(...skipping 4291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4802 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); | 4806 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); |
4803 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); | 4807 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); |
4804 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); | 4808 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); |
4805 } else { | 4809 } else { |
4806 EXPECT_TRUE(final_monitor_records.empty()) | 4810 EXPECT_TRUE(final_monitor_records.empty()) |
4807 << "Should not restore records after successful bookmark commit."; | 4811 << "Should not restore records after successful bookmark commit."; |
4808 } | 4812 } |
4809 } | 4813 } |
4810 | 4814 |
4811 } // namespace syncer | 4815 } // namespace syncer |
OLD | NEW |