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

Side by Side Diff: content/browser/renderer_host/render_process_host_browsertest.cc

Issue 1411073005: Migrating tests to use EmbeddedTestServer (/content) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 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 unified diff | Download patch
OLDNEW
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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "content/browser/renderer_host/render_process_host_impl.h" 6 #include "content/browser/renderer_host/render_process_host_impl.h"
7 #include "content/common/child_process_messages.h" 7 #include "content/common/child_process_messages.h"
8 #include "content/public/browser/render_process_host.h" 8 #include "content/public/browser/render_process_host.h"
9 #include "content/public/browser/render_process_host_observer.h" 9 #include "content/public/browser/render_process_host_observer.h"
10 #include "content/public/browser/render_view_host.h" 10 #include "content/public/browser/render_view_host.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 int host_destructions_; 55 int host_destructions_;
56 }; 56 };
57 57
58 // Sometimes the renderer process's ShutdownRequest (corresponding to the 58 // Sometimes the renderer process's ShutdownRequest (corresponding to the
59 // ViewMsg_WasSwappedOut from a previous navigation) doesn't arrive until after 59 // ViewMsg_WasSwappedOut from a previous navigation) doesn't arrive until after
60 // the browser process decides to re-use the renderer for a new purpose. This 60 // the browser process decides to re-use the renderer for a new purpose. This
61 // test makes sure the browser doesn't let the renderer die in that case. See 61 // test makes sure the browser doesn't let the renderer die in that case. See
62 // http://crbug.com/87176. 62 // http://crbug.com/87176.
63 IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, 63 IN_PROC_BROWSER_TEST_F(RenderProcessHostTest,
64 ShutdownRequestFromActiveTabIgnored) { 64 ShutdownRequestFromActiveTabIgnored) {
65 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 65 ASSERT_TRUE(embedded_test_server()->Start());
66 66
67 GURL test_url = embedded_test_server()->GetURL("/simple_page.html"); 67 GURL test_url = embedded_test_server()->GetURL("/simple_page.html");
68 NavigateToURL(shell(), test_url); 68 NavigateToURL(shell(), test_url);
69 RenderProcessHost* rph = 69 RenderProcessHost* rph =
70 shell()->web_contents()->GetRenderViewHost()->GetProcess(); 70 shell()->web_contents()->GetRenderViewHost()->GetProcess();
71 71
72 host_destructions_ = 0; 72 host_destructions_ = 0;
73 process_exits_ = 0; 73 process_exits_ = 0;
74 rph->AddObserver(this); 74 rph->AddObserver(this);
75 ChildProcessHostMsg_ShutdownRequest msg; 75 ChildProcessHostMsg_ShutdownRequest msg;
76 rph->OnMessageReceived(msg); 76 rph->OnMessageReceived(msg);
77 77
78 // If the RPH sends a mistaken ChildProcessMsg_Shutdown, the renderer process 78 // If the RPH sends a mistaken ChildProcessMsg_Shutdown, the renderer process
79 // will take some time to die. Wait for a second tab to load in order to give 79 // will take some time to die. Wait for a second tab to load in order to give
80 // that time to happen. 80 // that time to happen.
81 NavigateToURL(CreateBrowser(), test_url); 81 NavigateToURL(CreateBrowser(), test_url);
82 82
83 EXPECT_EQ(0, process_exits_); 83 EXPECT_EQ(0, process_exits_);
84 if (!host_destructions_) 84 if (!host_destructions_)
85 rph->RemoveObserver(this); 85 rph->RemoveObserver(this);
86 } 86 }
87 87
88 IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, 88 IN_PROC_BROWSER_TEST_F(RenderProcessHostTest,
89 GuestsAreNotSuitableHosts) { 89 GuestsAreNotSuitableHosts) {
90 // Set max renderers to 1 to force running out of processes. 90 // Set max renderers to 1 to force running out of processes.
91 content::RenderProcessHost::SetMaxRendererProcessCount(1); 91 content::RenderProcessHost::SetMaxRendererProcessCount(1);
92 92
93 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 93 ASSERT_TRUE(embedded_test_server()->Start());
94 94
95 GURL test_url = embedded_test_server()->GetURL("/simple_page.html"); 95 GURL test_url = embedded_test_server()->GetURL("/simple_page.html");
96 NavigateToURL(shell(), test_url); 96 NavigateToURL(shell(), test_url);
97 RenderProcessHost* rph = 97 RenderProcessHost* rph =
98 shell()->web_contents()->GetRenderViewHost()->GetProcess(); 98 shell()->web_contents()->GetRenderViewHost()->GetProcess();
99 // Make it believe it's a guest. 99 // Make it believe it's a guest.
100 reinterpret_cast<RenderProcessHostImpl*>(rph)-> 100 reinterpret_cast<RenderProcessHostImpl*>(rph)->
101 set_is_for_guests_only_for_testing(true); 101 set_is_for_guests_only_for_testing(true);
102 EXPECT_EQ(1, RenderProcessHostCount()); 102 EXPECT_EQ(1, RenderProcessHostCount());
103 103
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 logging_string_->append("ObserverLogger::RenderProcessHostDestroyed "); 153 logging_string_->append("ObserverLogger::RenderProcessHostDestroyed ");
154 host_destroyed_ = true; 154 host_destroyed_ = true;
155 } 155 }
156 156
157 std::string* logging_string_; 157 std::string* logging_string_;
158 bool host_destroyed_; 158 bool host_destroyed_;
159 }; 159 };
160 160
161 IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, 161 IN_PROC_BROWSER_TEST_F(RenderProcessHostTest,
162 AllProcessExitedCallsBeforeAnyHostDestroyedCalls) { 162 AllProcessExitedCallsBeforeAnyHostDestroyedCalls) {
163 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 163 ASSERT_TRUE(embedded_test_server()->Start());
164 164
165 GURL test_url = embedded_test_server()->GetURL("/simple_page.html"); 165 GURL test_url = embedded_test_server()->GetURL("/simple_page.html");
166 NavigateToURL(shell(), test_url); 166 NavigateToURL(shell(), test_url);
167 167
168 std::string logging_string; 168 std::string logging_string;
169 ShellCloser shell_closer(shell(), &logging_string); 169 ShellCloser shell_closer(shell(), &logging_string);
170 ObserverLogger observer_logger(&logging_string); 170 ObserverLogger observer_logger(&logging_string);
171 RenderProcessHost* rph = 171 RenderProcessHost* rph =
172 shell()->web_contents()->GetRenderViewHost()->GetProcess(); 172 shell()->web_contents()->GetRenderViewHost()->GetProcess();
173 173
(...skipping 18 matching lines...) Expand all
192 // If the test fails, and somehow the RPH is still alive somehow, at least 192 // If the test fails, and somehow the RPH is still alive somehow, at least
193 // deregister the observers so that the test fails and doesn't also crash. 193 // deregister the observers so that the test fails and doesn't also crash.
194 if (!observer_logger.host_destroyed()) { 194 if (!observer_logger.host_destroyed()) {
195 rph->RemoveObserver(&shell_closer); 195 rph->RemoveObserver(&shell_closer);
196 rph->RemoveObserver(&observer_logger); 196 rph->RemoveObserver(&observer_logger);
197 } 197 }
198 } 198 }
199 199
200 } // namespace 200 } // namespace
201 } // namespace content 201 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698