OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 14 matching lines...) Expand all Loading... |
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/nigori_util.h" | 28 #include "sync/engine/nigori_util.h" |
29 #include "sync/engine/process_updates_command.h" | 29 #include "sync/engine/process_updates_command.h" |
30 #include "sync/engine/sync_scheduler.h" | 30 #include "sync/engine/sync_scheduler.h" |
31 #include "sync/engine/syncer.h" | 31 #include "sync/engine/syncer.h" |
32 #include "sync/engine/syncer_proto_util.h" | 32 #include "sync/engine/syncer_proto_util.h" |
33 #include "sync/engine/syncer_util.h" | 33 #include "sync/engine/syncer_util.h" |
34 #include "sync/engine/syncproto.h" | 34 #include "sync/engine/syncproto.h" |
| 35 #include "sync/engine/throttled_data_type_tracker.h" |
35 #include "sync/engine/traffic_recorder.h" | 36 #include "sync/engine/traffic_recorder.h" |
36 #include "sync/internal_api/public/engine/model_safe_worker.h" | 37 #include "sync/internal_api/public/engine/model_safe_worker.h" |
37 #include "sync/internal_api/public/syncable/model_type.h" | 38 #include "sync/internal_api/public/syncable/model_type.h" |
38 #include "sync/protocol/bookmark_specifics.pb.h" | 39 #include "sync/protocol/bookmark_specifics.pb.h" |
39 #include "sync/protocol/nigori_specifics.pb.h" | 40 #include "sync/protocol/nigori_specifics.pb.h" |
40 #include "sync/protocol/preference_specifics.pb.h" | 41 #include "sync/protocol/preference_specifics.pb.h" |
41 #include "sync/protocol/sync.pb.h" | 42 #include "sync/protocol/sync.pb.h" |
42 #include "sync/sessions/sync_session_context.h" | 43 #include "sync/sessions/sync_session_context.h" |
43 #include "sync/syncable/syncable.h" | 44 #include "sync/syncable/syncable.h" |
44 #include "sync/test/engine/fake_model_worker.h" | 45 #include "sync/test/engine/fake_model_worker.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 worker_ = new FakeModelWorker(GROUP_PASSIVE); | 226 worker_ = new FakeModelWorker(GROUP_PASSIVE); |
226 std::vector<SyncEngineEventListener*> listeners; | 227 std::vector<SyncEngineEventListener*> listeners; |
227 listeners.push_back(this); | 228 listeners.push_back(this); |
228 | 229 |
229 ModelSafeRoutingInfo routing_info; | 230 ModelSafeRoutingInfo routing_info; |
230 std::vector<ModelSafeWorker*> workers; | 231 std::vector<ModelSafeWorker*> workers; |
231 | 232 |
232 GetModelSafeRoutingInfo(&routing_info); | 233 GetModelSafeRoutingInfo(&routing_info); |
233 GetWorkers(&workers); | 234 GetWorkers(&workers); |
234 | 235 |
| 236 throttled_data_type_tracker_.reset(new ThrottledDataTypeTracker(NULL)); |
| 237 |
235 context_.reset( | 238 context_.reset( |
236 new SyncSessionContext( | 239 new SyncSessionContext( |
237 mock_server_.get(), directory(), routing_info, workers, | 240 mock_server_.get(), directory(), routing_info, workers, |
238 &extensions_activity_monitor_, listeners, NULL, | 241 &extensions_activity_monitor_, throttled_data_type_tracker_.get(), |
239 &traffic_recorder_)); | 242 listeners, NULL, &traffic_recorder_)); |
240 ASSERT_FALSE(context_->resolver()); | 243 ASSERT_FALSE(context_->resolver()); |
241 syncer_ = new Syncer(); | 244 syncer_ = new Syncer(); |
242 session_.reset(MakeSession()); | 245 session_.reset(MakeSession()); |
243 | 246 |
244 ReadTransaction trans(FROM_HERE, directory()); | 247 ReadTransaction trans(FROM_HERE, directory()); |
245 syncable::Directory::ChildHandles children; | 248 syncable::Directory::ChildHandles children; |
246 directory()->GetChildHandlesById(&trans, trans.root_id(), &children); | 249 directory()->GetChildHandlesById(&trans, trans.root_id(), &children); |
247 ASSERT_EQ(0u, children.size()); | 250 ASSERT_EQ(0u, children.size()); |
248 saw_syncer_event_ = false; | 251 saw_syncer_event_ = false; |
249 root_id_ = TestIdFactory::root(); | 252 root_id_ = TestIdFactory::root(); |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 // more confusing. | 540 // more confusing. |
538 syncable::Id root_id_; | 541 syncable::Id root_id_; |
539 syncable::Id parent_id_; | 542 syncable::Id parent_id_; |
540 syncable::Id child_id_; | 543 syncable::Id child_id_; |
541 | 544 |
542 TestIdFactory ids_; | 545 TestIdFactory ids_; |
543 | 546 |
544 TestDirectorySetterUpper dir_maker_; | 547 TestDirectorySetterUpper dir_maker_; |
545 FakeEncryptor encryptor_; | 548 FakeEncryptor encryptor_; |
546 FakeExtensionsActivityMonitor extensions_activity_monitor_; | 549 FakeExtensionsActivityMonitor extensions_activity_monitor_; |
| 550 scoped_ptr<ThrottledDataTypeTracker> throttled_data_type_tracker_; |
547 scoped_ptr<MockConnectionManager> mock_server_; | 551 scoped_ptr<MockConnectionManager> mock_server_; |
548 | 552 |
549 Syncer* syncer_; | 553 Syncer* syncer_; |
550 | 554 |
551 scoped_ptr<SyncSession> session_; | 555 scoped_ptr<SyncSession> session_; |
552 scoped_ptr<SyncSessionContext> context_; | 556 scoped_ptr<SyncSessionContext> context_; |
553 bool saw_syncer_event_; | 557 bool saw_syncer_event_; |
554 base::TimeDelta last_short_poll_interval_received_; | 558 base::TimeDelta last_short_poll_interval_received_; |
555 base::TimeDelta last_long_poll_interval_received_; | 559 base::TimeDelta last_long_poll_interval_received_; |
556 base::TimeDelta last_sessions_commit_delay_seconds_; | 560 base::TimeDelta last_sessions_commit_delay_seconds_; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 { | 644 { |
641 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 645 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
642 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 646 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
643 ASSERT_TRUE(A.good()); | 647 ASSERT_TRUE(A.good()); |
644 A.Put(IS_UNSYNCED, true); | 648 A.Put(IS_UNSYNCED, true); |
645 A.Put(SPECIFICS, bookmark_data); | 649 A.Put(SPECIFICS, bookmark_data); |
646 A.Put(NON_UNIQUE_NAME, "bookmark"); | 650 A.Put(NON_UNIQUE_NAME, "bookmark"); |
647 } | 651 } |
648 | 652 |
649 // Now set the throttled types. | 653 // Now set the throttled types. |
650 context_->SetUnthrottleTime( | 654 context_->throttled_data_type_tracker()->SetUnthrottleTime( |
651 throttled_types, | 655 throttled_types, |
652 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1200)); | 656 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1200)); |
653 SyncShareNudge(); | 657 SyncShareNudge(); |
654 | 658 |
655 { | 659 { |
656 // Nothing should have been committed as bookmarks is throttled. | 660 // Nothing should have been committed as bookmarks is throttled. |
657 ReadTransaction rtrans(FROM_HERE, directory()); | 661 ReadTransaction rtrans(FROM_HERE, directory()); |
658 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); | 662 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); |
659 ASSERT_TRUE(entryA.good()); | 663 ASSERT_TRUE(entryA.good()); |
660 EXPECT_TRUE(entryA.Get(IS_UNSYNCED)); | 664 EXPECT_TRUE(entryA.Get(IS_UNSYNCED)); |
661 } | 665 } |
662 | 666 |
663 // Now unthrottle. | 667 // Now unthrottle. |
664 context_->SetUnthrottleTime( | 668 context_->throttled_data_type_tracker()->SetUnthrottleTime( |
665 throttled_types, | 669 throttled_types, |
666 base::TimeTicks::Now() - base::TimeDelta::FromSeconds(1200)); | 670 base::TimeTicks::Now() - base::TimeDelta::FromSeconds(1200)); |
667 SyncShareNudge(); | 671 SyncShareNudge(); |
668 { | 672 { |
669 // It should have been committed. | 673 // It should have been committed. |
670 ReadTransaction rtrans(FROM_HERE, directory()); | 674 ReadTransaction rtrans(FROM_HERE, directory()); |
671 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); | 675 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); |
672 ASSERT_TRUE(entryA.good()); | 676 ASSERT_TRUE(entryA.good()); |
673 EXPECT_FALSE(entryA.Get(IS_UNSYNCED)); | 677 EXPECT_FALSE(entryA.Get(IS_UNSYNCED)); |
674 } | 678 } |
(...skipping 4147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4822 | 4826 |
4823 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { | 4827 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { |
4824 Add(mid_id_); | 4828 Add(mid_id_); |
4825 Add(low_id_); | 4829 Add(low_id_); |
4826 Add(high_id_); | 4830 Add(high_id_); |
4827 SyncShareNudge(); | 4831 SyncShareNudge(); |
4828 ExpectLocalOrderIsByServerId(); | 4832 ExpectLocalOrderIsByServerId(); |
4829 } | 4833 } |
4830 | 4834 |
4831 } // namespace browser_sync | 4835 } // namespace browser_sync |
OLD | NEW |