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

Side by Side Diff: chrome/browser/signin/signin_browsertest.cc

Issue 60923002: [sync] Allow FakeURLFetcher to return an arbitrary URLRequestStatus (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_BROWSERTEST_H_ 5 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_BROWSERTEST_H_
6 #define CHROME_BROWSER_SIGNIN_SIGNIN_BROWSERTEST_H_ 6 #define CHROME_BROWSER_SIGNIN_SIGNIN_BROWSERTEST_H_
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "chrome/browser/signin/signin_manager.h" 9 #include "chrome/browser/signin/signin_manager.h"
10 #include "chrome/browser/signin/signin_manager_factory.h" 10 #include "chrome/browser/signin/signin_manager_factory.h"
11 #include "chrome/browser/signin/signin_promo.h" 11 #include "chrome/browser/signin/signin_promo.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/singleton_tabs.h" 13 #include "chrome/browser/ui/singleton_tabs.h"
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" 14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
15 #include "chrome/browser/ui/webui/signin/login_ui_service.h" 15 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
16 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 16 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
17 #include "chrome/common/url_constants.h" 17 #include "chrome/common/url_constants.h"
18 #include "chrome/test/base/in_process_browser_test.h" 18 #include "chrome/test/base/in_process_browser_test.h"
19 #include "chrome/test/base/ui_test_utils.h" 19 #include "chrome/test/base/ui_test_utils.h"
20 #include "content/public/browser/notification_service.h" 20 #include "content/public/browser/notification_service.h"
21 #include "content/public/browser/notification_types.h" 21 #include "content/public/browser/notification_types.h"
22 #include "content/public/browser/render_process_host.h" 22 #include "content/public/browser/render_process_host.h"
23 #include "content/public/browser/render_view_host.h" 23 #include "content/public/browser/render_view_host.h"
24 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
25 #include "content/public/browser/web_contents_observer.h" 25 #include "content/public/browser/web_contents_observer.h"
26 #include "content/public/common/content_switches.h" 26 #include "content/public/common/content_switches.h"
27 #include "google_apis/gaia/gaia_urls.h" 27 #include "google_apis/gaia/gaia_urls.h"
28 #include "net/http/http_status_code.h" 28 #include "net/http/http_status_code.h"
29 #include "net/url_request/test_url_fetcher_factory.h" 29 #include "net/url_request/test_url_fetcher_factory.h"
30 #include "net/url_request/url_request_status.h"
30 31
31 namespace { 32 namespace {
32 const char kNonSigninURL[] = "www.google.com"; 33 const char kNonSigninURL[] = "www.google.com";
33 } 34 }
34 35
35 class SigninBrowserTest : public InProcessBrowserTest { 36 class SigninBrowserTest : public InProcessBrowserTest {
36 public: 37 public:
37 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 38 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
38 https_server_.reset(new net::SpawnedTestServer( 39 https_server_.reset(new net::SpawnedTestServer(
39 net::SpawnedTestServer::TYPE_HTTPS, 40 net::SpawnedTestServer::TYPE_HTTPS,
40 net::SpawnedTestServer::kLocalhost, 41 net::SpawnedTestServer::kLocalhost,
41 base::FilePath(FILE_PATH_LITERAL("chrome/test/data")))); 42 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))));
42 ASSERT_TRUE(https_server_->Start()); 43 ASSERT_TRUE(https_server_->Start());
43 44
44 // Add a host resolver rule to map all outgoing requests to the test server. 45 // Add a host resolver rule to map all outgoing requests to the test server.
45 // This allows us to use "real" hostnames in URLs, which we can use to 46 // This allows us to use "real" hostnames in URLs, which we can use to
46 // create arbitrary SiteInstances. 47 // create arbitrary SiteInstances.
47 command_line->AppendSwitchASCII( 48 command_line->AppendSwitchASCII(
48 switches::kHostResolverRules, 49 switches::kHostResolverRules,
49 "MAP * " + https_server_->host_port_pair().ToString() + 50 "MAP * " + https_server_->host_port_pair().ToString() +
50 ",EXCLUDE localhost"); 51 ",EXCLUDE localhost");
51 command_line->AppendSwitch(switches::kIgnoreCertificateErrors); 52 command_line->AppendSwitch(switches::kIgnoreCertificateErrors);
52 } 53 }
53 54
54 virtual void SetUp() OVERRIDE { 55 virtual void SetUp() OVERRIDE {
55 factory_.reset(new net::URLFetcherImplFactory()); 56 factory_.reset(new net::URLFetcherImplFactory());
56 fake_factory_.reset(new net::FakeURLFetcherFactory(factory_.get())); 57 fake_factory_.reset(new net::FakeURLFetcherFactory(factory_.get()));
57 fake_factory_->SetFakeResponse( 58 fake_factory_->SetFakeResponse(
58 GaiaUrls::GetInstance()->service_login_url(), 59 GaiaUrls::GetInstance()->service_login_url(), std::string(),
59 std::string(), 60 net::HTTP_OK, net::URLRequestStatus::SUCCESS);
60 net::HTTP_OK); 61 fake_factory_->SetFakeResponse(
61 fake_factory_->SetFakeResponse(GURL(kNonSigninURL), 62 GURL(kNonSigninURL), std::string(), net::HTTP_OK,
62 std::string(), 63 net::URLRequestStatus::SUCCESS);
63 net::HTTP_OK);
64 // Yield control back to the InProcessBrowserTest framework. 64 // Yield control back to the InProcessBrowserTest framework.
65 InProcessBrowserTest::SetUp(); 65 InProcessBrowserTest::SetUp();
66 } 66 }
67 67
68 virtual void TearDown() OVERRIDE { 68 virtual void TearDown() OVERRIDE {
69 if (fake_factory_.get()) { 69 if (fake_factory_.get()) {
70 fake_factory_->ClearFakeResponses(); 70 fake_factory_->ClearFakeResponses();
71 fake_factory_.reset(); 71 fake_factory_.reset();
72 } 72 }
73 73
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 EXPECT_EQ(skip_url, web_contents->GetLastCommittedURL()); 233 EXPECT_EQ(skip_url, web_contents->GetLastCommittedURL());
234 EXPECT_EQ(ntp_url, web_contents->GetVisibleURL()); 234 EXPECT_EQ(ntp_url, web_contents->GetVisibleURL());
235 235
236 content::WindowedNotificationObserver observer( 236 content::WindowedNotificationObserver observer(
237 content::NOTIFICATION_LOAD_STOP, 237 content::NOTIFICATION_LOAD_STOP,
238 content::NotificationService::AllSources()); 238 content::NotificationService::AllSources());
239 observer.Wait(); 239 observer.Wait();
240 EXPECT_EQ(start_url, web_contents->GetLastCommittedURL()); 240 EXPECT_EQ(start_url, web_contents->GetLastCommittedURL());
241 } 241 }
242 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_BROWSERTEST_H_ 242 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_BROWSERTEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698