| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 last_sessions_commit_delay_seconds_ = new_delay; | 147 last_sessions_commit_delay_seconds_ = new_delay; |
| 148 } | 148 } |
| 149 virtual void OnReceivedClientInvalidationHintBufferSize( | 149 virtual void OnReceivedClientInvalidationHintBufferSize( |
| 150 int size) OVERRIDE { | 150 int size) OVERRIDE { |
| 151 last_client_invalidation_hint_buffer_size_ = size; | 151 last_client_invalidation_hint_buffer_size_ = size; |
| 152 } | 152 } |
| 153 virtual void OnSyncProtocolError( | 153 virtual void OnSyncProtocolError( |
| 154 const sessions::SyncSessionSnapshot& snapshot) OVERRIDE { | 154 const sessions::SyncSessionSnapshot& snapshot) OVERRIDE { |
| 155 } | 155 } |
| 156 | 156 |
| 157 void GetWorkers(std::vector<ModelSafeWorker*>* out) { | |
| 158 out->push_back(worker_.get()); | |
| 159 } | |
| 160 | |
| 161 void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { | 157 void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { |
| 162 // We're just testing the sync engine here, so we shunt everything to | 158 // We're just testing the sync engine here, so we shunt everything to |
| 163 // the SyncerThread. Datatypes which aren't enabled aren't in the map. | 159 // the SyncerThread. Datatypes which aren't enabled aren't in the map. |
| 164 for (ModelTypeSet::Iterator it = enabled_datatypes_.First(); | 160 for (ModelTypeSet::Iterator it = enabled_datatypes_.First(); |
| 165 it.Good(); it.Inc()) { | 161 it.Good(); it.Inc()) { |
| 166 (*out)[it.Get()] = GROUP_PASSIVE; | 162 (*out)[it.Get()] = GROUP_PASSIVE; |
| 167 } | 163 } |
| 168 } | 164 } |
| 169 | 165 |
| 170 virtual void OnSyncEngineEvent(const SyncEngineEvent& event) OVERRIDE { | 166 virtual void OnSyncEngineEvent(const SyncEngineEvent& event) OVERRIDE { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 204 |
| 209 virtual void SetUp() { | 205 virtual void SetUp() { |
| 210 dir_maker_.SetUp(); | 206 dir_maker_.SetUp(); |
| 211 mock_server_.reset(new MockConnectionManager(directory(), | 207 mock_server_.reset(new MockConnectionManager(directory(), |
| 212 &cancelation_signal_)); | 208 &cancelation_signal_)); |
| 213 debug_info_getter_.reset(new MockDebugInfoGetter); | 209 debug_info_getter_.reset(new MockDebugInfoGetter); |
| 214 EnableDatatype(BOOKMARKS); | 210 EnableDatatype(BOOKMARKS); |
| 215 EnableDatatype(NIGORI); | 211 EnableDatatype(NIGORI); |
| 216 EnableDatatype(PREFERENCES); | 212 EnableDatatype(PREFERENCES); |
| 217 EnableDatatype(NIGORI); | 213 EnableDatatype(NIGORI); |
| 218 worker_ = new FakeModelWorker(GROUP_PASSIVE); | 214 workers_.push_back(scoped_refptr<ModelSafeWorker>( |
| 215 new FakeModelWorker(GROUP_PASSIVE))); |
| 219 std::vector<SyncEngineEventListener*> listeners; | 216 std::vector<SyncEngineEventListener*> listeners; |
| 220 listeners.push_back(this); | 217 listeners.push_back(this); |
| 221 | 218 |
| 222 ModelSafeRoutingInfo routing_info; | 219 ModelSafeRoutingInfo routing_info; |
| 223 std::vector<ModelSafeWorker*> workers; | |
| 224 | |
| 225 GetModelSafeRoutingInfo(&routing_info); | 220 GetModelSafeRoutingInfo(&routing_info); |
| 226 GetWorkers(&workers); | |
| 227 | 221 |
| 228 context_.reset( | 222 context_.reset( |
| 229 new SyncSessionContext( | 223 new SyncSessionContext( |
| 230 mock_server_.get(), directory(), workers, | 224 mock_server_.get(), directory(), workers_, |
| 231 extensions_activity_, | 225 extensions_activity_, |
| 232 listeners, debug_info_getter_.get(), &traffic_recorder_, | 226 listeners, debug_info_getter_.get(), &traffic_recorder_, |
| 233 true, // enable keystore encryption | 227 true, // enable keystore encryption |
| 234 false, // force enable pre-commit GU avoidance experiment | 228 false, // force enable pre-commit GU avoidance experiment |
| 235 "fake_invalidator_client_id")); | 229 "fake_invalidator_client_id")); |
| 236 context_->set_routing_info(routing_info); | 230 context_->set_routing_info(routing_info); |
| 237 syncer_ = new Syncer(&cancelation_signal_); | 231 syncer_ = new Syncer(&cancelation_signal_); |
| 238 | 232 |
| 239 syncable::ReadTransaction trans(FROM_HERE, directory()); | 233 syncable::ReadTransaction trans(FROM_HERE, directory()); |
| 240 syncable::Directory::Metahandles children; | 234 syncable::Directory::Metahandles children; |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 | 491 |
| 498 Syncer* syncer_; | 492 Syncer* syncer_; |
| 499 | 493 |
| 500 scoped_ptr<SyncSession> session_; | 494 scoped_ptr<SyncSession> session_; |
| 501 scoped_ptr<SyncSessionContext> context_; | 495 scoped_ptr<SyncSessionContext> context_; |
| 502 bool saw_syncer_event_; | 496 bool saw_syncer_event_; |
| 503 base::TimeDelta last_short_poll_interval_received_; | 497 base::TimeDelta last_short_poll_interval_received_; |
| 504 base::TimeDelta last_long_poll_interval_received_; | 498 base::TimeDelta last_long_poll_interval_received_; |
| 505 base::TimeDelta last_sessions_commit_delay_seconds_; | 499 base::TimeDelta last_sessions_commit_delay_seconds_; |
| 506 int last_client_invalidation_hint_buffer_size_; | 500 int last_client_invalidation_hint_buffer_size_; |
| 507 scoped_refptr<ModelSafeWorker> worker_; | 501 std::vector<scoped_refptr<ModelSafeWorker> > workers_; |
| 508 | 502 |
| 509 ModelTypeSet enabled_datatypes_; | 503 ModelTypeSet enabled_datatypes_; |
| 510 TrafficRecorder traffic_recorder_; | 504 TrafficRecorder traffic_recorder_; |
| 511 sessions::NudgeTracker nudge_tracker_; | 505 sessions::NudgeTracker nudge_tracker_; |
| 512 scoped_ptr<MockDebugInfoGetter> debug_info_getter_; | 506 scoped_ptr<MockDebugInfoGetter> debug_info_getter_; |
| 513 | 507 |
| 514 DISALLOW_COPY_AND_ASSIGN(SyncerTest); | 508 DISALLOW_COPY_AND_ASSIGN(SyncerTest); |
| 515 }; | 509 }; |
| 516 | 510 |
| 517 TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) { | 511 TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) { |
| (...skipping 4284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4802 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); | 4796 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); |
| 4803 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); | 4797 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); |
| 4804 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); | 4798 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); |
| 4805 } else { | 4799 } else { |
| 4806 EXPECT_TRUE(final_monitor_records.empty()) | 4800 EXPECT_TRUE(final_monitor_records.empty()) |
| 4807 << "Should not restore records after successful bookmark commit."; | 4801 << "Should not restore records after successful bookmark commit."; |
| 4808 } | 4802 } |
| 4809 } | 4803 } |
| 4810 | 4804 |
| 4811 } // namespace syncer | 4805 } // namespace syncer |
| OLD | NEW |