| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 const base::TimeDelta& new_delay) OVERRIDE { | 140 const base::TimeDelta& new_delay) OVERRIDE { |
| 141 last_sessions_commit_delay_seconds_ = new_delay; | 141 last_sessions_commit_delay_seconds_ = new_delay; |
| 142 } | 142 } |
| 143 virtual void OnShouldStopSyncingPermanently() OVERRIDE { | 143 virtual void OnShouldStopSyncingPermanently() OVERRIDE { |
| 144 } | 144 } |
| 145 virtual void OnSyncProtocolError( | 145 virtual void OnSyncProtocolError( |
| 146 const sessions::SyncSessionSnapshot& snapshot) OVERRIDE { | 146 const sessions::SyncSessionSnapshot& snapshot) OVERRIDE { |
| 147 } | 147 } |
| 148 | 148 |
| 149 void GetWorkers(std::vector<ModelSafeWorker*>* out) { | 149 void GetWorkers(std::vector<ModelSafeWorker*>* out) { |
| 150 out->push_back(worker_.get()); | 150 out->push_back(control_worker_.get()); |
| 151 out->push_back(passive_worker_.get()); |
| 151 } | 152 } |
| 152 | 153 |
| 153 void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { | 154 void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { |
| 154 // We're just testing the sync engine here, so we shunt everything to | 155 // We're just testing the sync engine here, so we shunt everything to |
| 155 // the SyncerThread. Datatypes which aren't enabled aren't in the map. | 156 // the SyncerThread. Datatypes which aren't enabled aren't in the map. |
| 156 for (ModelTypeSet::Iterator it = enabled_datatypes_.First(); | 157 for (ModelTypeSet::Iterator it = enabled_datatypes_.First(); |
| 157 it.Good(); it.Inc()) { | 158 it.Good(); it.Inc()) { |
| 158 (*out)[it.Get()] = GROUP_PASSIVE; | 159 if (!IsControlType(it.Get())) { |
| 160 (*out)[it.Get()] = GROUP_PASSIVE; |
| 161 } else { |
| 162 (*out)[it.Get()] = GROUP_CONTROL; |
| 163 } |
| 159 } | 164 } |
| 160 } | 165 } |
| 161 | 166 |
| 162 virtual void OnSyncEngineEvent(const SyncEngineEvent& event) OVERRIDE { | 167 virtual void OnSyncEngineEvent(const SyncEngineEvent& event) OVERRIDE { |
| 163 DVLOG(1) << "HandleSyncEngineEvent in unittest " << event.what_happened; | 168 DVLOG(1) << "HandleSyncEngineEvent in unittest " << event.what_happened; |
| 164 // we only test for entry-specific events, not status changed ones. | 169 // we only test for entry-specific events, not status changed ones. |
| 165 switch (event.what_happened) { | 170 switch (event.what_happened) { |
| 166 case SyncEngineEvent::SYNC_CYCLE_BEGIN: // Fall through. | 171 case SyncEngineEvent::SYNC_CYCLE_BEGIN: // Fall through. |
| 167 case SyncEngineEvent::STATUS_CHANGED: | 172 case SyncEngineEvent::STATUS_CHANGED: |
| 168 case SyncEngineEvent::SYNC_CYCLE_ENDED: | 173 case SyncEngineEvent::SYNC_CYCLE_ENDED: |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 } while (should_loop); | 221 } while (should_loop); |
| 217 } | 222 } |
| 218 | 223 |
| 219 virtual void SetUp() { | 224 virtual void SetUp() { |
| 220 dir_maker_.SetUp(); | 225 dir_maker_.SetUp(); |
| 221 mock_server_.reset(new MockConnectionManager(directory())); | 226 mock_server_.reset(new MockConnectionManager(directory())); |
| 222 EnableDatatype(BOOKMARKS); | 227 EnableDatatype(BOOKMARKS); |
| 223 EnableDatatype(NIGORI); | 228 EnableDatatype(NIGORI); |
| 224 EnableDatatype(PREFERENCES); | 229 EnableDatatype(PREFERENCES); |
| 225 EnableDatatype(NIGORI); | 230 EnableDatatype(NIGORI); |
| 226 worker_ = new FakeModelWorker(GROUP_PASSIVE); | 231 passive_worker_ = new FakeModelWorker(GROUP_PASSIVE); |
| 232 control_worker_ = new FakeModelWorker(GROUP_CONTROL); |
| 227 std::vector<SyncEngineEventListener*> listeners; | 233 std::vector<SyncEngineEventListener*> listeners; |
| 228 listeners.push_back(this); | 234 listeners.push_back(this); |
| 229 | 235 |
| 230 ModelSafeRoutingInfo routing_info; | 236 ModelSafeRoutingInfo routing_info; |
| 231 std::vector<ModelSafeWorker*> workers; | 237 std::vector<ModelSafeWorker*> workers; |
| 232 | 238 |
| 233 GetModelSafeRoutingInfo(&routing_info); | 239 GetModelSafeRoutingInfo(&routing_info); |
| 234 GetWorkers(&workers); | 240 GetWorkers(&workers); |
| 235 | 241 |
| 236 throttled_data_type_tracker_.reset(new ThrottledDataTypeTracker(NULL)); | 242 throttled_data_type_tracker_.reset(new ThrottledDataTypeTracker(NULL)); |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 scoped_ptr<MockConnectionManager> mock_server_; | 562 scoped_ptr<MockConnectionManager> mock_server_; |
| 557 | 563 |
| 558 Syncer* syncer_; | 564 Syncer* syncer_; |
| 559 | 565 |
| 560 scoped_ptr<SyncSession> session_; | 566 scoped_ptr<SyncSession> session_; |
| 561 scoped_ptr<SyncSessionContext> context_; | 567 scoped_ptr<SyncSessionContext> context_; |
| 562 bool saw_syncer_event_; | 568 bool saw_syncer_event_; |
| 563 base::TimeDelta last_short_poll_interval_received_; | 569 base::TimeDelta last_short_poll_interval_received_; |
| 564 base::TimeDelta last_long_poll_interval_received_; | 570 base::TimeDelta last_long_poll_interval_received_; |
| 565 base::TimeDelta last_sessions_commit_delay_seconds_; | 571 base::TimeDelta last_sessions_commit_delay_seconds_; |
| 566 scoped_refptr<ModelSafeWorker> worker_; | 572 scoped_refptr<ModelSafeWorker> passive_worker_; |
| 573 scoped_refptr<ModelSafeWorker> control_worker_; |
| 567 | 574 |
| 568 ModelTypeSet enabled_datatypes_; | 575 ModelTypeSet enabled_datatypes_; |
| 569 TrafficRecorder traffic_recorder_; | 576 TrafficRecorder traffic_recorder_; |
| 570 | 577 |
| 571 FakeSyncEncryptionHandler fake_encryption_handler_; | 578 FakeSyncEncryptionHandler fake_encryption_handler_; |
| 572 | 579 |
| 573 DISALLOW_COPY_AND_ASSIGN(SyncerTest); | 580 DISALLOW_COPY_AND_ASSIGN(SyncerTest); |
| 574 }; | 581 }; |
| 575 | 582 |
| 576 TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) { | 583 TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) { |
| (...skipping 4204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4781 | 4788 |
| 4782 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { | 4789 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { |
| 4783 Add(mid_id_); | 4790 Add(mid_id_); |
| 4784 Add(low_id_); | 4791 Add(low_id_); |
| 4785 Add(high_id_); | 4792 Add(high_id_); |
| 4786 SyncShareNudge(); | 4793 SyncShareNudge(); |
| 4787 ExpectLocalOrderIsByServerId(); | 4794 ExpectLocalOrderIsByServerId(); |
| 4788 } | 4795 } |
| 4789 | 4796 |
| 4790 } // namespace syncer | 4797 } // namespace syncer |
| OLD | NEW |