Skip to content

Commit

Permalink
Use helper macros to define base::Features in //components/variations
Browse files Browse the repository at this point in the history
This allows:
- features to be defined with a consistent set of qualifiers, and for
  that set of qualifiers to be updated over time as appropriate.
- better PRESUBMIT checks to ensure that base::Features are not defined
  in headers.
- simplifies things for scripts trying to extract feature definitions
  out of C++ code.

The primary CL was generated using a script that automatically rewrites
base::Feature declarations and definitions to the macro form. Changes to
any files with known incompatibilities with the macros (base::Features
without static storage duration and base::Features declared as static
class members) were then fully reverted; those changes will be manually
handled in followups.

This is an automated cleanup pass with manual fixups to add additional
static specifiers where needed.

Bug: 1364289
Change-Id: Ib5c625ec8150f115cc819819ecb478a20b12d7af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3931194
Reviewed-by: Lei Zhang <thestig@chromium.org>
Auto-Submit: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Owners-Override: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1053881}
  • Loading branch information
zetafunction authored and Chromium LUCI CQ committed Oct 1, 2022
1 parent 08e2ab0 commit b30977a
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions components/variations/variations_seed_processor_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -500,15 +500,12 @@ TYPED_TEST(VariationsSeedProcessorTest, ForcingFlagAlreadyForced) {
}

TYPED_TEST(VariationsSeedProcessorTest, FeatureEnabledOrDisableByTrial) {
struct base::Feature kFeatureOffByDefault {
"kOff", base::FEATURE_DISABLED_BY_DEFAULT
};
struct base::Feature kFeatureOnByDefault {
"kOn", base::FEATURE_ENABLED_BY_DEFAULT
};
struct base::Feature kUnrelatedFeature {
"kUnrelated", base::FEATURE_DISABLED_BY_DEFAULT
};
static BASE_FEATURE(kFeatureOffByDefault, "kOff",
base::FEATURE_DISABLED_BY_DEFAULT);
static BASE_FEATURE(kFeatureOnByDefault, "kOn",
base::FEATURE_ENABLED_BY_DEFAULT);
static BASE_FEATURE(kUnrelatedFeature, "kUnrelated",
base::FEATURE_DISABLED_BY_DEFAULT);

struct {
const char* enable_feature;
Expand Down Expand Up @@ -571,12 +568,10 @@ TYPED_TEST(VariationsSeedProcessorTest, FeatureEnabledOrDisableByTrial) {
}

TYPED_TEST(VariationsSeedProcessorTest, FeatureAssociationAndForcing) {
struct base::Feature kFeatureOffByDefault {
"kFeatureOffByDefault", base::FEATURE_DISABLED_BY_DEFAULT
};
struct base::Feature kFeatureOnByDefault {
"kFeatureOnByDefault", base::FEATURE_ENABLED_BY_DEFAULT
};
static BASE_FEATURE(kFeatureOffByDefault, "kFeatureOffByDefault",
base::FEATURE_DISABLED_BY_DEFAULT);
static BASE_FEATURE(kFeatureOnByDefault, "kFeatureOnByDefault",
base::FEATURE_ENABLED_BY_DEFAULT);

enum OneHundredPercentGroup {
DEFAULT_GROUP,
Expand Down Expand Up @@ -1183,9 +1178,8 @@ TYPED_TEST(VariationsSeedProcessorTest, StudyWithLowerEntropyThanLayer) {
}

TYPED_TEST(VariationsSeedProcessorTest, StudiesWithOverlappingEnabledFeatures) {
static struct base::Feature kFeature {
"FeatureName", base::FEATURE_ENABLED_BY_DEFAULT
};
static BASE_FEATURE(kFeature, "FeatureName",
base::FEATURE_ENABLED_BY_DEFAULT);

VariationsSeed seed;

Expand Down Expand Up @@ -1225,9 +1219,8 @@ TYPED_TEST(VariationsSeedProcessorTest, StudiesWithOverlappingEnabledFeatures) {

TYPED_TEST(VariationsSeedProcessorTest,
StudiesWithOverlappingDisabledFeatures) {
static struct base::Feature kFeature {
"FeatureName", base::FEATURE_ENABLED_BY_DEFAULT
};
static BASE_FEATURE(kFeature, "FeatureName",
base::FEATURE_ENABLED_BY_DEFAULT);

VariationsSeed seed;

Expand Down

0 comments on commit b30977a

Please sign in to comment.