Chromium Code Reviews| Index: chrome/browser/renderer_host/test/render_process_host_browsertest.cc |
| =================================================================== |
| --- chrome/browser/renderer_host/test/render_process_host_browsertest.cc (revision 70598) |
| +++ chrome/browser/renderer_host/test/render_process_host_browsertest.cc (working copy) |
| @@ -2,10 +2,12 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include "base/command_line.h" |
| #include "chrome/browser/renderer_host/site_instance.h" |
| #include "chrome/browser/tab_contents/tab_contents.h" |
| #include "chrome/browser/renderer_host/render_process_host.h" |
| #include "chrome/browser/ui/browser.h" |
| +#include "chrome/common/chrome_switches.h" |
| #include "chrome/common/url_constants.h" |
| #include "chrome/test/in_process_browser_test.h" |
| #include "chrome/test/ui_test_utils.h" |
| @@ -28,6 +30,30 @@ |
| } |
| }; |
| +IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ProcessPerTab) { |
| + // Set max renderers to 1 to force running out of processes. |
| + RenderProcessHost::SetMaxRendererProcessCount(1); |
|
Charlie Reis
2011/01/06 18:27:59
I don't think you need this line. Even if the max
klobag.chromium
2011/01/06 20:23:02
I added some normal page cases.
|
| + |
| + CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
| + parsed_command_line.AppendSwitch(switches::kProcessPerTab); |
| + |
| + int tab_count = 1; |
| + |
| + // Change the first tab to be the new tab page (TYPE_DOMUI). |
| + GURL newtab(chrome::kChromeUINewTabURL); |
| + ui_test_utils::NavigateToURL(browser(), newtab); |
| + EXPECT_EQ(tab_count, browser()->tab_count()); |
| + EXPECT_EQ(1, RenderProcessHostCount()); |
| + |
| + // Create another new tab. It should share the previous process. |
| + browser()->NewTab(); |
| + if (browser()->tab_count() == tab_count) |
| + ui_test_utils::WaitForNewTab(browser()); |
| + tab_count++; |
| + EXPECT_EQ(tab_count, browser()->tab_count()); |
| + EXPECT_EQ(1, RenderProcessHostCount()); |
| +} |
| + |
| // When we hit the max number of renderers, verify that the way we do process |
| // sharing behaves correctly. In particular, this test is verifying that even |
| // when we hit the max process limit, that renderers of each type will wind up |