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

Unified Diff: components/subresource_filter/core/browser/subresource_filter_features_unittest.cc

Issue 2186233003: Introduce activation scope logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: one feature Created 4 years, 4 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: components/subresource_filter/core/browser/subresource_filter_features_unittest.cc
diff --git a/components/subresource_filter/core/browser/subresource_filter_features_unittest.cc b/components/subresource_filter/core/browser/subresource_filter_features_unittest.cc
index 78637e42047a3af0c9605900f6b778bd043d1486..06351c53d4e7df7ec507498a961bcd8d15b87be9 100644
--- a/components/subresource_filter/core/browser/subresource_filter_features_unittest.cc
+++ b/components/subresource_filter/core/browser/subresource_filter_features_unittest.cc
@@ -40,9 +40,93 @@ TEST(SubresourceFilterFeaturesTest, ActivationState) {
testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle(
test_case.feature_enabled ? base::FeatureList::OVERRIDE_ENABLE_FEATURE
: base::FeatureList::OVERRIDE_USE_DEFAULT,
- test_case.activation_state_param);
+ test_case.activation_state_param, kActivationScopeDisabled);
EXPECT_EQ(test_case.expected_activation_state, GetMaximumActivationState());
+ EXPECT_EQ(ActivationScope::DISABLED, GetCurrentActivationScope());
+ }
+}
+
+TEST(SubresourceFilterFeaturesTest, ActivationScope) {
+ const struct {
+ bool feature_enabled;
+ const char* activation_scope_param;
+ ActivationScope expected_activation_scope;
+ } kTestCases[] = {
+ {false, "", ActivationScope::DISABLED},
+ {false, "disabled", ActivationScope::DISABLED},
+ {false, "allsites", ActivationScope::DISABLED},
+ {false, "enabled", ActivationScope::DISABLED},
+ {false, "%$ garbage !%", ActivationScope::DISABLED},
+ {true, "", ActivationScope::DISABLED},
+ {true, "disable", ActivationScope::DISABLED},
+ {true, "Disable", ActivationScope::DISABLED},
+ {true, "disabled", ActivationScope::DISABLED},
+ {true, "%$ garbage !%", ActivationScope::DISABLED},
+ {true, kActivationScopeAllSites, ActivationScope::ALL_SITES},
+ {true, kActivationScopeActivationList, ActivationScope::ACTIVATION_LIST}};
+
+ for (const auto& test_case : kTestCases) {
+ SCOPED_TRACE(::testing::Message("Enabled = ") << test_case.feature_enabled);
+ SCOPED_TRACE(::testing::Message("ActivationScopeParam = \"")
+ << test_case.activation_scope_param << "\"");
+
+ base::FieldTrialList field_trial_list(nullptr /* entropy_provider */);
+ testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle(
+ test_case.feature_enabled ? base::FeatureList::OVERRIDE_ENABLE_FEATURE
+ : base::FeatureList::OVERRIDE_USE_DEFAULT,
+ kActivationScopeDisabled, test_case.activation_scope_param);
+
+ EXPECT_EQ(ActivationState::DISABLED, GetMaximumActivationState());
+ EXPECT_EQ(test_case.expected_activation_scope, GetCurrentActivationScope());
+ }
+}
+
+TEST(SubresourceFilterFeaturesTest, ActivationAStateAndScope) {
+ const struct {
+ bool feature_enabled;
+ const char* activation_state_param;
+ ActivationState expected_activation_state;
+ const char* activation_scope_param;
+ ActivationScope expected_activation_scope;
+ } kTestCases[] = {
+ {false, kActivationStateDisabled, ActivationState::DISABLED,
+ kActivationScopeDisabled, ActivationScope::DISABLED},
+ {true, kActivationStateDisabled, ActivationState::DISABLED,
+ kActivationScopeDisabled, ActivationScope::DISABLED},
+ {true, kActivationStateDisabled, ActivationState::DISABLED,
+ kActivationScopeAllSites, ActivationScope::ALL_SITES},
+ {true, kActivationStateDisabled, ActivationState::DISABLED,
+ kActivationScopeActivationList, ActivationScope::ACTIVATION_LIST},
+ {true, kActivationStateDisabled, ActivationState::DISABLED,
+ kActivationScopeAllSites, ActivationScope::ALL_SITES},
+ {true, kActivationStateDryRun, ActivationState::DRYRUN,
+ kActivationScopeDisabled, ActivationScope::DISABLED},
+ {true, kActivationStateDryRun, ActivationState::DRYRUN,
+ kActivationScopeAllSites, ActivationScope::ALL_SITES},
+ {true, kActivationStateDryRun, ActivationState::DRYRUN,
+ kActivationScopeActivationList, ActivationScope::ACTIVATION_LIST},
+ {true, kActivationStateDryRun, ActivationState::DRYRUN,
+ kActivationScopeAllSites, ActivationScope::ALL_SITES},
+ {true, kActivationStateEnabled, ActivationState::ENABLED,
+ kActivationScopeDisabled, ActivationScope::DISABLED},
+ {true, kActivationStateEnabled, ActivationState::ENABLED,
+ kActivationScopeAllSites, ActivationScope::ALL_SITES},
+ {true, kActivationStateEnabled, ActivationState::ENABLED,
+ kActivationScopeActivationList, ActivationScope::ACTIVATION_LIST},
+ {true, kActivationStateEnabled, ActivationState::ENABLED,
+ kActivationScopeAllSites, ActivationScope::ALL_SITES},
+ };
+
+ for (const auto& test_case : kTestCases) {
+ base::FieldTrialList field_trial_list(nullptr /* entropy_provider */);
+ testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle(
+ test_case.feature_enabled ? base::FeatureList::OVERRIDE_ENABLE_FEATURE
+ : base::FeatureList::OVERRIDE_USE_DEFAULT,
+ test_case.activation_state_param, test_case.activation_scope_param);
+
+ EXPECT_EQ(test_case.expected_activation_scope, GetCurrentActivationScope());
+ EXPECT_EQ(test_case.expected_activation_state, GetMaximumActivationState());
}
}

Powered by Google App Engine
This is Rietveld 408576698