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

Unified Diff: chrome/browser/sync/test/integration/sync_test.cc

Issue 2716413003: Initial clear server data impl (Closed)
Patch Set: Responding to Pavel's comments. Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
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..f55fd9cae86f40bd403857aa04d062cc6458d997 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)->SetupSyncForClear()) {
+ 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();
+}

Powered by Google App Engine
This is Rietveld 408576698