| 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 (syncable::ModelTypeSet::Iterator it = enabled_datatypes_.First(); | 157 for (syncable::ModelTypeSet::Iterator it = enabled_datatypes_.First(); |
| 157 it.Good(); it.Inc()) { | 158 it.Good(); it.Inc()) { |
| 158 (*out)[it.Get()] = GROUP_PASSIVE; | 159 if (!IsInternalType(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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 } while (should_loop); | 220 } while (should_loop); |
| 216 } | 221 } |
| 217 | 222 |
| 218 virtual void SetUp() { | 223 virtual void SetUp() { |
| 219 dir_maker_.SetUp(); | 224 dir_maker_.SetUp(); |
| 220 mock_server_.reset(new MockConnectionManager(directory())); | 225 mock_server_.reset(new MockConnectionManager(directory())); |
| 221 EnableDatatype(syncable::BOOKMARKS); | 226 EnableDatatype(syncable::BOOKMARKS); |
| 222 EnableDatatype(syncable::NIGORI); | 227 EnableDatatype(syncable::NIGORI); |
| 223 EnableDatatype(syncable::PREFERENCES); | 228 EnableDatatype(syncable::PREFERENCES); |
| 224 EnableDatatype(syncable::NIGORI); | 229 EnableDatatype(syncable::NIGORI); |
| 225 worker_ = new FakeModelWorker(GROUP_PASSIVE); | 230 passive_worker_ = new FakeModelWorker(GROUP_PASSIVE); |
| 231 control_worker_ = new FakeModelWorker(GROUP_CONTROL); |
| 226 std::vector<SyncEngineEventListener*> listeners; | 232 std::vector<SyncEngineEventListener*> listeners; |
| 227 listeners.push_back(this); | 233 listeners.push_back(this); |
| 228 | 234 |
| 229 ModelSafeRoutingInfo routing_info; | 235 ModelSafeRoutingInfo routing_info; |
| 230 std::vector<ModelSafeWorker*> workers; | 236 std::vector<ModelSafeWorker*> workers; |
| 231 | 237 |
| 232 GetModelSafeRoutingInfo(&routing_info); | 238 GetModelSafeRoutingInfo(&routing_info); |
| 233 GetWorkers(&workers); | 239 GetWorkers(&workers); |
| 234 | 240 |
| 235 throttled_data_type_tracker_.reset(new ThrottledDataTypeTracker(NULL)); | 241 throttled_data_type_tracker_.reset(new ThrottledDataTypeTracker(NULL)); |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 scoped_ptr<MockConnectionManager> mock_server_; | 556 scoped_ptr<MockConnectionManager> mock_server_; |
| 551 | 557 |
| 552 Syncer* syncer_; | 558 Syncer* syncer_; |
| 553 | 559 |
| 554 scoped_ptr<SyncSession> session_; | 560 scoped_ptr<SyncSession> session_; |
| 555 scoped_ptr<SyncSessionContext> context_; | 561 scoped_ptr<SyncSessionContext> context_; |
| 556 bool saw_syncer_event_; | 562 bool saw_syncer_event_; |
| 557 base::TimeDelta last_short_poll_interval_received_; | 563 base::TimeDelta last_short_poll_interval_received_; |
| 558 base::TimeDelta last_long_poll_interval_received_; | 564 base::TimeDelta last_long_poll_interval_received_; |
| 559 base::TimeDelta last_sessions_commit_delay_seconds_; | 565 base::TimeDelta last_sessions_commit_delay_seconds_; |
| 560 scoped_refptr<ModelSafeWorker> worker_; | 566 scoped_refptr<ModelSafeWorker> passive_worker_; |
| 567 scoped_refptr<ModelSafeWorker> control_worker_; |
| 561 | 568 |
| 562 syncable::ModelTypeSet enabled_datatypes_; | 569 syncable::ModelTypeSet enabled_datatypes_; |
| 563 csync::TrafficRecorder traffic_recorder_; | 570 csync::TrafficRecorder traffic_recorder_; |
| 564 | 571 |
| 565 DISALLOW_COPY_AND_ASSIGN(SyncerTest); | 572 DISALLOW_COPY_AND_ASSIGN(SyncerTest); |
| 566 }; | 573 }; |
| 567 | 574 |
| 568 TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) { | 575 TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) { |
| 569 { | 576 { |
| 570 Syncer::UnsyncedMetaHandles handles; | 577 Syncer::UnsyncedMetaHandles handles; |
| (...skipping 4254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4825 | 4832 |
| 4826 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { | 4833 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { |
| 4827 Add(mid_id_); | 4834 Add(mid_id_); |
| 4828 Add(low_id_); | 4835 Add(low_id_); |
| 4829 Add(high_id_); | 4836 Add(high_id_); |
| 4830 SyncShareNudge(); | 4837 SyncShareNudge(); |
| 4831 ExpectLocalOrderIsByServerId(); | 4838 ExpectLocalOrderIsByServerId(); |
| 4832 } | 4839 } |
| 4833 | 4840 |
| 4834 } // namespace csync | 4841 } // namespace csync |
| OLD | NEW |