| 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 12 matching lines...) Expand all Loading... |
| 23 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
| 24 #include "base/time/time.h" | 24 #include "base/time/time.h" |
| 25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
| 26 #include "sync/engine/get_commit_ids.h" | 26 #include "sync/engine/get_commit_ids.h" |
| 27 #include "sync/engine/net/server_connection_manager.h" | 27 #include "sync/engine/net/server_connection_manager.h" |
| 28 #include "sync/engine/process_updates_command.h" | 28 #include "sync/engine/process_updates_command.h" |
| 29 #include "sync/engine/sync_scheduler_impl.h" | 29 #include "sync/engine/sync_scheduler_impl.h" |
| 30 #include "sync/engine/syncer.h" | 30 #include "sync/engine/syncer.h" |
| 31 #include "sync/engine/syncer_proto_util.h" | 31 #include "sync/engine/syncer_proto_util.h" |
| 32 #include "sync/engine/traffic_recorder.h" | 32 #include "sync/engine/traffic_recorder.h" |
| 33 #include "sync/internal_api/public/base/cancelation_signal.h" |
| 33 #include "sync/internal_api/public/base/model_type.h" | 34 #include "sync/internal_api/public/base/model_type.h" |
| 34 #include "sync/internal_api/public/engine/model_safe_worker.h" | 35 #include "sync/internal_api/public/engine/model_safe_worker.h" |
| 35 #include "sync/protocol/bookmark_specifics.pb.h" | 36 #include "sync/protocol/bookmark_specifics.pb.h" |
| 36 #include "sync/protocol/nigori_specifics.pb.h" | 37 #include "sync/protocol/nigori_specifics.pb.h" |
| 37 #include "sync/protocol/preference_specifics.pb.h" | 38 #include "sync/protocol/preference_specifics.pb.h" |
| 38 #include "sync/protocol/sync.pb.h" | 39 #include "sync/protocol/sync.pb.h" |
| 39 #include "sync/sessions/sync_session_context.h" | 40 #include "sync/sessions/sync_session_context.h" |
| 40 #include "sync/syncable/mutable_entry.h" | 41 #include "sync/syncable/mutable_entry.h" |
| 41 #include "sync/syncable/nigori_util.h" | 42 #include "sync/syncable/nigori_util.h" |
| 42 #include "sync/syncable/syncable_delete_journal.h" | 43 #include "sync/syncable/syncable_delete_journal.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 void SyncShareConfigure() { | 198 void SyncShareConfigure() { |
| 198 session_.reset(SyncSession::Build(context_.get(), this)); | 199 session_.reset(SyncSession::Build(context_.get(), this)); |
| 199 EXPECT_TRUE(syncer_->ConfigureSyncShare( | 200 EXPECT_TRUE(syncer_->ConfigureSyncShare( |
| 200 GetRoutingInfoTypes(context_->routing_info()), | 201 GetRoutingInfoTypes(context_->routing_info()), |
| 201 sync_pb::GetUpdatesCallerInfo::RECONFIGURATION, | 202 sync_pb::GetUpdatesCallerInfo::RECONFIGURATION, |
| 202 session_.get())); | 203 session_.get())); |
| 203 } | 204 } |
| 204 | 205 |
| 205 virtual void SetUp() { | 206 virtual void SetUp() { |
| 206 dir_maker_.SetUp(); | 207 dir_maker_.SetUp(); |
| 207 mock_server_.reset(new MockConnectionManager(directory())); | 208 mock_server_.reset(new MockConnectionManager(directory(), |
| 209 &cancelation_signal_)); |
| 208 EnableDatatype(BOOKMARKS); | 210 EnableDatatype(BOOKMARKS); |
| 209 EnableDatatype(NIGORI); | 211 EnableDatatype(NIGORI); |
| 210 EnableDatatype(PREFERENCES); | 212 EnableDatatype(PREFERENCES); |
| 211 EnableDatatype(NIGORI); | 213 EnableDatatype(NIGORI); |
| 212 worker_ = new FakeModelWorker(GROUP_PASSIVE); | 214 worker_ = new FakeModelWorker(GROUP_PASSIVE); |
| 213 std::vector<SyncEngineEventListener*> listeners; | 215 std::vector<SyncEngineEventListener*> listeners; |
| 214 listeners.push_back(this); | 216 listeners.push_back(this); |
| 215 | 217 |
| 216 ModelSafeRoutingInfo routing_info; | 218 ModelSafeRoutingInfo routing_info; |
| 217 std::vector<ModelSafeWorker*> workers; | 219 std::vector<ModelSafeWorker*> workers; |
| 218 | 220 |
| 219 GetModelSafeRoutingInfo(&routing_info); | 221 GetModelSafeRoutingInfo(&routing_info); |
| 220 GetWorkers(&workers); | 222 GetWorkers(&workers); |
| 221 | 223 |
| 222 context_.reset( | 224 context_.reset( |
| 223 new SyncSessionContext( | 225 new SyncSessionContext( |
| 224 mock_server_.get(), directory(), workers, | 226 mock_server_.get(), directory(), workers, |
| 225 extensions_activity_, | 227 extensions_activity_, |
| 226 listeners, NULL, &traffic_recorder_, | 228 listeners, NULL, &traffic_recorder_, |
| 227 true, // enable keystore encryption | 229 true, // enable keystore encryption |
| 228 false, // force enable pre-commit GU avoidance experiment | 230 false, // force enable pre-commit GU avoidance experiment |
| 229 "fake_invalidator_client_id")); | 231 "fake_invalidator_client_id")); |
| 230 context_->set_routing_info(routing_info); | 232 context_->set_routing_info(routing_info); |
| 231 syncer_ = new Syncer(); | 233 syncer_ = new Syncer(&cancelation_signal_); |
| 232 | 234 |
| 233 syncable::ReadTransaction trans(FROM_HERE, directory()); | 235 syncable::ReadTransaction trans(FROM_HERE, directory()); |
| 234 syncable::Directory::Metahandles children; | 236 syncable::Directory::Metahandles children; |
| 235 directory()->GetChildHandlesById(&trans, trans.root_id(), &children); | 237 directory()->GetChildHandlesById(&trans, trans.root_id(), &children); |
| 236 ASSERT_EQ(0u, children.size()); | 238 ASSERT_EQ(0u, children.size()); |
| 237 saw_syncer_event_ = false; | 239 saw_syncer_event_ = false; |
| 238 root_id_ = TestIdFactory::root(); | 240 root_id_ = TestIdFactory::root(); |
| 239 parent_id_ = ids_.MakeServer("parent id"); | 241 parent_id_ = ids_.MakeServer("parent id"); |
| 240 child_id_ = ids_.MakeServer("child id"); | 242 child_id_ = ids_.MakeServer("child id"); |
| 241 directory()->set_store_birthday(mock_server_->store_birthday()); | 243 directory()->set_store_birthday(mock_server_->store_birthday()); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 syncable::Id root_id_; | 542 syncable::Id root_id_; |
| 541 syncable::Id parent_id_; | 543 syncable::Id parent_id_; |
| 542 syncable::Id child_id_; | 544 syncable::Id child_id_; |
| 543 | 545 |
| 544 TestIdFactory ids_; | 546 TestIdFactory ids_; |
| 545 | 547 |
| 546 TestDirectorySetterUpper dir_maker_; | 548 TestDirectorySetterUpper dir_maker_; |
| 547 FakeEncryptor encryptor_; | 549 FakeEncryptor encryptor_; |
| 548 scoped_refptr<ExtensionsActivity> extensions_activity_; | 550 scoped_refptr<ExtensionsActivity> extensions_activity_; |
| 549 scoped_ptr<MockConnectionManager> mock_server_; | 551 scoped_ptr<MockConnectionManager> mock_server_; |
| 552 CancelationSignal cancelation_signal_; |
| 550 | 553 |
| 551 Syncer* syncer_; | 554 Syncer* syncer_; |
| 552 | 555 |
| 553 scoped_ptr<SyncSession> session_; | 556 scoped_ptr<SyncSession> session_; |
| 554 scoped_ptr<SyncSessionContext> context_; | 557 scoped_ptr<SyncSessionContext> context_; |
| 555 bool saw_syncer_event_; | 558 bool saw_syncer_event_; |
| 556 base::TimeDelta last_short_poll_interval_received_; | 559 base::TimeDelta last_short_poll_interval_received_; |
| 557 base::TimeDelta last_long_poll_interval_received_; | 560 base::TimeDelta last_long_poll_interval_received_; |
| 558 base::TimeDelta last_sessions_commit_delay_seconds_; | 561 base::TimeDelta last_sessions_commit_delay_seconds_; |
| 559 int last_client_invalidation_hint_buffer_size_; | 562 int last_client_invalidation_hint_buffer_size_; |
| (...skipping 4173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4733 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); | 4736 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); |
| 4734 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); | 4737 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); |
| 4735 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); | 4738 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); |
| 4736 } else { | 4739 } else { |
| 4737 EXPECT_TRUE(final_monitor_records.empty()) | 4740 EXPECT_TRUE(final_monitor_records.empty()) |
| 4738 << "Should not restore records after successful bookmark commit."; | 4741 << "Should not restore records after successful bookmark commit."; |
| 4739 } | 4742 } |
| 4740 } | 4743 } |
| 4741 | 4744 |
| 4742 } // namespace syncer | 4745 } // namespace syncer |
| OLD | NEW |