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

Side by Side Diff: chrome/browser/extensions/api/proxy/proxy_apitest.cc

Issue 1296663003: Componentize proxy code from chrome/browser/net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updating for win p/f Created 5 years, 3 months 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
OLDNEW
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/prefs/pref_service.h" 5 #include "base/prefs/pref_service.h"
6 #include "chrome/browser/extensions/extension_apitest.h" 6 #include "chrome/browser/extensions/extension_apitest.h"
7 #include "chrome/browser/extensions/extension_util.h" 7 #include "chrome/browser/extensions/extension_util.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
11 #include "chrome/common/pref_names.h"
12 #include "components/proxy_config/proxy_config_dictionary.h" 11 #include "components/proxy_config/proxy_config_dictionary.h"
12 #include "components/proxy_config/proxy_config_pref_names.h"
13 #include "extensions/common/extension.h" 13 #include "extensions/common/extension.h"
14 #include "extensions/test/result_catcher.h" 14 #include "extensions/test/result_catcher.h"
15 15
16 namespace extensions { 16 namespace extensions {
17 17
18 namespace { 18 namespace {
19 19
20 const char kNoServer[] = ""; 20 const char kNoServer[] = "";
21 const char kNoBypass[] = ""; 21 const char kNoBypass[] = "";
22 const char kNoPac[] = ""; 22 const char kNoPac[] = "";
23 23
24 } // namespace 24 } // namespace
25 25
26 class ProxySettingsApiTest : public ExtensionApiTest { 26 class ProxySettingsApiTest : public ExtensionApiTest {
27 protected: 27 protected:
28 void ValidateSettings(int expected_mode, 28 void ValidateSettings(int expected_mode,
29 const std::string& expected_server, 29 const std::string& expected_server,
30 const std::string& bypass, 30 const std::string& bypass,
31 const std::string& expected_pac_url, 31 const std::string& expected_pac_url,
32 PrefService* pref_service) { 32 PrefService* pref_service) {
33 const PrefService::Preference* pref = 33 const PrefService::Preference* pref =
34 pref_service->FindPreference(prefs::kProxy); 34 pref_service->FindPreference(proxy_config::prefs::kProxy);
35 ASSERT_TRUE(pref != NULL); 35 ASSERT_TRUE(pref != NULL);
36 EXPECT_TRUE(pref->IsExtensionControlled()); 36 EXPECT_TRUE(pref->IsExtensionControlled());
37 37
38 ProxyConfigDictionary dict(pref_service->GetDictionary(prefs::kProxy)); 38 ProxyConfigDictionary dict(
39 pref_service->GetDictionary(proxy_config::prefs::kProxy));
39 40
40 ProxyPrefs::ProxyMode mode; 41 ProxyPrefs::ProxyMode mode;
41 ASSERT_TRUE(dict.GetMode(&mode)); 42 ASSERT_TRUE(dict.GetMode(&mode));
42 EXPECT_EQ(expected_mode, mode); 43 EXPECT_EQ(expected_mode, mode);
43 44
44 std::string value; 45 std::string value;
45 if (!bypass.empty()) { 46 if (!bypass.empty()) {
46 ASSERT_TRUE(dict.GetBypassList(&value)); 47 ASSERT_TRUE(dict.GetBypassList(&value));
47 EXPECT_EQ(bypass, value); 48 EXPECT_EQ(bypass, value);
48 } else { 49 } else {
(...skipping 10 matching lines...) Expand all
59 if (!expected_server.empty()) { 60 if (!expected_server.empty()) {
60 ASSERT_TRUE(dict.GetProxyServer(&value)); 61 ASSERT_TRUE(dict.GetProxyServer(&value));
61 EXPECT_EQ(expected_server, value); 62 EXPECT_EQ(expected_server, value);
62 } else { 63 } else {
63 EXPECT_FALSE(dict.GetProxyServer(&value)); 64 EXPECT_FALSE(dict.GetProxyServer(&value));
64 } 65 }
65 } 66 }
66 67
67 void ExpectNoSettings(PrefService* pref_service) { 68 void ExpectNoSettings(PrefService* pref_service) {
68 const PrefService::Preference* pref = 69 const PrefService::Preference* pref =
69 pref_service->FindPreference(prefs::kProxy); 70 pref_service->FindPreference(proxy_config::prefs::kProxy);
70 ASSERT_TRUE(pref != NULL); 71 ASSERT_TRUE(pref != NULL);
71 EXPECT_FALSE(pref->IsExtensionControlled()); 72 EXPECT_FALSE(pref->IsExtensionControlled());
72 } 73 }
73 74
74 bool SetIsIncognitoEnabled(bool enabled) { 75 bool SetIsIncognitoEnabled(bool enabled) {
75 ResultCatcher catcher; 76 ResultCatcher catcher;
76 extensions::util::SetIsIncognitoEnabled( 77 extensions::util::SetIsIncognitoEnabled(
77 GetSingleLoadedExtension()->id(), browser()->profile(), enabled); 78 GetSingleLoadedExtension()->id(), browser()->profile(), enabled);
78 if (!catcher.GetNextResult()) { 79 if (!catcher.GetNextResult()) {
79 message_ = catcher.message(); 80 message_ = catcher.message();
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 RunExtensionSubtest("proxy/events", "invalid_proxy.html")) << message_; 324 RunExtensionSubtest("proxy/events", "invalid_proxy.html")) << message_;
324 } 325 }
325 326
326 // Tests error events: PAC script parse error. 327 // Tests error events: PAC script parse error.
327 IN_PROC_BROWSER_TEST_F(ProxySettingsApiTest, ProxyEventsParseError) { 328 IN_PROC_BROWSER_TEST_F(ProxySettingsApiTest, ProxyEventsParseError) {
328 ASSERT_TRUE( 329 ASSERT_TRUE(
329 RunExtensionSubtest("proxy/events", "parse_error.html")) << message_; 330 RunExtensionSubtest("proxy/events", "parse_error.html")) << message_;
330 } 331 }
331 332
332 } // namespace extensions 333 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698