Add a ScopedFeatureList class for testing and start using it.
This class improves upon the current situation by ensuring a test
doesn't end up modifying the global feature list permanently.
Migrates a number of tests to new the scoped class.
BUG=620435
[email protected]
Review-Url: https://codereview.chromium.org/2226063002
Cr-Commit-Position: refs/heads/master@{#410589}
diff --git a/components/flags_ui/flags_state_unittest.cc b/components/flags_ui/flags_state_unittest.cc
index 8a036991..5c6bbc0a6 100644
--- a/components/flags_ui/flags_state_unittest.cc
+++ b/components/flags_ui/flags_state_unittest.cc
@@ -19,6 +19,7 @@
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/test/scoped_feature_list.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/flags_ui/feature_entry.h"
@@ -318,8 +319,8 @@
// Set the feature_list as the main instance so that
// variations::GetVariationParamValueByFeature below works.
- base::FeatureList::ClearInstanceForTesting();
- base::FeatureList::SetInstance(std::move(feature_list));
+ base::test::ScopedFeatureList scoped_feature_list;
+ scoped_feature_list.InitWithFeatureList(std::move(feature_list));
// The param should have the value predefined in this variation.
EXPECT_EQ(kTestParamValue,