Chromium Code Reviews| Index: chrome/browser/prefs/command_line_pref_store_unittest.cc | 
| diff --git a/chrome/browser/prefs/command_line_pref_store_unittest.cc b/chrome/browser/prefs/command_line_pref_store_unittest.cc | 
| index 031a7c9cba96b8967ae6b24499f57bf5d4e84078..227b16b9c311c2caf39caa57ffd582819ee6d40a 100644 | 
| --- a/chrome/browser/prefs/command_line_pref_store_unittest.cc | 
| +++ b/chrome/browser/prefs/command_line_pref_store_unittest.cc | 
| @@ -9,6 +9,7 @@ | 
| #include "base/string_util.h" | 
| #include "base/values.h" | 
| #include "chrome/browser/prefs/command_line_pref_store.h" | 
| +#include "chrome/browser/prefs/proxy_prefs.h" | 
| #include "chrome/common/chrome_switches.h" | 
| #include "chrome/common/pref_names.h" | 
| @@ -22,6 +23,14 @@ class TestCommandLinePrefStore : public CommandLinePrefStore { | 
| bool ProxySwitchesAreValid() { | 
| return ValidateProxySwitches(); | 
| } | 
| + | 
| + void VerifyIntPref(const std::string& path, int expected_value) { | 
| + Value* actual = NULL; | 
| + ASSERT_EQ(PrefStore::READ_OK, GetValue(path, &actual)); | 
| + int int_result = -1; | 
| + EXPECT_TRUE(actual->GetAsInteger(&int_result)); | 
| + EXPECT_EQ(expected_value, int_result); | 
| + } | 
| }; | 
| const char unknown_bool[] = "unknown_switch"; | 
| @@ -50,10 +59,11 @@ TEST(CommandLinePrefStoreTest, SimpleBooleanPref) { | 
| CommandLinePrefStore store(&cl); | 
| Value* actual = NULL; | 
| - ASSERT_EQ(PrefStore::READ_OK, store.GetValue(prefs::kNoProxyServer, &actual)); | 
| - bool result; | 
| - EXPECT_TRUE(actual->GetAsBoolean(&result)); | 
| - EXPECT_TRUE(result); | 
| + ASSERT_EQ(PrefStore::READ_OK, | 
| + store.GetValue(prefs::kProxyServerMode, &actual)); | 
| + int result = -1; | 
| + EXPECT_TRUE(actual->GetAsInteger(&result)); | 
| + EXPECT_EQ(ProxyPrefs::DISABLED, result); | 
| } | 
| // Tests a command line with no recognized prefs. | 
| @@ -76,15 +86,11 @@ TEST(CommandLinePrefStoreTest, MultipleSwitches) { | 
| cl.AppendSwitchASCII(switches::kProxyServer, "proxy"); | 
| cl.AppendSwitchASCII(switches::kProxyBypassList, "list"); | 
| cl.AppendSwitchASCII(unknown_bool, "a value"); | 
| - CommandLinePrefStore store(&cl); | 
| + TestCommandLinePrefStore store(&cl); | 
| Value* actual = NULL; | 
| EXPECT_EQ(PrefStore::READ_NO_VALUE, store.GetValue(unknown_bool, &actual)); | 
| - ASSERT_EQ(PrefStore::READ_OK, | 
| - store.GetValue(prefs::kProxyAutoDetect, &actual)); | 
| - bool bool_result = false; | 
| - EXPECT_TRUE(actual->GetAsBoolean(&bool_result)); | 
| - EXPECT_TRUE(bool_result); | 
| + store.VerifyIntPref(prefs::kProxyServerMode, ProxyPrefs::AUTO_DETECT); | 
| EXPECT_EQ(PrefStore::READ_NO_VALUE, store.GetValue(unknown_string, &actual)); | 
| std::string string_result = ""; | 
| @@ -124,3 +130,22 @@ TEST(CommandLinePrefStoreTest, ProxySwitchValidation) { | 
| TestCommandLinePrefStore store4(&cl2); | 
| EXPECT_TRUE(store4.ProxySwitchesAreValid()); | 
| } | 
| + | 
| +TEST(CommandLinePrefStoreTest, ManualProxyModeInference) { | 
| + CommandLine cl1(CommandLine::NO_PROGRAM); | 
| + cl1.AppendSwitch(unknown_string); | 
| + cl1.AppendSwitchASCII(switches::kProxyServer, "proxy"); | 
| + TestCommandLinePrefStore store1(&cl1); | 
| + store1.VerifyIntPref(prefs::kProxyServerMode, ProxyPrefs::MANUAL); | 
| + | 
| + CommandLine cl2(CommandLine::NO_PROGRAM); | 
| + cl2.AppendSwitch(unknown_string); | 
| + cl2.AppendSwitchASCII(switches::kProxyServer, "proxy"); | 
| + TestCommandLinePrefStore store2(&cl2); | 
| + store2.VerifyIntPref(prefs::kProxyServerMode, ProxyPrefs::MANUAL); | 
| 
 
Mattias Nissler (ping if slow)
2010/12/20 13:34:03
What's the difference between 1 and 2?
 
battre (please use the other)
2010/12/21 14:18:18
Deleted.
 
 | 
| + | 
| + CommandLine cl3(CommandLine::NO_PROGRAM); | 
| + cl3.AppendSwitchASCII(switches::kProxyPacUrl, "proxy"); | 
| + TestCommandLinePrefStore store3(&cl3); | 
| + store3.VerifyIntPref(prefs::kProxyServerMode, ProxyPrefs::MANUAL); | 
| +} |