Index: components/content_settings/core/browser/content_settings_utils_unittest.cc |
diff --git a/components/content_settings/core/browser/content_settings_utils_unittest.cc b/components/content_settings/core/browser/content_settings_utils_unittest.cc |
index f89b45b42f9f4ad3eda913c973a263da655d0eca..d5657bc3dbcbf210433a3dffa60d5571a4da3b5d 100644 |
--- a/components/content_settings/core/browser/content_settings_utils_unittest.cc |
+++ b/components/content_settings/core/browser/content_settings_utils_unittest.cc |
@@ -9,6 +9,21 @@ |
#include "components/content_settings/core/test/content_settings_test_utils.h" |
#include "testing/gtest/include/gtest/gtest.h" |
+namespace { |
+ |
+const char* const kContentSettingNames[] = { |
+ "default", |
+ "allow", |
+ "block", |
+ "ask", |
+ "session_only", |
+ "detect_important_content", |
+}; |
+static_assert(arraysize(kContentSettingNames) == CONTENT_SETTING_NUM_SETTINGS, |
+ "kContentSettingNames has an unexpected number of elements"); |
+ |
+} // namespace |
+ |
TEST(ContentSettingsUtilsTest, ParsePatternString) { |
content_settings::PatternPair pattern_pair; |
@@ -44,3 +59,25 @@ TEST(ContentSettingsUtilsTest, ParsePatternString) { |
EXPECT_FALSE(pattern_pair.first.IsValid()); |
EXPECT_FALSE(pattern_pair.second.IsValid()); |
} |
+ |
+TEST(ContentSettingsUtilsTest, ContentSettingsStringMap) { |
+ std::string setting_string = |
+ content_settings::ContentSettingToString(CONTENT_SETTING_NUM_SETTINGS); |
+ EXPECT_TRUE(setting_string.empty()); |
+ |
+ for (size_t i = 0; i < arraysize(kContentSettingNames); ++i) { |
+ ContentSetting setting = static_cast<ContentSetting>(i); |
+ setting_string = content_settings::ContentSettingToString(setting); |
+ EXPECT_EQ(kContentSettingNames[i], setting_string); |
+ |
+ ContentSetting converted_setting; |
+ if (i == 0) { |
+ EXPECT_FALSE(content_settings::ContentSettingFromString( |
+ kContentSettingNames[i], &converted_setting)); |
+ } else { |
+ EXPECT_TRUE(content_settings::ContentSettingFromString( |
+ kContentSettingNames[i], &converted_setting)); |
+ } |
+ EXPECT_EQ(setting, converted_setting); |
+ } |
+} |