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

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

Issue 2379433002: [Sync] Refactoring of sync integration test checkers to remove boilerplate await methods. (Closed)
Patch Set: Rebase Created 4 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/profile_sync_service_harness.h" 5 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <iterator> 8 #include <iterator>
9 #include <ostream> 9 #include <ostream>
10 #include <sstream> 10 #include <sstream>
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 221
222 bool ProfileSyncServiceHarness::AwaitMutualSyncCycleCompletion( 222 bool ProfileSyncServiceHarness::AwaitMutualSyncCycleCompletion(
223 ProfileSyncServiceHarness* partner) { 223 ProfileSyncServiceHarness* partner) {
224 std::vector<ProfileSyncServiceHarness*> harnesses; 224 std::vector<ProfileSyncServiceHarness*> harnesses;
225 harnesses.push_back(this); 225 harnesses.push_back(this);
226 harnesses.push_back(partner); 226 harnesses.push_back(partner);
227 return AwaitQuiescence(harnesses); 227 return AwaitQuiescence(harnesses);
228 } 228 }
229 229
230 bool ProfileSyncServiceHarness::AwaitGroupSyncCycleCompletion( 230 bool ProfileSyncServiceHarness::AwaitGroupSyncCycleCompletion(
231 std::vector<ProfileSyncServiceHarness*>& partners) { 231 const std::vector<ProfileSyncServiceHarness*>& partners) {
232 return AwaitQuiescence(partners); 232 return AwaitQuiescence(partners);
233 } 233 }
234 234
235 // static 235 // static
236 bool ProfileSyncServiceHarness::AwaitQuiescence( 236 bool ProfileSyncServiceHarness::AwaitQuiescence(
237 std::vector<ProfileSyncServiceHarness*>& clients) { 237 const std::vector<ProfileSyncServiceHarness*>& clients) {
238 std::vector<ProfileSyncService*> services; 238 std::vector<ProfileSyncService*> services;
239 if (clients.empty()) { 239 if (clients.empty()) {
240 return true; 240 return true;
241 } 241 }
242 242
243 for (std::vector<ProfileSyncServiceHarness*>::iterator it = clients.begin(); 243 for (const ProfileSyncServiceHarness* harness : clients) {
244 it != clients.end(); ++it) { 244 services.push_back(harness->service());
245 services.push_back((*it)->service());
246 } 245 }
247 QuiesceStatusChangeChecker checker(services); 246 return QuiesceStatusChangeChecker(services).Wait();
248 checker.Wait();
249 return !checker.TimedOut();
250 } 247 }
251 248
252 bool ProfileSyncServiceHarness::AwaitBackendInitialization() { 249 bool ProfileSyncServiceHarness::AwaitBackendInitialization() {
253 BackendInitializeChecker checker(service()); 250 if (!BackendInitializeChecker(service()).Wait()) {
254 checker.Wait();
255
256 if (checker.TimedOut()) {
257 LOG(ERROR) << "BackendInitializeChecker timed out."; 251 LOG(ERROR) << "BackendInitializeChecker timed out.";
258 return false; 252 return false;
259 } 253 }
260 254
261 if (!service()->IsBackendInitialized()) { 255 if (!service()->IsBackendInitialized()) {
262 LOG(ERROR) << "Service backend not initialized."; 256 LOG(ERROR) << "Service backend not initialized.";
263 return false; 257 return false;
264 } 258 }
265 259
266 // Make sure that initial sync wasn't blocked by a missing passphrase. 260 // Make sure that initial sync wasn't blocked by a missing passphrase.
267 if (service()->passphrase_required_reason() == syncer::REASON_DECRYPTION) { 261 if (service()->passphrase_required_reason() == syncer::REASON_DECRYPTION) {
268 LOG(ERROR) << "A passphrase is required for decryption. Sync cannot proceed" 262 LOG(ERROR) << "A passphrase is required for decryption. Sync cannot proceed"
269 " until SetDecryptionPassphrase is called."; 263 " until SetDecryptionPassphrase is called.";
270 return false; 264 return false;
271 } 265 }
272 266
273 if (HasAuthError(service())) { 267 if (HasAuthError(service())) {
274 LOG(ERROR) << "Credentials were rejected. Sync cannot proceed."; 268 LOG(ERROR) << "Credentials were rejected. Sync cannot proceed.";
275 return false; 269 return false;
276 } 270 }
277 271
278 return true; 272 return true;
279 } 273 }
280 274
281 bool ProfileSyncServiceHarness::AwaitSyncSetupCompletion() { 275 bool ProfileSyncServiceHarness::AwaitSyncSetupCompletion() {
282 SyncSetupChecker checker(service()); 276 if (!SyncSetupChecker(service()).Wait()) {
283 checker.Wait();
284
285 if (checker.TimedOut()) {
286 LOG(ERROR) << "SyncSetupChecker timed out."; 277 LOG(ERROR) << "SyncSetupChecker timed out.";
287 return false; 278 return false;
288 } 279 }
289 280
290 // Make sure that initial sync wasn't blocked by a missing passphrase. 281 // Make sure that initial sync wasn't blocked by a missing passphrase.
291 if (service()->passphrase_required_reason() == syncer::REASON_DECRYPTION) { 282 if (service()->passphrase_required_reason() == syncer::REASON_DECRYPTION) {
292 LOG(ERROR) << "A passphrase is required for decryption. Sync cannot proceed" 283 LOG(ERROR) << "A passphrase is required for decryption. Sync cannot proceed"
293 " until SetDecryptionPassphrase is called."; 284 " until SetDecryptionPassphrase is called.";
294 return false; 285 return false;
295 } 286 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 464
474 std::string ProfileSyncServiceHarness::GetServiceStatus() { 465 std::string ProfileSyncServiceHarness::GetServiceStatus() {
475 std::unique_ptr<base::DictionaryValue> value( 466 std::unique_ptr<base::DictionaryValue> value(
476 sync_driver::sync_ui_util::ConstructAboutInformation( 467 sync_driver::sync_ui_util::ConstructAboutInformation(
477 service(), service()->signin(), chrome::GetChannel())); 468 service(), service()->signin(), chrome::GetChannel()));
478 std::string service_status; 469 std::string service_status;
479 base::JSONWriter::WriteWithOptions( 470 base::JSONWriter::WriteWithOptions(
480 *value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &service_status); 471 *value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &service_status);
481 return service_status; 472 return service_status;
482 } 473 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698