OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 14 matching lines...) Expand all Loading... |
25 #include "chrome/browser/search_engines/template_url_service.h" | 25 #include "chrome/browser/search_engines/template_url_service.h" |
26 #include "chrome/browser/search_engines/template_url_service_factory.h" | 26 #include "chrome/browser/search_engines/template_url_service_factory.h" |
27 #include "chrome/browser/sync/notifier/p2p_notifier.h" | 27 #include "chrome/browser/sync/notifier/p2p_notifier.h" |
28 #include "chrome/browser/sync/profile_sync_service_harness.h" | 28 #include "chrome/browser/sync/profile_sync_service_harness.h" |
29 #include "chrome/browser/sync/protocol/sync.pb.h" | 29 #include "chrome/browser/sync/protocol/sync.pb.h" |
30 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" | 30 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" |
31 #include "chrome/browser/ui/browser.h" | 31 #include "chrome/browser/ui/browser.h" |
32 #include "chrome/browser/ui/browser_list.h" | 32 #include "chrome/browser/ui/browser_list.h" |
33 #include "chrome/common/chrome_paths.h" | 33 #include "chrome/common/chrome_paths.h" |
34 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
| 35 #include "chrome/common/net/gaia/gaia_urls.h" |
35 #include "chrome/test/base/testing_browser_process.h" | 36 #include "chrome/test/base/testing_browser_process.h" |
36 #include "chrome/test/base/ui_test_utils.h" | 37 #include "chrome/test/base/ui_test_utils.h" |
37 #include "content/browser/tab_contents/tab_contents.h" | 38 #include "content/browser/tab_contents/tab_contents.h" |
38 #include "content/public/common/url_fetcher.h" | 39 #include "content/public/common/url_fetcher.h" |
39 #include "content/public/common/url_fetcher_delegate.h" | 40 #include "content/public/common/url_fetcher_delegate.h" |
40 #include "content/test/test_browser_thread.h" | 41 #include "content/test/test_browser_thread.h" |
41 #include "content/test/test_url_fetcher_factory.h" | 42 #include "content/test/test_url_fetcher_factory.h" |
42 #include "googleurl/src/gurl.h" | 43 #include "googleurl/src/gurl.h" |
43 #include "net/base/escape.h" | 44 #include "net/base/escape.h" |
44 #include "net/base/network_change_notifier.h" | 45 #include "net/base/network_change_notifier.h" |
(...skipping 15 matching lines...) Expand all Loading... |
60 } | 61 } |
61 | 62 |
62 namespace { | 63 namespace { |
63 // The URLs for different calls in the Google Accounts programmatic login API. | 64 // The URLs for different calls in the Google Accounts programmatic login API. |
64 const char kClientLoginUrl[] = "https://www.google.com/accounts/ClientLogin"; | 65 const char kClientLoginUrl[] = "https://www.google.com/accounts/ClientLogin"; |
65 const char kGetUserInfoUrl[] = "https://www.google.com/accounts/GetUserInfo"; | 66 const char kGetUserInfoUrl[] = "https://www.google.com/accounts/GetUserInfo"; |
66 const char kIssueAuthTokenUrl[] = | 67 const char kIssueAuthTokenUrl[] = |
67 "https://www.google.com/accounts/IssueAuthToken"; | 68 "https://www.google.com/accounts/IssueAuthToken"; |
68 const char kSearchDomainCheckUrl[] = | 69 const char kSearchDomainCheckUrl[] = |
69 "https://www.google.com/searchdomaincheck?format=domain&type=chrome"; | 70 "https://www.google.com/searchdomaincheck?format=domain&type=chrome"; |
| 71 const char kOAuth2LoginTokenValidResponse[] = |
| 72 "{" |
| 73 " \"refresh_token\": \"rt1\"," |
| 74 " \"access_token\": \"at1\"," |
| 75 " \"expires_in\": 3600," |
| 76 " \"token_type\": \"Bearer\"" |
| 77 "}"; |
70 } | 78 } |
71 | 79 |
72 // Helper class that checks whether a sync test server is running or not. | 80 // Helper class that checks whether a sync test server is running or not. |
73 class SyncServerStatusChecker : public content::URLFetcherDelegate { | 81 class SyncServerStatusChecker : public content::URLFetcherDelegate { |
74 public: | 82 public: |
75 SyncServerStatusChecker() : running_(false) {} | 83 SyncServerStatusChecker() : running_(false) {} |
76 | 84 |
77 virtual void OnURLFetchComplete(const content::URLFetcher* source) { | 85 virtual void OnURLFetchComplete(const content::URLFetcher* source) { |
78 std::string data; | 86 std::string data; |
79 source->GetResponseAsString(&data); | 87 source->GetResponseAsString(&data); |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 372 |
365 void SyncTest::SetupMockGaiaResponses() { | 373 void SyncTest::SetupMockGaiaResponses() { |
366 username_ = "user@gmail.com"; | 374 username_ = "user@gmail.com"; |
367 password_ = "password"; | 375 password_ = "password"; |
368 factory_.reset(new URLFetcherImplFactory()); | 376 factory_.reset(new URLFetcherImplFactory()); |
369 fake_factory_.reset(new FakeURLFetcherFactory(factory_.get())); | 377 fake_factory_.reset(new FakeURLFetcherFactory(factory_.get())); |
370 fake_factory_->SetFakeResponse(kClientLoginUrl, "SID=sid\nLSID=lsid", true); | 378 fake_factory_->SetFakeResponse(kClientLoginUrl, "SID=sid\nLSID=lsid", true); |
371 fake_factory_->SetFakeResponse(kGetUserInfoUrl, "email=user@gmail.com", true); | 379 fake_factory_->SetFakeResponse(kGetUserInfoUrl, "email=user@gmail.com", true); |
372 fake_factory_->SetFakeResponse(kIssueAuthTokenUrl, "auth", true); | 380 fake_factory_->SetFakeResponse(kIssueAuthTokenUrl, "auth", true); |
373 fake_factory_->SetFakeResponse(kSearchDomainCheckUrl, ".google.com", true); | 381 fake_factory_->SetFakeResponse(kSearchDomainCheckUrl, ".google.com", true); |
| 382 fake_factory_->SetFakeResponse( |
| 383 GaiaUrls::GetInstance()->client_login_to_oauth2_url(), |
| 384 kOAuth2LoginTokenValidResponse, |
| 385 true); |
374 } | 386 } |
375 | 387 |
376 // Start up a local sync server based on the value of server_type_, which | 388 // Start up a local sync server based on the value of server_type_, which |
377 // was determined from the command line parameters. | 389 // was determined from the command line parameters. |
378 void SyncTest::SetUpTestServerIfRequired() { | 390 void SyncTest::SetUpTestServerIfRequired() { |
379 if (server_type_ == LOCAL_PYTHON_SERVER) { | 391 if (server_type_ == LOCAL_PYTHON_SERVER) { |
380 if (!SetUpLocalPythonTestServer()) | 392 if (!SetUpLocalPythonTestServer()) |
381 LOG(FATAL) << "Failed to set up local python sync and XMPP servers"; | 393 LOG(FATAL) << "Failed to set up local python sync and XMPP servers"; |
382 } else if (server_type_ == LOCAL_LIVE_SERVER) { | 394 } else if (server_type_ == LOCAL_LIVE_SERVER) { |
383 // Using mock gaia credentials requires the use of a mock XMPP server. | 395 // Using mock gaia credentials requires the use of a mock XMPP server. |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 | 706 |
695 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter, | 707 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter, |
696 const net::ProxyConfig& proxy_config) { | 708 const net::ProxyConfig& proxy_config) { |
697 base::WaitableEvent done(false, false); | 709 base::WaitableEvent done(false, false); |
698 BrowserThread::PostTask( | 710 BrowserThread::PostTask( |
699 BrowserThread::IO, FROM_HERE, | 711 BrowserThread::IO, FROM_HERE, |
700 base::Bind(&SetProxyConfigCallback, &done, | 712 base::Bind(&SetProxyConfigCallback, &done, |
701 make_scoped_refptr(context_getter), proxy_config)); | 713 make_scoped_refptr(context_getter), proxy_config)); |
702 done.Wait(); | 714 done.Wait(); |
703 } | 715 } |
OLD | NEW |