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

Unified Diff: base/feature_list_unittest.cc

Issue 2110083007: Updating FeatureList default initialization pattern (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing feedback 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
« base/feature_list.cc ('K') | « base/feature_list.cc ('k') | no next file » | 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 a7e7b71183b32e7e263e4f9c7c47c382d215f56c..583a01c7d146e31376c875ca21d26269e15f3497 100644
--- a/base/feature_list_unittest.cc
+++ b/base/feature_list_unittest.cc
@@ -457,4 +457,28 @@ TEST_F(FeatureListTest, InitializeInstance) {
EXPECT_FALSE(FeatureList::IsEnabled(kFeatureOffByDefault));
}
+TEST_F(FeatureListTest, UninitializedInstance_IsEnabledReturnsFalse) {
+ ClearFeatureListInstance();
+ // This test case simulates the calling pattern found in code which does not
+ // explicitly initialize the features list.
+ // All IsEnabled() calls should return the default value in this scenario.
+ EXPECT_EQ(nullptr, FeatureList::GetInstance());
+ EXPECT_TRUE(FeatureList::IsEnabled(kFeatureOnByDefault));
+ EXPECT_EQ(nullptr, FeatureList::GetInstance());
+ EXPECT_FALSE(FeatureList::IsEnabled(kFeatureOffByDefault));
+}
+
+TEST_F(FeatureListTest, UninitializedInstance_GetFieldTrialReturnsNullptr) {
+ ClearFeatureListInstance();
+ // This test case simulates the calling pattern found in code which does not
+ // explicitly initialize the features list.
+ // All GetFieldTrial() calls should return nullptr in this case.
+ // IsTrialActive() should also return false.
+ EXPECT_EQ(nullptr, FeatureList::GetInstance());
+ EXPECT_EQ(nullptr, FeatureList::GetFieldTrial(kFeatureOffByDefault));
+ EXPECT_EQ(nullptr, FeatureList::GetInstance());
+ EXPECT_EQ(nullptr, FeatureList::GetFieldTrial(kFeatureOnByDefault));
+ EXPECT_FALSE(FieldTrialList::IsTrialActive("Trial"));
+}
+
} // namespace base
« base/feature_list.cc ('K') | « base/feature_list.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698