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

Side by Side Diff: chrome/browser/sync/test/integration/sync_test.cc

Issue 2716413003: Initial clear server data impl (Closed)
Patch Set: Clear server data command 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sync/test/integration/sync_test.h" 5 #include "chrome/browser/sync/test/integration/sync_test.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 case TWO_CLIENT: 224 case TWO_CLIENT:
225 case TWO_CLIENT_LEGACY: { 225 case TWO_CLIENT_LEGACY: {
226 num_clients_ = 2; 226 num_clients_ = 2;
227 break; 227 break;
228 } 228 }
229 default: 229 default:
230 NOTREACHED() << "Invalid test type specified."; 230 NOTREACHED() << "Invalid test type specified.";
231 } 231 }
232 } 232 }
233 233
234 SyncTest::~SyncTest() {} 234 SyncTest::~SyncTest() {
235 sync_datatype_helper::DissociateWithTest(this);
236 }
235 237
236 void SyncTest::SetUp() { 238 void SyncTest::SetUp() {
237 // Sets |server_type_| if it wasn't specified by the test. 239 // Sets |server_type_| if it wasn't specified by the test.
238 DecideServerType(); 240 DecideServerType();
239 241
240 base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); 242 base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
241 if (cl->HasSwitch(switches::kPasswordFileForTest)) { 243 if (cl->HasSwitch(switches::kPasswordFileForTest)) {
242 ReadPasswordFile(); 244 ReadPasswordFile();
243 } else { 245 } else {
244 // Decide on username to use or create one. 246 // Decide on username to use or create one.
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 } else { 345 } else {
344 // Create new profiles in user data dir so that other profiles can know 346 // Create new profiles in user data dir so that other profiles can know
345 // about it. This is needed in tests such as supervised user cases which 347 // about it. This is needed in tests such as supervised user cases which
346 // assume browser->profile() as the custodian profile. 348 // assume browser->profile() as the custodian profile.
347 base::FilePath user_data_dir; 349 base::FilePath user_data_dir;
348 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); 350 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
349 CHECK( 351 CHECK(
350 tmp_profile_paths_[index]->CreateUniqueTempDirUnderPath(user_data_dir)); 352 tmp_profile_paths_[index]->CreateUniqueTempDirUnderPath(user_data_dir));
351 } 353 }
352 base::FilePath profile_path = tmp_profile_paths_[index]->GetPath(); 354 base::FilePath profile_path = tmp_profile_paths_[index]->GetPath();
355 LOG(WARNING) << "PROFILE PATH " << profile_path.value();
skym 2017/03/07 18:38:22 Should this be DVLOG? Did you mean to remove this?
wylieb 2017/03/07 19:52:23 Done.
353 if (UsingExternalServers()) { 356 if (UsingExternalServers()) {
354 // If running against an EXTERNAL_LIVE_SERVER, we signin profiles using real 357 // If running against an EXTERNAL_LIVE_SERVER, we signin profiles using real
355 // GAIA server. This requires creating profiles with no test hooks. 358 // GAIA server. This requires creating profiles with no test hooks.
356 InitializeProfile(index, MakeProfileForUISignin(profile_path)); 359 InitializeProfile(index, MakeProfileForUISignin(profile_path));
357 } else { 360 } else {
358 // Without need of real GAIA authentication, we create new test profiles. 361 // Without need of real GAIA authentication, we create new test profiles.
359 // For test profiles, a custom delegate needs to be used to do the 362 // For test profiles, a custom delegate needs to be used to do the
360 // initialization work before the profile is registered. 363 // initialization work before the profile is registered.
361 profile_delegates_[index] = 364 profile_delegates_[index] =
362 base::MakeUnique<SyncProfileDelegate>(base::Bind( 365 base::MakeUnique<SyncProfileDelegate>(base::Bind(
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 607
605 bool SyncTest::SetupSync() { 608 bool SyncTest::SetupSync() {
606 // Create sync profiles and clients if they haven't already been created. 609 // Create sync profiles and clients if they haven't already been created.
607 if (profiles_.empty()) { 610 if (profiles_.empty()) {
608 if (!SetupClients()) { 611 if (!SetupClients()) {
609 LOG(FATAL) << "SetupClients() failed."; 612 LOG(FATAL) << "SetupClients() failed.";
610 return false; 613 return false;
611 } 614 }
612 } 615 }
613 616
614 // Sync each of the profiles. 617 if (UsingExternalServers()) {
615 for (int i = 0; i < num_clients_; ++i) { 618 DVLOG(1) << "Setting up first client for clear.";
616 if (!GetClient(i)->SetupSync()) { 619 if (!GetClient(0)->SetupSyncForClear()) {
617 LOG(FATAL) << "SetupSync() failed."; 620 LOG(FATAL) << "SetupSync() failed.";
618 return false; 621 return false;
619 } 622 }
623
624 DVLOG(1) << "Done Setting up first client for clear";
skym 2017/03/07 18:38:22 Setting should be setting Also, end with punctuat
wylieb 2017/03/07 19:52:23 Done.
625 ClearServerData(GetClient(0));
626
627 // Sync each of the profiles.
628 for (int i = 1; i < num_clients_; ++i) {
629 DVLOG(1) << "Setting up " << i << " client";
630
631 if (!GetClient(i)->SetupSync()) {
632 LOG(FATAL) << "SetupSync() failed.";
633 return false;
634 }
635 }
636 } else {
637 // Sync each of the profiles.
638 for (int i = 0; i < num_clients_; ++i) {
skym 2017/03/07 18:38:22 This loop and logic seems extremely similar to jus
639 if (!GetClient(i)->SetupSync()) {
640 LOG(FATAL) << "SetupSync() failed.";
641 return false;
642 }
643 }
620 } 644 }
621 645
622 // Because clients may modify sync data as part of startup (for example local 646 // Because clients may modify sync data as part of startup (for example local
623 // session-releated data is rewritten), we need to ensure all startup-based 647 // session-releated data is rewritten), we need to ensure all startup-based
624 // changes have propagated between the clients. 648 // changes have propagated between the clients.
625 // 649 //
626 // Tests that don't use self-notifications can't await quiescense. They'll 650 // Tests that don't use self-notifications can't await quiescense. They'll
627 // have to find their own way of waiting for an initial state if they really 651 // have to find their own way of waiting for an initial state if they really
628 // need such guarantees. 652 // need such guarantees.
629 if (TestUsesSelfNotifications()) { 653 if (TestUsesSelfNotifications()) {
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 1156
1133 void SyncTest::TriggerSyncForModelTypes(int index, 1157 void SyncTest::TriggerSyncForModelTypes(int index,
1134 syncer::ModelTypeSet model_types) { 1158 syncer::ModelTypeSet model_types) {
1135 GetSyncService(index)->TriggerRefresh(model_types); 1159 GetSyncService(index)->TriggerRefresh(model_types);
1136 } 1160 }
1137 1161
1138 void SyncTest::SetPreexistingPreferencesFileContents( 1162 void SyncTest::SetPreexistingPreferencesFileContents(
1139 const std::string& contents) { 1163 const std::string& contents) {
1140 preexisting_preferences_file_contents_ = contents; 1164 preexisting_preferences_file_contents_ = contents;
1141 } 1165 }
1166
1167 void SyncTest::ClearServerData(ProfileSyncServiceHarness* harness) {
1168 // start config, at this point out bday is good
skym 2017/03/07 18:38:22 Sorry for all the obnoxious nits, but, https://goo
wylieb 2017/03/07 19:52:23 Done.
1169 base::RunLoop run_loop;
1170 harness->service()->ClearServerDataForTest(run_loop.QuitClosure());
1171 run_loop.Run();
1172
1173 harness->RestartSyncService();
1174 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698