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

Unified Diff: chrome/browser/extensions/extension_proxy_apitest.cc

Issue 5701003: Intorduce a separate preference for 'proxy server mode' (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 10 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_proxy_apitest.cc
diff --git a/chrome/browser/extensions/extension_proxy_apitest.cc b/chrome/browser/extensions/extension_proxy_apitest.cc
index f24b7ef5689474a45935bb6fc2f88222e5fafa3f..7032e2da74d4abe245d94d09c9cee1faf3b9822c 100644
--- a/chrome/browser/extensions/extension_proxy_apitest.cc
+++ b/chrome/browser/extensions/extension_proxy_apitest.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/prefs/proxy_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_switches.h"
@@ -22,11 +23,11 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ProxyAutoSettings) {
PrefService* pref_service = browser()->profile()->GetPrefs();
const PrefService::Preference* pref =
- pref_service->FindPreference(prefs::kProxyAutoDetect);
+ pref_service->FindPreference(prefs::kProxyServerMode);
ASSERT_TRUE(pref != NULL);
ASSERT_TRUE(pref->IsExtensionControlled());
- bool auto_detect = pref_service->GetBoolean(prefs::kProxyAutoDetect);
- EXPECT_TRUE(auto_detect);
+ int mode = pref_service->GetInteger(prefs::kProxyServerMode);
+ EXPECT_EQ(ProxyPrefs::AUTO_DETECT, mode);
pref = pref_service->FindPreference(prefs::kProxyPacUrl);
ASSERT_TRUE(pref != NULL);
@@ -53,7 +54,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ProxyManualSingle) {
// There should be no values superseding the extension-set proxy in this test.
const PrefService::Preference* pref =
- pref_service->FindPreference(prefs::kProxyServer);
+ pref_service->FindPreference(prefs::kProxyServer);
battre (please use the other) 2010/12/16 12:52:16 Nit: Indentation
gfeher 2010/12/16 14:28:17 Done.
ASSERT_TRUE(pref != NULL);
ASSERT_TRUE(pref->IsExtensionControlled());
std::string proxy_server = pref_service->GetString(prefs::kProxyServer);
@@ -64,10 +65,11 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ProxyManualSingle) {
// Other proxy prefs should also be set, so they're all controlled from one
// place.
- pref = pref_service->FindPreference(prefs::kProxyAutoDetect);
+ pref = pref_service->FindPreference(prefs::kProxyServerMode);
ASSERT_TRUE(pref != NULL);
EXPECT_TRUE(pref->IsExtensionControlled());
- EXPECT_FALSE(pref_service->GetBoolean(prefs::kProxyAutoDetect));
+ EXPECT_EQ(ProxyPrefs::MANUAL,
+ pref_service->GetInteger(prefs::kProxyServerMode));
pref = pref_service->FindPreference(prefs::kProxyPacUrl);
ASSERT_TRUE(pref != NULL);
@@ -75,6 +77,38 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ProxyManualSingle) {
EXPECT_EQ("", pref_service->GetString(prefs::kProxyPacUrl));
}
+// Tests setting to use the systems's proxy settings.
+IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ProxySystem) {
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kEnableExperimentalExtensionApis);
+
+ ASSERT_TRUE(RunExtensionTest("proxy/system")) << message_;
+ const 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.
+ const PrefService::Preference* pref =
+ pref_service->FindPreference(prefs::kProxyServerMode);
+ ASSERT_TRUE(pref != NULL);
+ ASSERT_TRUE(pref->IsExtensionControlled());
+ int proxy_server_mode = pref_service->GetInteger(prefs::kProxyServerMode);
+ EXPECT_EQ(ProxyPrefs::SYSTEM, proxy_server_mode);
+
+ // Other proxy prefs should also be set, so they're all controlled from one
+ // place.
+ pref = pref_service->FindPreference(prefs::kProxyPacUrl);
+ ASSERT_TRUE(pref != NULL);
+ EXPECT_TRUE(pref->IsExtensionControlled());
+ EXPECT_EQ("", pref_service->GetString(prefs::kProxyPacUrl));
+
+ pref = pref_service->FindPreference(prefs::kProxyServer);
+ ASSERT_TRUE(pref != NULL);
+ EXPECT_TRUE(pref->IsExtensionControlled());
+ EXPECT_EQ("", pref_service->GetString(prefs::kProxyServer));
+}
+
// Tests setting separate proxies for each scheme.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ProxyManualIndividual) {
CommandLine::ForCurrentProcess()->AppendSwitch(
@@ -88,7 +122,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ProxyManualIndividual) {
// There should be no values superseding the extension-set proxy in this test.
const PrefService::Preference* pref =
- pref_service->FindPreference(prefs::kProxyServer);
+ pref_service->FindPreference(prefs::kProxyServer);
battre (please use the other) 2010/12/16 12:52:16 Nit: Indentation
gfeher 2010/12/16 14:28:17 Done.
ASSERT_TRUE(pref != NULL);
ASSERT_TRUE(pref->IsExtensionControlled());
@@ -100,10 +134,11 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ProxyManualIndividual) {
// Other proxy prefs should also be set, so they're all controlled from one
// place.
- pref = pref_service->FindPreference(prefs::kProxyAutoDetect);
+ pref = pref_service->FindPreference(prefs::kProxyServerMode);
ASSERT_TRUE(pref != NULL);
EXPECT_TRUE(pref->IsExtensionControlled());
- EXPECT_FALSE(pref_service->GetBoolean(prefs::kProxyAutoDetect));
+ EXPECT_EQ(ProxyPrefs::MANUAL,
+ pref_service->GetInteger(prefs::kProxyServerMode));
pref = pref_service->FindPreference(prefs::kProxyPacUrl);
ASSERT_TRUE(pref != NULL);

Powered by Google App Engine
This is Rietveld 408576698