OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <string> |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/values.h" |
| 9 #include "base/version.h" |
| 10 #include "chrome/browser/prefs/proxy_prefs.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 |
| 13 class ProxyPrefsTest : public testing::Test { |
| 14 }; |
| 15 |
| 16 TEST_F(ProxyPrefsTest, StringToProxyMode) { |
| 17 ProxyPrefs::ProxyMode mode; |
| 18 EXPECT_TRUE(ProxyPrefs::StringToProxyMode("disabled", &mode)); |
| 19 EXPECT_EQ(ProxyPrefs::DISABLED, mode); |
| 20 EXPECT_TRUE(ProxyPrefs::StringToProxyMode("auto_detect", &mode)); |
| 21 EXPECT_EQ(ProxyPrefs::AUTO_DETECT, mode); |
| 22 EXPECT_TRUE(ProxyPrefs::StringToProxyMode("pac_script", &mode)); |
| 23 EXPECT_EQ(ProxyPrefs::PAC_SCRIPT, mode); |
| 24 EXPECT_TRUE(ProxyPrefs::StringToProxyMode("system", &mode)); |
| 25 EXPECT_EQ(ProxyPrefs::SYSTEM, mode); |
| 26 EXPECT_TRUE(ProxyPrefs::StringToProxyMode("fixed_servers", &mode)); |
| 27 EXPECT_EQ(ProxyPrefs::FIXED_SERVERS, mode); |
| 28 |
| 29 EXPECT_FALSE(ProxyPrefs::StringToProxyMode("monkey", &mode)); |
| 30 } |
| 31 |
| 32 TEST_F(ProxyPrefsTest, IntToProxyMode) { |
| 33 ASSERT_EQ(ProxyPrefs::DISABLED, 0); |
| 34 ASSERT_EQ(ProxyPrefs::AUTO_DETECT, 1); |
| 35 ASSERT_EQ(ProxyPrefs::PAC_SCRIPT, 2); |
| 36 ASSERT_EQ(ProxyPrefs::FIXED_SERVERS, 3); |
| 37 ASSERT_EQ(ProxyPrefs::SYSTEM, 4); |
| 38 // Update the following as necessary, don't change the previous ones. |
| 39 ASSERT_EQ(ProxyPrefs::NUM_MODES, 5); |
| 40 |
| 41 ProxyPrefs::ProxyMode mode; |
| 42 EXPECT_TRUE(ProxyPrefs::IntToProxyMode(0, &mode)); |
| 43 EXPECT_EQ(ProxyPrefs::DISABLED, mode); |
| 44 EXPECT_TRUE(ProxyPrefs::IntToProxyMode(1, &mode)); |
| 45 EXPECT_EQ(ProxyPrefs::AUTO_DETECT, mode); |
| 46 EXPECT_TRUE(ProxyPrefs::IntToProxyMode(2, &mode)); |
| 47 EXPECT_EQ(ProxyPrefs::PAC_SCRIPT, mode); |
| 48 EXPECT_TRUE(ProxyPrefs::IntToProxyMode(3, &mode)); |
| 49 EXPECT_EQ(ProxyPrefs::FIXED_SERVERS, mode); |
| 50 EXPECT_TRUE(ProxyPrefs::IntToProxyMode(4, &mode)); |
| 51 EXPECT_EQ(ProxyPrefs::SYSTEM, mode); |
| 52 |
| 53 EXPECT_FALSE(ProxyPrefs::IntToProxyMode(-1, &mode)); |
| 54 EXPECT_FALSE(ProxyPrefs::IntToProxyMode(ProxyPrefs::NUM_MODES, &mode)); |
| 55 } |
OLD | NEW |