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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
604 | 606 |
605 bool SyncTest::SetupSync() { | 607 bool SyncTest::SetupSync() { |
606 // Create sync profiles and clients if they haven't already been created. | 608 // Create sync profiles and clients if they haven't already been created. |
607 if (profiles_.empty()) { | 609 if (profiles_.empty()) { |
608 if (!SetupClients()) { | 610 if (!SetupClients()) { |
609 LOG(FATAL) << "SetupClients() failed."; | 611 LOG(FATAL) << "SetupClients() failed."; |
610 return false; | 612 return false; |
611 } | 613 } |
612 } | 614 } |
613 | 615 |
616 int clientIndex = 0; | |
617 if (UsingExternalServers()) { | |
skym
2017/03/07 21:32:25
Would be good to explain why you clear for externa
wylieb
2017/03/07 23:04:40
Done.
| |
618 DVLOG(1) << "Setting up first client for clear."; | |
skym
2017/03/07 21:32:25
Would be good to explain why we need to setup befo
wylieb
2017/03/07 23:04:40
Done.
| |
619 if (!GetClient(clientIndex++)->SetupSyncForClear()) { | |
skym
2017/03/07 21:32:25
This is clunky how you're using clientIndex++ here
wylieb
2017/03/07 23:04:40
Done.
| |
620 LOG(FATAL) << "SetupSync() failed."; | |
621 return false; | |
622 } | |
623 | |
624 DVLOG(1) << "Done setting up first client for clear."; | |
625 ClearServerData(GetClient(0)); | |
skym
2017/03/07 21:32:25
Probably need to give this function a return value
wylieb
2017/03/07 23:04:40
Done.
| |
626 } | |
627 | |
614 // Sync each of the profiles. | 628 // Sync each of the profiles. |
615 for (int i = 0; i < num_clients_; ++i) { | 629 for (int i = clientIndex; i < num_clients_; ++i) { |
skym
2017/03/07 21:32:25
Could reuse clientIndex instead of making a new va
wylieb
2017/03/07 23:04:40
Done.
| |
630 DVLOG(1) << "Setting up " << i << " client"; | |
631 | |
skym
2017/03/07 21:32:25
I'd remove this newline to keep it consistent with
wylieb
2017/03/07 23:04:40
Done.
| |
616 if (!GetClient(i)->SetupSync()) { | 632 if (!GetClient(i)->SetupSync()) { |
617 LOG(FATAL) << "SetupSync() failed."; | 633 LOG(FATAL) << "SetupSync() failed."; |
618 return false; | 634 return false; |
619 } | 635 } |
620 } | 636 } |
621 | 637 |
622 // Because clients may modify sync data as part of startup (for example local | 638 // 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 | 639 // session-releated data is rewritten), we need to ensure all startup-based |
624 // changes have propagated between the clients. | 640 // changes have propagated between the clients. |
625 // | 641 // |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1132 | 1148 |
1133 void SyncTest::TriggerSyncForModelTypes(int index, | 1149 void SyncTest::TriggerSyncForModelTypes(int index, |
1134 syncer::ModelTypeSet model_types) { | 1150 syncer::ModelTypeSet model_types) { |
1135 GetSyncService(index)->TriggerRefresh(model_types); | 1151 GetSyncService(index)->TriggerRefresh(model_types); |
1136 } | 1152 } |
1137 | 1153 |
1138 void SyncTest::SetPreexistingPreferencesFileContents( | 1154 void SyncTest::SetPreexistingPreferencesFileContents( |
1139 const std::string& contents) { | 1155 const std::string& contents) { |
1140 preexisting_preferences_file_contents_ = contents; | 1156 preexisting_preferences_file_contents_ = contents; |
1141 } | 1157 } |
1158 | |
1159 void SyncTest::ClearServerData(ProfileSyncServiceHarness* harness) { | |
1160 // Start configuration, at this point our birthday is out of date. | |
skym
2017/03/07 21:32:25
Errm, is that really true? Shouldn't our birthday
wylieb
2017/03/07 23:04:40
Done.
| |
1161 base::RunLoop run_loop; | |
1162 harness->service()->ClearServerDataForTest(run_loop.QuitClosure()); | |
1163 run_loop.Run(); | |
1164 | |
1165 // Restart sync, this will get our new birthday from the server. | |
1166 harness->RestartSyncService(); | |
skym
2017/03/07 21:32:25
It doesn't look like the success of this method is
wylieb
2017/03/07 23:04:40
Done.
| |
1167 } | |
OLD | NEW |