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

Unified Diff: base/feature_list_unittest.cc

Issue 1809633003: Allow trials to associate without overriding a feature. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a comment. Created 4 years, 9 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 | « base/feature_list.cc ('k') | components/variations/processed_study.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/feature_list_unittest.cc
diff --git a/base/feature_list_unittest.cc b/base/feature_list_unittest.cc
index 11cf179a8ce8fb64ee8752c3b99661c29e2f6a02..7155e866904cd9578d9498cc4adeff54d7a3b01c 100644
--- a/base/feature_list_unittest.cc
+++ b/base/feature_list_unittest.cc
@@ -6,6 +6,7 @@
#include <stddef.h>
+#include <algorithm>
#include <utility>
#include "base/format_macros.h"
@@ -178,6 +179,35 @@ TEST_F(FeatureListTest, FieldTrialOverrides) {
}
}
+TEST_F(FeatureListTest, FieldTrialAssociateUseDefault) {
+ FieldTrialList field_trial_list(nullptr);
+ scoped_ptr<FeatureList> feature_list(new FeatureList);
+
+ FieldTrial* trial1 = FieldTrialList::CreateFieldTrial("TrialExample1", "A");
+ FieldTrial* trial2 = FieldTrialList::CreateFieldTrial("TrialExample2", "B");
+ feature_list->RegisterFieldTrialOverride(
+ kFeatureOnByDefaultName, FeatureList::OVERRIDE_USE_DEFAULT, trial1);
+ feature_list->RegisterFieldTrialOverride(
+ kFeatureOffByDefaultName, FeatureList::OVERRIDE_USE_DEFAULT, trial2);
+ RegisterFeatureListInstance(std::move(feature_list));
+
+ // Initially, neither trial should be active.
+ EXPECT_FALSE(FieldTrialList::IsTrialActive(trial1->trial_name()));
+ EXPECT_FALSE(FieldTrialList::IsTrialActive(trial2->trial_name()));
+
+ // Check the feature enabled state is its default.
+ EXPECT_TRUE(FeatureList::IsEnabled(kFeatureOnByDefault));
+ // The above should have activated |trial1|.
+ EXPECT_TRUE(FieldTrialList::IsTrialActive(trial1->trial_name()));
+ EXPECT_FALSE(FieldTrialList::IsTrialActive(trial2->trial_name()));
+
+ // Check the feature enabled state is its default.
+ EXPECT_FALSE(FeatureList::IsEnabled(kFeatureOffByDefault));
+ // The above should have activated |trial2|.
+ EXPECT_TRUE(FieldTrialList::IsTrialActive(trial1->trial_name()));
+ EXPECT_TRUE(FieldTrialList::IsTrialActive(trial2->trial_name()));
+}
+
TEST_F(FeatureListTest, CommandLineTakesPrecedenceOverFieldTrial) {
ClearFeatureListInstance();
« no previous file with comments | « base/feature_list.cc ('k') | components/variations/processed_study.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698