| OLD | NEW |
| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/process/process.h" | 6 #include "base/process/process.h" |
| 7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/devtools/devtools_window.h" | 8 #include "chrome/browser/devtools/devtools_window.h" |
| 9 #include "chrome/browser/search/search.h" | 9 #include "chrome/browser/search/search.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 EXPECT_EQ(host_count, RenderProcessHostCount()); | 212 EXPECT_EQ(host_count, RenderProcessHostCount()); |
| 213 EXPECT_NE(rph1, rph3); | 213 EXPECT_NE(rph1, rph3); |
| 214 EXPECT_NE(rph2, rph3); | 214 EXPECT_NE(rph2, rph3); |
| 215 } | 215 } |
| 216 }; | 216 }; |
| 217 | 217 |
| 218 | 218 |
| 219 class ChromeRenderProcessHostTestWithCommandLine | 219 class ChromeRenderProcessHostTestWithCommandLine |
| 220 : public ChromeRenderProcessHostTest { | 220 : public ChromeRenderProcessHostTest { |
| 221 protected: | 221 protected: |
| 222 void SetUpCommandLine(CommandLine* command_line) override { | 222 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 223 command_line->AppendSwitchASCII(switches::kRendererProcessLimit, "1"); | 223 command_line->AppendSwitchASCII(switches::kRendererProcessLimit, "1"); |
| 224 } | 224 } |
| 225 }; | 225 }; |
| 226 | 226 |
| 227 // Disable on Mac 10.9 due to ongoing flakiness. (crbug.com/442785) | 227 // Disable on Mac 10.9 due to ongoing flakiness. (crbug.com/442785) |
| 228 #if defined(OS_MACOSX) | 228 #if defined(OS_MACOSX) |
| 229 #define MAYBE_ProcessPerTab DISABLED_ProcessPerTab | 229 #define MAYBE_ProcessPerTab DISABLED_ProcessPerTab |
| 230 #else | 230 #else |
| 231 #define MAYBE_ProcessPerTab ProcessPerTab | 231 #define MAYBE_ProcessPerTab ProcessPerTab |
| 232 #endif | 232 #endif |
| 233 | 233 |
| 234 IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, MAYBE_ProcessPerTab) { | 234 IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, MAYBE_ProcessPerTab) { |
| 235 // Set max renderers to 1 to force running out of processes. | 235 // Set max renderers to 1 to force running out of processes. |
| 236 content::RenderProcessHost::SetMaxRendererProcessCount(1); | 236 content::RenderProcessHost::SetMaxRendererProcessCount(1); |
| 237 | 237 |
| 238 CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 238 base::CommandLine& parsed_command_line = |
| 239 *base::CommandLine::ForCurrentProcess(); |
| 239 parsed_command_line.AppendSwitch(switches::kProcessPerTab); | 240 parsed_command_line.AppendSwitch(switches::kProcessPerTab); |
| 240 | 241 |
| 241 int tab_count = 1; | 242 int tab_count = 1; |
| 242 int host_count = 1; | 243 int host_count = 1; |
| 243 | 244 |
| 244 // Change the first tab to be the new tab page (TYPE_WEBUI). | 245 // Change the first tab to be the new tab page (TYPE_WEBUI). |
| 245 GURL omnibox(chrome::kChromeUIOmniboxURL); | 246 GURL omnibox(chrome::kChromeUIOmniboxURL); |
| 246 ui_test_utils::NavigateToURL(browser(), omnibox); | 247 ui_test_utils::NavigateToURL(browser(), omnibox); |
| 247 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); | 248 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); |
| 248 EXPECT_EQ(host_count, RenderProcessHostCount()); | 249 EXPECT_EQ(host_count, RenderProcessHostCount()); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 // Flaky test: crbug.com/394368 | 295 // Flaky test: crbug.com/394368 |
| 295 #define MAYBE_Backgrounding DISABLED_Backgrounding | 296 #define MAYBE_Backgrounding DISABLED_Backgrounding |
| 296 #else | 297 #else |
| 297 #define MAYBE_Backgrounding Backgrounding | 298 #define MAYBE_Backgrounding Backgrounding |
| 298 #endif | 299 #endif |
| 299 IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, MAYBE_Backgrounding) { | 300 IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, MAYBE_Backgrounding) { |
| 300 if (!base::Process::CanBackgroundProcesses()) { | 301 if (!base::Process::CanBackgroundProcesses()) { |
| 301 LOG(ERROR) << "Can't background processes"; | 302 LOG(ERROR) << "Can't background processes"; |
| 302 return; | 303 return; |
| 303 } | 304 } |
| 304 CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 305 base::CommandLine& parsed_command_line = |
| 306 *base::CommandLine::ForCurrentProcess(); |
| 305 parsed_command_line.AppendSwitch(switches::kProcessPerTab); | 307 parsed_command_line.AppendSwitch(switches::kProcessPerTab); |
| 306 | 308 |
| 307 // Change the first tab to be the omnibox page (TYPE_WEBUI). | 309 // Change the first tab to be the omnibox page (TYPE_WEBUI). |
| 308 GURL omnibox(chrome::kChromeUIOmniboxURL); | 310 GURL omnibox(chrome::kChromeUIOmniboxURL); |
| 309 ui_test_utils::NavigateToURL(browser(), omnibox); | 311 ui_test_utils::NavigateToURL(browser(), omnibox); |
| 310 | 312 |
| 311 // Create a new tab. It should be foreground. | 313 // Create a new tab. It should be foreground. |
| 312 GURL page1("data:text/html,hello world1"); | 314 GURL page1("data:text/html,hello world1"); |
| 313 base::Process process1 = ShowSingletonTab(page1); | 315 base::Process process1 = ShowSingletonTab(page1); |
| 314 ASSERT_TRUE(process1.IsValid()); | 316 ASSERT_TRUE(process1.IsValid()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 MAYBE_ProcessOverflowCommandLine) { | 372 MAYBE_ProcessOverflowCommandLine) { |
| 371 TestProcessOverflow(); | 373 TestProcessOverflow(); |
| 372 } | 374 } |
| 373 | 375 |
| 374 // Ensure that DevTools opened to debug DevTools is launched in a separate | 376 // Ensure that DevTools opened to debug DevTools is launched in a separate |
| 375 // process when --process-per-tab is set. See crbug.com/69873. | 377 // process when --process-per-tab is set. See crbug.com/69873. |
| 376 IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, | 378 IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, |
| 377 DevToolsOnSelfInOwnProcessPPT) { | 379 DevToolsOnSelfInOwnProcessPPT) { |
| 378 #if defined(OS_WIN) && defined(USE_ASH) | 380 #if defined(OS_WIN) && defined(USE_ASH) |
| 379 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 381 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 380 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 382 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 383 switches::kAshBrowserTests)) |
| 381 return; | 384 return; |
| 382 #endif | 385 #endif |
| 383 | 386 |
| 384 CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 387 base::CommandLine& parsed_command_line = |
| 388 *base::CommandLine::ForCurrentProcess(); |
| 385 parsed_command_line.AppendSwitch(switches::kProcessPerTab); | 389 parsed_command_line.AppendSwitch(switches::kProcessPerTab); |
| 386 | 390 |
| 387 int tab_count = 1; | 391 int tab_count = 1; |
| 388 int host_count = 1; | 392 int host_count = 1; |
| 389 | 393 |
| 390 GURL page1("data:text/html,hello world1"); | 394 GURL page1("data:text/html,hello world1"); |
| 391 ui_test_utils::WindowedTabAddedNotificationObserver observer1( | 395 ui_test_utils::WindowedTabAddedNotificationObserver observer1( |
| 392 content::NotificationService::AllSources()); | 396 content::NotificationService::AllSources()); |
| 393 chrome::ShowSingletonTab(browser(), page1); | 397 chrome::ShowSingletonTab(browser(), page1); |
| 394 observer1.Wait(); | 398 observer1.Wait(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 420 chrome::ToggleDevToolsWindow(browser(), DevToolsToggleAction::Toggle()); | 424 chrome::ToggleDevToolsWindow(browser(), DevToolsToggleAction::Toggle()); |
| 421 close_observer.Wait(); | 425 close_observer.Wait(); |
| 422 } | 426 } |
| 423 | 427 |
| 424 // Ensure that DevTools opened to debug DevTools is launched in a separate | 428 // Ensure that DevTools opened to debug DevTools is launched in a separate |
| 425 // process. See crbug.com/69873. | 429 // process. See crbug.com/69873. |
| 426 IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, | 430 IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, |
| 427 DevToolsOnSelfInOwnProcess) { | 431 DevToolsOnSelfInOwnProcess) { |
| 428 #if defined(OS_WIN) && defined(USE_ASH) | 432 #if defined(OS_WIN) && defined(USE_ASH) |
| 429 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 433 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 430 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 434 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 435 switches::kAshBrowserTests)) |
| 431 return; | 436 return; |
| 432 #endif | 437 #endif |
| 433 | 438 |
| 434 int tab_count = 1; | 439 int tab_count = 1; |
| 435 int host_count = 1; | 440 int host_count = 1; |
| 436 | 441 |
| 437 GURL page1("data:text/html,hello world1"); | 442 GURL page1("data:text/html,hello world1"); |
| 438 ui_test_utils::WindowedTabAddedNotificationObserver observer1( | 443 ui_test_utils::WindowedTabAddedNotificationObserver observer1( |
| 439 content::NotificationService::AllSources()); | 444 content::NotificationService::AllSources()); |
| 440 chrome::ShowSingletonTab(browser(), page1); | 445 chrome::ShowSingletonTab(browser(), page1); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 chrome::NOTIFICATION_BROWSER_CLOSED, | 527 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 523 content::NotificationService::AllSources()); | 528 content::NotificationService::AllSources()); |
| 524 | 529 |
| 525 // Kill the renderer process, simulating a crash. This should the ProcessDied | 530 // Kill the renderer process, simulating a crash. This should the ProcessDied |
| 526 // method to be called. Alternatively, RenderProcessHost::OnChannelError can | 531 // method to be called. Alternatively, RenderProcessHost::OnChannelError can |
| 527 // be called to directly force a call to ProcessDied. | 532 // be called to directly force a call to ProcessDied. |
| 528 wc1->GetRenderProcessHost()->Shutdown(-1, true); | 533 wc1->GetRenderProcessHost()->Shutdown(-1, true); |
| 529 | 534 |
| 530 observer.Wait(); | 535 observer.Wait(); |
| 531 } | 536 } |
| OLD | NEW |