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 #include "sync/sessions/sync_session.h" | 5 #include "sync/sessions/sync_session.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 | 205 |
206 std::vector<int64> unsynced_handles; | 206 std::vector<int64> unsynced_handles; |
207 unsynced_handles.push_back(1); | 207 unsynced_handles.push_back(1); |
208 unsynced_handles.push_back(2); | 208 unsynced_handles.push_back(2); |
209 status()->set_unsynced_handles(unsynced_handles); | 209 status()->set_unsynced_handles(unsynced_handles); |
210 EXPECT_FALSE(session_->HasMoreToSync()); | 210 EXPECT_FALSE(session_->HasMoreToSync()); |
211 status()->increment_num_successful_commits(); | 211 status()->increment_num_successful_commits(); |
212 EXPECT_TRUE(session_->HasMoreToSync()); | 212 EXPECT_TRUE(session_->HasMoreToSync()); |
213 } | 213 } |
214 | 214 |
215 TEST_F(SyncSessionTest, MoreToDownloadIfDownloadFailed) { | |
216 status()->set_updates_request_types(ParamsMeaningAllEnabledTypes()); | |
217 | |
218 // When DownloadUpdatesCommand fails, these should be false. | |
219 EXPECT_FALSE(status()->ServerSaysNothingMoreToDownload()); | |
220 EXPECT_FALSE(status()->download_updates_succeeded()); | |
221 | |
222 // Download updates has its own loop in the syncer; it shouldn't factor | |
223 // into HasMoreToSync. | |
224 EXPECT_FALSE(session_->HasMoreToSync()); | |
225 } | |
226 | |
227 TEST_F(SyncSessionTest, MoreToDownloadIfGotChangesRemaining) { | |
228 status()->set_updates_request_types(ParamsMeaningAllEnabledTypes()); | |
229 | |
230 // When the server returns changes_remaining, that means there's | |
231 // more to download. | |
232 status()->mutable_updates_response()->mutable_get_updates() | |
233 ->set_changes_remaining(1000L); | |
234 EXPECT_FALSE(status()->ServerSaysNothingMoreToDownload()); | |
235 EXPECT_TRUE(status()->download_updates_succeeded()); | |
236 | |
237 // Download updates has its own loop in the syncer; it shouldn't factor | |
238 // into HasMoreToSync. | |
239 EXPECT_FALSE(session_->HasMoreToSync()); | |
240 } | |
241 | |
242 TEST_F(SyncSessionTest, MoreToDownloadIfGotNoChangesRemaining) { | |
243 status()->set_updates_request_types(ParamsMeaningAllEnabledTypes()); | |
244 | |
245 // When the server returns a timestamp, that means we're up to date. | |
246 status()->mutable_updates_response()->mutable_get_updates() | |
247 ->set_changes_remaining(0); | |
248 EXPECT_TRUE(status()->ServerSaysNothingMoreToDownload()); | |
249 EXPECT_TRUE(status()->download_updates_succeeded()); | |
250 | |
251 // Download updates has its own loop in the syncer; it shouldn't factor | |
252 // into HasMoreToSync. | |
253 EXPECT_FALSE(session_->HasMoreToSync()); | |
254 } | |
255 | |
256 TEST_F(SyncSessionTest, MoreToDownloadIfGotNoChangesRemainingForSubset) { | |
257 status()->set_updates_request_types(ParamsMeaningJustOneEnabledType()); | |
258 | |
259 // When the server returns a timestamp, that means we're up to date for that | |
260 // type. But there may still be more to download if there are other | |
261 // datatypes that we didn't request on this go-round. | |
262 status()->mutable_updates_response()->mutable_get_updates() | |
263 ->set_changes_remaining(0); | |
264 | |
265 EXPECT_TRUE(status()->ServerSaysNothingMoreToDownload()); | |
266 EXPECT_TRUE(status()->download_updates_succeeded()); | |
267 | |
268 // Download updates has its own loop in the syncer; it shouldn't factor | |
269 // into HasMoreToSync. | |
270 EXPECT_FALSE(session_->HasMoreToSync()); | |
271 } | |
272 | |
273 TEST_F(SyncSessionTest, MoreToDownloadIfGotChangesRemainingAndEntries) { | |
274 status()->set_updates_request_types(ParamsMeaningAllEnabledTypes()); | |
275 // The actual entry count should not factor into the HasMoreToSync | |
276 // determination. | |
277 status()->mutable_updates_response()->mutable_get_updates()->add_entries(); | |
278 status()->mutable_updates_response()->mutable_get_updates() | |
279 ->set_changes_remaining(1000000L);; | |
280 EXPECT_FALSE(status()->ServerSaysNothingMoreToDownload()); | |
281 EXPECT_TRUE(status()->download_updates_succeeded()); | |
282 | |
283 // Download updates has its own loop in the syncer; it shouldn't factor | |
284 // into HasMoreToSync. | |
285 EXPECT_FALSE(session_->HasMoreToSync()); | |
286 } | |
287 | |
288 TEST_F(SyncSessionTest, MoreToDownloadIfGotNoChangesRemainingAndEntries) { | |
289 status()->set_updates_request_types(ParamsMeaningAllEnabledTypes()); | |
290 // The actual entry count should not factor into the HasMoreToSync | |
291 // determination. | |
292 status()->mutable_updates_response()->mutable_get_updates()->add_entries(); | |
293 status()->mutable_updates_response()->mutable_get_updates() | |
294 ->set_changes_remaining(0); | |
295 EXPECT_TRUE(status()->ServerSaysNothingMoreToDownload()); | |
296 EXPECT_TRUE(status()->download_updates_succeeded()); | |
297 | |
298 // Download updates has its own loop in the syncer; it shouldn't factor | |
299 // into HasMoreToSync. | |
300 EXPECT_FALSE(session_->HasMoreToSync()); | |
301 } | |
302 | |
303 TEST_F(SyncSessionTest, MoreToSyncIfConflictsResolved) { | 215 TEST_F(SyncSessionTest, MoreToSyncIfConflictsResolved) { |
304 // Conflict resolution happens after get updates and commit, | 216 // Conflict resolution happens after get updates and commit, |
305 // so we need to loop back and get updates / commit again now | 217 // so we need to loop back and get updates / commit again now |
306 // that we have made forward progress. | 218 // that we have made forward progress. |
307 status()->update_conflicts_resolved(true); | 219 status()->update_conflicts_resolved(true); |
308 EXPECT_TRUE(session_->HasMoreToSync()); | 220 EXPECT_TRUE(session_->HasMoreToSync()); |
309 } | 221 } |
310 | 222 |
311 TEST_F(SyncSessionTest, ResetTransientState) { | 223 TEST_F(SyncSessionTest, ResetTransientState) { |
312 status()->update_conflicts_resolved(true); | 224 status()->update_conflicts_resolved(true); |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 EXPECT_EQ(empty_payload, original[syncable::BOOKMARKS]); | 499 EXPECT_EQ(empty_payload, original[syncable::BOOKMARKS]); |
588 EXPECT_EQ(payload1, original[syncable::PASSWORDS]); | 500 EXPECT_EQ(payload1, original[syncable::PASSWORDS]); |
589 EXPECT_EQ(payload1, original[syncable::AUTOFILL]); | 501 EXPECT_EQ(payload1, original[syncable::AUTOFILL]); |
590 EXPECT_EQ(payload2, original[syncable::SESSIONS]); | 502 EXPECT_EQ(payload2, original[syncable::SESSIONS]); |
591 EXPECT_EQ(payload3, original[syncable::THEMES]); | 503 EXPECT_EQ(payload3, original[syncable::THEMES]); |
592 } | 504 } |
593 | 505 |
594 } // namespace | 506 } // namespace |
595 } // namespace sessions | 507 } // namespace sessions |
596 } // namespace browser_sync | 508 } // namespace browser_sync |
OLD | NEW |