| OLD | NEW |
| 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 30 matching lines...) Expand all Loading... |
| 41 #include "chrome/common/chrome_switches.h" | 41 #include "chrome/common/chrome_switches.h" |
| 42 #include "chrome/test/base/testing_browser_process.h" | 42 #include "chrome/test/base/testing_browser_process.h" |
| 43 #include "chrome/test/base/ui_test_utils.h" | 43 #include "chrome/test/base/ui_test_utils.h" |
| 44 #include "components/webdata/encryptor/encryptor.h" | 44 #include "components/webdata/encryptor/encryptor.h" |
| 45 #include "content/public/browser/web_contents.h" | 45 #include "content/public/browser/web_contents.h" |
| 46 #include "content/public/test/test_browser_thread.h" | 46 #include "content/public/test/test_browser_thread.h" |
| 47 #include "google_apis/gaia/gaia_urls.h" | 47 #include "google_apis/gaia/gaia_urls.h" |
| 48 #include "net/base/escape.h" | 48 #include "net/base/escape.h" |
| 49 #include "net/base/load_flags.h" | 49 #include "net/base/load_flags.h" |
| 50 #include "net/base/network_change_notifier.h" | 50 #include "net/base/network_change_notifier.h" |
| 51 #include "net/http/http_status_code.h" |
| 51 #include "net/proxy/proxy_config.h" | 52 #include "net/proxy/proxy_config.h" |
| 52 #include "net/proxy/proxy_config_service_fixed.h" | 53 #include "net/proxy/proxy_config_service_fixed.h" |
| 53 #include "net/proxy/proxy_service.h" | 54 #include "net/proxy/proxy_service.h" |
| 54 #include "net/test/spawned_test_server/spawned_test_server.h" | 55 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 55 #include "net/url_request/test_url_fetcher_factory.h" | 56 #include "net/url_request/test_url_fetcher_factory.h" |
| 56 #include "net/url_request/url_fetcher.h" | 57 #include "net/url_request/url_fetcher.h" |
| 57 #include "net/url_request/url_fetcher_delegate.h" | 58 #include "net/url_request/url_fetcher_delegate.h" |
| 58 #include "net/url_request/url_request_context.h" | 59 #include "net/url_request/url_request_context.h" |
| 59 #include "net/url_request/url_request_context_getter.h" | 60 #include "net/url_request/url_request_context_getter.h" |
| 60 #include "net/url_request/url_request_status.h" | 61 #include "net/url_request/url_request_status.h" |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 } | 423 } |
| 423 | 424 |
| 424 void SyncTest::SetupMockGaiaResponses() { | 425 void SyncTest::SetupMockGaiaResponses() { |
| 425 username_ = "user@gmail.com"; | 426 username_ = "user@gmail.com"; |
| 426 password_ = "password"; | 427 password_ = "password"; |
| 427 factory_.reset(new net::URLFetcherImplFactory()); | 428 factory_.reset(new net::URLFetcherImplFactory()); |
| 428 fake_factory_.reset(new net::FakeURLFetcherFactory(factory_.get())); | 429 fake_factory_.reset(new net::FakeURLFetcherFactory(factory_.get())); |
| 429 fake_factory_->SetFakeResponse( | 430 fake_factory_->SetFakeResponse( |
| 430 GaiaUrls::GetInstance()->client_login_url(), | 431 GaiaUrls::GetInstance()->client_login_url(), |
| 431 "SID=sid\nLSID=lsid", | 432 "SID=sid\nLSID=lsid", |
| 432 true); | 433 net::HTTP_OK); |
| 433 fake_factory_->SetFakeResponse( | 434 fake_factory_->SetFakeResponse( |
| 434 GaiaUrls::GetInstance()->get_user_info_url(), | 435 GaiaUrls::GetInstance()->get_user_info_url(), |
| 435 "email=user@gmail.com\ndisplayEmail=user@gmail.com", | 436 "email=user@gmail.com\ndisplayEmail=user@gmail.com", |
| 436 true); | 437 net::HTTP_OK); |
| 437 fake_factory_->SetFakeResponse( | 438 fake_factory_->SetFakeResponse( |
| 438 GaiaUrls::GetInstance()->issue_auth_token_url(), | 439 GaiaUrls::GetInstance()->issue_auth_token_url(), |
| 439 "auth", | 440 "auth", |
| 440 true); | 441 net::HTTP_OK); |
| 441 fake_factory_->SetFakeResponse( | 442 fake_factory_->SetFakeResponse( |
| 442 GURL(GoogleURLTracker::kSearchDomainCheckURL), | 443 GURL(GoogleURLTracker::kSearchDomainCheckURL), |
| 443 ".google.com", | 444 ".google.com", |
| 444 true); | 445 net::HTTP_OK); |
| 445 fake_factory_->SetFakeResponse( | 446 fake_factory_->SetFakeResponse( |
| 446 GaiaUrls::GetInstance()->client_login_to_oauth2_url(), | 447 GaiaUrls::GetInstance()->client_login_to_oauth2_url(), |
| 447 "some_response", | 448 "some_response", |
| 448 true); | 449 net::HTTP_OK); |
| 449 fake_factory_->SetFakeResponse( | 450 fake_factory_->SetFakeResponse( |
| 450 GaiaUrls::GetInstance()->oauth2_token_url(), | 451 GaiaUrls::GetInstance()->oauth2_token_url(), |
| 451 "{" | 452 "{" |
| 452 " \"refresh_token\": \"rt1\"," | 453 " \"refresh_token\": \"rt1\"," |
| 453 " \"access_token\": \"at1\"," | 454 " \"access_token\": \"at1\"," |
| 454 " \"expires_in\": 3600," | 455 " \"expires_in\": 3600," |
| 455 " \"token_type\": \"Bearer\"" | 456 " \"token_type\": \"Bearer\"" |
| 456 "}", | 457 "}", |
| 457 true); | 458 net::HTTP_OK); |
| 458 fake_factory_->SetFakeResponse( | 459 fake_factory_->SetFakeResponse( |
| 459 GaiaUrls::GetInstance()->oauth1_login_url(), | 460 GaiaUrls::GetInstance()->oauth1_login_url(), |
| 460 "SID=sid\nLSID=lsid\nAuth=auth_token", | 461 "SID=sid\nLSID=lsid\nAuth=auth_token", |
| 461 true); | 462 net::HTTP_OK); |
| 462 } | 463 } |
| 463 | 464 |
| 464 void SyncTest::ClearMockGaiaResponses() { | 465 void SyncTest::ClearMockGaiaResponses() { |
| 465 // Clear any mock gaia responses that might have been set. | 466 // Clear any mock gaia responses that might have been set. |
| 466 if (fake_factory_) { | 467 if (fake_factory_) { |
| 467 fake_factory_->ClearFakeResponses(); | 468 fake_factory_->ClearFakeResponses(); |
| 468 fake_factory_.reset(); | 469 fake_factory_.reset(); |
| 469 } | 470 } |
| 470 | 471 |
| 471 // Cancel any outstanding URL fetches and destroy the URLFetcherImplFactory we | 472 // Cancel any outstanding URL fetches and destroy the URLFetcherImplFactory we |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 | 831 |
| 831 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter, | 832 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter, |
| 832 const net::ProxyConfig& proxy_config) { | 833 const net::ProxyConfig& proxy_config) { |
| 833 base::WaitableEvent done(false, false); | 834 base::WaitableEvent done(false, false); |
| 834 BrowserThread::PostTask( | 835 BrowserThread::PostTask( |
| 835 BrowserThread::IO, FROM_HERE, | 836 BrowserThread::IO, FROM_HERE, |
| 836 base::Bind(&SetProxyConfigCallback, &done, | 837 base::Bind(&SetProxyConfigCallback, &done, |
| 837 make_scoped_refptr(context_getter), proxy_config)); | 838 make_scoped_refptr(context_getter), proxy_config)); |
| 838 done.Wait(); | 839 done.Wait(); |
| 839 } | 840 } |
| OLD | NEW |