OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 ASSERT_TRUE(ModelMatchesVerifier(0)); | 226 ASSERT_TRUE(ModelMatchesVerifier(0)); |
227 | 227 |
228 // Made bookmark changes while sync is on. | 228 // Made bookmark changes while sync is on. |
229 Move(0, tier1_a->GetChild(0), tier1_b, 1); | 229 Move(0, tier1_a->GetChild(0), tier1_b, 1); |
230 Remove(0, tier1_b, 0); | 230 Remove(0, tier1_b, 0); |
231 ASSERT_TRUE(AddFolder(0, tier1_b, 1, "tier2_c")); | 231 ASSERT_TRUE(AddFolder(0, tier1_b, 1, "tier2_c")); |
232 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0))); | 232 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0))); |
233 ASSERT_TRUE(ModelMatchesVerifier(0)); | 233 ASSERT_TRUE(ModelMatchesVerifier(0)); |
234 | 234 |
235 // Let server to return rollback command on next sync request. | 235 // Let server to return rollback command on next sync request. |
236 GetFakeServer()->TriggerError(sync_pb::SyncEnums::USER_ROLLBACK); | 236 ASSERT_TRUE(GetFakeServer()->TriggerError(sync_pb::SyncEnums::USER_ROLLBACK)); |
237 | 237 |
238 // Make another change to trigger downloading of rollback command. | 238 // Make another change to trigger downloading of rollback command. |
239 Remove(0, tier1_b, 0); | 239 Remove(0, tier1_b, 0); |
240 | 240 |
241 // Wait for rollback to finish and sync backend is completely shut down. | 241 // Wait for rollback to finish and sync backend is completely shut down. |
242 SyncRollbackChecker rollback_checker(GetSyncService(0)); | 242 SyncRollbackChecker rollback_checker(GetSyncService(0)); |
243 ASSERT_TRUE(rollback_checker.Wait()); | 243 ASSERT_TRUE(rollback_checker.Wait()); |
244 SyncBackendStoppedChecker shutdown_checker(GetSyncService(0)); | 244 SyncBackendStoppedChecker shutdown_checker(GetSyncService(0)); |
245 ASSERT_TRUE(shutdown_checker.Wait()); | 245 ASSERT_TRUE(shutdown_checker.Wait()); |
246 | 246 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 ASSERT_TRUE(ModelMatchesVerifier(0)); | 280 ASSERT_TRUE(ModelMatchesVerifier(0)); |
281 | 281 |
282 // Made bookmark changes while sync is on. | 282 // Made bookmark changes while sync is on. |
283 Remove(0, GetOtherNode(0), 1); | 283 Remove(0, GetOtherNode(0), 1); |
284 ASSERT_TRUE(AddURL(0, GetOtherNode(0), 1, "url2", | 284 ASSERT_TRUE(AddURL(0, GetOtherNode(0), 1, "url2", |
285 GURL("http://www.yahoo.com"))); | 285 GURL("http://www.yahoo.com"))); |
286 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 286 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); |
287 ASSERT_TRUE(ModelMatchesVerifier(0)); | 287 ASSERT_TRUE(ModelMatchesVerifier(0)); |
288 | 288 |
289 // Let server to return rollback command on next sync request. | 289 // Let server to return rollback command on next sync request. |
290 GetFakeServer()->TriggerError(sync_pb::SyncEnums::USER_ROLLBACK); | 290 ASSERT_TRUE(GetFakeServer()->TriggerError(sync_pb::SyncEnums::USER_ROLLBACK)); |
291 | 291 |
292 // Make another change to trigger downloading of rollback command. | 292 // Make another change to trigger downloading of rollback command. |
293 Remove(0, GetOtherNode(0), 0); | 293 Remove(0, GetOtherNode(0), 0); |
294 | 294 |
295 // Wait for sync backend is completely shut down. | 295 // Wait for sync backend is completely shut down. |
296 SyncBackendStoppedChecker shutdown_checker(GetSyncService(0)); | 296 SyncBackendStoppedChecker shutdown_checker(GetSyncService(0)); |
297 ASSERT_TRUE(shutdown_checker.Wait()); | 297 ASSERT_TRUE(shutdown_checker.Wait()); |
298 | 298 |
299 // With rollback disabled, bookmarks in backup DB should not be restored. | 299 // With rollback disabled, bookmarks in backup DB should not be restored. |
300 // Only bookmark added during sync is present. | 300 // Only bookmark added during sync is present. |
(...skipping 26 matching lines...) Expand all Loading... |
327 ASSERT_TRUE(ModelMatchesVerifier(0)); | 327 ASSERT_TRUE(ModelMatchesVerifier(0)); |
328 | 328 |
329 // Made bookmark changes while sync is on. | 329 // Made bookmark changes while sync is on. |
330 Remove(0, GetOtherNode(0), 1); | 330 Remove(0, GetOtherNode(0), 1); |
331 ASSERT_TRUE(AddURL(0, GetOtherNode(0), 1, "url2", | 331 ASSERT_TRUE(AddURL(0, GetOtherNode(0), 1, "url2", |
332 GURL("http://www.yahoo.com"))); | 332 GURL("http://www.yahoo.com"))); |
333 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 333 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); |
334 ASSERT_TRUE(ModelMatchesVerifier(0)); | 334 ASSERT_TRUE(ModelMatchesVerifier(0)); |
335 | 335 |
336 // Let server to return birthday error on next sync request. | 336 // Let server to return birthday error on next sync request. |
337 GetFakeServer()->TriggerError(sync_pb::SyncEnums::NOT_MY_BIRTHDAY); | 337 ASSERT_TRUE(GetFakeServer()->TriggerError( |
| 338 sync_pb::SyncEnums::NOT_MY_BIRTHDAY)); |
338 | 339 |
339 // Make another change to trigger downloading of rollback command. | 340 // Make another change to trigger downloading of rollback command. |
340 Remove(0, GetOtherNode(0), 0); | 341 Remove(0, GetOtherNode(0), 0); |
341 | 342 |
342 // Wait sync backend is completely shut down. | 343 // Wait sync backend is completely shut down. |
343 SyncBackendStoppedChecker shutdown_checker(GetSyncService(0)); | 344 SyncBackendStoppedChecker shutdown_checker(GetSyncService(0)); |
344 ASSERT_TRUE(shutdown_checker.Wait()); | 345 ASSERT_TRUE(shutdown_checker.Wait()); |
345 | 346 |
346 // Shouldn't restore bookmarks with sign-out only. | 347 // Shouldn't restore bookmarks with sign-out only. |
347 ASSERT_EQ(1, GetOtherNode(0)->child_count()); | 348 ASSERT_EQ(1, GetOtherNode(0)->child_count()); |
(...skipping 24 matching lines...) Expand all Loading... |
372 | 373 |
373 ASSERT_TRUE(AddURL(0, GetOtherNode(0), 1, "url1", | 374 ASSERT_TRUE(AddURL(0, GetOtherNode(0), 1, "url1", |
374 GURL("http://www.nhl.com"))); | 375 GURL("http://www.nhl.com"))); |
375 | 376 |
376 // Delete backup DB. | 377 // Delete backup DB. |
377 base::DeleteFile( | 378 base::DeleteFile( |
378 GetProfile(0)->GetPath().Append(FILE_PATH_LITERAL("Sync Data Backup")), | 379 GetProfile(0)->GetPath().Append(FILE_PATH_LITERAL("Sync Data Backup")), |
379 true); | 380 true); |
380 | 381 |
381 // Let server to return rollback command on next sync request. | 382 // Let server to return rollback command on next sync request. |
382 GetFakeServer()->TriggerError(sync_pb::SyncEnums::USER_ROLLBACK); | 383 ASSERT_TRUE(GetFakeServer()->TriggerError(sync_pb::SyncEnums::USER_ROLLBACK)); |
383 | 384 |
384 // Make another change to trigger downloading of rollback command. | 385 // Make another change to trigger downloading of rollback command. |
385 Remove(0, GetOtherNode(0), 0); | 386 Remove(0, GetOtherNode(0), 0); |
386 | 387 |
387 // Wait for rollback to finish and sync backend is completely shut down. | 388 // Wait for rollback to finish and sync backend is completely shut down. |
388 SyncRollbackChecker rollback_checker(GetSyncService(0)); | 389 SyncRollbackChecker rollback_checker(GetSyncService(0)); |
389 ASSERT_TRUE(rollback_checker.Wait()); | 390 ASSERT_TRUE(rollback_checker.Wait()); |
390 SyncBackendStoppedChecker checker(GetSyncService(0)); | 391 SyncBackendStoppedChecker checker(GetSyncService(0)); |
391 ASSERT_TRUE(checker.Wait()); | 392 ASSERT_TRUE(checker.Wait()); |
392 | 393 |
(...skipping 22 matching lines...) Expand all Loading... |
415 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0))); | 416 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0))); |
416 ASSERT_TRUE(ModelMatchesVerifier(0)); | 417 ASSERT_TRUE(ModelMatchesVerifier(0)); |
417 | 418 |
418 // Made bookmark changes while sync is on. | 419 // Made bookmark changes while sync is on. |
419 Remove(0, sub_folder, 0); | 420 Remove(0, sub_folder, 0); |
420 Remove(0, sub_folder, 0); | 421 Remove(0, sub_folder, 0); |
421 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0))); | 422 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0))); |
422 ASSERT_TRUE(ModelMatchesVerifier(0)); | 423 ASSERT_TRUE(ModelMatchesVerifier(0)); |
423 | 424 |
424 // Let server to return rollback command on next sync request. | 425 // Let server to return rollback command on next sync request. |
425 GetFakeServer()->TriggerError(sync_pb::SyncEnums::USER_ROLLBACK); | 426 ASSERT_TRUE(GetFakeServer()->TriggerError(sync_pb::SyncEnums::USER_ROLLBACK)); |
426 | 427 |
427 // Make another change to trigger downloading of rollback command. | 428 // Make another change to trigger downloading of rollback command. |
428 Remove(0, sub_folder, 0); | 429 Remove(0, sub_folder, 0); |
429 | 430 |
430 // Wait for rollback to finish and sync backend is completely shut down. | 431 // Wait for rollback to finish and sync backend is completely shut down. |
431 SyncRollbackChecker rollback_checker(GetSyncService(0)); | 432 SyncRollbackChecker rollback_checker(GetSyncService(0)); |
432 ASSERT_TRUE(rollback_checker.Wait()); | 433 ASSERT_TRUE(rollback_checker.Wait()); |
433 SyncBackendStoppedChecker shutdown_checker(GetSyncService(0)); | 434 SyncBackendStoppedChecker shutdown_checker(GetSyncService(0)); |
434 ASSERT_TRUE(shutdown_checker.Wait()); | 435 ASSERT_TRUE(shutdown_checker.Wait()); |
435 | 436 |
436 // Verify bookmarks are unchanged. | 437 // Verify bookmarks are unchanged. |
437 ASSERT_EQ(3, sub_folder->child_count()); | 438 ASSERT_EQ(3, sub_folder->child_count()); |
438 ASSERT_EQ(GURL(kUrl1), sub_folder->GetChild(0)->url()); | 439 ASSERT_EQ(GURL(kUrl1), sub_folder->GetChild(0)->url()); |
439 ASSERT_EQ(GURL(kUrl2), sub_folder->GetChild(1)->url()); | 440 ASSERT_EQ(GURL(kUrl2), sub_folder->GetChild(1)->url()); |
440 ASSERT_EQ(GURL(kUrl3), sub_folder->GetChild(2)->url()); | 441 ASSERT_EQ(GURL(kUrl3), sub_folder->GetChild(2)->url()); |
441 } | 442 } |
OLD | NEW |