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

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

Issue 1575153004: [Sync] Simplify sync startup behavior. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@setup
Patch Set: Better comment + tests. Created 4 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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 invalidation_forwarders_[index] = 589 invalidation_forwarders_[index] =
590 new P2PInvalidationForwarder(clients_[index]->service(), 590 new P2PInvalidationForwarder(clients_[index]->service(),
591 p2p_invalidation_service); 591 p2p_invalidation_service);
592 } 592 }
593 } 593 }
594 594
595 bool SyncTest::SetupSync() { 595 bool SyncTest::SetupSync() {
596 if (create_gaia_account_at_runtime_) { 596 if (create_gaia_account_at_runtime_) {
597 CHECK(UsingExternalServers()) << 597 CHECK(UsingExternalServers()) <<
598 "Cannot create Gaia accounts without external authentication servers"; 598 "Cannot create Gaia accounts without external authentication servers";
599 if (!CreateGaiaAccount(username_, password_)) 599 if (!CreateGaiaAccount(username_, password_)) {
600 LOG(FATAL) << "Could not create Gaia account."; 600 LOG(FATAL) << "Could not create Gaia account.";
601 return false;
602 }
601 } 603 }
602 // Create sync profiles and clients if they haven't already been created. 604 // Create sync profiles and clients if they haven't already been created.
603 if (profiles_.empty()) { 605 if (profiles_.empty()) {
604 if (!SetupClients()) 606 if (!SetupClients()) {
605 LOG(FATAL) << "SetupClients() failed."; 607 LOG(FATAL) << "SetupClients() failed.";
608 return false;
609 }
606 } 610 }
607 611
608 // Sync each of the profiles. 612 // Sync each of the profiles.
609 for (int i = 0; i < num_clients_; ++i) { 613 for (int i = 0; i < num_clients_; ++i) {
610 if (!GetClient(i)->SetupSync()) 614 if (!GetClient(i)->SetupSync()) {
611 LOG(FATAL) << "SetupSync() failed."; 615 LOG(FATAL) << "SetupSync() failed.";
616 return false;
617 }
612 } 618 }
613 619
614 // Because clients may modify sync data as part of startup (for example local 620 // Because clients may modify sync data as part of startup (for example local
615 // session-releated data is rewritten), we need to ensure all startup-based 621 // session-releated data is rewritten), we need to ensure all startup-based
616 // changes have propagated between the clients. 622 // changes have propagated between the clients.
617 // 623 //
618 // Tests that don't use self-notifications can't await quiescense. They'll 624 // Tests that don't use self-notifications can't await quiescense. They'll
619 // have to find their own way of waiting for an initial state if they really 625 // have to find their own way of waiting for an initial state if they really
620 // need such guarantees. 626 // need such guarantees.
621 if (TestUsesSelfNotifications()) { 627 if (TestUsesSelfNotifications()) {
622 AwaitQuiescence(); 628 if (!AwaitQuiescence()) {
629 LOG(FATAL) << "AwaitQuiescence() failed.";
630 return false;
631 }
623 } 632 }
624 633
625 // SyncRefresher is used instead of invalidations to notify other profiles to 634 // SyncRefresher is used instead of invalidations to notify other profiles to
626 // do a sync refresh on committed data sets. This is only needed when running 635 // do a sync refresh on committed data sets. This is only needed when running
627 // tests against external live server, otherwise invalidation service is used. 636 // tests against external live server, otherwise invalidation service is used.
628 // With external live servers, the profiles commit data on first sync cycle 637 // With external live servers, the profiles commit data on first sync cycle
629 // automatically after signing in. To avoid misleading sync commit 638 // automatically after signing in. To avoid misleading sync commit
630 // notifications at start up, we start the SyncRefresher observers post 639 // notifications at start up, we start the SyncRefresher observers post
631 // client set up. 640 // client set up.
632 if (UsingExternalServers()) { 641 if (UsingExternalServers()) {
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 1140
1132 void SyncTest::TriggerSyncForModelTypes(int index, 1141 void SyncTest::TriggerSyncForModelTypes(int index,
1133 syncer::ModelTypeSet model_types) { 1142 syncer::ModelTypeSet model_types) {
1134 GetSyncService(index)->TriggerRefresh(model_types); 1143 GetSyncService(index)->TriggerRefresh(model_types);
1135 } 1144 }
1136 1145
1137 void SyncTest::SetPreexistingPreferencesFileContents( 1146 void SyncTest::SetPreexistingPreferencesFileContents(
1138 const std::string& contents) { 1147 const std::string& contents) {
1139 preexisting_preferences_file_contents_ = contents; 1148 preexisting_preferences_file_contents_ = contents;
1140 } 1149 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698