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_command.h" | 26 #include "sync/engine/get_commit_ids_command.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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 222 |
222 context_.reset( | 223 context_.reset( |
223 new SyncSessionContext( | 224 new SyncSessionContext( |
224 mock_server_.get(), directory(), workers, | 225 mock_server_.get(), directory(), workers, |
225 extensions_activity_, | 226 extensions_activity_, |
226 listeners, NULL, &traffic_recorder_, | 227 listeners, NULL, &traffic_recorder_, |
227 true, // enable keystore encryption | 228 true, // enable keystore encryption |
228 false, // force enable pre-commit GU avoidance experiment | 229 false, // force enable pre-commit GU avoidance experiment |
229 "fake_invalidator_client_id")); | 230 "fake_invalidator_client_id")); |
230 context_->set_routing_info(routing_info); | 231 context_->set_routing_info(routing_info); |
231 syncer_ = new Syncer(); | 232 syncer_ = new Syncer(&cancelation_signal_); |
232 | 233 |
233 syncable::ReadTransaction trans(FROM_HERE, directory()); | 234 syncable::ReadTransaction trans(FROM_HERE, directory()); |
234 syncable::Directory::Metahandles children; | 235 syncable::Directory::Metahandles children; |
235 directory()->GetChildHandlesById(&trans, trans.root_id(), &children); | 236 directory()->GetChildHandlesById(&trans, trans.root_id(), &children); |
236 ASSERT_EQ(0u, children.size()); | 237 ASSERT_EQ(0u, children.size()); |
237 saw_syncer_event_ = false; | 238 saw_syncer_event_ = false; |
238 root_id_ = TestIdFactory::root(); | 239 root_id_ = TestIdFactory::root(); |
239 parent_id_ = ids_.MakeServer("parent id"); | 240 parent_id_ = ids_.MakeServer("parent id"); |
240 child_id_ = ids_.MakeServer("child id"); | 241 child_id_ = ids_.MakeServer("child id"); |
241 directory()->set_store_birthday(mock_server_->store_birthday()); | 242 directory()->set_store_birthday(mock_server_->store_birthday()); |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 syncable::Id root_id_; | 545 syncable::Id root_id_; |
545 syncable::Id parent_id_; | 546 syncable::Id parent_id_; |
546 syncable::Id child_id_; | 547 syncable::Id child_id_; |
547 | 548 |
548 TestIdFactory ids_; | 549 TestIdFactory ids_; |
549 | 550 |
550 TestDirectorySetterUpper dir_maker_; | 551 TestDirectorySetterUpper dir_maker_; |
551 FakeEncryptor encryptor_; | 552 FakeEncryptor encryptor_; |
552 scoped_refptr<ExtensionsActivity> extensions_activity_; | 553 scoped_refptr<ExtensionsActivity> extensions_activity_; |
553 scoped_ptr<MockConnectionManager> mock_server_; | 554 scoped_ptr<MockConnectionManager> mock_server_; |
| 555 CancelationSignal cancelation_signal_; |
554 | 556 |
555 Syncer* syncer_; | 557 Syncer* syncer_; |
556 | 558 |
557 scoped_ptr<SyncSession> session_; | 559 scoped_ptr<SyncSession> session_; |
558 scoped_ptr<SyncSessionContext> context_; | 560 scoped_ptr<SyncSessionContext> context_; |
559 bool saw_syncer_event_; | 561 bool saw_syncer_event_; |
560 base::TimeDelta last_short_poll_interval_received_; | 562 base::TimeDelta last_short_poll_interval_received_; |
561 base::TimeDelta last_long_poll_interval_received_; | 563 base::TimeDelta last_long_poll_interval_received_; |
562 base::TimeDelta last_sessions_commit_delay_seconds_; | 564 base::TimeDelta last_sessions_commit_delay_seconds_; |
563 int last_client_invalidation_hint_buffer_size_; | 565 int last_client_invalidation_hint_buffer_size_; |
(...skipping 4242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4806 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); | 4808 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); |
4807 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); | 4809 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); |
4808 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); | 4810 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); |
4809 } else { | 4811 } else { |
4810 EXPECT_TRUE(final_monitor_records.empty()) | 4812 EXPECT_TRUE(final_monitor_records.empty()) |
4811 << "Should not restore records after successful bookmark commit."; | 4813 << "Should not restore records after successful bookmark commit."; |
4812 } | 4814 } |
4813 } | 4815 } |
4814 | 4816 |
4815 } // namespace syncer | 4817 } // namespace syncer |
OLD | NEW |