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

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: Rebase Created 7 years, 6 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/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/synchronization/waitable_event.h" 17 #include "base/synchronization/waitable_event.h"
18 #include "base/test/test_timeouts.h" 18 #include "base/test/test_timeouts.h"
19 #include "base/threading/platform_thread.h" 19 #include "base/threading/platform_thread.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 if (!cl->HasSwitch(switches::kSyncShortInitialRetryOverride)) 206 if (!cl->HasSwitch(switches::kSyncShortInitialRetryOverride))
209 cl->AppendSwitch(switches::kSyncShortInitialRetryOverride); 207 cl->AppendSwitch(switches::kSyncShortInitialRetryOverride);
210 208
211 // TODO(sync): Fix enable_disable_test.cc to play nice with priority 209 // TODO(sync): Fix enable_disable_test.cc to play nice with priority
212 // preferences. 210 // preferences.
213 if (!cl->HasSwitch(switches::kDisableSyncPriorityPreferences)) 211 if (!cl->HasSwitch(switches::kDisableSyncPriorityPreferences))
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 profiles_[index] = MakeProfile( 297 profiles_[index] = MakeProfile(
300 base::StringPrintf(FILE_PATH_LITERAL("Profile%d"), index)); 298 base::StringPrintf(FILE_PATH_LITERAL("Profile%d"), index));
301 EXPECT_FALSE(GetProfile(index) == NULL) << "Could not create Profile " 299 EXPECT_FALSE(GetProfile(index) == NULL) << "Could not create Profile "
302 << index << "."; 300 << index << ".";
303 301
304 browsers_[index] = new Browser(Browser::CreateParams( 302 browsers_[index] = new Browser(Browser::CreateParams(
305 GetProfile(index), chrome::HOST_DESKTOP_TYPE_NATIVE)); 303 GetProfile(index), chrome::HOST_DESKTOP_TYPE_NATIVE));
306 EXPECT_FALSE(GetBrowser(index) == NULL) << "Could not create Browser " 304 EXPECT_FALSE(GetBrowser(index) == NULL) << "Could not create Browser "
307 << index << "."; 305 << index << ".";
308 306
307 invalidation::P2PInvalidationService* p2p_invalidation_service =
308 InvalidationServiceFactory::GetInstance()->
309 BuildAndUseP2PInvalidationServiceForTest(GetProfile(index));
310 p2p_invalidation_service->UpdateCredentials(username_, password_);
311
309 // Make sure the ProfileSyncService has been created before creating the 312 // Make sure the ProfileSyncService has been created before creating the
310 // ProfileSyncServiceHarness - some tests expect the ProfileSyncService to 313 // ProfileSyncServiceHarness - some tests expect the ProfileSyncService to
311 // already exist. 314 // already exist.
312 ProfileSyncServiceFactory::GetForProfile(GetProfile(index)); 315 ProfileSyncServiceFactory::GetForProfile(GetProfile(index));
313 316
314 clients_[index] = new ProfileSyncServiceHarness(GetProfile(index), 317 clients_[index] =
315 username_, 318 ProfileSyncServiceHarness::CreateForIntegrationTest(
316 password_); 319 GetProfile(index),
320 username_,
321 password_,
322 p2p_invalidation_service);
317 EXPECT_FALSE(GetClient(index) == NULL) << "Could not create Client " 323 EXPECT_FALSE(GetClient(index) == NULL) << "Could not create Client "
318 << index << "."; 324 << index << ".";
319 325
320 ui_test_utils::WaitForBookmarkModelToLoad( 326 ui_test_utils::WaitForBookmarkModelToLoad(
321 BookmarkModelFactory::GetForProfile(GetProfile(index))); 327 BookmarkModelFactory::GetForProfile(GetProfile(index)));
322 ui_test_utils::WaitForHistoryToLoad(HistoryServiceFactory::GetForProfile( 328 ui_test_utils::WaitForHistoryToLoad(HistoryServiceFactory::GetForProfile(
323 GetProfile(index), Profile::EXPLICIT_ACCESS)); 329 GetProfile(index), Profile::EXPLICIT_ACCESS));
324 ui_test_utils::WaitForTemplateURLServiceToLoad( 330 ui_test_utils::WaitForTemplateURLServiceToLoad(
325 TemplateURLServiceFactory::GetForProfile(GetProfile(index))); 331 TemplateURLServiceFactory::GetForProfile(GetProfile(index)));
326 } 332 }
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 825
820 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter, 826 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter,
821 const net::ProxyConfig& proxy_config) { 827 const net::ProxyConfig& proxy_config) {
822 base::WaitableEvent done(false, false); 828 base::WaitableEvent done(false, false);
823 BrowserThread::PostTask( 829 BrowserThread::PostTask(
824 BrowserThread::IO, FROM_HERE, 830 BrowserThread::IO, FROM_HERE,
825 base::Bind(&SetProxyConfigCallback, &done, 831 base::Bind(&SetProxyConfigCallback, &done,
826 make_scoped_refptr(context_getter), proxy_config)); 832 make_scoped_refptr(context_getter), proxy_config));
827 done.Wait(); 833 done.Wait();
828 } 834 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_unittest.cc ('k') | chrome/browser/sync/test_profile_sync_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698