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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 GetWorkers(&workers); | 226 GetWorkers(&workers); |
227 | 227 |
228 context_.reset( | 228 context_.reset( |
229 new SyncSessionContext( | 229 new SyncSessionContext( |
230 mock_server_.get(), directory(), workers, | 230 mock_server_.get(), directory(), workers, |
231 extensions_activity_, | 231 extensions_activity_, |
232 listeners, debug_info_getter_.get(), &traffic_recorder_, | 232 listeners, debug_info_getter_.get(), &traffic_recorder_, |
233 true, // enable keystore encryption | 233 true, // enable keystore encryption |
234 false, // force enable pre-commit GU avoidance experiment | 234 false, // force enable pre-commit GU avoidance experiment |
235 "fake_invalidator_client_id")); | 235 "fake_invalidator_client_id")); |
236 context_->set_routing_info(routing_info); | 236 context_->SetRoutingInfo(routing_info); |
237 syncer_ = new Syncer(&cancelation_signal_); | 237 syncer_ = new Syncer(&cancelation_signal_); |
238 | 238 |
239 syncable::ReadTransaction trans(FROM_HERE, directory()); | 239 syncable::ReadTransaction trans(FROM_HERE, directory()); |
240 syncable::Directory::Metahandles children; | 240 syncable::Directory::Metahandles children; |
241 directory()->GetChildHandlesById(&trans, trans.root_id(), &children); | 241 directory()->GetChildHandlesById(&trans, trans.root_id(), &children); |
242 ASSERT_EQ(0u, children.size()); | 242 ASSERT_EQ(0u, children.size()); |
243 saw_syncer_event_ = false; | 243 saw_syncer_event_ = false; |
244 root_id_ = TestIdFactory::root(); | 244 root_id_ = TestIdFactory::root(); |
245 parent_id_ = ids_.MakeServer("parent id"); | 245 parent_id_ = ids_.MakeServer("parent id"); |
246 child_id_ = ids_.MakeServer("child id"); | 246 child_id_ = ids_.MakeServer("child id"); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 return entry.GetMetahandle(); | 435 return entry.GetMetahandle(); |
436 } | 436 } |
437 | 437 |
438 void EnableDatatype(ModelType model_type) { | 438 void EnableDatatype(ModelType model_type) { |
439 enabled_datatypes_.Put(model_type); | 439 enabled_datatypes_.Put(model_type); |
440 | 440 |
441 ModelSafeRoutingInfo routing_info; | 441 ModelSafeRoutingInfo routing_info; |
442 GetModelSafeRoutingInfo(&routing_info); | 442 GetModelSafeRoutingInfo(&routing_info); |
443 | 443 |
444 if (context_) { | 444 if (context_) { |
445 context_->set_routing_info(routing_info); | 445 context_->SetRoutingInfo(routing_info); |
446 } | 446 } |
447 | 447 |
448 mock_server_->ExpectGetUpdatesRequestTypes(enabled_datatypes_); | 448 mock_server_->ExpectGetUpdatesRequestTypes(enabled_datatypes_); |
449 } | 449 } |
450 | 450 |
451 void DisableDatatype(ModelType model_type) { | 451 void DisableDatatype(ModelType model_type) { |
452 enabled_datatypes_.Remove(model_type); | 452 enabled_datatypes_.Remove(model_type); |
453 | 453 |
454 ModelSafeRoutingInfo routing_info; | 454 ModelSafeRoutingInfo routing_info; |
455 GetModelSafeRoutingInfo(&routing_info); | 455 GetModelSafeRoutingInfo(&routing_info); |
456 | 456 |
457 if (context_) { | 457 if (context_) { |
458 context_->set_routing_info(routing_info); | 458 context_->SetRoutingInfo(routing_info); |
459 } | 459 } |
460 | 460 |
461 mock_server_->ExpectGetUpdatesRequestTypes(enabled_datatypes_); | 461 mock_server_->ExpectGetUpdatesRequestTypes(enabled_datatypes_); |
462 } | 462 } |
463 | 463 |
464 Cryptographer* GetCryptographer(syncable::BaseTransaction* trans) { | 464 Cryptographer* GetCryptographer(syncable::BaseTransaction* trans) { |
465 return directory()->GetCryptographer(trans); | 465 return directory()->GetCryptographer(trans); |
466 } | 466 } |
467 | 467 |
468 // Configures SyncSessionContext and NudgeTracker so Syncer won't call | 468 // Configures SyncSessionContext and NudgeTracker so Syncer won't call |
(...skipping 4333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4802 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); | 4802 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); |
4803 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); | 4803 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); |
4804 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); | 4804 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); |
4805 } else { | 4805 } else { |
4806 EXPECT_TRUE(final_monitor_records.empty()) | 4806 EXPECT_TRUE(final_monitor_records.empty()) |
4807 << "Should not restore records after successful bookmark commit."; | 4807 << "Should not restore records after successful bookmark commit."; |
4808 } | 4808 } |
4809 } | 4809 } |
4810 | 4810 |
4811 } // namespace syncer | 4811 } // namespace syncer |
OLD | NEW |