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

Unified Diff: chrome/browser/component_updater/subresource_filter_component_installer_unittest.cc

Issue 2838193002: Split the ScopedSubresourceFilterFeatureToggle into two helper classes. (Closed)
Patch Set: Rebase. Created 3 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/component_updater/subresource_filter_component_installer_unittest.cc
diff --git a/chrome/browser/component_updater/subresource_filter_component_installer_unittest.cc b/chrome/browser/component_updater/subresource_filter_component_installer_unittest.cc
index 9c9dae1d278040a221a96cd4ef24a25ad7a7db4f..906be57b166cda0039a08700518926596742b3a0 100644
--- a/chrome/browser/component_updater/subresource_filter_component_installer_unittest.cc
+++ b/chrome/browser/component_updater/subresource_filter_component_installer_unittest.cc
@@ -85,6 +85,13 @@ class SubresourceFilterMockComponentUpdateService
DISALLOW_COPY_AND_ASSIGN(SubresourceFilterMockComponentUpdateService);
};
+subresource_filter::Configuration CreateConfigUsingRulesetFlavor(
+ const char* ruleset_flavor) {
+ subresource_filter::Configuration config;
+ config.ruleset_flavor = ruleset_flavor;
+ return config;
+}
+
} // namespace
namespace component_updater {
@@ -166,11 +173,8 @@ class SubresourceFilterComponentInstallerTest : public PlatformTest {
void ExpectInstallerTag(const char* expected_tag,
const char* ruleset_flavor) {
- base::FieldTrialList field_trial_list(nullptr /* entropy_provider */);
- subresource_filter::testing::ScopedSubresourceFilterFeatureToggle
- scoped_feature_toggle(base::FeatureList::OVERRIDE_ENABLE_FEATURE,
- {{subresource_filter::kRulesetFlavorParameterName,
- ruleset_flavor}});
+ subresource_filter::testing::ScopedSubresourceFilterConfigurator
+ scoped_configuration(CreateConfigUsingRulesetFlavor(ruleset_flavor));
EXPECT_EQ(expected_tag,
SubresourceFilterComponentInstallerTraits::GetInstallerTag());
}
@@ -190,11 +194,8 @@ class SubresourceFilterComponentInstallerTest : public PlatformTest {
TEST_F(SubresourceFilterComponentInstallerTest,
TestComponentRegistrationWhenFeatureDisabled) {
- base::FieldTrialList field_trial_list(nullptr);
subresource_filter::testing::ScopedSubresourceFilterFeatureToggle
- scoped_feature_toggle(base::FeatureList::OVERRIDE_DISABLE_FEATURE,
- subresource_filter::kActivationLevelEnabled,
- subresource_filter::kActivationScopeNoSites);
+ scoped_feature(base::FeatureList::OVERRIDE_DISABLE_FEATURE);
std::unique_ptr<SubresourceFilterMockComponentUpdateService>
component_updater(new SubresourceFilterMockComponentUpdateService());
EXPECT_CALL(*component_updater, RegisterComponent(testing::_)).Times(0);
@@ -204,11 +205,8 @@ TEST_F(SubresourceFilterComponentInstallerTest,
TEST_F(SubresourceFilterComponentInstallerTest,
TestComponentRegistrationWhenFeatureEnabled) {
- base::FieldTrialList field_trial_list(nullptr);
subresource_filter::testing::ScopedSubresourceFilterFeatureToggle
- scoped_feature_toggle(base::FeatureList::OVERRIDE_ENABLE_FEATURE,
- subresource_filter::kActivationLevelDisabled,
- subresource_filter::kActivationScopeNoSites);
+ scoped_feature(base::FeatureList::OVERRIDE_ENABLE_FEATURE);
std::unique_ptr<SubresourceFilterMockComponentUpdateService>
component_updater(new SubresourceFilterMockComponentUpdateService());
EXPECT_CALL(*component_updater, RegisterComponent(testing::_))
@@ -274,10 +272,8 @@ TEST_F(SubresourceFilterComponentInstallerTest, InstallerTag) {
}
TEST_F(SubresourceFilterComponentInstallerTest, InstallerAttributesDefault) {
- base::FieldTrialList field_trial_list(nullptr /* entropy_provider */);
- subresource_filter::testing::ScopedSubresourceFilterFeatureToggle
- scoped_feature_toggle(base::FeatureList::OVERRIDE_ENABLE_FEATURE,
- std::map<std::string, std::string>());
+ subresource_filter::testing::ScopedSubresourceFilterConfigurator
+ scoped_configuration((subresource_filter::Configuration()));
EXPECT_EQ(update_client::InstallerAttributes(), GetInstallerAttributes());
}
@@ -285,25 +281,10 @@ TEST_F(SubresourceFilterComponentInstallerTest, InstallerAttributesCustomTag) {
constexpr char kTagKey[] = "tag";
constexpr char kTagValue[] = "a";
- base::FieldTrialList field_trial_list(nullptr /* entropy_provider */);
- subresource_filter::testing::ScopedSubresourceFilterFeatureToggle
- scoped_feature_toggle(
- base::FeatureList::OVERRIDE_ENABLE_FEATURE,
- {{subresource_filter::kRulesetFlavorParameterName, kTagValue}});
+ subresource_filter::testing::ScopedSubresourceFilterConfigurator
+ scoped_configuration(CreateConfigUsingRulesetFlavor(kTagValue));
EXPECT_EQ(update_client::InstallerAttributes({{kTagKey, kTagValue}}),
GetInstallerAttributes());
}
-TEST_F(SubresourceFilterComponentInstallerTest,
- InstallerAttributesFeatureDisabled) {
- constexpr char kTagValue[] = "test_value";
-
- base::FieldTrialList field_trial_list(nullptr /* entropy_provider */);
- subresource_filter::testing::ScopedSubresourceFilterFeatureToggle
- scoped_feature_toggle(
- base::FeatureList::OVERRIDE_USE_DEFAULT,
- {{subresource_filter::kRulesetFlavorParameterName, kTagValue}});
- EXPECT_EQ(update_client::InstallerAttributes(), GetInstallerAttributes());
-}
-
} // namespace component_updater
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698