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

Side by Side Diff: sync/sessions/sync_session_unittest.cc

Issue 10006046: Abort sync cycles when download step fails (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Retry on migration done responses Created 8 years, 8 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
« no previous file with comments | « sync/sessions/sync_session.cc ('k') | sync/test/engine/mock_connection_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) { 215 TEST_F(SyncSessionTest, MoreToDownloadIfDownloadFailed) {
216 status()->set_updates_request_types(ParamsMeaningAllEnabledTypes()); 216 status()->set_updates_request_types(ParamsMeaningAllEnabledTypes());
217 217
218 status()->set_last_download_updates_result(NETWORK_IO_ERROR);
219
218 // When DownloadUpdatesCommand fails, these should be false. 220 // When DownloadUpdatesCommand fails, these should be false.
219 EXPECT_FALSE(status()->ServerSaysNothingMoreToDownload()); 221 EXPECT_FALSE(status()->ServerSaysNothingMoreToDownload());
220 EXPECT_FALSE(status()->download_updates_succeeded()); 222 EXPECT_FALSE(status()->download_updates_succeeded());
221 223
222 // Download updates has its own loop in the syncer; it shouldn't factor 224 // Download updates has its own loop in the syncer; it shouldn't factor
223 // into HasMoreToSync. 225 // into HasMoreToSync.
224 EXPECT_FALSE(session_->HasMoreToSync()); 226 EXPECT_FALSE(session_->HasMoreToSync());
225 } 227 }
226 228
227 TEST_F(SyncSessionTest, MoreToDownloadIfGotChangesRemaining) { 229 TEST_F(SyncSessionTest, MoreToDownloadIfGotChangesRemaining) {
228 status()->set_updates_request_types(ParamsMeaningAllEnabledTypes()); 230 status()->set_updates_request_types(ParamsMeaningAllEnabledTypes());
229 231
230 // When the server returns changes_remaining, that means there's 232 // When the server returns changes_remaining, that means there's
231 // more to download. 233 // more to download.
234 status()->set_last_download_updates_result(SYNCER_OK);
232 status()->mutable_updates_response()->mutable_get_updates() 235 status()->mutable_updates_response()->mutable_get_updates()
233 ->set_changes_remaining(1000L); 236 ->set_changes_remaining(1000L);
234 EXPECT_FALSE(status()->ServerSaysNothingMoreToDownload()); 237 EXPECT_FALSE(status()->ServerSaysNothingMoreToDownload());
235 EXPECT_TRUE(status()->download_updates_succeeded()); 238 EXPECT_TRUE(status()->download_updates_succeeded());
236 239
237 // Download updates has its own loop in the syncer; it shouldn't factor 240 // Download updates has its own loop in the syncer; it shouldn't factor
238 // into HasMoreToSync. 241 // into HasMoreToSync.
239 EXPECT_FALSE(session_->HasMoreToSync()); 242 EXPECT_FALSE(session_->HasMoreToSync());
240 } 243 }
241 244
242 TEST_F(SyncSessionTest, MoreToDownloadIfGotNoChangesRemaining) { 245 TEST_F(SyncSessionTest, MoreToDownloadIfGotNoChangesRemaining) {
243 status()->set_updates_request_types(ParamsMeaningAllEnabledTypes()); 246 status()->set_updates_request_types(ParamsMeaningAllEnabledTypes());
244 247
245 // When the server returns a timestamp, that means we're up to date. 248 status()->set_last_download_updates_result(SYNCER_OK);
246 status()->mutable_updates_response()->mutable_get_updates() 249 status()->mutable_updates_response()->mutable_get_updates()
247 ->set_changes_remaining(0); 250 ->set_changes_remaining(0);
248 EXPECT_TRUE(status()->ServerSaysNothingMoreToDownload()); 251 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()); 252 EXPECT_TRUE(status()->download_updates_succeeded());
297 253
298 // Download updates has its own loop in the syncer; it shouldn't factor 254 // Download updates has its own loop in the syncer; it shouldn't factor
299 // into HasMoreToSync. 255 // into HasMoreToSync.
300 EXPECT_FALSE(session_->HasMoreToSync()); 256 EXPECT_FALSE(session_->HasMoreToSync());
301 } 257 }
302 258
303 TEST_F(SyncSessionTest, MoreToSyncIfConflictsResolved) { 259 TEST_F(SyncSessionTest, MoreToSyncIfConflictsResolved) {
304 // Conflict resolution happens after get updates and commit, 260 // Conflict resolution happens after get updates and commit,
305 // so we need to loop back and get updates / commit again now 261 // so we need to loop back and get updates / commit again now
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 EXPECT_EQ(empty_payload, original[syncable::BOOKMARKS]); 543 EXPECT_EQ(empty_payload, original[syncable::BOOKMARKS]);
588 EXPECT_EQ(payload1, original[syncable::PASSWORDS]); 544 EXPECT_EQ(payload1, original[syncable::PASSWORDS]);
589 EXPECT_EQ(payload1, original[syncable::AUTOFILL]); 545 EXPECT_EQ(payload1, original[syncable::AUTOFILL]);
590 EXPECT_EQ(payload2, original[syncable::SESSIONS]); 546 EXPECT_EQ(payload2, original[syncable::SESSIONS]);
591 EXPECT_EQ(payload3, original[syncable::THEMES]); 547 EXPECT_EQ(payload3, original[syncable::THEMES]);
592 } 548 }
593 549
594 } // namespace 550 } // namespace
595 } // namespace sessions 551 } // namespace sessions
596 } // namespace browser_sync 552 } // namespace browser_sync
OLDNEW
« no previous file with comments | « sync/sessions/sync_session.cc ('k') | sync/test/engine/mock_connection_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698