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

Unified Diff: components/flags_ui/flags_state_unittest.cc

Issue 2129543002: Registering field trial for a feature overridden in chrome://flags. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: After code review #1 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
« components/flags_ui/flags_state.h ('K') | « 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..990e136e023d5f3cfc57979d796a20b57c7ed49a 100644
--- a/components/flags_ui/flags_state_unittest.cc
+++ b/components/flags_ui/flags_state_unittest.cc
@@ -268,10 +268,13 @@ TEST_F(FlagsStateTest, ConvertFlagsToSwitches) {
TEST_F(FlagsStateTest, RegisterAllFeatureVariationParameters) {
const FeatureEntry& entry = kEntries[7];
+ std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
+
// Select the "Disabled" variation.
flags_state_->SetFeatureEntryEnabled(&flags_storage_, entry.NameForOption(0),
true);
- flags_state_->RegisterAllFeatureVariationParameters(&flags_storage_);
+ flags_state_->RegisterAllFeatureVariationParameters(&flags_storage_,
+ feature_list.get());
// No value should be associated.
EXPECT_EQ("", variations::GetVariationParamValue(kTestTrial, kTestParam));
// The trial should not be created.
@@ -282,10 +285,19 @@ TEST_F(FlagsStateTest, RegisterAllFeatureVariationParameters) {
flags_state_->SetFeatureEntryEnabled(&flags_storage_, entry.NameForOption(1),
true);
- flags_state_->RegisterAllFeatureVariationParameters(&flags_storage_);
+ flags_state_->RegisterAllFeatureVariationParameters(&flags_storage_,
+ feature_list.get());
+ // Set the feature_list as the main instance so that
+ // variations::GetVariationParamValueByFeature below works.
+ base::FeatureList::ClearInstanceForTesting();
+ base::FeatureList::SetInstance(std::move(feature_list));
+
// The value should be associated.
EXPECT_EQ(kTestParamValue1,
variations::GetVariationParamValue(kTestTrial, kTestParam));
+ // The value should be associated also via the name of the feature.
+ EXPECT_EQ(kTestParamValue1, variations::GetVariationParamValueByFeature(
+ kTestFeature2, kTestParam));
// The trial should be created.
trial = base::FieldTrialList::Find(kTestTrial);
@@ -296,7 +308,8 @@ TEST_F(FlagsStateTest, RegisterAllFeatureVariationParameters) {
// Select the second "Enabled" variation.
flags_state_->SetFeatureEntryEnabled(&flags_storage_, entry.NameForOption(2),
true);
- flags_state_->RegisterAllFeatureVariationParameters(&flags_storage_);
+ flags_state_->RegisterAllFeatureVariationParameters(&flags_storage_,
+ feature_list.get());
// Associating for the second time should not change the value.
EXPECT_EQ(kTestParamValue1,
variations::GetVariationParamValue(kTestTrial, kTestParam));
« components/flags_ui/flags_state.h ('K') | « components/flags_ui/flags_state.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698