| 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 <gtest/gtest.h> | 5 #include <gtest/gtest.h> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/prefs/command_line_pref_store.h" | 11 #include "chrome/browser/prefs/command_line_pref_store.h" |
| 12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 14 #include "components/proxy_config/proxy_config_dictionary.h" | 14 #include "components/proxy_config/proxy_config_dictionary.h" |
| 15 #include "components/proxy_config/proxy_config_pref_names.h" |
| 15 #include "ui/base/ui_base_switches.h" | 16 #include "ui/base/ui_base_switches.h" |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 const char unknown_bool[] = "unknown_switch"; | 20 const char unknown_bool[] = "unknown_switch"; |
| 20 const char unknown_string[] = "unknown_other_switch"; | 21 const char unknown_string[] = "unknown_other_switch"; |
| 21 | 22 |
| 22 } // namespace | 23 } // namespace |
| 23 | 24 |
| 24 class TestCommandLinePrefStore : public CommandLinePrefStore { | 25 class TestCommandLinePrefStore : public CommandLinePrefStore { |
| 25 public: | 26 public: |
| 26 explicit TestCommandLinePrefStore(base::CommandLine* cl) | 27 explicit TestCommandLinePrefStore(base::CommandLine* cl) |
| 27 : CommandLinePrefStore(cl) {} | 28 : CommandLinePrefStore(cl) {} |
| 28 | 29 |
| 29 bool ProxySwitchesAreValid() { | 30 bool ProxySwitchesAreValid() { |
| 30 return ValidateProxySwitches(); | 31 return ValidateProxySwitches(); |
| 31 } | 32 } |
| 32 | 33 |
| 33 void VerifyProxyMode(ProxyPrefs::ProxyMode expected_mode) { | 34 void VerifyProxyMode(ProxyPrefs::ProxyMode expected_mode) { |
| 34 const base::Value* value = NULL; | 35 const base::Value* value = NULL; |
| 35 ASSERT_TRUE(GetValue(prefs::kProxy, &value)); | 36 ASSERT_TRUE(GetValue(proxy_config::prefs::kProxy, &value)); |
| 36 ASSERT_EQ(base::Value::TYPE_DICTIONARY, value->GetType()); | 37 ASSERT_EQ(base::Value::TYPE_DICTIONARY, value->GetType()); |
| 37 ProxyConfigDictionary dict( | 38 ProxyConfigDictionary dict( |
| 38 static_cast<const base::DictionaryValue*>(value)); | 39 static_cast<const base::DictionaryValue*>(value)); |
| 39 ProxyPrefs::ProxyMode actual_mode; | 40 ProxyPrefs::ProxyMode actual_mode; |
| 40 ASSERT_TRUE(dict.GetMode(&actual_mode)); | 41 ASSERT_TRUE(dict.GetMode(&actual_mode)); |
| 41 EXPECT_EQ(expected_mode, actual_mode); | 42 EXPECT_EQ(expected_mode, actual_mode); |
| 42 } | 43 } |
| 43 | 44 |
| 44 void VerifySSLCipherSuites(const char* const* ciphers, | 45 void VerifySSLCipherSuites(const char* const* ciphers, |
| 45 size_t cipher_count) { | 46 size_t cipher_count) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 scoped_refptr<TestCommandLinePrefStore> store = | 108 scoped_refptr<TestCommandLinePrefStore> store = |
| 108 new TestCommandLinePrefStore(&cl); | 109 new TestCommandLinePrefStore(&cl); |
| 109 | 110 |
| 110 const base::Value* actual = NULL; | 111 const base::Value* actual = NULL; |
| 111 EXPECT_FALSE(store->GetValue(unknown_bool, &actual)); | 112 EXPECT_FALSE(store->GetValue(unknown_bool, &actual)); |
| 112 EXPECT_FALSE(store->GetValue(unknown_string, &actual)); | 113 EXPECT_FALSE(store->GetValue(unknown_string, &actual)); |
| 113 | 114 |
| 114 store->VerifyProxyMode(ProxyPrefs::MODE_FIXED_SERVERS); | 115 store->VerifyProxyMode(ProxyPrefs::MODE_FIXED_SERVERS); |
| 115 | 116 |
| 116 const base::Value* value = NULL; | 117 const base::Value* value = NULL; |
| 117 ASSERT_TRUE(store->GetValue(prefs::kProxy, &value)); | 118 ASSERT_TRUE(store->GetValue(proxy_config::prefs::kProxy, &value)); |
| 118 ASSERT_EQ(base::Value::TYPE_DICTIONARY, value->GetType()); | 119 ASSERT_EQ(base::Value::TYPE_DICTIONARY, value->GetType()); |
| 119 ProxyConfigDictionary dict(static_cast<const base::DictionaryValue*>(value)); | 120 ProxyConfigDictionary dict(static_cast<const base::DictionaryValue*>(value)); |
| 120 | 121 |
| 121 std::string string_result; | 122 std::string string_result; |
| 122 | 123 |
| 123 ASSERT_TRUE(dict.GetProxyServer(&string_result)); | 124 ASSERT_TRUE(dict.GetProxyServer(&string_result)); |
| 124 EXPECT_EQ("proxy", string_result); | 125 EXPECT_EQ("proxy", string_result); |
| 125 | 126 |
| 126 ASSERT_TRUE(dict.GetBypassList(&string_result)); | 127 ASSERT_TRUE(dict.GetBypassList(&string_result)); |
| 127 EXPECT_EQ("list", string_result); | 128 EXPECT_EQ("list", string_result); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 cl3.AppendSwitchASCII(switches::kCipherSuiteBlacklist, | 211 cl3.AppendSwitchASCII(switches::kCipherSuiteBlacklist, |
| 211 "0x0004;MOAR;0x0005"); | 212 "0x0004;MOAR;0x0005"); |
| 212 scoped_refptr<TestCommandLinePrefStore> store3 = | 213 scoped_refptr<TestCommandLinePrefStore> store3 = |
| 213 new TestCommandLinePrefStore(&cl3); | 214 new TestCommandLinePrefStore(&cl3); |
| 214 const char* const expected_ciphers3[] = { | 215 const char* const expected_ciphers3[] = { |
| 215 "0x0004;MOAR;0x0005" | 216 "0x0004;MOAR;0x0005" |
| 216 }; | 217 }; |
| 217 store3->VerifySSLCipherSuites(expected_ciphers3, | 218 store3->VerifySSLCipherSuites(expected_ciphers3, |
| 218 arraysize(expected_ciphers3)); | 219 arraysize(expected_ciphers3)); |
| 219 } | 220 } |
| OLD | NEW |