diff options
author | mpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-12 19:58:20 +0000 |
---|---|---|
committer | mpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-12 19:58:20 +0000 |
commit | 56cdae31f0087dacbd297ca1284109eb044c7599 (patch) | |
tree | 355349d020e8b715dd903def0bc032dbbeeb17ed | |
parent | 89c7ed00c4d37c0b917d4a681d94d6a4ce782c33 (diff) | |
download | chromium_src-56cdae31f0087dacbd297ca1284109eb044c7599.zip chromium_src-56cdae31f0087dacbd297ca1284109eb044c7599.tar.gz chromium_src-56cdae31f0087dacbd297ca1284109eb044c7599.tar.bz2 |
Run ExtensionViewTest in single-process mode to try to make it less flaky.
Changed InProcessBrowserTest to restore the original CommandLine after it
tears down.
Review URL: http://codereview.chromium.org/42084
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11568 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-x | chrome/browser/extensions/extension_view_unittest.cc | 3 | ||||
-rw-r--r-- | chrome/test/in_process_browser_test.cc | 12 | ||||
-rw-r--r-- | chrome/test/in_process_browser_test.h | 11 |
3 files changed, 25 insertions, 1 deletions
diff --git a/chrome/browser/extensions/extension_view_unittest.cc b/chrome/browser/extensions/extension_view_unittest.cc index 102b9bb..4003954 100755 --- a/chrome/browser/extensions/extension_view_unittest.cc +++ b/chrome/browser/extensions/extension_view_unittest.cc @@ -104,6 +104,9 @@ class ExtensionViewTest : public InProcessBrowserTest { // with the wrong MessageLoop. ExtensionErrorReporter::Init(false); + // Use single-process in an attempt to speed it up and make it less flaky. + EnableSingleProcess(); + InProcessBrowserTest::SetUp(); } }; diff --git a/chrome/test/in_process_browser_test.cc b/chrome/test/in_process_browser_test.cc index aec6391..3768a75 100644 --- a/chrome/test/in_process_browser_test.cc +++ b/chrome/test/in_process_browser_test.cc @@ -47,7 +47,9 @@ bool DieFileDie(const std::wstring& file, bool recurse) { InProcessBrowserTest::InProcessBrowserTest() : browser_(NULL), show_window_(false), - dom_automation_enabled_(false) { + dom_automation_enabled_(false), + single_process_(false), + original_single_process_(false) { } void InProcessBrowserTest::SetUp() { @@ -70,6 +72,7 @@ void InProcessBrowserTest::SetUp() { browser_shutdown::delete_resources_on_shutdown = false; CommandLine* command_line = CommandLine::ForCurrentProcessMutable(); + original_command_line_.reset(new CommandLine(*command_line)); // Hide windows on show. if (!command_line->HasSwitch(kUnitTestShowWindows) && !show_window_) @@ -78,6 +81,9 @@ void InProcessBrowserTest::SetUp() { if (dom_automation_enabled_) command_line->AppendSwitch(switches::kDomAutomationController); + if (single_process_) + command_line->AppendSwitch(switches::kSingleProcess); + command_line->AppendSwitchWithValue(switches::kUserDataDir, user_data_dir); // For some reason the sandbox wasn't happy running in test mode. These @@ -86,6 +92,7 @@ void InProcessBrowserTest::SetUp() { // Single-process mode is not set in BrowserMain so it needs to be processed // explicitlty. + original_single_process_ = RenderProcessHost::run_renderer_in_process(); if (command_line->HasSwitch(switches::kSingleProcess)) RenderProcessHost::set_run_renderer_in_process(true); @@ -114,6 +121,9 @@ void InProcessBrowserTest::TearDown() { browser_shutdown::delete_resources_on_shutdown = true; BrowserView::SetShowState(-1); + + *CommandLine::ForCurrentProcessMutable() = *original_command_line_; + RenderProcessHost::set_run_renderer_in_process(original_single_process_); } void InProcessBrowserTest::Observe(NotificationType type, diff --git a/chrome/test/in_process_browser_test.h b/chrome/test/in_process_browser_test.h index 90dcdc9..89de9b9 100644 --- a/chrome/test/in_process_browser_test.h +++ b/chrome/test/in_process_browser_test.h @@ -77,6 +77,7 @@ class InProcessBrowserTest : public testing::Test, public NotificationObserver { // constructor. void set_show_window(bool show) { show_window_ = show; } void EnableDOMAutomation() { dom_automation_enabled_ = true; } + void EnableSingleProcess() { single_process_ = true; } private: // Invokes CreateBrowser to create a browser, then RunTestOnMainThread, and @@ -100,6 +101,16 @@ class InProcessBrowserTest : public testing::Test, public NotificationObserver { // that can send messages back to the browser). bool dom_automation_enabled_; + // Whether to run the test in single-process mode. + bool single_process_; + + // We muck with the global command line for this process. Keep the original + // so we can reset it when we're done. + scoped_ptr<CommandLine> original_command_line_; + + // Saved to restore the value of RenderProcessHost::run_renderer_in_process. + bool original_single_process_; + DISALLOW_COPY_AND_ASSIGN(InProcessBrowserTest); }; |