| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/files/file_path.h" |
| 6 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 7 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/login/login_prompt.h" | 12 #include "chrome/browser/ui/login/login_prompt.h" |
| 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 13 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
| 14 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
| 16 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
| 17 #include "content/public/browser/notification_details.h" | 18 #include "content/public/browser/notification_details.h" |
| 18 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
| 19 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/browser/web_contents_observer.h" | 21 #include "content/public/browser/web_contents_observer.h" |
| 21 #include "content/public/test/browser_test_utils.h" | 22 #include "content/public/test/browser_test_utils.h" |
| 22 #include "net/base/test_data_directory.h" | 23 #include "net/base/test_data_directory.h" |
| 24 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 23 #include "net/test/spawned_test_server/spawned_test_server.h" | 25 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 24 | 26 |
| 25 namespace { | 27 namespace { |
| 26 | 28 |
| 27 // PAC script that sends all requests to an invalid proxy server. | 29 // PAC script that sends all requests to an invalid proxy server. |
| 28 const base::FilePath::CharType kPACScript[] = FILE_PATH_LITERAL( | 30 const base::FilePath::CharType kPACScript[] = FILE_PATH_LITERAL( |
| 29 "bad_server.pac"); | 31 "bad_server.pac"); |
| 30 | 32 |
| 31 // Verify kPACScript is installed as the PAC script. | 33 // Verify kPACScript is installed as the PAC script. |
| 32 void VerifyProxyScript(Browser* browser) { | 34 void VerifyProxyScript(Browser* browser) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 .ReplaceComponents(replacements)); | 138 .ReplaceComponents(replacements)); |
| 137 | 139 |
| 138 const base::string16 result = watcher.WaitAndGetTitle(); | 140 const base::string16 result = watcher.WaitAndGetTitle(); |
| 139 EXPECT_TRUE(base::EqualsASCII(result, "PASS")); | 141 EXPECT_TRUE(base::EqualsASCII(result, "PASS")); |
| 140 EXPECT_TRUE(observer.auth_handled()); | 142 EXPECT_TRUE(observer.auth_handled()); |
| 141 } | 143 } |
| 142 | 144 |
| 143 // Fetch PAC script via an http:// URL. | 145 // Fetch PAC script via an http:// URL. |
| 144 class HttpProxyScriptBrowserTest : public InProcessBrowserTest { | 146 class HttpProxyScriptBrowserTest : public InProcessBrowserTest { |
| 145 public: | 147 public: |
| 146 HttpProxyScriptBrowserTest() | 148 HttpProxyScriptBrowserTest() { |
| 147 : http_server_(net::SpawnedTestServer::TYPE_HTTP, | 149 http_server_.ServeFilesFromSourceDirectory("chrome/test/data"); |
| 148 net::SpawnedTestServer::kLocalhost, | |
| 149 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))) { | |
| 150 } | 150 } |
| 151 ~HttpProxyScriptBrowserTest() override {} | 151 ~HttpProxyScriptBrowserTest() override {} |
| 152 | 152 |
| 153 void SetUp() override { | 153 void SetUp() override { |
| 154 ASSERT_TRUE(http_server_.Start()); | 154 ASSERT_TRUE(http_server_.Start()); |
| 155 InProcessBrowserTest::SetUp(); | 155 InProcessBrowserTest::SetUp(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void SetUpCommandLine(base::CommandLine* command_line) override { | 158 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 159 base::FilePath pac_script_path(FILE_PATH_LITERAL("files")); | 159 base::FilePath pac_script_path(FILE_PATH_LITERAL("/")); |
| 160 command_line->AppendSwitchASCII(switches::kProxyPacUrl, http_server_.GetURL( | 160 command_line->AppendSwitchASCII(switches::kProxyPacUrl, http_server_.GetURL( |
| 161 pac_script_path.Append(kPACScript).MaybeAsASCII()).spec()); | 161 pac_script_path.Append(kPACScript).MaybeAsASCII()).spec()); |
| 162 } | 162 } |
| 163 | 163 |
| 164 private: | 164 private: |
| 165 net::SpawnedTestServer http_server_; | 165 net::EmbeddedTestServer http_server_; |
| 166 | 166 |
| 167 DISALLOW_COPY_AND_ASSIGN(HttpProxyScriptBrowserTest); | 167 DISALLOW_COPY_AND_ASSIGN(HttpProxyScriptBrowserTest); |
| 168 }; | 168 }; |
| 169 | 169 |
| 170 IN_PROC_BROWSER_TEST_F(HttpProxyScriptBrowserTest, Verify) { | 170 IN_PROC_BROWSER_TEST_F(HttpProxyScriptBrowserTest, Verify) { |
| 171 VerifyProxyScript(browser()); | 171 VerifyProxyScript(browser()); |
| 172 } | 172 } |
| 173 | 173 |
| 174 // Fetch PAC script via a file:// URL. | 174 // Fetch PAC script via a file:// URL. |
| 175 class FileProxyScriptBrowserTest : public InProcessBrowserTest { | 175 class FileProxyScriptBrowserTest : public InProcessBrowserTest { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 | 269 |
| 270 private: | 270 private: |
| 271 DISALLOW_COPY_AND_ASSIGN(OutOfProcessProxyResolverBrowserTest); | 271 DISALLOW_COPY_AND_ASSIGN(OutOfProcessProxyResolverBrowserTest); |
| 272 }; | 272 }; |
| 273 | 273 |
| 274 IN_PROC_BROWSER_TEST_F(OutOfProcessProxyResolverBrowserTest, Verify) { | 274 IN_PROC_BROWSER_TEST_F(OutOfProcessProxyResolverBrowserTest, Verify) { |
| 275 VerifyProxyScript(browser()); | 275 VerifyProxyScript(browser()); |
| 276 } | 276 } |
| 277 | 277 |
| 278 } // namespace | 278 } // namespace |
| OLD | NEW |