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

Unified Diff: components/variations/variations_seed_processor_unittest.cc

Issue 2226063002: Add a ScopedFeatureList class for testing and start using it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix issue in previous patchset. Created 4 years, 4 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 | « components/variations/variations_associated_data_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/variations/variations_seed_processor_unittest.cc
diff --git a/components/variations/variations_seed_processor_unittest.cc b/components/variations/variations_seed_processor_unittest.cc
index 1ab8a497a38411046a4c3090e804444be1d9606b..d1e9967a2e18767b6954923593a4ad4724ad7499 100644
--- a/components/variations/variations_seed_processor_unittest.cc
+++ b/components/variations/variations_seed_processor_unittest.cc
@@ -21,6 +21,7 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/mock_entropy_provider.h"
+#include "base/test/scoped_feature_list.h"
#include "components/variations/processed_study.h"
#include "components/variations/study_filtering.h"
#include "components/variations/variations_associated_data.h"
@@ -117,8 +118,6 @@ class VariationsSeedProcessorTest : public ::testing::Test {
// process singletons.
testing::ClearAllVariationIDs();
testing::ClearAllVariationParams();
-
- base::FeatureList::ClearInstanceForTesting();
}
bool CreateTrialFromStudy(const Study& study) {
@@ -621,7 +620,6 @@ TEST_F(VariationsSeedProcessorTest, FeatureEnabledOrDisableByTrial) {
SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]", i));
base::FieldTrialList field_trial_list(nullptr);
- base::FeatureList::ClearInstanceForTesting();
std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
Study study;
@@ -638,7 +636,8 @@ TEST_F(VariationsSeedProcessorTest, FeatureEnabledOrDisableByTrial) {
association->add_disable_feature(test_case.disable_feature);
EXPECT_TRUE(CreateTrialFromStudyWithFeatureList(study, feature_list.get()));
- base::FeatureList::SetInstance(std::move(feature_list));
+ base::test::ScopedFeatureList scoped_feature_list;
+ scoped_feature_list.InitWithFeatureList(std::move(feature_list));
// |kUnrelatedFeature| should not be affected.
EXPECT_FALSE(base::FeatureList::IsEnabled(kUnrelatedFeature));
@@ -744,7 +743,6 @@ TEST_F(VariationsSeedProcessorTest, FeatureAssociationAndForcing) {
test_case.disable_features_command_line, static_cast<int>(group)));
base::FieldTrialList field_trial_list(nullptr);
- base::FeatureList::ClearInstanceForTesting();
std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
feature_list->InitializeFromCommandLine(
test_case.enable_features_command_line,
@@ -773,7 +771,8 @@ TEST_F(VariationsSeedProcessorTest, FeatureAssociationAndForcing) {
->set_forcing_feature_off(test_case.feature.name);
EXPECT_TRUE(CreateTrialFromStudyWithFeatureList(study, feature_list.get()));
- base::FeatureList::SetInstance(std::move(feature_list));
+ base::test::ScopedFeatureList scoped_feature_list;
+ scoped_feature_list.InitWithFeatureList(std::move(feature_list));
// Trial should not be activated initially, but later might get activated
// depending on the expected values.
@@ -814,7 +813,6 @@ TEST_F(VariationsSeedProcessorTest, FeaturesInExpiredStudies) {
base::StringPrintf("Test[%" PRIuS "]: %s", i, test_case.feature.name));
base::FieldTrialList field_trial_list(nullptr);
- base::FeatureList::ClearInstanceForTesting();
std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
feature_list->InitializeFromCommandLine(std::string(), std::string());
@@ -837,7 +835,8 @@ TEST_F(VariationsSeedProcessorTest, FeaturesInExpiredStudies) {
}
EXPECT_TRUE(CreateTrialFromStudyWithFeatureList(study, feature_list.get()));
- base::FeatureList::SetInstance(std::move(feature_list));
+ base::test::ScopedFeatureList scoped_feature_list;
+ scoped_feature_list.InitWithFeatureList(std::move(feature_list));
// Tthe feature should not be enabled, because the study is expired.
EXPECT_EQ(test_case.expected_feature_enabled,
« no previous file with comments | « components/variations/variations_associated_data_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698