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

Unified Diff: base/test/test_suite.cc

Issue 2876153002: Support Using ScopedFeatureList in BrowserTest (Closed)
Patch Set: revert changes in commandline Created 3 years, 6 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/test/test_suite.h ('k') | chrome/browser/net/predictor.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/test_suite.cc
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc
index c9bfe9e0f0173558f90130aead0fabe5b8370864..d8a61df6df4c7375a7678b43cc925c5a16189490 100644
--- a/base/test/test_suite.cc
+++ b/base/test/test_suite.cc
@@ -135,8 +135,7 @@ int RunUnitTestsUsingBaseTestSuite(int argc, char **argv) {
Bind(&TestSuite::Run, Unretained(&test_suite)));
}
-TestSuite::TestSuite(int argc, char** argv)
- : initialized_command_line_(false), created_feature_list_(false) {
+TestSuite::TestSuite(int argc, char** argv) : initialized_command_line_(false) {
PreInitialize();
InitializeFromCommandLine(argc, argv);
// Logging must be initialized before any thread has a chance to call logging
@@ -146,7 +145,7 @@ TestSuite::TestSuite(int argc, char** argv)
#if defined(OS_WIN)
TestSuite::TestSuite(int argc, wchar_t** argv)
- : initialized_command_line_(false), created_feature_list_(false) {
+ : initialized_command_line_(false) {
PreInitialize();
InitializeFromCommandLine(argc, argv);
// Logging must be initialized before any thread has a chance to call logging
@@ -342,13 +341,19 @@ void TestSuite::Initialize() {
debug::WaitForDebugger(60, true);
}
#endif
-
// Set up a FeatureList instance, so that code using that API will not hit a
- // an error that it's not set. If a FeatureList was created in this way (i.e.
- // one didn't exist previously), it will be cleared in Shutdown() via
- // ClearInstanceForTesting().
- created_feature_list_ =
- FeatureList::InitializeInstance(std::string(), std::string());
+ // an error that it's not set. It will be cleared automatically.
+ // TestFeatureForBrowserTest1 and TestFeatureForBrowserTest2 used in
+ // BrowserTestScopedFeatureListTest and
+ // ContentBrowserTestScopedFeatureListTest to ensure ScopedFeatureList works.
+ std::string enabled =
+ CommandLine::ForCurrentProcess()->GetSwitchValueASCII("enable-features");
+ std::string disabled =
+ CommandLine::ForCurrentProcess()->GetSwitchValueASCII("disable-features");
+ enabled += ",TestFeatureForBrowserTest1";
+ disabled += ",TestFeatureForBrowserTest2";
Ilya Sherman 2017/06/28 16:20:20 Let's omit these for now, and perhaps add them in
chaopeng 2017/06/28 17:24:13 But BrowserTestScopedFeatureListTest need this fea
chaopeng 2017/06/28 18:00:12 I need to revert this change to load empty string
+
+ scoped_feature_list_.InitFromCommandLine(enabled, disabled);
#if defined(OS_IOS)
InitIOSTestMessageLoop();
@@ -412,10 +417,6 @@ void TestSuite::Initialize() {
void TestSuite::Shutdown() {
base::debug::StopProfiling();
-
- // Clear the FeatureList that was created by Initialize().
- if (created_feature_list_)
- FeatureList::ClearInstanceForTesting();
}
} // namespace base
« no previous file with comments | « base/test/test_suite.h ('k') | chrome/browser/net/predictor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698