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

Side by Side Diff: ui/views/controls/webview/webview_interactive_uitest.cc

Issue 1159183002: Improve process crash handling in RenderViewHost & mock RenderProcessHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile problem in webview_interactive_uitest.cc Created 5 years, 6 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
« no previous file with comments | « content/public/test/test_renderer_host.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/views/controls/webview/webview.h" 5 #include "ui/views/controls/webview/webview.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "content/public/browser/web_contents.h" 9 #include "content/public/browser/web_contents.h"
10 #include "content/public/test/mock_render_process_host.h"
10 #include "content/public/test/test_browser_context.h" 11 #include "content/public/test/test_browser_context.h"
11 #include "content/public/test/test_browser_thread.h" 12 #include "content/public/test/test_browser_thread.h"
12 #include "content/public/test/test_renderer_host.h" 13 #include "content/public/test/test_renderer_host.h"
13 #include "content/public/test/web_contents_tester.h" 14 #include "content/public/test/web_contents_tester.h"
14 #include "ui/base/ime/text_input_focus_manager.h" 15 #include "ui/base/ime/text_input_focus_manager.h"
15 #include "ui/base/ui_base_switches.h" 16 #include "ui/base/ui_base_switches.h"
16 #include "ui/gl/gl_surface.h" 17 #include "ui/gl/gl_surface.h"
17 #include "ui/views/test/test_views_delegate.h" 18 #include "ui/views/test/test_views_delegate.h"
18 #include "ui/views/test/webview_test_helper.h" 19 #include "ui/views/test/webview_test_helper.h"
19 #include "ui/views/test/widget_test.h" 20 #include "ui/views/test/widget_test.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 EXPECT_TRUE(widget->IsActive()); 83 EXPECT_TRUE(widget->IsActive());
83 84
84 ui::TextInputFocusManager* text_input_focus_manager = 85 ui::TextInputFocusManager* text_input_focus_manager =
85 ui::TextInputFocusManager::GetInstance(); 86 ui::TextInputFocusManager::GetInstance();
86 EXPECT_EQ(nullptr, webview->GetTextInputClient()); 87 EXPECT_EQ(nullptr, webview->GetTextInputClient());
87 EXPECT_EQ(text_input_focus_manager->GetFocusedTextInputClient(), 88 EXPECT_EQ(text_input_focus_manager->GetFocusedTextInputClient(),
88 webview->GetTextInputClient()); 89 webview->GetTextInputClient());
89 90
90 // Case 1: Creates a new WebContents. 91 // Case 1: Creates a new WebContents.
91 content::WebContents* web_contents1 = webview->GetWebContents(); 92 content::WebContents* web_contents1 = webview->GetWebContents();
93 web_contents1->GetRenderViewHost()->GetProcess()->Init();
92 content::RenderViewHostTester::For(web_contents1->GetRenderViewHost()) 94 content::RenderViewHostTester::For(web_contents1->GetRenderViewHost())
93 ->CreateRenderView(base::string16(), MSG_ROUTING_NONE, MSG_ROUTING_NONE, 95 ->CreateRenderView(base::string16(), MSG_ROUTING_NONE, MSG_ROUTING_NONE,
94 -1, false); 96 -1, false);
95 webview->RequestFocus(); 97 webview->RequestFocus();
96 ui::TextInputClient* client1 = webview->GetTextInputClient(); 98 ui::TextInputClient* client1 = webview->GetTextInputClient();
97 EXPECT_NE(nullptr, client1); 99 EXPECT_NE(nullptr, client1);
98 EXPECT_EQ(text_input_focus_manager->GetFocusedTextInputClient(), client1); 100 EXPECT_EQ(text_input_focus_manager->GetFocusedTextInputClient(), client1);
99 101
100 // Case 2: Replaces a WebContents by SetWebContents(). 102 // Case 2: Replaces a WebContents by SetWebContents().
101 scoped_ptr<content::WebContents> web_contents2( 103 scoped_ptr<content::WebContents> web_contents2(
102 content::WebContentsTester::CreateTestWebContents(browser_context(), 104 content::WebContentsTester::CreateTestWebContents(browser_context(),
103 nullptr)); 105 nullptr));
106 web_contents2->GetRenderViewHost()->GetProcess()->Init();
104 content::RenderViewHostTester::For(web_contents2->GetRenderViewHost()) 107 content::RenderViewHostTester::For(web_contents2->GetRenderViewHost())
105 ->CreateRenderView(base::string16(), MSG_ROUTING_NONE, MSG_ROUTING_NONE, 108 ->CreateRenderView(base::string16(), MSG_ROUTING_NONE, MSG_ROUTING_NONE,
106 -1, false); 109 -1, false);
107 webview->SetWebContents(web_contents2.get()); 110 webview->SetWebContents(web_contents2.get());
108 ui::TextInputClient* client2 = webview->GetTextInputClient(); 111 ui::TextInputClient* client2 = webview->GetTextInputClient();
109 EXPECT_NE(nullptr, client2); 112 EXPECT_NE(nullptr, client2);
110 EXPECT_EQ(text_input_focus_manager->GetFocusedTextInputClient(), client2); 113 EXPECT_EQ(text_input_focus_manager->GetFocusedTextInputClient(), client2);
111 EXPECT_NE(client1, client2); 114 EXPECT_NE(client1, client2);
112 115
113 widget->Close(); 116 widget->Close();
114 RunPendingMessages(); 117 RunPendingMessages();
115 } 118 }
116 119
117 } // namespace 120 } // namespace
OLDNEW
« no previous file with comments | « content/public/test/test_renderer_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698