Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 604 | 604 |
| 605 bool SyncTest::SetupSync() { | 605 bool SyncTest::SetupSync() { |
| 606 // Create sync profiles and clients if they haven't already been created. | 606 // Create sync profiles and clients if they haven't already been created. |
| 607 if (profiles_.empty()) { | 607 if (profiles_.empty()) { |
| 608 if (!SetupClients()) { | 608 if (!SetupClients()) { |
| 609 LOG(FATAL) << "SetupClients() failed."; | 609 LOG(FATAL) << "SetupClients() failed."; |
| 610 return false; | 610 return false; |
| 611 } | 611 } |
| 612 } | 612 } |
| 613 | 613 |
| 614 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
| |
| 615 // If we're using external servers, clear server data so the account starts | |
| 616 // with a clean slate. | |
| 617 if (UsingExternalServers()) { | |
| 618 // Setup the first client so the sync engine is initialized, which is | |
| 619 // required to clear server data. | |
| 620 DVLOG(1) << "Setting up first client for clear."; | |
| 621 if (!GetClient(clientIndex)->SetupSyncForClear()) { | |
| 622 LOG(FATAL) << "SetupSync() failed."; | |
| 623 return false; | |
| 624 } | |
| 625 | |
| 626 DVLOG(1) << "Done setting up first client for clear."; | |
| 627 if (!ClearServerData(GetClient(clientIndex++))) { | |
| 628 LOG(FATAL) << "ClearServerData failed."; | |
| 629 return false; | |
| 630 } | |
| 631 } | |
| 632 | |
| 614 // Sync each of the profiles. | 633 // Sync each of the profiles. |
| 615 for (int i = 0; i < num_clients_; ++i) { | 634 for (; clientIndex < num_clients_; clientIndex++) { |
| 616 if (!GetClient(i)->SetupSync()) { | 635 DVLOG(1) << "Setting up " << clientIndex << " client"; |
| 636 if (!GetClient(clientIndex)->SetupSync()) { | |
| 617 LOG(FATAL) << "SetupSync() failed."; | 637 LOG(FATAL) << "SetupSync() failed."; |
| 618 return false; | 638 return false; |
| 619 } | 639 } |
| 620 } | 640 } |
| 621 | 641 |
| 622 // Because clients may modify sync data as part of startup (for example local | 642 // 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 | 643 // session-releated data is rewritten), we need to ensure all startup-based |
| 624 // changes have propagated between the clients. | 644 // changes have propagated between the clients. |
| 625 // | 645 // |
| 626 // Tests that don't use self-notifications can't await quiescense. They'll | 646 // Tests that don't use self-notifications can't await quiescense. They'll |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1132 | 1152 |
| 1133 void SyncTest::TriggerSyncForModelTypes(int index, | 1153 void SyncTest::TriggerSyncForModelTypes(int index, |
| 1134 syncer::ModelTypeSet model_types) { | 1154 syncer::ModelTypeSet model_types) { |
| 1135 GetSyncService(index)->TriggerRefresh(model_types); | 1155 GetSyncService(index)->TriggerRefresh(model_types); |
| 1136 } | 1156 } |
| 1137 | 1157 |
| 1138 void SyncTest::SetPreexistingPreferencesFileContents( | 1158 void SyncTest::SetPreexistingPreferencesFileContents( |
| 1139 const std::string& contents) { | 1159 const std::string& contents) { |
| 1140 preexisting_preferences_file_contents_ = contents; | 1160 preexisting_preferences_file_contents_ = contents; |
| 1141 } | 1161 } |
| 1162 | |
| 1163 bool SyncTest::ClearServerData(ProfileSyncServiceHarness* harness) { | |
| 1164 // At this point our birthday is good. | |
| 1165 base::RunLoop run_loop; | |
| 1166 harness->service()->ClearServerDataForTest(run_loop.QuitClosure()); | |
| 1167 run_loop.Run(); | |
| 1168 | |
| 1169 // 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
| |
| 1170 // server. | |
| 1171 return harness->RestartSyncService(); | |
| 1172 } | |
| OLD | NEW |