Commit 8d9af57e authored by Fabio Tirelo's avatar Fabio Tirelo Committed by Commit Bot

Init ScopedFeatureList with feature enabled status

The goal is to offer a shortcut for cases when tests may either
enable or disable a feature based on a condition.

Examples that could be simplified if such method exists:
 - https://cs.chromium.org/chromium/src/components/autofill/core/browser/form_structure_unittest.cc?l=50
 - https://cs.chromium.org/chromium/src/ui/app_list/views/search_result_page_view_unittest.cc?l=62

Change-Id: I408cae760aa6a031770498202eb817e3bbd63a6b
Reviewed-on: https://chromium-review.googlesource.com/1005421Reviewed-by: default avatarRobert Kaplow <rkaplow@chromium.org>
Commit-Queue: Fabio Tirelo <ftirelo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549704}
parent d2e18617
...@@ -136,6 +136,15 @@ void ScopedFeatureList::InitAndDisableFeature(const Feature& feature) { ...@@ -136,6 +136,15 @@ void ScopedFeatureList::InitAndDisableFeature(const Feature& feature) {
InitWithFeaturesAndFieldTrials({}, {}, {feature}); InitWithFeaturesAndFieldTrials({}, {}, {feature});
} }
void ScopedFeatureList::InitWithFeatureState(const Feature& feature,
bool enabled) {
if (enabled) {
InitAndEnableFeature(feature);
} else {
InitAndDisableFeature(feature);
}
}
void ScopedFeatureList::InitWithFeaturesAndFieldTrials( void ScopedFeatureList::InitWithFeaturesAndFieldTrials(
const std::vector<Feature>& enabled_features, const std::vector<Feature>& enabled_features,
const std::vector<FieldTrial*>& trials_for_enabled_features, const std::vector<FieldTrial*>& trials_for_enabled_features,
......
...@@ -83,6 +83,11 @@ class ScopedFeatureList final { ...@@ -83,6 +83,11 @@ class ScopedFeatureList final {
// FeatureList and overridden with single disabled feature. // FeatureList and overridden with single disabled feature.
void InitAndDisableFeature(const Feature& feature); void InitAndDisableFeature(const Feature& feature);
// Initializes and registers a FeatureList instance based on present
// FeatureList and overriden with a single feature either enabled or
// disabled depending on |enabled|.
void InitWithFeatureState(const Feature& feature, bool enabled);
private: private:
// Initializes and registers a FeatureList instance based on present // Initializes and registers a FeatureList instance based on present
// FeatureList and overridden with the given enabled and disabled features. // FeatureList and overridden with the given enabled and disabled features.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment