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

Side by Side Diff: content/browser/frame_host/frame_tree_unittest.cc

Issue 894843003: Move the RenderProcessGone IPC from RenderViewHost to RenderFrameHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix conflict with dalecurtis' CL Created 5 years, 10 months 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 "content/browser/frame_host/frame_tree.h" 5 #include "content/browser/frame_host/frame_tree.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "content/browser/frame_host/navigator_impl.h" 9 #include "content/browser/frame_host/navigator_impl.h"
10 #include "content/browser/frame_host/render_frame_host_factory.h" 10 #include "content/browser/frame_host/render_frame_host_factory.h"
11 #include "content/browser/frame_host/render_frame_host_impl.h" 11 #include "content/browser/frame_host/render_frame_host_impl.h"
12 #include "content/browser/renderer_host/render_view_host_impl.h" 12 #include "content/browser/renderer_host/render_view_host_impl.h"
13 #include "content/browser/web_contents/web_contents_impl.h" 13 #include "content/browser/web_contents/web_contents_impl.h"
14 #include "content/common/view_messages.h" 14 #include "content/common/frame_messages.h"
15 #include "content/public/browser/web_contents_observer.h" 15 #include "content/public/browser/web_contents_observer.h"
16 #include "content/public/test/mock_render_process_host.h" 16 #include "content/public/test/mock_render_process_host.h"
17 #include "content/public/test/test_browser_context.h" 17 #include "content/public/test/test_browser_context.h"
18 #include "content/public/test/test_browser_thread_bundle.h" 18 #include "content/public/test/test_browser_thread_bundle.h"
19 #include "content/test/test_render_frame_host.h" 19 #include "content/test/test_render_frame_host.h"
20 #include "content/test/test_render_view_host.h" 20 #include "content/test/test_render_view_host.h"
21 #include "content/test/test_web_contents.h" 21 #include "content/test/test_web_contents.h"
22 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
23 23
24 namespace content { 24 namespace content {
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // recovery from a render process crash. 222 // recovery from a render process crash.
223 TEST_F(FrameTreeTest, ObserverWalksTreeAfterCrash) { 223 TEST_F(FrameTreeTest, ObserverWalksTreeAfterCrash) {
224 TreeWalkingWebContentsLogger activity(contents()); 224 TreeWalkingWebContentsLogger activity(contents());
225 225
226 main_test_rfh()->OnCreateChildFrame(22, std::string(), SandboxFlags::NONE); 226 main_test_rfh()->OnCreateChildFrame(22, std::string(), SandboxFlags::NONE);
227 EXPECT_EQ("RenderFrameCreated(22) -> 1: [22: []]", activity.GetLog()); 227 EXPECT_EQ("RenderFrameCreated(22) -> 1: [22: []]", activity.GetLog());
228 main_test_rfh()->OnCreateChildFrame(23, std::string(), SandboxFlags::NONE); 228 main_test_rfh()->OnCreateChildFrame(23, std::string(), SandboxFlags::NONE);
229 EXPECT_EQ("RenderFrameCreated(23) -> 1: [22: [], 23: []]", activity.GetLog()); 229 EXPECT_EQ("RenderFrameCreated(23) -> 1: [22: [], 23: []]", activity.GetLog());
230 230
231 // Crash the renderer 231 // Crash the renderer
232 test_rvh()->OnMessageReceived(ViewHostMsg_RenderProcessGone( 232 main_rfh()->OnMessageReceived(FrameHostMsg_RenderProcessGone(
233 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); 233 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1));
234 EXPECT_EQ( 234 EXPECT_EQ(
235 "RenderFrameDeleted(22) -> 1: []\n" 235 "RenderFrameDeleted(22) -> 1: []\n"
236 "RenderFrameDeleted(23) -> 1: []\n" 236 "RenderFrameDeleted(23) -> 1: []\n"
237 "RenderProcessGone -> 1: []", 237 "RenderProcessGone -> 1: []",
238 activity.GetLog()); 238 activity.GetLog());
239 } 239 }
240 240
241 // Ensure that frames are not added to the tree, if the process passed in 241 // Ensure that frames are not added to the tree, if the process passed in
242 // is different than the process of the parent node. 242 // is different than the process of the parent node.
243 TEST_F(FrameTreeTest, FailAddFrameWithWrongProcessId) { 243 TEST_F(FrameTreeTest, FailAddFrameWithWrongProcessId) {
244 FrameTree* frame_tree = contents()->GetFrameTree(); 244 FrameTree* frame_tree = contents()->GetFrameTree();
245 FrameTreeNode* root = frame_tree->root(); 245 FrameTreeNode* root = frame_tree->root();
246 int process_id = root->current_frame_host()->GetProcess()->GetID(); 246 int process_id = root->current_frame_host()->GetProcess()->GetID();
247 247
248 ASSERT_EQ("1: []", GetTreeState(frame_tree)); 248 ASSERT_EQ("1: []", GetTreeState(frame_tree));
249 249
250 // Simulate attaching a frame from mismatched process id. 250 // Simulate attaching a frame from mismatched process id.
251 ASSERT_FALSE(frame_tree->AddFrame(root, process_id + 1, 1, std::string())); 251 ASSERT_FALSE(frame_tree->AddFrame(root, process_id + 1, 1, std::string()));
252 ASSERT_EQ("1: []", GetTreeState(frame_tree)); 252 ASSERT_EQ("1: []", GetTreeState(frame_tree));
253 } 253 }
254 254
255 } // namespace content 255 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/frame_tree_node.cc ('k') | content/browser/frame_host/render_frame_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698