summaryrefslogtreecommitdiffstats
path: root/net/proxy/proxy_config_service_linux_unittest.cc
diff options
context:
space:
mode:
authormdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-20 21:46:48 +0000
committermdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-20 21:46:48 +0000
commit6b5fe749c6f755f498769ff913b1a522049ff6ba (patch)
tree494283c2c74736d947a13f8c196ae0353c1c32d0 /net/proxy/proxy_config_service_linux_unittest.cc
parent7184ea172212bfc0b6379dc3c730b90dfba7b046 (diff)
downloadchromium_src-6b5fe749c6f755f498769ff913b1a522049ff6ba.zip
chromium_src-6b5fe749c6f755f498769ff913b1a522049ff6ba.tar.gz
chromium_src-6b5fe749c6f755f498769ff913b1a522049ff6ba.tar.bz2
Linux: split ProxyConfigServiceLinux::SettingGetter::Setting into several enums, one for each type of setting. This provides additional type safety.
Review URL: http://codereview.chromium.org/7033040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86149 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/proxy_config_service_linux_unittest.cc')
-rw-r--r--net/proxy/proxy_config_service_linux_unittest.cc35
1 files changed, 18 insertions, 17 deletions
diff --git a/net/proxy/proxy_config_service_linux_unittest.cc b/net/proxy/proxy_config_service_linux_unittest.cc
index 8d37e07..d16aaaa 100644
--- a/net/proxy/proxy_config_service_linux_unittest.cc
+++ b/net/proxy/proxy_config_service_linux_unittest.cc
@@ -63,13 +63,12 @@ struct GConfValues {
// Mapping from a setting name to the location of the corresponding
// value (inside a EnvVarValues or GConfValues struct).
-template<typename value_type>
+template<typename key_type, typename value_type>
struct SettingsTable {
- typedef ProxyConfigServiceLinux::SettingGetter::Setting Setting;
- typedef std::map<Setting, value_type*> map_type;
+ typedef std::map<key_type, value_type*> map_type;
// Gets the value from its location
- value_type Get(Setting key) {
+ value_type Get(key_type key) {
typename map_type::const_iterator it = settings.find(key);
// In case there's a typo or the unittest becomes out of sync.
CHECK(it != settings.end()) << "key " << key << " not found";
@@ -193,7 +192,7 @@ class MockSettingGetter
return "test";
}
- virtual bool GetString(Setting key, std::string* result) {
+ virtual bool GetString(StringSetting key, std::string* result) {
const char* value = strings_table.Get(key);
if (value) {
*result = value;
@@ -202,13 +201,7 @@ class MockSettingGetter
return false;
}
- virtual bool GetInt(Setting key, int* result) {
- // We don't bother to distinguish unset keys from 0 values.
- *result = ints_table.Get(key);
- return true;
- }
-
- virtual bool GetBool(Setting key, bool* result) {
+ virtual bool GetBool(BoolSetting key, bool* result) {
BoolSettingValue value = bools_table.Get(key);
switch (value) {
case UNSET:
@@ -222,7 +215,14 @@ class MockSettingGetter
return true;
}
- virtual bool GetStringList(Setting key, std::vector<std::string>* result) {
+ virtual bool GetInt(IntSetting key, int* result) {
+ // We don't bother to distinguish unset keys from 0 values.
+ *result = ints_table.Get(key);
+ return true;
+ }
+
+ virtual bool GetStringList(StringListSetting key,
+ std::vector<std::string>* result) {
*result = string_lists_table.Get(key);
// We don't bother to distinguish unset keys from empty lists.
return !result->empty();
@@ -240,10 +240,11 @@ class MockSettingGetter
GConfValues values;
private:
- SettingsTable<const char*> strings_table;
- SettingsTable<int> ints_table;
- SettingsTable<BoolSettingValue> bools_table;
- SettingsTable<std::vector<std::string> > string_lists_table;
+ SettingsTable<StringSetting, const char*> strings_table;
+ SettingsTable<BoolSetting, BoolSettingValue> bools_table;
+ SettingsTable<IntSetting, int> ints_table;
+ SettingsTable<StringListSetting,
+ std::vector<std::string> > string_lists_table;
};
} // namespace