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

Unified Diff: chrome/browser/prefs/proxy_prefs_unittest.cc

Issue 6004003: Introduce a separate preference for 'proxy server mode' (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Extraction undone - as per Mattias' request 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/prefs/proxy_prefs_unittest.cc
diff --git a/chrome/browser/prefs/proxy_prefs_unittest.cc b/chrome/browser/prefs/proxy_prefs_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..952413f49d2528cf7f047045cc69212a32bbc5c8
--- /dev/null
+++ b/chrome/browser/prefs/proxy_prefs_unittest.cc
@@ -0,0 +1,55 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <string>
+
+#include "base/logging.h"
+#include "base/values.h"
+#include "base/version.h"
+#include "chrome/browser/prefs/proxy_prefs.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+class ProxyPrefsTest : public testing::Test {
+};
+
+TEST_F(ProxyPrefsTest, StringToProxyMode) {
+ ProxyPrefs::ProxyMode mode;
+ EXPECT_TRUE(ProxyPrefs::StringToProxyMode("disabled", &mode));
+ EXPECT_EQ(ProxyPrefs::DISABLED, mode);
+ EXPECT_TRUE(ProxyPrefs::StringToProxyMode("auto_detect", &mode));
+ EXPECT_EQ(ProxyPrefs::AUTO_DETECT, mode);
+ EXPECT_TRUE(ProxyPrefs::StringToProxyMode("pac_script", &mode));
+ EXPECT_EQ(ProxyPrefs::PAC_SCRIPT, mode);
+ EXPECT_TRUE(ProxyPrefs::StringToProxyMode("system", &mode));
+ EXPECT_EQ(ProxyPrefs::SYSTEM, mode);
+ EXPECT_TRUE(ProxyPrefs::StringToProxyMode("fixed_servers", &mode));
+ EXPECT_EQ(ProxyPrefs::FIXED_SERVERS, mode);
+
+ EXPECT_FALSE(ProxyPrefs::StringToProxyMode("monkey", &mode));
+}
+
+TEST_F(ProxyPrefsTest, IntToProxyMode) {
+ ASSERT_EQ(ProxyPrefs::DISABLED, 0);
+ ASSERT_EQ(ProxyPrefs::AUTO_DETECT, 1);
+ ASSERT_EQ(ProxyPrefs::PAC_SCRIPT, 2);
+ ASSERT_EQ(ProxyPrefs::FIXED_SERVERS, 3);
+ ASSERT_EQ(ProxyPrefs::SYSTEM, 4);
+ // Update the following as necessary, don't change the previous ones.
+ ASSERT_EQ(ProxyPrefs::NUM_MODES, 5);
+
+ ProxyPrefs::ProxyMode mode;
+ EXPECT_TRUE(ProxyPrefs::IntToProxyMode(0, &mode));
+ EXPECT_EQ(ProxyPrefs::DISABLED, mode);
+ EXPECT_TRUE(ProxyPrefs::IntToProxyMode(1, &mode));
+ EXPECT_EQ(ProxyPrefs::AUTO_DETECT, mode);
+ EXPECT_TRUE(ProxyPrefs::IntToProxyMode(2, &mode));
+ EXPECT_EQ(ProxyPrefs::PAC_SCRIPT, mode);
+ EXPECT_TRUE(ProxyPrefs::IntToProxyMode(3, &mode));
+ EXPECT_EQ(ProxyPrefs::FIXED_SERVERS, mode);
+ EXPECT_TRUE(ProxyPrefs::IntToProxyMode(4, &mode));
+ EXPECT_EQ(ProxyPrefs::SYSTEM, mode);
+
+ EXPECT_FALSE(ProxyPrefs::IntToProxyMode(-1, &mode));
+ EXPECT_FALSE(ProxyPrefs::IntToProxyMode(ProxyPrefs::NUM_MODES, &mode));
+}

Powered by Google App Engine
This is Rietveld 408576698