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

Side by Side Diff: chrome/test/live_sync/live_sync_test.cc

Issue 7524033: Add a scoper object for URLFetcher::Factory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 4 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
« no previous file with comments | « chrome/common/net/gaia/gaia_oauth_client_unittest.cc ('k') | content/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/test/live_sync/live_sync_test.h" 5 #include "chrome/test/live_sync/live_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/command_line.h" 10 #include "base/command_line.h"
(...skipping 11 matching lines...) Expand all
22 #include "chrome/browser/profiles/profile_manager.h" 22 #include "chrome/browser/profiles/profile_manager.h"
23 #include "chrome/browser/sync/profile_sync_service_harness.h" 23 #include "chrome/browser/sync/profile_sync_service_harness.h"
24 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
25 #include "chrome/common/chrome_paths.h" 25 #include "chrome/common/chrome_paths.h"
26 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
27 #include "chrome/test/live_sync/sync_datatype_helper.h" 27 #include "chrome/test/live_sync/sync_datatype_helper.h"
28 #include "chrome/test/testing_browser_process.h" 28 #include "chrome/test/testing_browser_process.h"
29 #include "chrome/test/ui_test_utils.h" 29 #include "chrome/test/ui_test_utils.h"
30 #include "content/browser/browser_thread.h" 30 #include "content/browser/browser_thread.h"
31 #include "content/browser/tab_contents/tab_contents.h" 31 #include "content/browser/tab_contents/tab_contents.h"
32 #include "content/common/test_url_fetcher_factory.h"
33 #include "content/common/url_fetcher.h" 32 #include "content/common/url_fetcher.h"
33 #include "content/test/test_url_fetcher_factory.h"
34 #include "googleurl/src/gurl.h" 34 #include "googleurl/src/gurl.h"
35 #include "net/base/escape.h" 35 #include "net/base/escape.h"
36 #include "net/base/network_change_notifier.h" 36 #include "net/base/network_change_notifier.h"
37 #include "net/proxy/proxy_config.h" 37 #include "net/proxy/proxy_config.h"
38 #include "net/proxy/proxy_config_service_fixed.h" 38 #include "net/proxy/proxy_config_service_fixed.h"
39 #include "net/proxy/proxy_service.h" 39 #include "net/proxy/proxy_service.h"
40 #include "net/test/test_server.h" 40 #include "net/test/test_server.h"
41 #include "net/url_request/url_request_context.h" 41 #include "net/url_request/url_request_context.h"
42 #include "net/url_request/url_request_context_getter.h" 42 #include "net/url_request/url_request_context_getter.h"
43 #include "net/url_request/url_request_status.h" 43 #include "net/url_request/url_request_status.h"
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 // integration tests on Linux causes error as we make external DNS lookups. 314 // integration tests on Linux causes error as we make external DNS lookups.
315 resolver->AllowDirectLookup("*.thawte.com"); 315 resolver->AllowDirectLookup("*.thawte.com");
316 resolver->AllowDirectLookup("*.geotrust.com"); 316 resolver->AllowDirectLookup("*.geotrust.com");
317 resolver->AllowDirectLookup("*.gstatic.com"); 317 resolver->AllowDirectLookup("*.gstatic.com");
318 mock_host_resolver_override_.reset( 318 mock_host_resolver_override_.reset(
319 new net::ScopedDefaultHostResolverProc(resolver)); 319 new net::ScopedDefaultHostResolverProc(resolver));
320 } 320 }
321 321
322 void LiveSyncTest::TearDownInProcessBrowserTestFixture() { 322 void LiveSyncTest::TearDownInProcessBrowserTestFixture() {
323 mock_host_resolver_override_.reset(); 323 mock_host_resolver_override_.reset();
324
325 // Switch back to using the default URLFetcher factory. This is a no-op if
326 // a fake factory wasn't used.
327 URLFetcher::set_factory(NULL);
328 } 324 }
329 325
330 void LiveSyncTest::ReadPasswordFile() { 326 void LiveSyncTest::ReadPasswordFile() {
331 CommandLine* cl = CommandLine::ForCurrentProcess(); 327 CommandLine* cl = CommandLine::ForCurrentProcess();
332 password_file_ = cl->GetSwitchValuePath(switches::kPasswordFileForTest); 328 password_file_ = cl->GetSwitchValuePath(switches::kPasswordFileForTest);
333 if (password_file_.empty()) 329 if (password_file_.empty())
334 LOG(FATAL) << "Can't run live server test without specifying --" 330 LOG(FATAL) << "Can't run live server test without specifying --"
335 << switches::kPasswordFileForTest << "=<filename>"; 331 << switches::kPasswordFileForTest << "=<filename>";
336 std::string file_contents; 332 std::string file_contents;
337 file_util::ReadFileToString(password_file_, &file_contents); 333 file_util::ReadFileToString(password_file_, &file_contents);
(...skipping 11 matching lines...) Expand all
349 345
350 void LiveSyncTest::SetupMockGaiaResponses() { 346 void LiveSyncTest::SetupMockGaiaResponses() {
351 username_ = "user@gmail.com"; 347 username_ = "user@gmail.com";
352 password_ = "password"; 348 password_ = "password";
353 integration_factory_.reset(new URLFetcherFactory()); 349 integration_factory_.reset(new URLFetcherFactory());
354 factory_.reset(new FakeURLFetcherFactory(integration_factory_.get())); 350 factory_.reset(new FakeURLFetcherFactory(integration_factory_.get()));
355 factory_->SetFakeResponse(kClientLoginUrl, "SID=sid\nLSID=lsid", true); 351 factory_->SetFakeResponse(kClientLoginUrl, "SID=sid\nLSID=lsid", true);
356 factory_->SetFakeResponse(kGetUserInfoUrl, "email=user@gmail.com", true); 352 factory_->SetFakeResponse(kGetUserInfoUrl, "email=user@gmail.com", true);
357 factory_->SetFakeResponse(kIssueAuthTokenUrl, "auth", true); 353 factory_->SetFakeResponse(kIssueAuthTokenUrl, "auth", true);
358 factory_->SetFakeResponse(kSearchDomainCheckUrl, ".google.com", true); 354 factory_->SetFakeResponse(kSearchDomainCheckUrl, ".google.com", true);
359 URLFetcher::set_factory(factory_.get());
360 } 355 }
361 356
362 // Start up a local sync server based on the value of server_type_, which 357 // Start up a local sync server based on the value of server_type_, which
363 // was determined from the command line parameters. 358 // was determined from the command line parameters.
364 void LiveSyncTest::SetUpTestServerIfRequired() { 359 void LiveSyncTest::SetUpTestServerIfRequired() {
365 if (server_type_ == LOCAL_PYTHON_SERVER) { 360 if (server_type_ == LOCAL_PYTHON_SERVER) {
366 if (!SetUpLocalPythonTestServer()) 361 if (!SetUpLocalPythonTestServer())
367 LOG(FATAL) << "Failed to set up local python test server"; 362 LOG(FATAL) << "Failed to set up local python test server";
368 } else if (server_type_ == LOCAL_LIVE_SERVER) { 363 } else if (server_type_ == LOCAL_LIVE_SERVER) {
369 if (!SetUpLocalTestServer()) 364 if (!SetUpLocalTestServer())
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 const net::ProxyConfig& proxy_config) { 519 const net::ProxyConfig& proxy_config) {
525 base::WaitableEvent done(false, false); 520 base::WaitableEvent done(false, false);
526 BrowserThread::PostTask( 521 BrowserThread::PostTask(
527 BrowserThread::IO, 522 BrowserThread::IO,
528 FROM_HERE, 523 FROM_HERE,
529 new SetProxyConfigTask(&done, 524 new SetProxyConfigTask(&done,
530 context_getter, 525 context_getter,
531 proxy_config)); 526 proxy_config));
532 done.Wait(); 527 done.Wait();
533 } 528 }
OLDNEW
« no previous file with comments | « chrome/common/net/gaia/gaia_oauth_client_unittest.cc ('k') | content/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698