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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } | 144 } |
145 virtual void OnReceivedSessionsCommitDelay( | 145 virtual void OnReceivedSessionsCommitDelay( |
146 const base::TimeDelta& new_delay) OVERRIDE { | 146 const base::TimeDelta& new_delay) OVERRIDE { |
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 OnReceivedGuRetryDelay(const base::TimeDelta& delay) OVERRIDE {} | 153 virtual void OnReceivedGuRetryDelay(const base::TimeDelta& delay) OVERRIDE {} |
154 virtual void OnSyncProtocolError( | 154 virtual void OnSyncProtocolError(const SyncProtocolError& error) OVERRIDE {} |
155 const sessions::SyncSessionSnapshot& snapshot) OVERRIDE { | |
156 } | |
157 | 155 |
158 void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { | 156 void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { |
159 // We're just testing the sync engine here, so we shunt everything to | 157 // We're just testing the sync engine here, so we shunt everything to |
160 // the SyncerThread. Datatypes which aren't enabled aren't in the map. | 158 // the SyncerThread. Datatypes which aren't enabled aren't in the map. |
161 for (ModelTypeSet::Iterator it = enabled_datatypes_.First(); | 159 for (ModelTypeSet::Iterator it = enabled_datatypes_.First(); |
162 it.Good(); it.Inc()) { | 160 it.Good(); it.Inc()) { |
163 (*out)[it.Get()] = GROUP_PASSIVE; | 161 (*out)[it.Get()] = GROUP_PASSIVE; |
164 } | 162 } |
165 } | 163 } |
166 | 164 |
167 virtual void OnSyncEngineEvent(const SyncEngineEvent& event) OVERRIDE { | 165 virtual void OnSyncCycleEvent(const SyncCycleEvent& event) OVERRIDE { |
168 DVLOG(1) << "HandleSyncEngineEvent in unittest " << event.what_happened; | 166 DVLOG(1) << "HandleSyncEngineEvent in unittest " << event.what_happened; |
169 // we only test for entry-specific events, not status changed ones. | 167 // we only test for entry-specific events, not status changed ones. |
170 switch (event.what_happened) { | 168 switch (event.what_happened) { |
171 case SyncEngineEvent::SYNC_CYCLE_BEGIN: // Fall through. | 169 case SyncCycleEvent::SYNC_CYCLE_BEGIN: // Fall through. |
172 case SyncEngineEvent::STATUS_CHANGED: | 170 case SyncCycleEvent::STATUS_CHANGED: |
173 case SyncEngineEvent::SYNC_CYCLE_ENDED: | 171 case SyncCycleEvent::SYNC_CYCLE_ENDED: |
174 return; | 172 return; |
175 default: | 173 default: |
176 CHECK(false) << "Handling unknown error type in unit tests!!"; | 174 CHECK(false) << "Handling unknown error type in unit tests!!"; |
177 } | 175 } |
178 saw_syncer_event_ = true; | 176 saw_syncer_event_ = true; |
179 } | 177 } |
180 | 178 |
| 179 virtual void OnActionableError(const SyncProtocolError& error) OVERRIDE {} |
| 180 virtual void OnRetryTimeChanged(base::Time retry_time) OVERRIDE {} |
| 181 virtual void OnThrottledTypesChanged(ModelTypeSet throttled_types) OVERRIDE {} |
| 182 |
181 void ResetSession() { | 183 void ResetSession() { |
182 session_.reset(SyncSession::Build(context_.get(), this)); | 184 session_.reset(SyncSession::Build(context_.get(), this)); |
183 } | 185 } |
184 | 186 |
185 void SyncShareNudge() { | 187 void SyncShareNudge() { |
186 ResetSession(); | 188 ResetSession(); |
187 | 189 |
188 // Pretend we've seen a local change, to make the nudge_tracker look normal. | 190 // Pretend we've seen a local change, to make the nudge_tracker look normal. |
189 nudge_tracker_.RecordLocalChange(ModelTypeSet(BOOKMARKS)); | 191 nudge_tracker_.RecordLocalChange(ModelTypeSet(BOOKMARKS)); |
190 | 192 |
(...skipping 4610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4801 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); | 4803 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); |
4802 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); | 4804 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); |
4803 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); | 4805 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); |
4804 } else { | 4806 } else { |
4805 EXPECT_TRUE(final_monitor_records.empty()) | 4807 EXPECT_TRUE(final_monitor_records.empty()) |
4806 << "Should not restore records after successful bookmark commit."; | 4808 << "Should not restore records after successful bookmark commit."; |
4807 } | 4809 } |
4808 } | 4810 } |
4809 | 4811 |
4810 } // namespace syncer | 4812 } // namespace syncer |
OLD | NEW |