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

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

Issue 17911005: Merge 208347 "Revert 208315 "Make use of InvalidationService"" (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1547/src/
Patch Set: Created 7 years, 5 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"
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"
26 #include "chrome/browser/lifetime/application_lifetime.h" 24 #include "chrome/browser/lifetime/application_lifetime.h"
27 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/profiles/profile_manager.h" 26 #include "chrome/browser/profiles/profile_manager.h"
29 #include "chrome/browser/search_engines/template_url_service.h" 27 #include "chrome/browser/search_engines/template_url_service.h"
30 #include "chrome/browser/search_engines/template_url_service_factory.h" 28 #include "chrome/browser/search_engines/template_url_service_factory.h"
31 #include "chrome/browser/sync/profile_sync_service_factory.h" 29 #include "chrome/browser/sync/profile_sync_service_factory.h"
32 #include "chrome/browser/sync/profile_sync_service_harness.h" 30 #include "chrome/browser/sync/profile_sync_service_harness.h"
33 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" 31 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
34 #include "chrome/browser/ui/browser.h" 32 #include "chrome/browser/ui/browser.h"
35 #include "chrome/browser/ui/browser_finder.h" 33 #include "chrome/browser/ui/browser_finder.h"
(...skipping 19 matching lines...) Expand all
55 #include "net/url_request/url_fetcher.h" 53 #include "net/url_request/url_fetcher.h"
56 #include "net/url_request/url_fetcher_delegate.h" 54 #include "net/url_request/url_fetcher_delegate.h"
57 #include "net/url_request/url_request_context.h" 55 #include "net/url_request/url_request_context.h"
58 #include "net/url_request/url_request_context_getter.h" 56 #include "net/url_request/url_request_context_getter.h"
59 #include "net/url_request/url_request_status.h" 57 #include "net/url_request/url_request_status.h"
60 #include "sync/engine/sync_scheduler_impl.h" 58 #include "sync/engine/sync_scheduler_impl.h"
61 #include "sync/notifier/p2p_invalidator.h" 59 #include "sync/notifier/p2p_invalidator.h"
62 #include "sync/protocol/sync.pb.h" 60 #include "sync/protocol/sync.pb.h"
63 61
64 using content::BrowserThread; 62 using content::BrowserThread;
65 using invalidation::InvalidationServiceFactory;
66 63
67 namespace switches { 64 namespace switches {
68 const char kPasswordFileForTest[] = "password-file-for-test"; 65 const char kPasswordFileForTest[] = "password-file-for-test";
69 const char kSyncUserForTest[] = "sync-user-for-test"; 66 const char kSyncUserForTest[] = "sync-user-for-test";
70 const char kSyncPasswordForTest[] = "sync-password-for-test"; 67 const char kSyncPasswordForTest[] = "sync-password-for-test";
71 const char kSyncServerCommandLine[] = "sync-server-command-line"; 68 const char kSyncServerCommandLine[] = "sync-server-command-line";
72 } 69 }
73 70
74 // Helper class that checks whether a sync test server is running or not. 71 // Helper class that checks whether a sync test server is running or not.
75 class SyncServerStatusChecker : public net::URLFetcherDelegate { 72 class SyncServerStatusChecker : public net::URLFetcherDelegate {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // Stop the local sync test server. This is a no-op if one wasn't started. 189 // Stop the local sync test server. This is a no-op if one wasn't started.
193 TearDownLocalTestServer(); 190 TearDownLocalTestServer();
194 } 191 }
195 192
196 void SyncTest::SetUpCommandLine(CommandLine* cl) { 193 void SyncTest::SetUpCommandLine(CommandLine* cl) {
197 AddTestSwitches(cl); 194 AddTestSwitches(cl);
198 AddOptionalTypesToCommandLine(cl); 195 AddOptionalTypesToCommandLine(cl);
199 } 196 }
200 197
201 void SyncTest::AddTestSwitches(CommandLine* cl) { 198 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
202 // Disable non-essential access of external network resources. 204 // Disable non-essential access of external network resources.
203 if (!cl->HasSwitch(switches::kDisableBackgroundNetworking)) 205 if (!cl->HasSwitch(switches::kDisableBackgroundNetworking))
204 cl->AppendSwitch(switches::kDisableBackgroundNetworking); 206 cl->AppendSwitch(switches::kDisableBackgroundNetworking);
205 207
206 if (!cl->HasSwitch(switches::kSyncShortInitialRetryOverride)) 208 if (!cl->HasSwitch(switches::kSyncShortInitialRetryOverride))
207 cl->AppendSwitch(switches::kSyncShortInitialRetryOverride); 209 cl->AppendSwitch(switches::kSyncShortInitialRetryOverride);
208 210
209 // TODO(sync): Fix enable_disable_test.cc to play nice with priority 211 // TODO(sync): Fix enable_disable_test.cc to play nice with priority
210 // preferences. 212 // preferences.
211 if (!cl->HasSwitch(switches::kDisableSyncPriorityPreferences)) 213 if (!cl->HasSwitch(switches::kDisableSyncPriorityPreferences))
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 profiles_[index] = MakeProfile( 299 profiles_[index] = MakeProfile(
298 base::StringPrintf(FILE_PATH_LITERAL("Profile%d"), index)); 300 base::StringPrintf(FILE_PATH_LITERAL("Profile%d"), index));
299 EXPECT_FALSE(GetProfile(index) == NULL) << "Could not create Profile " 301 EXPECT_FALSE(GetProfile(index) == NULL) << "Could not create Profile "
300 << index << "."; 302 << index << ".";
301 303
302 browsers_[index] = new Browser(Browser::CreateParams( 304 browsers_[index] = new Browser(Browser::CreateParams(
303 GetProfile(index), chrome::HOST_DESKTOP_TYPE_NATIVE)); 305 GetProfile(index), chrome::HOST_DESKTOP_TYPE_NATIVE));
304 EXPECT_FALSE(GetBrowser(index) == NULL) << "Could not create Browser " 306 EXPECT_FALSE(GetBrowser(index) == NULL) << "Could not create Browser "
305 << index << "."; 307 << index << ".";
306 308
307 invalidation::P2PInvalidationService* p2p_invalidation_service =
308 InvalidationServiceFactory::GetInstance()->
309 BuildAndUseP2PInvalidationServiceForTest(GetProfile(index));
310 p2p_invalidation_service->UpdateCredentials(username_, password_);
311
312 // Make sure the ProfileSyncService has been created before creating the 309 // Make sure the ProfileSyncService has been created before creating the
313 // ProfileSyncServiceHarness - some tests expect the ProfileSyncService to 310 // ProfileSyncServiceHarness - some tests expect the ProfileSyncService to
314 // already exist. 311 // already exist.
315 ProfileSyncServiceFactory::GetForProfile(GetProfile(index)); 312 ProfileSyncServiceFactory::GetForProfile(GetProfile(index));
316 313
317 clients_[index] = 314 clients_[index] = new ProfileSyncServiceHarness(GetProfile(index),
318 ProfileSyncServiceHarness::CreateForIntegrationTest( 315 username_,
319 GetProfile(index), 316 password_);
320 username_,
321 password_,
322 p2p_invalidation_service);
323 EXPECT_FALSE(GetClient(index) == NULL) << "Could not create Client " 317 EXPECT_FALSE(GetClient(index) == NULL) << "Could not create Client "
324 << index << "."; 318 << index << ".";
325 319
326 ui_test_utils::WaitForBookmarkModelToLoad( 320 ui_test_utils::WaitForBookmarkModelToLoad(
327 BookmarkModelFactory::GetForProfile(GetProfile(index))); 321 BookmarkModelFactory::GetForProfile(GetProfile(index)));
328 ui_test_utils::WaitForHistoryToLoad(HistoryServiceFactory::GetForProfile( 322 ui_test_utils::WaitForHistoryToLoad(HistoryServiceFactory::GetForProfile(
329 GetProfile(index), Profile::EXPLICIT_ACCESS)); 323 GetProfile(index), Profile::EXPLICIT_ACCESS));
330 ui_test_utils::WaitForTemplateURLServiceToLoad( 324 ui_test_utils::WaitForTemplateURLServiceToLoad(
331 TemplateURLServiceFactory::GetForProfile(GetProfile(index))); 325 TemplateURLServiceFactory::GetForProfile(GetProfile(index)));
332 } 326 }
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 819
826 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter, 820 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter,
827 const net::ProxyConfig& proxy_config) { 821 const net::ProxyConfig& proxy_config) {
828 base::WaitableEvent done(false, false); 822 base::WaitableEvent done(false, false);
829 BrowserThread::PostTask( 823 BrowserThread::PostTask(
830 BrowserThread::IO, FROM_HERE, 824 BrowserThread::IO, FROM_HERE,
831 base::Bind(&SetProxyConfigCallback, &done, 825 base::Bind(&SetProxyConfigCallback, &done,
832 make_scoped_refptr(context_getter), proxy_config)); 826 make_scoped_refptr(context_getter), proxy_config));
833 done.Wait(); 827 done.Wait();
834 } 828 }
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