Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 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/url_request/test_url_fetcher_factory.h" | 28 #include "net/url_request/test_url_fetcher_factory.h" |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 const char kNonSigninURL[] = "www.google.com"; | 31 const char kNonSigninURL[] = "www.google.com"; |
|
akalin
2013/09/19 18:54:00
const GURL
| |
| 32 } | 32 } |
| 33 | 33 |
| 34 class SigninBrowserTest : public InProcessBrowserTest { | 34 class SigninBrowserTest : public InProcessBrowserTest { |
| 35 public: | 35 public: |
| 36 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 36 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 37 https_server_.reset(new net::SpawnedTestServer( | 37 https_server_.reset(new net::SpawnedTestServer( |
| 38 net::SpawnedTestServer::TYPE_HTTPS, | 38 net::SpawnedTestServer::TYPE_HTTPS, |
| 39 net::SpawnedTestServer::kLocalhost, | 39 net::SpawnedTestServer::kLocalhost, |
| 40 base::FilePath(FILE_PATH_LITERAL("chrome/test/data")))); | 40 base::FilePath(FILE_PATH_LITERAL("chrome/test/data")))); |
| 41 ASSERT_TRUE(https_server_->Start()); | 41 ASSERT_TRUE(https_server_->Start()); |
| 42 | 42 |
| 43 // Add a host resolver rule to map all outgoing requests to the test server. | 43 // Add a host resolver rule to map all outgoing requests to the test server. |
| 44 // This allows us to use "real" hostnames in URLs, which we can use to | 44 // This allows us to use "real" hostnames in URLs, which we can use to |
| 45 // create arbitrary SiteInstances. | 45 // create arbitrary SiteInstances. |
| 46 command_line->AppendSwitchASCII( | 46 command_line->AppendSwitchASCII( |
| 47 switches::kHostResolverRules, | 47 switches::kHostResolverRules, |
| 48 "MAP * " + https_server_->host_port_pair().ToString() + | 48 "MAP * " + https_server_->host_port_pair().ToString() + |
| 49 ",EXCLUDE localhost"); | 49 ",EXCLUDE localhost"); |
| 50 command_line->AppendSwitch(switches::kIgnoreCertificateErrors); | 50 command_line->AppendSwitch(switches::kIgnoreCertificateErrors); |
| 51 } | 51 } |
| 52 | 52 |
| 53 virtual void SetUp() OVERRIDE { | 53 virtual void SetUp() OVERRIDE { |
| 54 factory_.reset(new net::URLFetcherImplFactory()); | 54 factory_.reset(new net::URLFetcherImplFactory()); |
| 55 fake_factory_.reset(new net::FakeURLFetcherFactory(factory_.get())); | 55 fake_factory_.reset(new net::FakeURLFetcherFactory(factory_.get())); |
| 56 fake_factory_->SetFakeResponseForURL( | 56 fake_factory_->SetFakeResponse( |
| 57 GaiaUrls::GetInstance()->service_login_url(), | 57 GaiaUrls::GetInstance()->service_login_url(), |
| 58 std::string(), | 58 std::string(), |
| 59 true); | 59 true); |
| 60 fake_factory_->SetFakeResponse(kNonSigninURL, std::string(), true); | 60 fake_factory_->SetFakeResponse(GURL(kNonSigninURL), std::string(), true); |
| 61 // Yield control back to the InProcessBrowserTest framework. | 61 // Yield control back to the InProcessBrowserTest framework. |
| 62 InProcessBrowserTest::SetUp(); | 62 InProcessBrowserTest::SetUp(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 virtual void TearDown() OVERRIDE { | 65 virtual void TearDown() OVERRIDE { |
| 66 if (fake_factory_.get()) { | 66 if (fake_factory_.get()) { |
| 67 fake_factory_->ClearFakeResponses(); | 67 fake_factory_->ClearFakeResponses(); |
| 68 fake_factory_.reset(); | 68 fake_factory_.reset(); |
| 69 } | 69 } |
| 70 | 70 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 EXPECT_EQ(skip_url, web_contents->GetLastCommittedURL()); | 229 EXPECT_EQ(skip_url, web_contents->GetLastCommittedURL()); |
| 230 EXPECT_EQ(ntp_url, web_contents->GetVisibleURL()); | 230 EXPECT_EQ(ntp_url, web_contents->GetVisibleURL()); |
| 231 | 231 |
| 232 content::WindowedNotificationObserver observer( | 232 content::WindowedNotificationObserver observer( |
| 233 content::NOTIFICATION_LOAD_STOP, | 233 content::NOTIFICATION_LOAD_STOP, |
| 234 content::NotificationService::AllSources()); | 234 content::NotificationService::AllSources()); |
| 235 observer.Wait(); | 235 observer.Wait(); |
| 236 EXPECT_EQ(start_url, web_contents->GetLastCommittedURL()); | 236 EXPECT_EQ(start_url, web_contents->GetLastCommittedURL()); |
| 237 } | 237 } |
| 238 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_BROWSERTEST_H_ | 238 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_BROWSERTEST_H_ |
| OLD | NEW |