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

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

Issue 6240013: Make proxy settings one atomic dictionary in the PrefStores such that modifications are atomic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/out/Debug
Patch Set: Updated to ToT and addressed Matt's comments in base-CL Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
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 2518ff9595377056f2e101e64f7fc0aadb6f3ba1..02d59e2e5ba5bd20684f7696c6776ceceb14c649 100644
--- a/chrome/browser/prefs/command_line_pref_store_unittest.cc
+++ b/chrome/browser/prefs/command_line_pref_store_unittest.cc
@@ -26,10 +26,14 @@ class TestCommandLinePrefStore : public CommandLinePrefStore {
return ValidateProxySwitches();
}
- void VerifyIntPref(const std::string& path, int expected_value) {
- Value* actual = NULL;
- ASSERT_EQ(PrefStore::READ_OK, GetValue(path, &actual));
- EXPECT_TRUE(FundamentalValue(expected_value).Equals(actual));
+ void VerifyProxyMode(ProxyPrefs::ProxyMode expected_mode) {
+ Value* value = NULL;
+ ASSERT_EQ(PrefStore::READ_OK, GetValue(prefs::kProxy, &value));
+ ASSERT_EQ(Value::TYPE_DICTIONARY, value->GetType());
+ ProxyPrefsDictionary dict(static_cast<DictionaryValue*>(value));
+ ProxyPrefs::ProxyMode actual_mode;
+ ASSERT_TRUE(dict.GetMode(&actual_mode));
+ EXPECT_EQ(expected_mode, actual_mode);
}
};
@@ -59,7 +63,7 @@ TEST(CommandLinePrefStoreTest, SimpleBooleanPref) {
scoped_refptr<TestCommandLinePrefStore> store =
new TestCommandLinePrefStore(&cl);
- store->VerifyIntPref(prefs::kProxyMode, ProxyPrefs::MODE_DIRECT);
+ store->VerifyProxyMode(ProxyPrefs::MODE_DIRECT);
}
// Tests a command line with no recognized prefs.
@@ -78,7 +82,6 @@ TEST(CommandLinePrefStoreTest, NoPrefs) {
TEST(CommandLinePrefStoreTest, MultipleSwitches) {
CommandLine cl(CommandLine::NO_PROGRAM);
cl.AppendSwitch(unknown_string);
- cl.AppendSwitch(switches::kProxyAutoDetect);
cl.AppendSwitchASCII(switches::kProxyServer, "proxy");
cl.AppendSwitchASCII(switches::kProxyBypassList, "list");
cl.AppendSwitchASCII(unknown_bool, "a value");
@@ -87,16 +90,21 @@ TEST(CommandLinePrefStoreTest, MultipleSwitches) {
Value* actual = NULL;
EXPECT_EQ(PrefStore::READ_NO_VALUE, store->GetValue(unknown_bool, &actual));
- store->VerifyIntPref(prefs::kProxyMode, ProxyPrefs::MODE_AUTO_DETECT);
-
EXPECT_EQ(PrefStore::READ_NO_VALUE, store->GetValue(unknown_string, &actual));
+
+ store->VerifyProxyMode(ProxyPrefs::MODE_FIXED_SERVERS);
+
+ Value* value = NULL;
+ ASSERT_EQ(PrefStore::READ_OK, store->GetValue(prefs::kProxy, &value));
+ ASSERT_EQ(Value::TYPE_DICTIONARY, value->GetType());
+ ProxyPrefsDictionary dict(static_cast<DictionaryValue*>(value));
+
std::string string_result = "";
- ASSERT_EQ(PrefStore::READ_OK, store->GetValue(prefs::kProxyServer, &actual));
- EXPECT_TRUE(actual->GetAsString(&string_result));
+
+ ASSERT_TRUE(dict.GetProxyServer(&string_result));
EXPECT_EQ("proxy", string_result);
- ASSERT_EQ(PrefStore::READ_OK,
- store->GetValue(prefs::kProxyBypassList, &actual));
- EXPECT_TRUE(actual->GetAsString(&string_result));
+
+ ASSERT_TRUE(dict.GetBypassList(&string_result));
EXPECT_EQ("list", string_result);
}
@@ -138,11 +146,11 @@ TEST(CommandLinePrefStoreTest, ManualProxyModeInference) {
cl1.AppendSwitchASCII(switches::kProxyServer, "proxy");
scoped_refptr<TestCommandLinePrefStore> store1 =
new TestCommandLinePrefStore(&cl1);
- store1->VerifyIntPref(prefs::kProxyMode, ProxyPrefs::MODE_FIXED_SERVERS);
+ store1->VerifyProxyMode(ProxyPrefs::MODE_FIXED_SERVERS);
CommandLine cl2(CommandLine::NO_PROGRAM);
cl2.AppendSwitchASCII(switches::kProxyPacUrl, "proxy");
scoped_refptr<TestCommandLinePrefStore> store2 =
new TestCommandLinePrefStore(&cl2);
- store2->VerifyIntPref(prefs::kProxyMode, ProxyPrefs::MODE_PAC_SCRIPT);
+ store2->VerifyProxyMode(ProxyPrefs::MODE_PAC_SCRIPT);
}

Powered by Google App Engine
This is Rietveld 408576698