OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/subresource_filter/core/browser/subresource_filter_features
.h" |
| 6 |
| 7 #include <string> |
| 8 |
| 9 #include "base/metrics/field_trial.h" |
| 10 #include "components/subresource_filter/core/browser/subresource_filter_features
_test_support.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 |
| 13 namespace subresource_filter { |
| 14 |
| 15 TEST(SubresourceFilterFeaturesTest, ActivationState) { |
| 16 const struct { |
| 17 bool feature_enabled; |
| 18 const char* activation_state_param; |
| 19 ActivationState expected_activation_state; |
| 20 } kTestCases[] = {{false, "", ActivationState::DISABLED}, |
| 21 {false, "disabled", ActivationState::DISABLED}, |
| 22 {false, "dryrun", ActivationState::DISABLED}, |
| 23 {false, "enabled", ActivationState::DISABLED}, |
| 24 {false, "%$ garbage !%", ActivationState::DISABLED}, |
| 25 {true, "", ActivationState::DISABLED}, |
| 26 {true, "disable", ActivationState::DISABLED}, |
| 27 {true, "Disable", ActivationState::DISABLED}, |
| 28 {true, "disabled", ActivationState::DISABLED}, |
| 29 {true, "%$ garbage !%", ActivationState::DISABLED}, |
| 30 {true, kActivationStateDryRun, ActivationState::DRYRUN}, |
| 31 {true, kActivationStateEnabled, ActivationState::ENABLED}, |
| 32 {true, "Enabled", ActivationState::ENABLED}}; |
| 33 |
| 34 for (const auto& test_case : kTestCases) { |
| 35 SCOPED_TRACE(::testing::Message("Enabled = ") << test_case.feature_enabled); |
| 36 SCOPED_TRACE(::testing::Message("ActivationStateParam = \"") |
| 37 << test_case.activation_state_param << "\""); |
| 38 |
| 39 base::FieldTrialList field_trial_list(nullptr /* entropy_provider */); |
| 40 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( |
| 41 test_case.feature_enabled ? base::FeatureList::OVERRIDE_ENABLE_FEATURE |
| 42 : base::FeatureList::OVERRIDE_USE_DEFAULT, |
| 43 test_case.activation_state_param); |
| 44 |
| 45 EXPECT_EQ(test_case.expected_activation_state, GetMaximumActivationState()); |
| 46 } |
| 47 } |
| 48 |
| 49 } // namespace subresource_filter |
OLD | NEW |