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

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: Rebase 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 cc0a2067e4c654ad9b9eb55ad3043c7f142f52e3..f8a908fde0a3f0440d67c1d341705372f8aa0963 100644
--- a/components/flags_ui/flags_state_unittest.cc
+++ b/components/flags_ui/flags_state_unittest.cc
@@ -267,10 +267,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 "Default" 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.
@@ -281,7 +284,8 @@ 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());
// No value should be associated as this is the default option.
EXPECT_EQ("",
variations::GetVariationParamValue(kTestTrial, kTestParam));
@@ -295,7 +299,8 @@ TEST_F(FlagsStateTest, RegisterAllFeatureVariationParameters) {
// Select the only one 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("",
variations::GetVariationParamValue(kTestTrial, kTestParam));
@@ -303,13 +308,26 @@ TEST_F(FlagsStateTest, RegisterAllFeatureVariationParameters) {
TEST_F(FlagsStateTest, RegisterAllFeatureVariationParametersNonDefault) {
const FeatureEntry& entry = kEntries[7];
+ std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
+
// Select the only one variation.
flags_state_->SetFeatureEntryEnabled(&flags_storage_, entry.NameForOption(2),
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 param should have the value predefined in this variation.
EXPECT_EQ(kTestParamValue,
variations::GetVariationParamValue(kTestTrial, kTestParam));
+
+ // The value should be associated also via the name of the feature.
+ EXPECT_EQ(kTestParamValue, variations::GetVariationParamValueByFeature(
+ kTestFeature2, kTestParam));
}
base::CommandLine::StringType CreateSwitch(const std::string& value) {
« 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