| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 TypeDebugInfoCache(); | 103 TypeDebugInfoCache(); |
| 104 virtual ~TypeDebugInfoCache(); | 104 virtual ~TypeDebugInfoCache(); |
| 105 | 105 |
| 106 CommitCounters GetLatestCommitCounters(ModelType type) const; | 106 CommitCounters GetLatestCommitCounters(ModelType type) const; |
| 107 UpdateCounters GetLatestUpdateCounters(ModelType type) const; | 107 UpdateCounters GetLatestUpdateCounters(ModelType type) const; |
| 108 StatusCounters GetLatestStatusCounters(ModelType type) const; | 108 StatusCounters GetLatestStatusCounters(ModelType type) const; |
| 109 | 109 |
| 110 // TypeDebugInfoObserver implementation. | 110 // TypeDebugInfoObserver implementation. |
| 111 virtual void OnCommitCountersUpdated( | 111 virtual void OnCommitCountersUpdated( |
| 112 syncer::ModelType type, | 112 syncer::ModelType type, |
| 113 const CommitCounters& counters) OVERRIDE; | 113 const CommitCounters& counters) override; |
| 114 virtual void OnUpdateCountersUpdated( | 114 virtual void OnUpdateCountersUpdated( |
| 115 syncer::ModelType type, | 115 syncer::ModelType type, |
| 116 const UpdateCounters& counters) OVERRIDE; | 116 const UpdateCounters& counters) override; |
| 117 virtual void OnStatusCountersUpdated( | 117 virtual void OnStatusCountersUpdated( |
| 118 syncer::ModelType type, | 118 syncer::ModelType type, |
| 119 const StatusCounters& counters) OVERRIDE; | 119 const StatusCounters& counters) override; |
| 120 | 120 |
| 121 private: | 121 private: |
| 122 std::map<ModelType, CommitCounters> commit_counters_map_; | 122 std::map<ModelType, CommitCounters> commit_counters_map_; |
| 123 std::map<ModelType, UpdateCounters> update_counters_map_; | 123 std::map<ModelType, UpdateCounters> update_counters_map_; |
| 124 std::map<ModelType, StatusCounters> status_counters_map_; | 124 std::map<ModelType, StatusCounters> status_counters_map_; |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 TypeDebugInfoCache::TypeDebugInfoCache() {} | 127 TypeDebugInfoCache::TypeDebugInfoCache() {} |
| 128 | 128 |
| 129 TypeDebugInfoCache::~TypeDebugInfoCache() {} | 129 TypeDebugInfoCache::~TypeDebugInfoCache() {} |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 public SyncEngineEventListener { | 186 public SyncEngineEventListener { |
| 187 protected: | 187 protected: |
| 188 SyncerTest() | 188 SyncerTest() |
| 189 : extensions_activity_(new ExtensionsActivity), | 189 : extensions_activity_(new ExtensionsActivity), |
| 190 syncer_(NULL), | 190 syncer_(NULL), |
| 191 saw_syncer_event_(false), | 191 saw_syncer_event_(false), |
| 192 last_client_invalidation_hint_buffer_size_(10) { | 192 last_client_invalidation_hint_buffer_size_(10) { |
| 193 } | 193 } |
| 194 | 194 |
| 195 // SyncSession::Delegate implementation. | 195 // SyncSession::Delegate implementation. |
| 196 virtual void OnThrottled(const base::TimeDelta& throttle_duration) OVERRIDE { | 196 virtual void OnThrottled(const base::TimeDelta& throttle_duration) override { |
| 197 FAIL() << "Should not get silenced."; | 197 FAIL() << "Should not get silenced."; |
| 198 } | 198 } |
| 199 virtual void OnTypesThrottled( | 199 virtual void OnTypesThrottled( |
| 200 ModelTypeSet types, | 200 ModelTypeSet types, |
| 201 const base::TimeDelta& throttle_duration) OVERRIDE { | 201 const base::TimeDelta& throttle_duration) override { |
| 202 FAIL() << "Should not get silenced."; | 202 FAIL() << "Should not get silenced."; |
| 203 } | 203 } |
| 204 virtual bool IsCurrentlyThrottled() OVERRIDE { | 204 virtual bool IsCurrentlyThrottled() override { |
| 205 return false; | 205 return false; |
| 206 } | 206 } |
| 207 virtual void OnReceivedLongPollIntervalUpdate( | 207 virtual void OnReceivedLongPollIntervalUpdate( |
| 208 const base::TimeDelta& new_interval) OVERRIDE { | 208 const base::TimeDelta& new_interval) override { |
| 209 last_long_poll_interval_received_ = new_interval; | 209 last_long_poll_interval_received_ = new_interval; |
| 210 } | 210 } |
| 211 virtual void OnReceivedShortPollIntervalUpdate( | 211 virtual void OnReceivedShortPollIntervalUpdate( |
| 212 const base::TimeDelta& new_interval) OVERRIDE { | 212 const base::TimeDelta& new_interval) override { |
| 213 last_short_poll_interval_received_ = new_interval; | 213 last_short_poll_interval_received_ = new_interval; |
| 214 } | 214 } |
| 215 virtual void OnReceivedCustomNudgeDelays( | 215 virtual void OnReceivedCustomNudgeDelays( |
| 216 const std::map<ModelType, base::TimeDelta>& delay_map) OVERRIDE { | 216 const std::map<ModelType, base::TimeDelta>& delay_map) override { |
| 217 std::map<ModelType, base::TimeDelta>::const_iterator iter = | 217 std::map<ModelType, base::TimeDelta>::const_iterator iter = |
| 218 delay_map.find(SESSIONS); | 218 delay_map.find(SESSIONS); |
| 219 if (iter != delay_map.end() && iter->second > base::TimeDelta()) | 219 if (iter != delay_map.end() && iter->second > base::TimeDelta()) |
| 220 last_sessions_commit_delay_ = iter->second; | 220 last_sessions_commit_delay_ = iter->second; |
| 221 iter = delay_map.find(BOOKMARKS); | 221 iter = delay_map.find(BOOKMARKS); |
| 222 if (iter != delay_map.end() && iter->second > base::TimeDelta()) | 222 if (iter != delay_map.end() && iter->second > base::TimeDelta()) |
| 223 last_bookmarks_commit_delay_ = iter->second; | 223 last_bookmarks_commit_delay_ = iter->second; |
| 224 } | 224 } |
| 225 virtual void OnReceivedClientInvalidationHintBufferSize( | 225 virtual void OnReceivedClientInvalidationHintBufferSize( |
| 226 int size) OVERRIDE { | 226 int size) override { |
| 227 last_client_invalidation_hint_buffer_size_ = size; | 227 last_client_invalidation_hint_buffer_size_ = size; |
| 228 } | 228 } |
| 229 virtual void OnReceivedGuRetryDelay(const base::TimeDelta& delay) OVERRIDE {} | 229 virtual void OnReceivedGuRetryDelay(const base::TimeDelta& delay) override {} |
| 230 virtual void OnReceivedMigrationRequest(ModelTypeSet types) OVERRIDE {} | 230 virtual void OnReceivedMigrationRequest(ModelTypeSet types) override {} |
| 231 virtual void OnProtocolEvent(const ProtocolEvent& event) OVERRIDE {} | 231 virtual void OnProtocolEvent(const ProtocolEvent& event) override {} |
| 232 virtual void OnSyncProtocolError(const SyncProtocolError& error) OVERRIDE {} | 232 virtual void OnSyncProtocolError(const SyncProtocolError& error) override {} |
| 233 | 233 |
| 234 void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { | 234 void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { |
| 235 // We're just testing the sync engine here, so we shunt everything to | 235 // We're just testing the sync engine here, so we shunt everything to |
| 236 // the SyncerThread. Datatypes which aren't enabled aren't in the map. | 236 // the SyncerThread. Datatypes which aren't enabled aren't in the map. |
| 237 for (ModelTypeSet::Iterator it = enabled_datatypes_.First(); | 237 for (ModelTypeSet::Iterator it = enabled_datatypes_.First(); |
| 238 it.Good(); it.Inc()) { | 238 it.Good(); it.Inc()) { |
| 239 (*out)[it.Get()] = GROUP_PASSIVE; | 239 (*out)[it.Get()] = GROUP_PASSIVE; |
| 240 } | 240 } |
| 241 } | 241 } |
| 242 | 242 |
| 243 virtual void OnSyncCycleEvent(const SyncCycleEvent& event) OVERRIDE { | 243 virtual void OnSyncCycleEvent(const SyncCycleEvent& event) override { |
| 244 DVLOG(1) << "HandleSyncEngineEvent in unittest " << event.what_happened; | 244 DVLOG(1) << "HandleSyncEngineEvent in unittest " << event.what_happened; |
| 245 // we only test for entry-specific events, not status changed ones. | 245 // we only test for entry-specific events, not status changed ones. |
| 246 switch (event.what_happened) { | 246 switch (event.what_happened) { |
| 247 case SyncCycleEvent::SYNC_CYCLE_BEGIN: // Fall through. | 247 case SyncCycleEvent::SYNC_CYCLE_BEGIN: // Fall through. |
| 248 case SyncCycleEvent::STATUS_CHANGED: | 248 case SyncCycleEvent::STATUS_CHANGED: |
| 249 case SyncCycleEvent::SYNC_CYCLE_ENDED: | 249 case SyncCycleEvent::SYNC_CYCLE_ENDED: |
| 250 return; | 250 return; |
| 251 default: | 251 default: |
| 252 CHECK(false) << "Handling unknown error type in unit tests!!"; | 252 CHECK(false) << "Handling unknown error type in unit tests!!"; |
| 253 } | 253 } |
| 254 saw_syncer_event_ = true; | 254 saw_syncer_event_ = true; |
| 255 } | 255 } |
| 256 | 256 |
| 257 virtual void OnActionableError(const SyncProtocolError& error) OVERRIDE {} | 257 virtual void OnActionableError(const SyncProtocolError& error) override {} |
| 258 virtual void OnRetryTimeChanged(base::Time retry_time) OVERRIDE {} | 258 virtual void OnRetryTimeChanged(base::Time retry_time) override {} |
| 259 virtual void OnThrottledTypesChanged(ModelTypeSet throttled_types) OVERRIDE {} | 259 virtual void OnThrottledTypesChanged(ModelTypeSet throttled_types) override {} |
| 260 virtual void OnMigrationRequested(ModelTypeSet types) OVERRIDE {} | 260 virtual void OnMigrationRequested(ModelTypeSet types) override {} |
| 261 | 261 |
| 262 void ResetSession() { | 262 void ResetSession() { |
| 263 session_.reset(SyncSession::Build(context_.get(), this)); | 263 session_.reset(SyncSession::Build(context_.get(), this)); |
| 264 } | 264 } |
| 265 | 265 |
| 266 void SyncShareNudge() { | 266 void SyncShareNudge() { |
| 267 ResetSession(); | 267 ResetSession(); |
| 268 | 268 |
| 269 // Pretend we've seen a local change, to make the nudge_tracker look normal. | 269 // Pretend we've seen a local change, to make the nudge_tracker look normal. |
| 270 nudge_tracker_.RecordLocalChange(ModelTypeSet(BOOKMARKS)); | 270 nudge_tracker_.RecordLocalChange(ModelTypeSet(BOOKMARKS)); |
| (...skipping 4778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5049 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); | 5049 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); |
| 5050 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); | 5050 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); |
| 5051 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); | 5051 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); |
| 5052 } else { | 5052 } else { |
| 5053 EXPECT_TRUE(final_monitor_records.empty()) | 5053 EXPECT_TRUE(final_monitor_records.empty()) |
| 5054 << "Should not restore records after successful bookmark commit."; | 5054 << "Should not restore records after successful bookmark commit."; |
| 5055 } | 5055 } |
| 5056 } | 5056 } |
| 5057 | 5057 |
| 5058 } // namespace syncer | 5058 } // namespace syncer |
| OLD | NEW |