Index: base/feature_list_unittest.cc |
diff --git a/base/feature_list_unittest.cc b/base/feature_list_unittest.cc |
index cb8f74466f258c2213f20bf3be8c8633a09ef238..9169421da3564284f95380659bf2cc9385ed3870 100644 |
--- a/base/feature_list_unittest.cc |
+++ b/base/feature_list_unittest.cc |
@@ -6,6 +6,7 @@ |
#include "base/format_macros.h" |
#include "base/metrics/field_trial.h" |
+#include "base/strings/string_util.h" |
#include "base/strings/stringprintf.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -23,6 +24,13 @@ struct Feature kFeatureOffByDefault { |
kFeatureOffByDefaultName, FEATURE_DISABLED_BY_DEFAULT |
}; |
+std::string SortFeatureListString(const std::string& feature_list) { |
+ std::vector<std::string> features = |
+ FeatureList::SplitFeatureListString(feature_list); |
+ std::sort(features.begin(), features.end()); |
+ return JoinString(features, ","); |
+} |
+ |
} // namespace |
class FeatureListTest : public testing::Test { |
@@ -308,4 +316,25 @@ TEST_F(FeatureListTest, AssociateReportingFieldTrial) { |
} |
} |
+TEST_F(FeatureListTest, GetFeatureOverrides) { |
+ ClearFeatureListInstance(); |
+ FieldTrialList field_trial_list(nullptr); |
+ scoped_ptr<FeatureList> feature_list(new FeatureList); |
+ feature_list->InitializeFromCommandLine("A,X", "D"); |
+ |
+ FieldTrial* trial = FieldTrialList::CreateFieldTrial("Trial", "Group"); |
+ feature_list->RegisterFieldTrialOverride(kFeatureOffByDefaultName, |
+ FeatureList::OVERRIDE_ENABLE_FEATURE, |
+ trial); |
+ |
+ RegisterFeatureListInstance(feature_list.Pass()); |
+ |
+ std::string enable_features; |
+ std::string disable_features; |
+ FeatureList::GetInstance()->GetFeatureOverrides(&enable_features, |
+ &disable_features); |
+ EXPECT_EQ("A,OffByDefault,X", SortFeatureListString(enable_features)); |
+ EXPECT_EQ("D", SortFeatureListString(disable_features)); |
+} |
+ |
} // namespace base |