Chromium Code Reviews| Index: chrome/browser/sync/test/integration/sync_test.cc |
| diff --git a/chrome/browser/sync/test/integration/sync_test.cc b/chrome/browser/sync/test/integration/sync_test.cc |
| index f40d1f98fd44fbfb4f595c9aa98392743c0720e2..eaff9b7e277ecd7608e0486400b1921ec03c90d3 100644 |
| --- a/chrome/browser/sync/test/integration/sync_test.cc |
| +++ b/chrome/browser/sync/test/integration/sync_test.cc |
| @@ -611,9 +611,29 @@ bool SyncTest::SetupSync() { |
| } |
| } |
| + int clientIndex = 0; |
|
pavely
2017/03/08 21:15:14
SyncTest::SetupSync contains sequence of calls to
wylieb
2017/03/09 18:42:26
Good point. The readability is bad here. I factore
|
| + // If we're using external servers, clear server data so the account starts |
| + // with a clean slate. |
| + if (UsingExternalServers()) { |
| + // Setup the first client so the sync engine is initialized, which is |
| + // required to clear server data. |
| + DVLOG(1) << "Setting up first client for clear."; |
| + if (!GetClient(clientIndex)->SetupSyncForClear()) { |
| + LOG(FATAL) << "SetupSync() failed."; |
| + return false; |
| + } |
| + |
| + DVLOG(1) << "Done setting up first client for clear."; |
| + if (!ClearServerData(GetClient(clientIndex++))) { |
| + LOG(FATAL) << "ClearServerData failed."; |
| + return false; |
| + } |
| + } |
| + |
| // Sync each of the profiles. |
| - for (int i = 0; i < num_clients_; ++i) { |
| - if (!GetClient(i)->SetupSync()) { |
| + for (; clientIndex < num_clients_; clientIndex++) { |
| + DVLOG(1) << "Setting up " << clientIndex << " client"; |
| + if (!GetClient(clientIndex)->SetupSync()) { |
| LOG(FATAL) << "SetupSync() failed."; |
| return false; |
| } |
| @@ -1139,3 +1159,14 @@ void SyncTest::SetPreexistingPreferencesFileContents( |
| const std::string& contents) { |
| preexisting_preferences_file_contents_ = contents; |
| } |
| + |
| +bool SyncTest::ClearServerData(ProfileSyncServiceHarness* harness) { |
| + // At this point our birthday is good. |
| + base::RunLoop run_loop; |
| + harness->service()->ClearServerDataForTest(run_loop.QuitClosure()); |
| + run_loop.Run(); |
| + |
| + // Our birthday is bad here so restart sync to get the new birthday from the |
|
pavely
2017/03/08 21:15:14
"Our birthday is bad" => "Our birthday is invalida
|
| + // server. |
| + return harness->RestartSyncService(); |
| +} |