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

Unified Diff: chrome/browser/sync/test/integration/sync_test.cc

Issue 234113002: Use FakeServer-based invalidations for Sync tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/test/integration/sync_test.cc
diff --git a/chrome/browser/sync/test/integration/sync_test.cc b/chrome/browser/sync/test/integration/sync_test.cc
index 68bdae55b16cbf004b7d135c272082c6ee2c1c96..f0c7e3bb8b8a96af6400e9d399a1eead74388734 100644
--- a/chrome/browser/sync/test/integration/sync_test.cc
+++ b/chrome/browser/sync/test/integration/sync_test.cc
@@ -36,6 +36,7 @@
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
+#include "chrome/browser/sync/test/integration/fake_server_invalidation_service.h"
#include "chrome/browser/sync/test/integration/p2p_invalidation_forwarder.h"
#include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
#include "chrome/browser/sync/test/integration/single_client_status_change_checker.h"
@@ -353,14 +354,6 @@ void SyncTest::InitializeInstance(int index) {
EXPECT_FALSE(GetBrowser(index) == NULL) << "Could not create Browser "
<< index << ".";
- invalidation::P2PInvalidationService* p2p_invalidation_service =
- static_cast<invalidation::P2PInvalidationService*>(
- InvalidationServiceFactory::GetInstance()->SetTestingFactoryAndUse(
- GetProfile(index),
- TestUsesSelfNotifications() ?
- BuildSelfNotifyingP2PInvalidationService
- : BuildRealisticP2PInvalidationService));
- p2p_invalidation_service->UpdateCredentials(username_, password_);
// Make sure the ProfileSyncService has been created before creating the
// ProfileSyncServiceHarness - some tests expect the ProfileSyncService to
@@ -382,11 +375,7 @@ void SyncTest::InitializeInstance(int index) {
password_);
EXPECT_FALSE(GetClient(index) == NULL) << "Could not create Client "
<< index << ".";
-
- // Start listening for and emitting notificaitons of commits.
- invalidation_forwarders_[index] =
- new P2PInvalidationForwarder(clients_[index]->service(),
- p2p_invalidation_service);
+ InitializeInvalidations(index);
test::WaitForBookmarkModelToLoad(
BookmarkModelFactory::GetForProfile(GetProfile(index)));
@@ -396,6 +385,31 @@ void SyncTest::InitializeInstance(int index) {
TemplateURLServiceFactory::GetForProfile(GetProfile(index)));
}
+void SyncTest::InitializeInvalidations(int index) {
+ if (server_type_ == IN_PROCESS_FAKE_SERVER) {
+ CHECK(fake_server_.get());
+ fake_server::FakeServerInvalidationService* invalidation_service =
+ static_cast<fake_server::FakeServerInvalidationService*>(
+ InvalidationServiceFactory::GetInstance()->SetTestingFactoryAndUse(
+ GetProfile(index),
+ fake_server::FakeServerInvalidationService::Build));
+ fake_server_->AddObserver(invalidation_service);
+ } else {
+ invalidation::P2PInvalidationService* p2p_invalidation_service =
+ static_cast<invalidation::P2PInvalidationService*>(
+ InvalidationServiceFactory::GetInstance()->SetTestingFactoryAndUse(
+ GetProfile(index),
+ TestUsesSelfNotifications() ?
+ BuildSelfNotifyingP2PInvalidationService
+ : BuildRealisticP2PInvalidationService));
+ p2p_invalidation_service->UpdateCredentials(username_, password_);
+ // Start listening for and emitting notificaitons of commits.
+ invalidation_forwarders_[index] =
+ new P2PInvalidationForwarder(clients_[index]->service(),
+ p2p_invalidation_service);
+ }
+}
+
bool SyncTest::SetupSync() {
// Create sync profiles and clients if they haven't already been created.
if (profiles_.empty()) {
@@ -606,8 +620,6 @@ void SyncTest::SetUpTestServerIfRequired() {
LOG(FATAL) << "Failed to set up local test server";
} else if (server_type_ == IN_PROCESS_FAKE_SERVER) {
fake_server_.reset(new fake_server::FakeServer());
- // Similar to LOCAL_LIVE_SERVER, we must start this for XMPP.
- SetUpLocalPythonTestServer();
SetupMockGaiaResponses();
} else if (server_type_ == EXTERNAL_LIVE_SERVER) {
// Nothing to do; we'll just talk to the URL we were given.

Powered by Google App Engine
This is Rietveld 408576698