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

Side by Side Diff: components/content_settings/core/browser/website_settings_registry_unittest.cc

Issue 2476493003: Remove FundamentalValue
Patch Set: Fix Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/content_settings/core/browser/website_settings_registry.h" 5 #include "components/content_settings/core/browser/website_settings_registry.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "components/content_settings/core/browser/website_settings_info.h" 10 #include "components/content_settings/core/browser/website_settings_info.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 EXPECT_EQ("profile.content_settings.exceptions.auto_select_certificate", 81 EXPECT_EQ("profile.content_settings.exceptions.auto_select_certificate",
82 info->pref_name()); 82 info->pref_name());
83 EXPECT_EQ("profile.default_content_setting_values.auto_select_certificate", 83 EXPECT_EQ("profile.default_content_setting_values.auto_select_certificate",
84 info->default_value_pref_name()); 84 info->default_value_pref_name());
85 ASSERT_FALSE(info->initial_default_value()); 85 ASSERT_FALSE(info->initial_default_value());
86 EXPECT_EQ(PrefRegistry::NO_REGISTRATION_FLAGS, 86 EXPECT_EQ(PrefRegistry::NO_REGISTRATION_FLAGS,
87 info->GetPrefRegistrationFlags()); 87 info->GetPrefRegistrationFlags());
88 88
89 // Register a new setting. 89 // Register a new setting.
90 registry()->Register(static_cast<ContentSettingsType>(10), "test", 90 registry()->Register(static_cast<ContentSettingsType>(10), "test",
91 base::MakeUnique<base::FundamentalValue>(999), 91 base::MakeUnique<base::Value>(999),
92 WebsiteSettingsInfo::SYNCABLE, 92 WebsiteSettingsInfo::SYNCABLE,
93 WebsiteSettingsInfo::LOSSY, 93 WebsiteSettingsInfo::LOSSY,
94 WebsiteSettingsInfo::TOP_LEVEL_ORIGIN_ONLY_SCOPE, 94 WebsiteSettingsInfo::TOP_LEVEL_ORIGIN_ONLY_SCOPE,
95 WebsiteSettingsRegistry::ALL_PLATFORMS, 95 WebsiteSettingsRegistry::ALL_PLATFORMS,
96 WebsiteSettingsInfo::INHERIT_IN_INCOGNITO); 96 WebsiteSettingsInfo::INHERIT_IN_INCOGNITO);
97 info = registry()->Get(static_cast<ContentSettingsType>(10)); 97 info = registry()->Get(static_cast<ContentSettingsType>(10));
98 ASSERT_TRUE(info); 98 ASSERT_TRUE(info);
99 EXPECT_EQ("profile.content_settings.exceptions.test", info->pref_name()); 99 EXPECT_EQ("profile.content_settings.exceptions.test", info->pref_name());
100 EXPECT_EQ("profile.default_content_setting_values.test", 100 EXPECT_EQ("profile.default_content_setting_values.test",
101 info->default_value_pref_name()); 101 info->default_value_pref_name());
102 int setting; 102 int setting;
103 ASSERT_TRUE(info->initial_default_value()->GetAsInteger(&setting)); 103 ASSERT_TRUE(info->initial_default_value()->GetAsInteger(&setting));
104 EXPECT_EQ(999, setting); 104 EXPECT_EQ(999, setting);
105 #if defined(OS_ANDROID) || defined(OS_IOS) 105 #if defined(OS_ANDROID) || defined(OS_IOS)
106 EXPECT_EQ(PrefRegistry::LOSSY_PREF, info->GetPrefRegistrationFlags()); 106 EXPECT_EQ(PrefRegistry::LOSSY_PREF, info->GetPrefRegistrationFlags());
107 #else 107 #else
108 EXPECT_EQ(PrefRegistry::LOSSY_PREF | 108 EXPECT_EQ(PrefRegistry::LOSSY_PREF |
109 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF, 109 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF,
110 info->GetPrefRegistrationFlags()); 110 info->GetPrefRegistrationFlags());
111 #endif 111 #endif
112 EXPECT_EQ(WebsiteSettingsInfo::TOP_LEVEL_ORIGIN_ONLY_SCOPE, 112 EXPECT_EQ(WebsiteSettingsInfo::TOP_LEVEL_ORIGIN_ONLY_SCOPE,
113 info->scoping_type()); 113 info->scoping_type());
114 EXPECT_EQ(WebsiteSettingsInfo::INHERIT_IN_INCOGNITO, 114 EXPECT_EQ(WebsiteSettingsInfo::INHERIT_IN_INCOGNITO,
115 info->incognito_behavior()); 115 info->incognito_behavior());
116 } 116 }
117 117
118 TEST_F(WebsiteSettingsRegistryTest, Iteration) { 118 TEST_F(WebsiteSettingsRegistryTest, Iteration) {
119 registry()->Register(static_cast<ContentSettingsType>(10), "test", 119 registry()->Register(static_cast<ContentSettingsType>(10), "test",
120 base::MakeUnique<base::FundamentalValue>(999), 120 base::MakeUnique<base::Value>(999),
121 WebsiteSettingsInfo::SYNCABLE, 121 WebsiteSettingsInfo::SYNCABLE,
122 WebsiteSettingsInfo::LOSSY, 122 WebsiteSettingsInfo::LOSSY,
123 WebsiteSettingsInfo::TOP_LEVEL_ORIGIN_ONLY_SCOPE, 123 WebsiteSettingsInfo::TOP_LEVEL_ORIGIN_ONLY_SCOPE,
124 WebsiteSettingsRegistry::ALL_PLATFORMS, 124 WebsiteSettingsRegistry::ALL_PLATFORMS,
125 WebsiteSettingsInfo::INHERIT_IN_INCOGNITO); 125 WebsiteSettingsInfo::INHERIT_IN_INCOGNITO);
126 126
127 bool found = false; 127 bool found = false;
128 for (const WebsiteSettingsInfo* info : *registry()) { 128 for (const WebsiteSettingsInfo* info : *registry()) {
129 EXPECT_EQ(registry()->Get(info->type()), info); 129 EXPECT_EQ(registry()->Get(info->type()), info);
130 if (info->type() == 10) { 130 if (info->type() == 10) {
131 EXPECT_FALSE(found); 131 EXPECT_FALSE(found);
132 found = true; 132 found = true;
133 } 133 }
134 } 134 }
135 135
136 EXPECT_TRUE(found); 136 EXPECT_TRUE(found);
137 } 137 }
138 138
139 } // namespace content_settings 139 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698