diff options
author | pam@chromium.org <pam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-04 09:13:44 +0000 |
---|---|---|
committer | pam@chromium.org <pam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-04 09:13:44 +0000 |
commit | a9c23a5d29f9aab00fd936801e0dbbed91c18796 (patch) | |
tree | ed72849a3f2b0701ce08c429fea2c6f1936929ce /chrome/browser/extensions/extension_proxy_apitest.cc | |
parent | a06f7c07423533d4a6ba654be81ce70e82f0449d (diff) | |
download | chromium_src-a9c23a5d29f9aab00fd936801e0dbbed91c18796.zip chromium_src-a9c23a5d29f9aab00fd936801e0dbbed91c18796.tar.gz chromium_src-a9c23a5d29f9aab00fd936801e0dbbed91c18796.tar.bz2 |
First stage of proxy extension API.
Adds a basic API that will cover the features available with the --proxy-server command-line switch,
once the underlying proxy config is rewritten to actually access the pref dynamically rather than
only ever loading a proxy config on startup.
BUG=48930
TEST=covered by browser_tests (ExtensionApiTest.Proxy*)
Review URL: http://codereview.chromium.org/3074013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54882 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_proxy_apitest.cc')
-rw-r--r-- | chrome/browser/extensions/extension_proxy_apitest.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_proxy_apitest.cc b/chrome/browser/extensions/extension_proxy_apitest.cc new file mode 100644 index 0000000..cb88131c --- /dev/null +++ b/chrome/browser/extensions/extension_proxy_apitest.cc @@ -0,0 +1,50 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/browser.h" +#include "chrome/browser/extensions/extension_apitest.h" +#include "chrome/browser/pref_service.h" +#include "chrome/common/chrome_switches.h" +#include "chrome/common/extensions/extension.h" +#include "chrome/common/pref_names.h" + +// Tests setting a single proxy to cover all schemes. +IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ProxySingle) { + CommandLine::ForCurrentProcess()->AppendSwitch( + switches::kEnableExperimentalExtensionApis); + + ASSERT_TRUE(RunExtensionTest("proxy/single")) << message_; + Extension* extension = GetSingleLoadedExtension(); + ASSERT_TRUE(extension); + + PrefService* pref_service = browser()->profile()->GetPrefs(); + + // There should be no values superseding the extension-set proxy in this test. + std::string proxy_server = pref_service->GetString(prefs::kProxyServer); + + ASSERT_EQ("http=http://127.0.0.1:100;" + "https=http://127.0.0.1:100;" + "ftp=http://127.0.0.1:100;" + "socks=http://9.9.9.9", proxy_server); +} + +// Tests setting separate proxies for each scheme. +IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ProxyIndividual) { + CommandLine::ForCurrentProcess()->AppendSwitch( + switches::kEnableExperimentalExtensionApis); + + ASSERT_TRUE(RunExtensionTest("proxy/individual")) << message_; + Extension* extension = GetSingleLoadedExtension(); + ASSERT_TRUE(extension); + + PrefService* pref_service = browser()->profile()->GetPrefs(); + + // There should be no values superseding the extension-set proxy in this test. + std::string proxy_server = pref_service->GetString(prefs::kProxyServer); + + ASSERT_EQ("http=http://1.1.1.1;" + "https=socks://2.2.2.2;" + "ftp=http://3.3.3.3:9000;" + "socks=socks4://4.4.4.4:9090", proxy_server); +} |