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

Unified Diff: components/flags_ui/flags_state_unittest.cc

Issue 2146903002: Clean-up the code for default variations in chrome://flags. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: iOS test crash fix? #2 Created 4 years, 5 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/flags_ui/flags_state.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/flags_ui/flags_state_unittest.cc
diff --git a/components/flags_ui/flags_state_unittest.cc b/components/flags_ui/flags_state_unittest.cc
index b95373a5f4ba8775df577b6b104c9dd971de43c7..cc0a2067e4c654ad9b9eb55ad3043c7f142f52e3 100644
--- a/components/flags_ui/flags_state_unittest.cc
+++ b/components/flags_ui/flags_state_unittest.cc
@@ -62,22 +62,17 @@ const char kDisableFeatures[] = "dummy-disable-features";
const char kTestTrial[] = "TestTrial";
const char kTestParam[] = "param";
-const char kTestParamValue1[] = "value1";
-const char kTestParamValue2[] = "value2";
+const char kTestParamValue[] = "value";
const base::Feature kTestFeature1{"FeatureName1",
base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kTestFeature2{"FeatureName2",
base::FEATURE_ENABLED_BY_DEFAULT};
-const FeatureEntry::FeatureParam kTestVariationDefault[] = {
- {kTestParam, kTestParamValue1}};
-
const FeatureEntry::FeatureParam kTestVariationOther[] = {
- {kTestParam, kTestParamValue2}};
+ {kTestParam, kTestParamValue}};
const FeatureEntry::FeatureVariation kTestVariations[] = {
- {"", kTestVariationDefault, 1},
{"dummy description", kTestVariationOther, 1}};
// Those have to be valid ids for the translation system but the value are
@@ -148,6 +143,10 @@ class FlagsStateTest : public ::testing::Test {
flags_state_.reset(new FlagsState(kEntries, arraysize(kEntries)));
}
+ ~FlagsStateTest() override {
+ variations::testing::ClearAllVariationParams();
+ }
+
TestingPrefServiceSimple prefs_;
PrefServiceFlagsStorage flags_storage_;
std::unique_ptr<FlagsState> flags_state_;
@@ -268,7 +267,7 @@ TEST_F(FlagsStateTest, ConvertFlagsToSwitches) {
TEST_F(FlagsStateTest, RegisterAllFeatureVariationParameters) {
const FeatureEntry& entry = kEntries[7];
- // Select the "Disabled" variation.
+ // Select the "Default" variation.
flags_state_->SetFeatureEntryEnabled(&flags_storage_, entry.NameForOption(0),
true);
flags_state_->RegisterAllFeatureVariationParameters(&flags_storage_);
@@ -278,13 +277,13 @@ TEST_F(FlagsStateTest, RegisterAllFeatureVariationParameters) {
base::FieldTrial* trial = base::FieldTrialList::Find(kTestTrial);
EXPECT_EQ(nullptr, trial);
- // Select the first "Enabled" variation.
+ // Select the default "Enabled" variation.
flags_state_->SetFeatureEntryEnabled(&flags_storage_, entry.NameForOption(1),
true);
flags_state_->RegisterAllFeatureVariationParameters(&flags_storage_);
- // The value should be associated.
- EXPECT_EQ(kTestParamValue1,
+ // No value should be associated as this is the default option.
+ EXPECT_EQ("",
variations::GetVariationParamValue(kTestTrial, kTestParam));
// The trial should be created.
@@ -293,12 +292,23 @@ TEST_F(FlagsStateTest, RegisterAllFeatureVariationParameters) {
// The about:flags group should be selected for the trial.
EXPECT_EQ(internal::kTrialGroupAboutFlags, trial->group_name());
- // Select the second "Enabled" variation.
+ // Select the only one variation.
flags_state_->SetFeatureEntryEnabled(&flags_storage_, entry.NameForOption(2),
true);
flags_state_->RegisterAllFeatureVariationParameters(&flags_storage_);
// Associating for the second time should not change the value.
- EXPECT_EQ(kTestParamValue1,
+ EXPECT_EQ("",
+ variations::GetVariationParamValue(kTestTrial, kTestParam));
+}
+
+TEST_F(FlagsStateTest, RegisterAllFeatureVariationParametersNonDefault) {
+ const FeatureEntry& entry = kEntries[7];
+ // Select the only one variation.
+ flags_state_->SetFeatureEntryEnabled(&flags_storage_, entry.NameForOption(2),
+ true);
+ flags_state_->RegisterAllFeatureVariationParameters(&flags_storage_);
+ // The param should have the value predefined in this variation.
+ EXPECT_EQ(kTestParamValue,
variations::GetVariationParamValue(kTestTrial, kTestParam));
}
« no previous file with comments | « components/flags_ui/flags_state.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698