| 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..992ebf2eb22c6ebc35f43a59091974490cf20f47 100644
|
| --- a/chrome/browser/sync/test/integration/sync_test.cc
|
| +++ b/chrome/browser/sync/test/integration/sync_test.cc
|
| @@ -611,9 +611,21 @@ bool SyncTest::SetupSync() {
|
| }
|
| }
|
|
|
| + int clientIndex = 0;
|
| + // If we're using external servers, clear server data so the account starts
|
| + // with a clean slate.
|
| + if (UsingExternalServers()) {
|
| + if (!SetupAndClearClient(clientIndex++)) {
|
| + LOG(FATAL) << "Setting up and clearing data for client "
|
| + << clientIndex - 1 << " 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;
|
| }
|
| @@ -660,6 +672,23 @@ bool SyncTest::SetupSync() {
|
| return true;
|
| }
|
|
|
| +bool SyncTest::SetupAndClearClient(size_t index) {
|
| + // 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(index)->SetupSyncForClearingServerData()) {
|
| + LOG(FATAL) << "SetupSync() failed.";
|
| + return false;
|
| + }
|
| +
|
| + DVLOG(1) << "Done setting up first client for clear.";
|
| + if (!ClearServerData(GetClient(index++))) {
|
| + LOG(FATAL) << "ClearServerData failed.";
|
| + return false;
|
| + }
|
| + return true;
|
| +}
|
| +
|
| void SyncTest::TearDownOnMainThread() {
|
| for (size_t i = 0; i < clients_.size(); ++i) {
|
| clients_[i]->service()->RequestStop(ProfileSyncService::CLEAR_DATA);
|
| @@ -1139,3 +1168,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 invalidated on the server here so restart sync to get
|
| + // the new birthday from the server.
|
| + return harness->RestartSyncService();
|
| +}
|
|
|