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

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

Issue 15580002: Make use of InvalidationService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First set of review fixes Created 7 years, 7 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 <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"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
16 #include "base/synchronization/waitable_event.h" 16 #include "base/synchronization/waitable_event.h"
17 #include "base/test/test_timeouts.h" 17 #include "base/test/test_timeouts.h"
18 #include "base/threading/platform_thread.h" 18 #include "base/threading/platform_thread.h"
19 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
20 #include "base/values.h" 20 #include "base/values.h"
21 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 21 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
22 #include "chrome/browser/google/google_url_tracker.h" 22 #include "chrome/browser/google/google_url_tracker.h"
23 #include "chrome/browser/history/history_service_factory.h" 23 #include "chrome/browser/history/history_service_factory.h"
24 #include "chrome/browser/invalidation/invalidation_service_factory.h"
25 #include "chrome/browser/invalidation/p2p_invalidation_service.h"
24 #include "chrome/browser/lifetime/application_lifetime.h" 26 #include "chrome/browser/lifetime/application_lifetime.h"
25 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/profiles/profile_manager.h" 28 #include "chrome/browser/profiles/profile_manager.h"
27 #include "chrome/browser/search_engines/template_url_service.h" 29 #include "chrome/browser/search_engines/template_url_service.h"
28 #include "chrome/browser/search_engines/template_url_service_factory.h" 30 #include "chrome/browser/search_engines/template_url_service_factory.h"
29 #include "chrome/browser/sync/profile_sync_service_factory.h" 31 #include "chrome/browser/sync/profile_sync_service_factory.h"
30 #include "chrome/browser/sync/profile_sync_service_harness.h" 32 #include "chrome/browser/sync/profile_sync_service_harness.h"
31 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" 33 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
32 #include "chrome/browser/ui/browser.h" 34 #include "chrome/browser/ui/browser.h"
33 #include "chrome/browser/ui/browser_finder.h" 35 #include "chrome/browser/ui/browser_finder.h"
(...skipping 19 matching lines...) Expand all
53 #include "net/url_request/url_fetcher.h" 55 #include "net/url_request/url_fetcher.h"
54 #include "net/url_request/url_fetcher_delegate.h" 56 #include "net/url_request/url_fetcher_delegate.h"
55 #include "net/url_request/url_request_context.h" 57 #include "net/url_request/url_request_context.h"
56 #include "net/url_request/url_request_context_getter.h" 58 #include "net/url_request/url_request_context_getter.h"
57 #include "net/url_request/url_request_status.h" 59 #include "net/url_request/url_request_status.h"
58 #include "sync/engine/sync_scheduler_impl.h" 60 #include "sync/engine/sync_scheduler_impl.h"
59 #include "sync/notifier/p2p_invalidator.h" 61 #include "sync/notifier/p2p_invalidator.h"
60 #include "sync/protocol/sync.pb.h" 62 #include "sync/protocol/sync.pb.h"
61 63
62 using content::BrowserThread; 64 using content::BrowserThread;
65 using invalidation::InvalidationServiceFactory;
63 66
64 namespace switches { 67 namespace switches {
65 const char kPasswordFileForTest[] = "password-file-for-test"; 68 const char kPasswordFileForTest[] = "password-file-for-test";
66 const char kSyncUserForTest[] = "sync-user-for-test"; 69 const char kSyncUserForTest[] = "sync-user-for-test";
67 const char kSyncPasswordForTest[] = "sync-password-for-test"; 70 const char kSyncPasswordForTest[] = "sync-password-for-test";
68 const char kSyncServerCommandLine[] = "sync-server-command-line"; 71 const char kSyncServerCommandLine[] = "sync-server-command-line";
69 } 72 }
70 73
71 // Helper class that checks whether a sync test server is running or not. 74 // Helper class that checks whether a sync test server is running or not.
72 class SyncServerStatusChecker : public net::URLFetcherDelegate { 75 class SyncServerStatusChecker : public net::URLFetcherDelegate {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 // Stop the local sync test server. This is a no-op if one wasn't started. 192 // Stop the local sync test server. This is a no-op if one wasn't started.
190 TearDownLocalTestServer(); 193 TearDownLocalTestServer();
191 } 194 }
192 195
193 void SyncTest::SetUpCommandLine(CommandLine* cl) { 196 void SyncTest::SetUpCommandLine(CommandLine* cl) {
194 AddTestSwitches(cl); 197 AddTestSwitches(cl);
195 AddOptionalTypesToCommandLine(cl); 198 AddOptionalTypesToCommandLine(cl);
196 } 199 }
197 200
198 void SyncTest::AddTestSwitches(CommandLine* cl) { 201 void SyncTest::AddTestSwitches(CommandLine* cl) {
199 // TODO(rsimha): Until we implement a fake Tango server against which tests
200 // can run, we need to set the --sync-notification-method to "p2p".
201 if (!cl->HasSwitch(switches::kSyncNotificationMethod))
202 cl->AppendSwitchASCII(switches::kSyncNotificationMethod, "p2p");
203
204 // Disable non-essential access of external network resources. 202 // Disable non-essential access of external network resources.
205 if (!cl->HasSwitch(switches::kDisableBackgroundNetworking)) 203 if (!cl->HasSwitch(switches::kDisableBackgroundNetworking))
206 cl->AppendSwitch(switches::kDisableBackgroundNetworking); 204 cl->AppendSwitch(switches::kDisableBackgroundNetworking);
207 205
208 // TODO(sync): remove this once keystore encryption is enabled by default. 206 // TODO(sync): remove this once keystore encryption is enabled by default.
209 if (!cl->HasSwitch(switches::kSyncKeystoreEncryption)) 207 if (!cl->HasSwitch(switches::kSyncKeystoreEncryption))
210 cl->AppendSwitch(switches::kSyncKeystoreEncryption); 208 cl->AppendSwitch(switches::kSyncKeystoreEncryption);
211 209
212 if (!cl->HasSwitch(switches::kSyncShortInitialRetryOverride)) 210 if (!cl->HasSwitch(switches::kSyncShortInitialRetryOverride))
213 cl->AppendSwitch(switches::kSyncShortInitialRetryOverride); 211 cl->AppendSwitch(switches::kSyncShortInitialRetryOverride);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 profiles_[index] = MakeProfile( 301 profiles_[index] = MakeProfile(
304 base::StringPrintf(FILE_PATH_LITERAL("Profile%d"), index)); 302 base::StringPrintf(FILE_PATH_LITERAL("Profile%d"), index));
305 EXPECT_FALSE(GetProfile(index) == NULL) << "Could not create Profile " 303 EXPECT_FALSE(GetProfile(index) == NULL) << "Could not create Profile "
306 << index << "."; 304 << index << ".";
307 305
308 browsers_[index] = new Browser(Browser::CreateParams( 306 browsers_[index] = new Browser(Browser::CreateParams(
309 GetProfile(index), chrome::HOST_DESKTOP_TYPE_NATIVE)); 307 GetProfile(index), chrome::HOST_DESKTOP_TYPE_NATIVE));
310 EXPECT_FALSE(GetBrowser(index) == NULL) << "Could not create Browser " 308 EXPECT_FALSE(GetBrowser(index) == NULL) << "Could not create Browser "
311 << index << "."; 309 << index << ".";
312 310
311 invalidation::P2PInvalidationService* p2p_invalidation_service =
312 InvalidationServiceFactory::GetInstance()->
313 BuildAndUseP2PInvalidationServiceForTest(GetProfile(index));
dcheng 2013/05/23 00:35:45 Nit: I think I'd expect a 4 space indent (rather t
rlarocque 2013/05/23 21:43:27 Done.
314 p2p_invalidation_service->UpdateCredentials(username_, password_);
315
313 // Make sure the ProfileSyncService has been created before creating the 316 // Make sure the ProfileSyncService has been created before creating the
314 // ProfileSyncServiceHarness - some tests expect the ProfileSyncService to 317 // ProfileSyncServiceHarness - some tests expect the ProfileSyncService to
315 // already exist. 318 // already exist.
316 ProfileSyncServiceFactory::GetForProfile(GetProfile(index)); 319 ProfileSyncServiceFactory::GetForProfile(GetProfile(index));
317 320
318 clients_[index] = new ProfileSyncServiceHarness(GetProfile(index), 321 clients_[index] =
319 username_, 322 ProfileSyncServiceHarness::CreateForIntegrationTest(
320 password_); 323 GetProfile(index),
324 username_,
325 password_,
326 p2p_invalidation_service);
321 EXPECT_FALSE(GetClient(index) == NULL) << "Could not create Client " 327 EXPECT_FALSE(GetClient(index) == NULL) << "Could not create Client "
322 << index << "."; 328 << index << ".";
323 329
324 ui_test_utils::WaitForBookmarkModelToLoad( 330 ui_test_utils::WaitForBookmarkModelToLoad(
325 BookmarkModelFactory::GetForProfile(GetProfile(index))); 331 BookmarkModelFactory::GetForProfile(GetProfile(index)));
326 ui_test_utils::WaitForHistoryToLoad(HistoryServiceFactory::GetForProfile( 332 ui_test_utils::WaitForHistoryToLoad(HistoryServiceFactory::GetForProfile(
327 GetProfile(index), Profile::EXPLICIT_ACCESS)); 333 GetProfile(index), Profile::EXPLICIT_ACCESS));
328 ui_test_utils::WaitForTemplateURLServiceToLoad( 334 ui_test_utils::WaitForTemplateURLServiceToLoad(
329 TemplateURLServiceFactory::GetForProfile(GetProfile(index))); 335 TemplateURLServiceFactory::GetForProfile(GetProfile(index)));
330 } 336 }
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 829
824 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter, 830 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter,
825 const net::ProxyConfig& proxy_config) { 831 const net::ProxyConfig& proxy_config) {
826 base::WaitableEvent done(false, false); 832 base::WaitableEvent done(false, false);
827 BrowserThread::PostTask( 833 BrowserThread::PostTask(
828 BrowserThread::IO, FROM_HERE, 834 BrowserThread::IO, FROM_HERE,
829 base::Bind(&SetProxyConfigCallback, &done, 835 base::Bind(&SetProxyConfigCallback, &done,
830 make_scoped_refptr(context_getter), proxy_config)); 836 make_scoped_refptr(context_getter), proxy_config));
831 done.Wait(); 837 done.Wait();
832 } 838 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698