Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: sync/engine/syncer_unittest.cc

Issue 10825137: FYI: Control Data + Per-Device Metadata (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 const base::TimeDelta& new_delay) OVERRIDE { 139 const base::TimeDelta& new_delay) OVERRIDE {
140 last_sessions_commit_delay_seconds_ = new_delay; 140 last_sessions_commit_delay_seconds_ = new_delay;
141 } 141 }
142 virtual void OnShouldStopSyncingPermanently() OVERRIDE { 142 virtual void OnShouldStopSyncingPermanently() OVERRIDE {
143 } 143 }
144 virtual void OnSyncProtocolError( 144 virtual void OnSyncProtocolError(
145 const sessions::SyncSessionSnapshot& snapshot) OVERRIDE { 145 const sessions::SyncSessionSnapshot& snapshot) OVERRIDE {
146 } 146 }
147 147
148 void GetWorkers(std::vector<ModelSafeWorker*>* out) { 148 void GetWorkers(std::vector<ModelSafeWorker*>* out) {
149 out->push_back(worker_.get()); 149 out->push_back(control_worker_.get());
150 out->push_back(passive_worker_.get());
150 } 151 }
151 152
152 void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { 153 void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) {
153 // We're just testing the sync engine here, so we shunt everything to 154 // We're just testing the sync engine here, so we shunt everything to
154 // the SyncerThread. Datatypes which aren't enabled aren't in the map. 155 // the SyncerThread. Datatypes which aren't enabled aren't in the map.
155 for (ModelTypeSet::Iterator it = enabled_datatypes_.First(); 156 for (ModelTypeSet::Iterator it = enabled_datatypes_.First();
156 it.Good(); it.Inc()) { 157 it.Good(); it.Inc()) {
157 (*out)[it.Get()] = GROUP_PASSIVE; 158 if (!IsControlType(it.Get())) {
159 (*out)[it.Get()] = GROUP_PASSIVE;
160 } else {
161 (*out)[it.Get()] = GROUP_CONTROL;
162 }
158 } 163 }
159 } 164 }
160 165
161 virtual void OnSyncEngineEvent(const SyncEngineEvent& event) OVERRIDE { 166 virtual void OnSyncEngineEvent(const SyncEngineEvent& event) OVERRIDE {
162 DVLOG(1) << "HandleSyncEngineEvent in unittest " << event.what_happened; 167 DVLOG(1) << "HandleSyncEngineEvent in unittest " << event.what_happened;
163 // we only test for entry-specific events, not status changed ones. 168 // we only test for entry-specific events, not status changed ones.
164 switch (event.what_happened) { 169 switch (event.what_happened) {
165 case SyncEngineEvent::SYNC_CYCLE_BEGIN: // Fall through. 170 case SyncEngineEvent::SYNC_CYCLE_BEGIN: // Fall through.
166 case SyncEngineEvent::STATUS_CHANGED: 171 case SyncEngineEvent::STATUS_CHANGED:
167 case SyncEngineEvent::SYNC_CYCLE_ENDED: 172 case SyncEngineEvent::SYNC_CYCLE_ENDED:
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(BOOKMARKS); 226 EnableDatatype(BOOKMARKS);
222 EnableDatatype(NIGORI); 227 EnableDatatype(NIGORI);
223 EnableDatatype(PREFERENCES); 228 EnableDatatype(PREFERENCES);
224 EnableDatatype(NIGORI); 229 EnableDatatype(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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 scoped_ptr<MockConnectionManager> mock_server_; 560 scoped_ptr<MockConnectionManager> mock_server_;
555 561
556 Syncer* syncer_; 562 Syncer* syncer_;
557 563
558 scoped_ptr<SyncSession> session_; 564 scoped_ptr<SyncSession> session_;
559 scoped_ptr<SyncSessionContext> context_; 565 scoped_ptr<SyncSessionContext> context_;
560 bool saw_syncer_event_; 566 bool saw_syncer_event_;
561 base::TimeDelta last_short_poll_interval_received_; 567 base::TimeDelta last_short_poll_interval_received_;
562 base::TimeDelta last_long_poll_interval_received_; 568 base::TimeDelta last_long_poll_interval_received_;
563 base::TimeDelta last_sessions_commit_delay_seconds_; 569 base::TimeDelta last_sessions_commit_delay_seconds_;
564 scoped_refptr<ModelSafeWorker> worker_; 570 scoped_refptr<ModelSafeWorker> passive_worker_;
571 scoped_refptr<ModelSafeWorker> control_worker_;
565 572
566 ModelTypeSet enabled_datatypes_; 573 ModelTypeSet enabled_datatypes_;
567 TrafficRecorder traffic_recorder_; 574 TrafficRecorder traffic_recorder_;
568 575
569 DISALLOW_COPY_AND_ASSIGN(SyncerTest); 576 DISALLOW_COPY_AND_ASSIGN(SyncerTest);
570 }; 577 };
571 578
572 TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) { 579 TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) {
573 { 580 {
574 Syncer::UnsyncedMetaHandles handles; 581 Syncer::UnsyncedMetaHandles handles;
(...skipping 4282 matching lines...) Expand 10 before | Expand all | Expand 10 after
4857 4864
4858 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { 4865 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) {
4859 Add(mid_id_); 4866 Add(mid_id_);
4860 Add(low_id_); 4867 Add(low_id_);
4861 Add(high_id_); 4868 Add(high_id_);
4862 SyncShareNudge(); 4869 SyncShareNudge();
4863 ExpectLocalOrderIsByServerId(); 4870 ExpectLocalOrderIsByServerId();
4864 } 4871 }
4865 4872
4866 } // namespace syncer 4873 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698