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

Side by Side Diff: components/subresource_filter/core/browser/subresource_filter_features_unittest.cc

Issue 2837163004: Make call sites of subresource_filter::GetActiveConfigurations const-correct. (Closed)
Patch Set: Addressed comments from pkalinnikov@. Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « components/subresource_filter/core/browser/subresource_filter_features.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/subresource_filter/core/browser/subresource_filter_features .h" 5 #include "components/subresource_filter/core/browser/subresource_filter_features .h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "components/subresource_filter/core/browser/subresource_filter_features _test_support.h" 10 #include "components/subresource_filter/core/browser/subresource_filter_features _test_support.h"
(...skipping 24 matching lines...) Expand all
35 SCOPED_TRACE(::testing::Message("Enabled = ") << test_case.feature_enabled); 35 SCOPED_TRACE(::testing::Message("Enabled = ") << test_case.feature_enabled);
36 SCOPED_TRACE(::testing::Message("ActivationLevelParam = \"") 36 SCOPED_TRACE(::testing::Message("ActivationLevelParam = \"")
37 << test_case.activation_level_param << "\""); 37 << test_case.activation_level_param << "\"");
38 38
39 base::FieldTrialList field_trial_list(nullptr /* entropy_provider */); 39 base::FieldTrialList field_trial_list(nullptr /* entropy_provider */);
40 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( 40 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle(
41 test_case.feature_enabled ? base::FeatureList::OVERRIDE_ENABLE_FEATURE 41 test_case.feature_enabled ? base::FeatureList::OVERRIDE_ENABLE_FEATURE
42 : base::FeatureList::OVERRIDE_USE_DEFAULT, 42 : base::FeatureList::OVERRIDE_USE_DEFAULT,
43 test_case.activation_level_param, kActivationScopeNoSites); 43 test_case.activation_level_param, kActivationScopeNoSites);
44 44
45 auto active_configurations = GetActiveConfigurations(); 45 const auto active_configurations = GetActiveConfigurations();
46 const Configuration& actual_configuration = 46 const Configuration& actual_configuration =
47 active_configurations->the_one_and_only(); 47 active_configurations->the_one_and_only();
48 EXPECT_EQ(test_case.expected_activation_level, 48 EXPECT_EQ(test_case.expected_activation_level,
49 actual_configuration.activation_level); 49 actual_configuration.activation_level);
50 EXPECT_EQ(ActivationScope::NO_SITES, actual_configuration.activation_scope); 50 EXPECT_EQ(ActivationScope::NO_SITES, actual_configuration.activation_scope);
51 } 51 }
52 } 52 }
53 53
54 TEST(SubresourceFilterFeaturesTest, ActivationScope) { 54 TEST(SubresourceFilterFeaturesTest, ActivationScope) {
55 const struct { 55 const struct {
(...skipping 18 matching lines...) Expand all
74 SCOPED_TRACE(::testing::Message("Enabled = ") << test_case.feature_enabled); 74 SCOPED_TRACE(::testing::Message("Enabled = ") << test_case.feature_enabled);
75 SCOPED_TRACE(::testing::Message("ActivationScopeParam = \"") 75 SCOPED_TRACE(::testing::Message("ActivationScopeParam = \"")
76 << test_case.activation_scope_param << "\""); 76 << test_case.activation_scope_param << "\"");
77 77
78 base::FieldTrialList field_trial_list(nullptr /* entropy_provider */); 78 base::FieldTrialList field_trial_list(nullptr /* entropy_provider */);
79 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( 79 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle(
80 test_case.feature_enabled ? base::FeatureList::OVERRIDE_ENABLE_FEATURE 80 test_case.feature_enabled ? base::FeatureList::OVERRIDE_ENABLE_FEATURE
81 : base::FeatureList::OVERRIDE_USE_DEFAULT, 81 : base::FeatureList::OVERRIDE_USE_DEFAULT,
82 kActivationLevelDisabled, test_case.activation_scope_param); 82 kActivationLevelDisabled, test_case.activation_scope_param);
83 83
84 auto active_configurations = GetActiveConfigurations(); 84 const auto active_configurations = GetActiveConfigurations();
85 const Configuration& actual_configuration = 85 const Configuration& actual_configuration =
86 active_configurations->the_one_and_only(); 86 active_configurations->the_one_and_only();
87 EXPECT_EQ(ActivationLevel::DISABLED, actual_configuration.activation_level); 87 EXPECT_EQ(ActivationLevel::DISABLED, actual_configuration.activation_level);
88 EXPECT_EQ(test_case.expected_activation_scope, 88 EXPECT_EQ(test_case.expected_activation_scope,
89 actual_configuration.activation_scope); 89 actual_configuration.activation_scope);
90 } 90 }
91 } 91 }
92 92
93 TEST(SubresourceFilterFeaturesTest, ActivationLevelAndScope) { 93 TEST(SubresourceFilterFeaturesTest, ActivationLevelAndScope) {
94 const struct { 94 const struct {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 {false, kActivationLevelEnabled, ActivationLevel::DISABLED, 127 {false, kActivationLevelEnabled, ActivationLevel::DISABLED,
128 kActivationScopeAllSites, ActivationScope::NO_SITES}}; 128 kActivationScopeAllSites, ActivationScope::NO_SITES}};
129 129
130 for (const auto& test_case : kTestCases) { 130 for (const auto& test_case : kTestCases) {
131 base::FieldTrialList field_trial_list(nullptr /* entropy_provider */); 131 base::FieldTrialList field_trial_list(nullptr /* entropy_provider */);
132 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( 132 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle(
133 test_case.feature_enabled ? base::FeatureList::OVERRIDE_ENABLE_FEATURE 133 test_case.feature_enabled ? base::FeatureList::OVERRIDE_ENABLE_FEATURE
134 : base::FeatureList::OVERRIDE_USE_DEFAULT, 134 : base::FeatureList::OVERRIDE_USE_DEFAULT,
135 test_case.activation_level_param, test_case.activation_scope_param); 135 test_case.activation_level_param, test_case.activation_scope_param);
136 136
137 auto active_configurations = GetActiveConfigurations(); 137 const auto active_configurations = GetActiveConfigurations();
138 const Configuration& actual_configuration = 138 const Configuration& actual_configuration =
139 active_configurations->the_one_and_only(); 139 active_configurations->the_one_and_only();
140 EXPECT_EQ(test_case.expected_activation_level, 140 EXPECT_EQ(test_case.expected_activation_level,
141 actual_configuration.activation_level); 141 actual_configuration.activation_level);
142 EXPECT_EQ(test_case.expected_activation_scope, 142 EXPECT_EQ(test_case.expected_activation_scope,
143 actual_configuration.activation_scope); 143 actual_configuration.activation_scope);
144 } 144 }
145 } 145 }
146 146
147 TEST(SubresourceFilterFeaturesTest, ActivationList) { 147 TEST(SubresourceFilterFeaturesTest, ActivationList) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 SCOPED_TRACE(::testing::Message("ActivationListParam = \"") 185 SCOPED_TRACE(::testing::Message("ActivationListParam = \"")
186 << test_case.activation_list_param << "\""); 186 << test_case.activation_list_param << "\"");
187 187
188 base::FieldTrialList field_trial_list(nullptr /* entropy_provider */); 188 base::FieldTrialList field_trial_list(nullptr /* entropy_provider */);
189 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( 189 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle(
190 test_case.feature_enabled ? base::FeatureList::OVERRIDE_ENABLE_FEATURE 190 test_case.feature_enabled ? base::FeatureList::OVERRIDE_ENABLE_FEATURE
191 : base::FeatureList::OVERRIDE_USE_DEFAULT, 191 : base::FeatureList::OVERRIDE_USE_DEFAULT,
192 kActivationLevelDisabled, kActivationScopeNoSites, 192 kActivationLevelDisabled, kActivationScopeNoSites,
193 test_case.activation_list_param); 193 test_case.activation_list_param);
194 194
195 auto active_configurations = GetActiveConfigurations(); 195 const auto active_configurations = GetActiveConfigurations();
196 const Configuration& actual_configuration = 196 const Configuration& actual_configuration =
197 active_configurations->the_one_and_only(); 197 active_configurations->the_one_and_only();
198 EXPECT_EQ(test_case.expected_activation_list, 198 EXPECT_EQ(test_case.expected_activation_list,
199 actual_configuration.activation_list); 199 actual_configuration.activation_list);
200 } 200 }
201 } 201 }
202 202
203 TEST(SubresourceFilterFeaturesTest, PerfMeasurementRate) { 203 TEST(SubresourceFilterFeaturesTest, PerfMeasurementRate) {
204 const struct { 204 const struct {
205 bool feature_enabled; 205 bool feature_enabled;
(...skipping 18 matching lines...) Expand all
224 SCOPED_TRACE(::testing::Message("PerfMeasurementParam = \"") 224 SCOPED_TRACE(::testing::Message("PerfMeasurementParam = \"")
225 << test_case.perf_measurement_param << "\""); 225 << test_case.perf_measurement_param << "\"");
226 226
227 base::FieldTrialList field_trial_list(nullptr /* entropy_provider */); 227 base::FieldTrialList field_trial_list(nullptr /* entropy_provider */);
228 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( 228 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle(
229 test_case.feature_enabled ? base::FeatureList::OVERRIDE_ENABLE_FEATURE 229 test_case.feature_enabled ? base::FeatureList::OVERRIDE_ENABLE_FEATURE
230 : base::FeatureList::OVERRIDE_USE_DEFAULT, 230 : base::FeatureList::OVERRIDE_USE_DEFAULT,
231 {{kPerformanceMeasurementRateParameterName, 231 {{kPerformanceMeasurementRateParameterName,
232 test_case.perf_measurement_param}}); 232 test_case.perf_measurement_param}});
233 233
234 auto active_configurations = GetActiveConfigurations(); 234 const auto active_configurations = GetActiveConfigurations();
235 const Configuration& actual_configuration = 235 const Configuration& actual_configuration =
236 active_configurations->the_one_and_only(); 236 active_configurations->the_one_and_only();
237 EXPECT_EQ(test_case.expected_perf_measurement_rate, 237 EXPECT_EQ(test_case.expected_perf_measurement_rate,
238 actual_configuration.performance_measurement_rate); 238 actual_configuration.performance_measurement_rate);
239 } 239 }
240 } 240 }
241 241
242 TEST(SubresourceFilterFeaturesTest, SuppressNotifications) { 242 TEST(SubresourceFilterFeaturesTest, SuppressNotifications) {
243 const struct { 243 const struct {
244 bool feature_enabled; 244 bool feature_enabled;
(...skipping 15 matching lines...) Expand all
260 SCOPED_TRACE(::testing::Message("SuppressNotificationsParam = \"") 260 SCOPED_TRACE(::testing::Message("SuppressNotificationsParam = \"")
261 << test_case.suppress_notifications_param << "\""); 261 << test_case.suppress_notifications_param << "\"");
262 262
263 base::FieldTrialList field_trial_list(nullptr /* entropy_provider */); 263 base::FieldTrialList field_trial_list(nullptr /* entropy_provider */);
264 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( 264 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle(
265 test_case.feature_enabled ? base::FeatureList::OVERRIDE_ENABLE_FEATURE 265 test_case.feature_enabled ? base::FeatureList::OVERRIDE_ENABLE_FEATURE
266 : base::FeatureList::OVERRIDE_USE_DEFAULT, 266 : base::FeatureList::OVERRIDE_USE_DEFAULT,
267 {{kSuppressNotificationsParameterName, 267 {{kSuppressNotificationsParameterName,
268 test_case.suppress_notifications_param}}); 268 test_case.suppress_notifications_param}});
269 269
270 auto active_configurations = GetActiveConfigurations(); 270 const auto active_configurations = GetActiveConfigurations();
271 const Configuration& actual_configuration = 271 const Configuration& actual_configuration =
272 active_configurations->the_one_and_only(); 272 active_configurations->the_one_and_only();
273 EXPECT_EQ(test_case.expected_suppress_notifications_value, 273 EXPECT_EQ(test_case.expected_suppress_notifications_value,
274 actual_configuration.should_suppress_notifications); 274 actual_configuration.should_suppress_notifications);
275 } 275 }
276 } 276 }
277 277
278 TEST(SubresourceFilterFeaturesTest, WhitelistSiteOnReload) { 278 TEST(SubresourceFilterFeaturesTest, WhitelistSiteOnReload) {
279 const struct { 279 const struct {
280 bool feature_enabled; 280 bool feature_enabled;
(...skipping 15 matching lines...) Expand all
296 SCOPED_TRACE(::testing::Message("WhitelistSiteOnReloadParam = \"") 296 SCOPED_TRACE(::testing::Message("WhitelistSiteOnReloadParam = \"")
297 << test_case.whitelist_site_on_reload_param << "\""); 297 << test_case.whitelist_site_on_reload_param << "\"");
298 298
299 base::FieldTrialList field_trial_list(nullptr /* entropy_provider */); 299 base::FieldTrialList field_trial_list(nullptr /* entropy_provider */);
300 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( 300 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle(
301 test_case.feature_enabled ? base::FeatureList::OVERRIDE_ENABLE_FEATURE 301 test_case.feature_enabled ? base::FeatureList::OVERRIDE_ENABLE_FEATURE
302 : base::FeatureList::OVERRIDE_USE_DEFAULT, 302 : base::FeatureList::OVERRIDE_USE_DEFAULT,
303 {{kWhitelistSiteOnReloadParameterName, 303 {{kWhitelistSiteOnReloadParameterName,
304 test_case.whitelist_site_on_reload_param}}); 304 test_case.whitelist_site_on_reload_param}});
305 305
306 auto active_configurations = GetActiveConfigurations(); 306 const auto active_configurations = GetActiveConfigurations();
307 const Configuration& actual_configuration = 307 const Configuration& actual_configuration =
308 active_configurations->the_one_and_only(); 308 active_configurations->the_one_and_only();
309 EXPECT_EQ(test_case.expected_whitelist_site_on_reload_value, 309 EXPECT_EQ(test_case.expected_whitelist_site_on_reload_value,
310 actual_configuration.should_whitelist_site_on_reload); 310 actual_configuration.should_whitelist_site_on_reload);
311 } 311 }
312 } 312 }
313 313
314 } // namespace subresource_filter 314 } // namespace subresource_filter
OLDNEW
« no previous file with comments | « components/subresource_filter/core/browser/subresource_filter_features.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698