Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <limits> | 5 #include <limits> |
| 6 | 6 |
| 7 #include "base/command_line.h" | |
| 7 #include "content/public/common/content_constants.h" | 8 #include "content/public/common/content_constants.h" |
| 9 #include "content/public/common/content_switches.h" | |
| 8 #include "content/public/test/mock_render_process_host.h" | 10 #include "content/public/test/mock_render_process_host.h" |
| 9 #include "content/test/test_render_view_host.h" | 11 #include "content/test/test_render_view_host.h" |
| 10 | 12 |
| 11 namespace content { | 13 namespace content { |
| 12 | 14 |
| 13 class RenderProcessHostUnitTest : public RenderViewHostTestHarness {}; | 15 class RenderProcessHostUnitTest : public RenderViewHostTestHarness {}; |
| 14 | 16 |
| 15 // Tests that guest RenderProcessHosts are not considered suitable hosts when | 17 // Tests that guest RenderProcessHosts are not considered suitable hosts when |
| 16 // searching for RenderProcessHost. | 18 // searching for RenderProcessHost. |
| 17 TEST_F(RenderProcessHostUnitTest, GuestsAreNotSuitableHosts) { | 19 TEST_F(RenderProcessHostUnitTest, GuestsAreNotSuitableHosts) { |
| 18 GURL test_url("http://foo.com"); | 20 GURL test_url("http://foo.com"); |
| 19 | 21 |
| 20 MockRenderProcessHost guest_host(browser_context()); | 22 MockRenderProcessHost guest_host(browser_context()); |
| 21 guest_host.set_is_isolated_guest(true); | 23 guest_host.set_is_isolated_guest(true); |
| 22 | 24 |
| 23 EXPECT_FALSE(RenderProcessHostImpl::IsSuitableHost( | 25 EXPECT_FALSE(RenderProcessHostImpl::IsSuitableHost( |
| 24 &guest_host, browser_context(), test_url)); | 26 &guest_host, browser_context(), test_url)); |
| 25 EXPECT_TRUE(RenderProcessHostImpl::IsSuitableHost( | 27 EXPECT_TRUE(RenderProcessHostImpl::IsSuitableHost( |
| 26 process(), browser_context(), test_url)); | 28 process(), browser_context(), test_url)); |
| 27 EXPECT_EQ( | 29 EXPECT_EQ( |
| 28 process(), | 30 process(), |
| 29 RenderProcessHost::GetExistingProcessHost(browser_context(), test_url)); | 31 RenderProcessHost::GetExistingProcessHost(browser_context(), test_url)); |
| 30 } | 32 } |
| 31 | 33 |
| 32 #if !defined(OS_ANDROID) | 34 #if !defined(OS_ANDROID) |
| 33 TEST_F(RenderProcessHostUnitTest, RendererProcessLimit) { | 35 TEST_F(RenderProcessHostUnitTest, RendererProcessLimit) { |
| 36 // This test shouldn't run with --site-per-process mode, since it doesn't | |
| 37 // allow renderer process reuse, which this test explicitly exercises. | |
| 38 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
|
ppi
2014/09/25 08:36:59
The condition that disables the process reuse in R
| |
| 39 switches::kSitePerProcess)) | |
| 40 return; | |
| 41 | |
| 34 // Disable any overrides. | 42 // Disable any overrides. |
| 35 RenderProcessHostImpl::SetMaxRendererProcessCount(0); | 43 RenderProcessHostImpl::SetMaxRendererProcessCount(0); |
| 36 | 44 |
| 37 // Verify that the limit is between 1 and kMaxRendererProcessCount. | 45 // Verify that the limit is between 1 and kMaxRendererProcessCount. |
| 38 EXPECT_GT(RenderProcessHostImpl::GetMaxRendererProcessCount(), 0u); | 46 EXPECT_GT(RenderProcessHostImpl::GetMaxRendererProcessCount(), 0u); |
| 39 EXPECT_LE(RenderProcessHostImpl::GetMaxRendererProcessCount(), | 47 EXPECT_LE(RenderProcessHostImpl::GetMaxRendererProcessCount(), |
| 40 kMaxRendererProcessCount); | 48 kMaxRendererProcessCount); |
| 41 | 49 |
| 42 // Add dummy process hosts to saturate the limit. | 50 // Add dummy process hosts to saturate the limit. |
| 43 ASSERT_NE(0u, kMaxRendererProcessCount); | 51 ASSERT_NE(0u, kMaxRendererProcessCount); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 70 } | 78 } |
| 71 | 79 |
| 72 // Verify that the renderer sharing still won't happen. | 80 // Verify that the renderer sharing still won't happen. |
| 73 GURL test_url("http://foo.com"); | 81 GURL test_url("http://foo.com"); |
| 74 EXPECT_FALSE(RenderProcessHostImpl::ShouldTryToUseExistingProcessHost( | 82 EXPECT_FALSE(RenderProcessHostImpl::ShouldTryToUseExistingProcessHost( |
| 75 browser_context(), test_url)); | 83 browser_context(), test_url)); |
| 76 } | 84 } |
| 77 #endif | 85 #endif |
| 78 | 86 |
| 79 } // namespace content | 87 } // namespace content |
| OLD | NEW |