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

Unified Diff: chrome/test/in_process_browser_test.cc

Issue 4724004: Group commandline settings in UI test and in process browser test. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync to head Created 10 years, 1 month 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 | « chrome/test/in_process_browser_test.h ('k') | chrome/test/ui/ui_test.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/in_process_browser_test.cc
===================================================================
--- chrome/test/in_process_browser_test.cc (revision 66188)
+++ chrome/test/in_process_browser_test.cc (working copy)
@@ -139,7 +139,54 @@
// Allow subclasses the opportunity to make changes to the command line before
// running any tests.
SetUpCommandLine(command_line);
+ // Add command line arguments that are used by all InProcessBrowserTests.
+ PrepareTestCommandLine(command_line);
+ // Save the single process mode state before it was reset in this test. This
+ // state will be recovered in TearDown(). Single-process mode is not set in
+ // BrowserMain so it needs to be processed explicitly.
+ original_single_process_ = RenderProcessHost::run_renderer_in_process();
+ if (command_line->HasSwitch(switches::kSingleProcess))
+ RenderProcessHost::set_run_renderer_in_process(true);
+
+#if defined(OS_CHROMEOS)
+ chromeos::CrosLibrary::Get()->GetTestApi()->SetUseStubImpl();
+
+ // Make sure that the log directory exists.
+ FilePath log_dir = logging::GetSessionLogFile(*command_line).DirName();
+ file_util::CreateDirectory(log_dir);
+#endif // defined(OS_CHROMEOS)
+
+ SandboxInitWrapper sandbox_wrapper;
+ MainFunctionParams params(*command_line, sandbox_wrapper, NULL);
+ params.ui_task =
+ NewRunnableMethod(this, &InProcessBrowserTest::RunTestOnMainThreadLoop);
+
+ host_resolver_ = new net::RuleBasedHostResolverProc(
+ new IntranetRedirectHostResolverProc(NULL));
+
+ // Something inside the browser does this lookup implicitly. Make it fail
+ // to avoid external dependency. It won't break the tests.
+ host_resolver_->AddSimulatedFailure("*.google.com");
+
+ // See http://en.wikipedia.org/wiki/Web_Proxy_Autodiscovery_Protocol
+ // We don't want the test code to use it.
+ host_resolver_->AddSimulatedFailure("wpad");
+
+ net::ScopedDefaultHostResolverProc scoped_host_resolver_proc(
+ host_resolver_.get());
+
+ SetUpInProcessBrowserTestFixture();
+
+ BrowserMain(params);
+ TearDownInProcessBrowserTestFixture();
+}
+
+void InProcessBrowserTest::PrepareTestCommandLine(
+ CommandLine* command_line) {
+ // Propagate commandline settings from test_launcher_utils.
+ test_launcher_utils::PrepareBrowserCommandLineForTests(command_line);
+
#if defined(OS_WIN)
// Hide windows on show.
if (!command_line->HasSwitch(kUnitTestShowWindows) && !show_window_)
@@ -152,12 +199,6 @@
// This is a Browser test.
command_line->AppendSwitchASCII(switches::kTestType, kBrowserTestType);
- // Single-process mode is not set in BrowserMain so it needs to be processed
- // explicitly.
- original_single_process_ = RenderProcessHost::run_renderer_in_process();
- if (command_line->HasSwitch(switches::kSingleProcess))
- RenderProcessHost::set_run_renderer_in_process(true);
-
#if defined(OS_WIN)
// The Windows sandbox requires that the browser and child processes are the
// same binary. So we launch browser_process.exe which loads chrome.dll
@@ -184,40 +225,6 @@
// If ncecessary, disable TabCloseableStateWatcher.
if (!tab_closeable_state_watcher_enabled_)
command_line->AppendSwitch(switches::kDisableTabCloseableStateWatcher);
-
- test_launcher_utils::PrepareBrowserCommandLineForTests(command_line);
-
-#if defined(OS_CHROMEOS)
- chromeos::CrosLibrary::Get()->GetTestApi()->SetUseStubImpl();
-
- // Make sure that the log directory exists.
- FilePath log_dir = logging::GetSessionLogFile(*command_line).DirName();
- file_util::CreateDirectory(log_dir);
-#endif // defined(OS_CHROMEOS)
-
- SandboxInitWrapper sandbox_wrapper;
- MainFunctionParams params(*command_line, sandbox_wrapper, NULL);
- params.ui_task =
- NewRunnableMethod(this, &InProcessBrowserTest::RunTestOnMainThreadLoop);
-
- host_resolver_ = new net::RuleBasedHostResolverProc(
- new IntranetRedirectHostResolverProc(NULL));
-
- // Something inside the browser does this lookup implicitly. Make it fail
- // to avoid external dependency. It won't break the tests.
- host_resolver_->AddSimulatedFailure("*.google.com");
-
- // See http://en.wikipedia.org/wiki/Web_Proxy_Autodiscovery_Protocol
- // We don't want the test code to use it.
- host_resolver_->AddSimulatedFailure("wpad");
-
- net::ScopedDefaultHostResolverProc scoped_host_resolver_proc(
- host_resolver_.get());
-
- SetUpInProcessBrowserTestFixture();
-
- BrowserMain(params);
- TearDownInProcessBrowserTestFixture();
}
bool InProcessBrowserTest::CreateUserDataDirectory() {
« no previous file with comments | « chrome/test/in_process_browser_test.h ('k') | chrome/test/ui/ui_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698