| 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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 // Start listening for and emitting notifications of commits. | 583 // Start listening for and emitting notifications of commits. |
| 584 invalidation_forwarders_[index] = | 584 invalidation_forwarders_[index] = |
| 585 new P2PInvalidationForwarder(clients_[index]->service(), | 585 new P2PInvalidationForwarder(clients_[index]->service(), |
| 586 p2p_invalidation_service); | 586 p2p_invalidation_service); |
| 587 } | 587 } |
| 588 } | 588 } |
| 589 | 589 |
| 590 bool SyncTest::SetupSync() { | 590 bool SyncTest::SetupSync() { |
| 591 // Create sync profiles and clients if they haven't already been created. | 591 // Create sync profiles and clients if they haven't already been created. |
| 592 if (profiles_.empty()) { | 592 if (profiles_.empty()) { |
| 593 if (!SetupClients()) | 593 if (!SetupClients()) { |
| 594 LOG(FATAL) << "SetupClients() failed."; | 594 LOG(FATAL) << "SetupClients() failed."; |
| 595 return false; |
| 596 } |
| 595 } | 597 } |
| 596 | 598 |
| 597 // Sync each of the profiles. | 599 // Sync each of the profiles. |
| 598 for (int i = 0; i < num_clients_; ++i) { | 600 for (int i = 0; i < num_clients_; ++i) { |
| 599 if (!GetClient(i)->SetupSync()) | 601 if (!GetClient(i)->SetupSync()) { |
| 600 LOG(FATAL) << "SetupSync() failed."; | 602 LOG(FATAL) << "SetupSync() failed."; |
| 603 return false; |
| 604 } |
| 601 } | 605 } |
| 602 | 606 |
| 603 // Because clients may modify sync data as part of startup (for example local | 607 // Because clients may modify sync data as part of startup (for example local |
| 604 // session-releated data is rewritten), we need to ensure all startup-based | 608 // session-releated data is rewritten), we need to ensure all startup-based |
| 605 // changes have propagated between the clients. | 609 // changes have propagated between the clients. |
| 606 // | 610 // |
| 607 // Tests that don't use self-notifications can't await quiescense. They'll | 611 // Tests that don't use self-notifications can't await quiescense. They'll |
| 608 // have to find their own way of waiting for an initial state if they really | 612 // have to find their own way of waiting for an initial state if they really |
| 609 // need such guarantees. | 613 // need such guarantees. |
| 610 if (TestUsesSelfNotifications()) { | 614 if (TestUsesSelfNotifications()) { |
| 611 AwaitQuiescence(); | 615 if (!AwaitQuiescence()) { |
| 616 LOG(FATAL) << "AwaitQuiescence() failed."; |
| 617 return false; |
| 618 } |
| 612 } | 619 } |
| 613 | 620 |
| 614 // SyncRefresher is used instead of invalidations to notify other profiles to | 621 // SyncRefresher is used instead of invalidations to notify other profiles to |
| 615 // do a sync refresh on committed data sets. This is only needed when running | 622 // do a sync refresh on committed data sets. This is only needed when running |
| 616 // tests against external live server, otherwise invalidation service is used. | 623 // tests against external live server, otherwise invalidation service is used. |
| 617 // With external live servers, the profiles commit data on first sync cycle | 624 // With external live servers, the profiles commit data on first sync cycle |
| 618 // automatically after signing in. To avoid misleading sync commit | 625 // automatically after signing in. To avoid misleading sync commit |
| 619 // notifications at start up, we start the SyncRefresher observers post | 626 // notifications at start up, we start the SyncRefresher observers post |
| 620 // client set up. | 627 // client set up. |
| 621 if (UsingExternalServers()) { | 628 if (UsingExternalServers()) { |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 | 1118 |
| 1112 void SyncTest::TriggerSyncForModelTypes(int index, | 1119 void SyncTest::TriggerSyncForModelTypes(int index, |
| 1113 syncer::ModelTypeSet model_types) { | 1120 syncer::ModelTypeSet model_types) { |
| 1114 GetSyncService(index)->TriggerRefresh(model_types); | 1121 GetSyncService(index)->TriggerRefresh(model_types); |
| 1115 } | 1122 } |
| 1116 | 1123 |
| 1117 void SyncTest::SetPreexistingPreferencesFileContents( | 1124 void SyncTest::SetPreexistingPreferencesFileContents( |
| 1118 const std::string& contents) { | 1125 const std::string& contents) { |
| 1119 preexisting_preferences_file_contents_ = contents; | 1126 preexisting_preferences_file_contents_ = contents; |
| 1120 } | 1127 } |
| OLD | NEW |