| OLD | NEW |
| 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
_test_support.h" | 5 #include "components/subresource_filter/core/browser/subresource_filter_features
_test_support.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| 11 #include "base/metrics/field_trial_params.h" |
| 11 #include "components/subresource_filter/core/browser/subresource_filter_features
.h" | 12 #include "components/subresource_filter/core/browser/subresource_filter_features
.h" |
| 12 #include "components/variations/variations_associated_data.h" | 13 #include "components/variations/variations_associated_data.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 15 |
| 15 namespace subresource_filter { | 16 namespace subresource_filter { |
| 16 namespace testing { | 17 namespace testing { |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 constexpr const char kTestFieldTrialName[] = "FieldTrialNameShouldNotMatter"; | 20 constexpr const char kTestFieldTrialName[] = "FieldTrialNameShouldNotMatter"; |
| 20 constexpr const char kTestExperimentGroupName[] = "GroupNameShouldNotMatter"; | 21 constexpr const char kTestExperimentGroupName[] = "GroupNameShouldNotMatter"; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 34 {kActivationScopeParameterName, activation_scope}, | 35 {kActivationScopeParameterName, activation_scope}, |
| 35 {kActivationListsParameterName, activation_lists}, | 36 {kActivationListsParameterName, activation_lists}, |
| 36 {kPerformanceMeasurementRateParameterName, | 37 {kPerformanceMeasurementRateParameterName, |
| 37 performance_measurement_rate}, | 38 performance_measurement_rate}, |
| 38 {kSuppressNotificationsParameterName, suppress_notifications}, | 39 {kSuppressNotificationsParameterName, suppress_notifications}, |
| 39 {kWhitelistSiteOnReloadParameterName, whitelist_site_on_reload}}) {} | 40 {kWhitelistSiteOnReloadParameterName, whitelist_site_on_reload}}) {} |
| 40 | 41 |
| 41 ScopedSubresourceFilterFeatureToggle::ScopedSubresourceFilterFeatureToggle( | 42 ScopedSubresourceFilterFeatureToggle::ScopedSubresourceFilterFeatureToggle( |
| 42 base::FeatureList::OverrideState feature_state, | 43 base::FeatureList::OverrideState feature_state, |
| 43 std::map<std::string, std::string> variation_params) { | 44 std::map<std::string, std::string> variation_params) { |
| 44 EXPECT_TRUE(variations::AssociateVariationParams( | 45 EXPECT_TRUE(base::AssociateFieldTrialParams( |
| 45 kTestFieldTrialName, kTestExperimentGroupName, variation_params)); | 46 kTestFieldTrialName, kTestExperimentGroupName, variation_params)); |
| 46 | 47 |
| 47 base::FieldTrial* field_trial = base::FieldTrialList::CreateFieldTrial( | 48 base::FieldTrial* field_trial = base::FieldTrialList::CreateFieldTrial( |
| 48 kTestFieldTrialName, kTestExperimentGroupName); | 49 kTestFieldTrialName, kTestExperimentGroupName); |
| 49 | 50 |
| 50 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); | 51 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); |
| 51 feature_list->RegisterFieldTrialOverride(kSafeBrowsingSubresourceFilter.name, | 52 feature_list->RegisterFieldTrialOverride(kSafeBrowsingSubresourceFilter.name, |
| 52 feature_state, field_trial); | 53 feature_state, field_trial); |
| 53 | 54 |
| 54 // Since we are adding a scoped feature list after browser start, copy over | 55 // Since we are adding a scoped feature list after browser start, copy over |
| (...skipping 10 matching lines...) Expand all Loading... |
| 65 | 66 |
| 66 scoped_feature_list_.InitWithFeatureList(std::move(feature_list)); | 67 scoped_feature_list_.InitWithFeatureList(std::move(feature_list)); |
| 67 } | 68 } |
| 68 | 69 |
| 69 ScopedSubresourceFilterFeatureToggle::~ScopedSubresourceFilterFeatureToggle() { | 70 ScopedSubresourceFilterFeatureToggle::~ScopedSubresourceFilterFeatureToggle() { |
| 70 variations::testing::ClearAllVariationParams(); | 71 variations::testing::ClearAllVariationParams(); |
| 71 } | 72 } |
| 72 | 73 |
| 73 } // namespace testing | 74 } // namespace testing |
| 74 } // namespace subresource_filter | 75 } // namespace subresource_filter |
| OLD | NEW |