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

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

Issue 183803026: Clean up InvalidationService test infrastructure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 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 | Annotate | Revision Log
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 <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 base::WaitableEvent* done, 98 base::WaitableEvent* done,
99 net::URLRequestContextGetter* url_request_context_getter, 99 net::URLRequestContextGetter* url_request_context_getter,
100 const net::ProxyConfig& proxy_config) { 100 const net::ProxyConfig& proxy_config) {
101 net::ProxyService* proxy_service = 101 net::ProxyService* proxy_service =
102 url_request_context_getter->GetURLRequestContext()->proxy_service(); 102 url_request_context_getter->GetURLRequestContext()->proxy_service();
103 proxy_service->ResetConfigService( 103 proxy_service->ResetConfigService(
104 new net::ProxyConfigServiceFixed(proxy_config)); 104 new net::ProxyConfigServiceFixed(proxy_config));
105 done->Signal(); 105 done->Signal();
106 } 106 }
107 107
108 BrowserContextKeyedService* BuildP2PInvalidationService(
109 content::BrowserContext* context) {
110 Profile* profile = static_cast<Profile*>(context);
111 return new invalidation::P2PInvalidationService(profile);
112 }
113
108 SyncTest::SyncTest(TestType test_type) 114 SyncTest::SyncTest(TestType test_type)
109 : test_type_(test_type), 115 : test_type_(test_type),
110 server_type_(SERVER_TYPE_UNDECIDED), 116 server_type_(SERVER_TYPE_UNDECIDED),
111 num_clients_(-1), 117 num_clients_(-1),
112 use_verifier_(true), 118 use_verifier_(true),
113 notifications_enabled_(true), 119 notifications_enabled_(true),
114 test_server_handle_(base::kNullProcessHandle) { 120 test_server_handle_(base::kNullProcessHandle) {
115 sync_datatype_helper::AssociateWithTest(this); 121 sync_datatype_helper::AssociateWithTest(this);
116 switch (test_type_) { 122 switch (test_type_) {
117 case SINGLE_CLIENT: { 123 case SINGLE_CLIENT: {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 base::StringPrintf(FILE_PATH_LITERAL("Profile%d"), index)); 313 base::StringPrintf(FILE_PATH_LITERAL("Profile%d"), index));
308 EXPECT_FALSE(GetProfile(index) == NULL) << "Could not create Profile " 314 EXPECT_FALSE(GetProfile(index) == NULL) << "Could not create Profile "
309 << index << "."; 315 << index << ".";
310 316
311 browsers_[index] = new Browser(Browser::CreateParams( 317 browsers_[index] = new Browser(Browser::CreateParams(
312 GetProfile(index), chrome::GetActiveDesktop())); 318 GetProfile(index), chrome::GetActiveDesktop()));
313 EXPECT_FALSE(GetBrowser(index) == NULL) << "Could not create Browser " 319 EXPECT_FALSE(GetBrowser(index) == NULL) << "Could not create Browser "
314 << index << "."; 320 << index << ".";
315 321
316 invalidation::P2PInvalidationService* p2p_invalidation_service = 322 invalidation::P2PInvalidationService* p2p_invalidation_service =
317 InvalidationServiceFactory::GetInstance()-> 323 static_cast<invalidation::P2PInvalidationService*>(
318 BuildAndUseP2PInvalidationServiceForTest(GetProfile(index)); 324 InvalidationServiceFactory::GetInstance()->SetTestingFactoryAndUse(
325 GetProfile(index), BuildP2PInvalidationService));
319 p2p_invalidation_service->UpdateCredentials(username_, password_); 326 p2p_invalidation_service->UpdateCredentials(username_, password_);
320 327
321 // Make sure the ProfileSyncService has been created before creating the 328 // Make sure the ProfileSyncService has been created before creating the
322 // ProfileSyncServiceHarness - some tests expect the ProfileSyncService to 329 // ProfileSyncServiceHarness - some tests expect the ProfileSyncService to
323 // already exist. 330 // already exist.
324 ProfileSyncService* profile_sync_service = 331 ProfileSyncService* profile_sync_service =
325 ProfileSyncServiceFactory::GetForProfile(GetProfile(index)); 332 ProfileSyncServiceFactory::GetForProfile(GetProfile(index));
326 333
327 if (server_type_ == IN_PROCESS_FAKE_SERVER) { 334 if (server_type_ == IN_PROCESS_FAKE_SERVER) {
328 // TODO(pvalenzuela): Run the fake server via EmbeddedTestServer. 335 // TODO(pvalenzuela): Run the fake server via EmbeddedTestServer.
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 BrowserThread::IO, FROM_HERE, 872 BrowserThread::IO, FROM_HERE,
866 base::Bind(&SetProxyConfigCallback, &done, 873 base::Bind(&SetProxyConfigCallback, &done,
867 make_scoped_refptr(context_getter), proxy_config)); 874 make_scoped_refptr(context_getter), proxy_config));
868 done.Wait(); 875 done.Wait();
869 } 876 }
870 877
871 void SyncTest::UseFakeServer() { 878 void SyncTest::UseFakeServer() {
872 DCHECK_EQ(SERVER_TYPE_UNDECIDED, server_type_); 879 DCHECK_EQ(SERVER_TYPE_UNDECIDED, server_type_);
873 server_type_ = IN_PROCESS_FAKE_SERVER; 880 server_type_ = IN_PROCESS_FAKE_SERVER;
874 } 881 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698