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

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

Issue 2665473002: Add support for custom subresource filter InstallerAttributes. (Closed)
Patch Set: address comments Created 3 years, 10 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: 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 7b345b23e01077066e75791963dd3693332acb15..c4640f7cba4a2e1d5dabf898a7cd9fd0a501fdf0 100644
--- a/chrome/browser/component_updater/subresource_filter_component_installer_unittest.cc
+++ b/chrome/browser/component_updater/subresource_filter_component_installer_unittest.cc
@@ -154,6 +154,21 @@ class SubresourceFilterComponentInstallerTest : public PlatformTest {
base::RunLoop().RunUntilIdle();
}
+ update_client::InstallerAttributes GetInstallerAttributes() {
+ return traits_->GetInstallerAttributes();
+ }
+
+ 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}});
+ EXPECT_EQ(expected_tag,
+ SubresourceFilterComponentInstallerTraits::GetInstallerTag());
+ }
+
private:
content::TestBrowserThreadBundle thread_bundle_;
base::ScopedTempDir component_install_dir_;
@@ -238,4 +253,47 @@ TEST_F(SubresourceFilterComponentInstallerTest, LoadFileWithData) {
EXPECT_EQ(expected_license_contents, actual_license_contents);
}
+TEST_F(SubresourceFilterComponentInstallerTest, InstallerTag) {
+ ExpectInstallerTag("", "");
+ ExpectInstallerTag("a", "a");
+ ExpectInstallerTag("b", "b");
+ ExpectInstallerTag("c", "c");
+ ExpectInstallerTag("d", "d");
+ ExpectInstallerTag("invalid", "e");
+ ExpectInstallerTag("invalid", "foo");
+}
+
+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>());
+ EXPECT_EQ(update_client::InstallerAttributes(), GetInstallerAttributes());
+}
+
+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}});
+ 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

Powered by Google App Engine
This is Rietveld 408576698