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

Side by Side Diff: base/test/test_suite.cc

Issue 2876153002: Support Using ScopedFeatureList in BrowserTest (Closed)
Patch Set: leave tests and changes in test_suites to following patch Created 3 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 unified diff | Download patch
« no previous file with comments | « base/test/test_suite.h ('k') | chrome/browser/net/predictor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/test/test_suite.h" 5 #include "base/test/test_suite.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/base_paths.h" 10 #include "base/base_paths.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 128 }
129 129
130 } // namespace 130 } // namespace
131 131
132 int RunUnitTestsUsingBaseTestSuite(int argc, char **argv) { 132 int RunUnitTestsUsingBaseTestSuite(int argc, char **argv) {
133 TestSuite test_suite(argc, argv); 133 TestSuite test_suite(argc, argv);
134 return LaunchUnitTests(argc, argv, 134 return LaunchUnitTests(argc, argv,
135 Bind(&TestSuite::Run, Unretained(&test_suite))); 135 Bind(&TestSuite::Run, Unretained(&test_suite)));
136 } 136 }
137 137
138 TestSuite::TestSuite(int argc, char** argv) 138 TestSuite::TestSuite(int argc, char** argv) : initialized_command_line_(false) {
139 : initialized_command_line_(false), created_feature_list_(false) {
140 PreInitialize(); 139 PreInitialize();
141 InitializeFromCommandLine(argc, argv); 140 InitializeFromCommandLine(argc, argv);
142 // Logging must be initialized before any thread has a chance to call logging 141 // Logging must be initialized before any thread has a chance to call logging
143 // functions. 142 // functions.
144 InitializeLogging(); 143 InitializeLogging();
145 } 144 }
146 145
147 #if defined(OS_WIN) 146 #if defined(OS_WIN)
148 TestSuite::TestSuite(int argc, wchar_t** argv) 147 TestSuite::TestSuite(int argc, wchar_t** argv)
149 : initialized_command_line_(false), created_feature_list_(false) { 148 : initialized_command_line_(false) {
150 PreInitialize(); 149 PreInitialize();
151 InitializeFromCommandLine(argc, argv); 150 InitializeFromCommandLine(argc, argv);
152 // Logging must be initialized before any thread has a chance to call logging 151 // Logging must be initialized before any thread has a chance to call logging
153 // functions. 152 // functions.
154 InitializeLogging(); 153 InitializeLogging();
155 } 154 }
156 #endif // defined(OS_WIN) 155 #endif // defined(OS_WIN)
157 156
158 TestSuite::~TestSuite() { 157 TestSuite::~TestSuite() {
159 if (initialized_command_line_) 158 if (initialized_command_line_)
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 #endif // defined(_DEBUG) && defined(_HAS_EXCEPTIONS) && (_HAS_EXCEPTIONS == 1) 334 #endif // defined(_DEBUG) && defined(_HAS_EXCEPTIONS) && (_HAS_EXCEPTIONS == 1)
336 #endif // defined(OS_WIN) 335 #endif // defined(OS_WIN)
337 } 336 }
338 337
339 void TestSuite::Initialize() { 338 void TestSuite::Initialize() {
340 #if !defined(OS_IOS) 339 #if !defined(OS_IOS)
341 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kWaitForDebugger)) { 340 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kWaitForDebugger)) {
342 debug::WaitForDebugger(60, true); 341 debug::WaitForDebugger(60, true);
343 } 342 }
344 #endif 343 #endif
345
346 // Set up a FeatureList instance, so that code using that API will not hit a 344 // Set up a FeatureList instance, so that code using that API will not hit a
347 // an error that it's not set. If a FeatureList was created in this way (i.e. 345 // an error that it's not set. It will be cleared automatically.
348 // one didn't exist previously), it will be cleared in Shutdown() via 346 // TODO(chaopeng) Should load the actually features in command line here.
349 // ClearInstanceForTesting(). 347 scoped_feature_list_.InitFromCommandLine(std::string(), std::string());
350 created_feature_list_ =
351 FeatureList::InitializeInstance(std::string(), std::string());
352 348
353 #if defined(OS_IOS) 349 #if defined(OS_IOS)
354 InitIOSTestMessageLoop(); 350 InitIOSTestMessageLoop();
355 #endif // OS_IOS 351 #endif // OS_IOS
356 352
357 #if defined(OS_ANDROID) 353 #if defined(OS_ANDROID)
358 InitAndroidTestMessageLoop(); 354 InitAndroidTestMessageLoop();
359 #endif // else defined(OS_ANDROID) 355 #endif // else defined(OS_ANDROID)
360 356
361 CHECK(debug::EnableInProcessStackDumping()); 357 CHECK(debug::EnableInProcessStackDumping());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 401
406 TestTimeouts::Initialize(); 402 TestTimeouts::Initialize();
407 403
408 trace_to_file_.BeginTracingFromCommandLineOptions(); 404 trace_to_file_.BeginTracingFromCommandLineOptions();
409 405
410 base::debug::StartProfiling(GetProfileName()); 406 base::debug::StartProfiling(GetProfileName());
411 } 407 }
412 408
413 void TestSuite::Shutdown() { 409 void TestSuite::Shutdown() {
414 base::debug::StopProfiling(); 410 base::debug::StopProfiling();
415
416 // Clear the FeatureList that was created by Initialize().
417 if (created_feature_list_)
418 FeatureList::ClearInstanceForTesting();
419 } 411 }
420 412
421 } // namespace base 413 } // namespace base
OLDNEW
« 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