Chromium Code Reviews| Index: chrome/browser/sync/test/integration/single_client_backup_rollback_test.cc |
| diff --git a/chrome/browser/sync/test/integration/single_client_backup_rollback_test.cc b/chrome/browser/sync/test/integration/single_client_backup_rollback_test.cc |
| index b204a59cba0e4a4159334353dadc25d9007e643f..5a9e0b29665ee3f5f81654c1dbe9179651bc9d80 100644 |
| --- a/chrome/browser/sync/test/integration/single_client_backup_rollback_test.cc |
| +++ b/chrome/browser/sync/test/integration/single_client_backup_rollback_test.cc |
| @@ -29,10 +29,14 @@ class SingleClientBackupRollbackTest : public SyncTest { |
| SingleClientBackupRollbackTest() : SyncTest(SINGLE_CLIENT) {} |
| virtual ~SingleClientBackupRollbackTest() {} |
| - virtual void SetUp() OVERRIDE { |
| + void DisableBackup() { |
| + CommandLine::ForCurrentProcess()->AppendSwitch( |
| + switches::kSyncDisableBackup); |
| + } |
| + |
| + void EnableRollback() { |
| CommandLine::ForCurrentProcess()->AppendSwitch( |
| switches::kSyncEnableRollback); |
| - SyncTest::SetUp(); |
| } |
| private: |
| @@ -79,12 +83,82 @@ class BackupModeChecker { |
| }; |
| #if defined(ENABLE_PRE_SYNC_BACKUP) |
| +#define MAYBE_TestBackupDisabled TestBackupDisabled |
| +#else |
| +#define MAYBE_TestBackupDisabled DISABLED_TestBackupDisabled |
| +#endif |
| +IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, |
| + MAYBE_TestBackupDisabled) { |
| + DisableBackup(); |
| + |
| + ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; |
| + |
| + BackupModeChecker checker(GetSyncService(0), |
| + base::TimeDelta::FromSeconds(15)); |
| + ASSERT_FALSE(checker.Wait()); |
|
pval...(no longer on Chromium)
2014/06/28 00:12:00
does Wait() have to wait the entire timeout to eve
haitaol1
2014/07/01 16:49:36
Unfortunately yes because backup controller won't
|
| + |
| + ASSERT_EQ(ProfileSyncService::IDLE, GetSyncService(0)->backend_mode()); |
| +} |
| + |
| +#if defined(ENABLE_PRE_SYNC_BACKUP) |
| +#define MAYBE_TestBackupOnly TestBackupOnly |
| +#else |
| +#define MAYBE_TestBackupOnly DISABLED_TestBackupOnly |
| +#endif |
| +IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, |
| + MAYBE_TestBackupOnly) { |
| + ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; |
| + |
| + // Starting state: |
| + // other_node |
| + // -> http://mail.google.com "url0" |
| + // -> http://www.nhl.com "url1" |
| + ASSERT_TRUE(AddURL(0, GetOtherNode(0), 0, "url0", |
| + GURL("http://mail.google.com"))); |
| + ASSERT_TRUE(AddURL(0, GetOtherNode(0), 1, "url1", |
| + GURL("http://www.nhl.com"))); |
| + |
| + BackupModeChecker checker(GetSyncService(0), |
| + base::TimeDelta::FromSeconds(15)); |
| + ASSERT_TRUE(checker.Wait()); |
| + |
| + // Setup sync, wait for its completion, and make sure changes were synced. |
| + ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| + ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); |
| + ASSERT_TRUE(ModelMatchesVerifier(0)); |
| + |
| + // Made bookmark changes while sync is on. |
| + Remove(0, GetOtherNode(0), 1); |
| + ASSERT_TRUE(AddURL(0, GetOtherNode(0), 1, "url2", |
| + GURL("http://www.yahoo.com"))); |
| + ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); |
| + ASSERT_TRUE(ModelMatchesVerifier(0)); |
| + |
| + // Let server to return rollback command on next sync request. |
| + GetFakeServer()->TriggerError(sync_pb::SyncEnums::USER_ROLLBACK); |
| + |
| + // Make another change to trigger downloading of rollback command. |
| + Remove(0, GetOtherNode(0), 0); |
|
pval...(no longer on Chromium)
2014/06/28 00:12:00
Is there another way we can trigger a sync that wo
haitaol1
2014/07/01 16:49:36
Can you point me to a sample to trigger invalidati
pval...(no longer on Chromium)
2014/07/02 18:10:59
Let's save it for another CL. Add a TODO here (in
|
| + |
| + // Wait for sync to switch to backup mode after finishing rollback. |
|
pval...(no longer on Chromium)
2014/06/28 00:12:00
Update comment to reflect that a rollback isn't ac
haitaol1
2014/07/01 16:49:36
Done.
|
| + ASSERT_TRUE(checker.Wait()); |
| + |
| + // With rollback disabled, bookmarks in backup DB should not be restored. |
| + // Only bookmark added during sync is present. |
| + ASSERT_EQ(1, GetOtherNode(0)->child_count()); |
| + ASSERT_EQ(GURL("http://www.yahoo.com"), |
| + GetOtherNode(0)->GetChild(0)->url()); |
| +} |
| + |
| +#if defined(ENABLE_PRE_SYNC_BACKUP) |
| #define MAYBE_TestBackupRollback TestBackupRollback |
| #else |
| #define MAYBE_TestBackupRollback DISABLED_TestBackupRollback |
| #endif |
| IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, |
| MAYBE_TestBackupRollback) { |
| + EnableRollback(); |
| + |
| ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; |
| // Starting state: |
| @@ -146,6 +220,8 @@ IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, |
| // backup mode. |
| IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, |
| MAYBE_TestPrefBackupRollback) { |
| + EnableRollback(); |
| + |
| const char kUrl1[] = "http://www.google.com"; |
| const char kUrl2[] = "http://map.google.com"; |
| const char kUrl3[] = "http://plus.google.com"; |
| @@ -187,3 +263,46 @@ IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, |
| ASSERT_EQ(kUrl2, |
| preferences_helper::GetPrefs(0)->GetString(prefs::kHomePage)); |
| } |
| + |
| +#if defined(ENABLE_PRE_SYNC_BACKUP) |
| +#define MAYBE_RollbackNoBackup RollbackNoBackup |
| +#else |
| +#define MAYBE_RollbackNoBackup DISABLED_RollbackNoBackup |
| +#endif |
| +IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, |
| + MAYBE_RollbackNoBackup) { |
| + EnableRollback(); |
| + |
| + ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; |
| + |
| + // Setup sync, wait for its completion, and make sure changes were synced. |
| + ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| + |
| + // Starting state: |
| + // other_node |
| + // -> http://mail.google.com "url0" |
| + // -> http://www.nhl.com "url1" |
| + ASSERT_TRUE(AddURL(0, GetOtherNode(0), 0, "url0", |
| + GURL("http://mail.google.com"))); |
| + ASSERT_TRUE(AddURL(0, GetOtherNode(0), 1, "url1", |
| + GURL("http://www.nhl.com"))); |
| + |
| + ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); |
| + ASSERT_TRUE(ModelMatchesVerifier(0)); |
| + |
| + // Let server to return rollback command on next sync request. |
| + GetFakeServer()->TriggerError(sync_pb::SyncEnums::USER_ROLLBACK); |
| + |
| + // Make another change to trigger downloading of rollback command. |
| + Remove(0, GetOtherNode(0), 0); |
| + |
| + // Wait for sync to switch to backup mode after finishing rollback. |
| + BackupModeChecker checker(GetSyncService(0), |
| + base::TimeDelta::FromSeconds(15)); |
| + ASSERT_TRUE(checker.Wait()); |
| + |
| + // Without backup DB, bookmarks added during sync shouldn't be removed. |
| + ASSERT_EQ(1, GetOtherNode(0)->child_count()); |
| + ASSERT_EQ(GURL("http://www.nhl.com"), |
| + GetOtherNode(0)->GetChild(0)->url()); |
| +} |