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

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

Issue 2716413003: Initial clear server data impl (Closed)
Patch Set: Fixed various CL 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..5581d3d09e049c3b807d67fcf0b7e6cba65e2b0a 100644
--- a/chrome/browser/sync/test/integration/sync_test.cc
+++ b/chrome/browser/sync/test/integration/sync_test.cc
@@ -231,7 +231,9 @@ SyncTest::SyncTest(TestType test_type)
}
}
-SyncTest::~SyncTest() {}
+SyncTest::~SyncTest() {
+ sync_datatype_helper::DissociateWithTest(this);
+}
void SyncTest::SetUp() {
// Sets |server_type_| if it wasn't specified by the test.
@@ -611,9 +613,29 @@ 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()) {
+ // 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 +1161,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
+ // server.
+ return harness->RestartSyncService();
+}

Powered by Google App Engine
This is Rietveld 408576698