OLD | NEW |
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/mock_render_process_host.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 ui::TextInputFocusManager* text_input_focus_manager = | 85 ui::TextInputFocusManager* text_input_focus_manager = |
86 ui::TextInputFocusManager::GetInstance(); | 86 ui::TextInputFocusManager::GetInstance(); |
87 EXPECT_EQ(nullptr, webview->GetTextInputClient()); | 87 EXPECT_EQ(nullptr, webview->GetTextInputClient()); |
88 EXPECT_EQ(text_input_focus_manager->GetFocusedTextInputClient(), | 88 EXPECT_EQ(text_input_focus_manager->GetFocusedTextInputClient(), |
89 webview->GetTextInputClient()); | 89 webview->GetTextInputClient()); |
90 | 90 |
91 // Case 1: Creates a new WebContents. | 91 // Case 1: Creates a new WebContents. |
92 content::WebContents* web_contents1 = webview->GetWebContents(); | 92 content::WebContents* web_contents1 = webview->GetWebContents(); |
93 web_contents1->GetRenderViewHost()->GetProcess()->Init(); | 93 web_contents1->GetRenderViewHost()->GetProcess()->Init(); |
94 content::RenderViewHostTester::For(web_contents1->GetRenderViewHost()) | 94 content::RenderViewHostTester::For(web_contents1->GetRenderViewHost()) |
95 ->CreateRenderView(base::string16(), MSG_ROUTING_NONE, MSG_ROUTING_NONE, | 95 ->CreateTestRenderView(base::string16(), MSG_ROUTING_NONE, |
96 -1, false); | 96 MSG_ROUTING_NONE, -1, false); |
97 webview->RequestFocus(); | 97 webview->RequestFocus(); |
98 ui::TextInputClient* client1 = webview->GetTextInputClient(); | 98 ui::TextInputClient* client1 = webview->GetTextInputClient(); |
99 EXPECT_NE(nullptr, client1); | 99 EXPECT_NE(nullptr, client1); |
100 EXPECT_EQ(text_input_focus_manager->GetFocusedTextInputClient(), client1); | 100 EXPECT_EQ(text_input_focus_manager->GetFocusedTextInputClient(), client1); |
101 | 101 |
102 // Case 2: Replaces a WebContents by SetWebContents(). | 102 // Case 2: Replaces a WebContents by SetWebContents(). |
103 scoped_ptr<content::WebContents> web_contents2( | 103 scoped_ptr<content::WebContents> web_contents2( |
104 content::WebContentsTester::CreateTestWebContents(browser_context(), | 104 content::WebContentsTester::CreateTestWebContents(browser_context(), |
105 nullptr)); | 105 nullptr)); |
106 web_contents2->GetRenderViewHost()->GetProcess()->Init(); | 106 web_contents2->GetRenderViewHost()->GetProcess()->Init(); |
107 content::RenderViewHostTester::For(web_contents2->GetRenderViewHost()) | 107 content::RenderViewHostTester::For(web_contents2->GetRenderViewHost()) |
108 ->CreateRenderView(base::string16(), MSG_ROUTING_NONE, MSG_ROUTING_NONE, | 108 ->CreateTestRenderView(base::string16(), MSG_ROUTING_NONE, |
109 -1, false); | 109 MSG_ROUTING_NONE, -1, false); |
110 webview->SetWebContents(web_contents2.get()); | 110 webview->SetWebContents(web_contents2.get()); |
111 ui::TextInputClient* client2 = webview->GetTextInputClient(); | 111 ui::TextInputClient* client2 = webview->GetTextInputClient(); |
112 EXPECT_NE(nullptr, client2); | 112 EXPECT_NE(nullptr, client2); |
113 EXPECT_EQ(text_input_focus_manager->GetFocusedTextInputClient(), client2); | 113 EXPECT_EQ(text_input_focus_manager->GetFocusedTextInputClient(), client2); |
114 EXPECT_NE(client1, client2); | 114 EXPECT_NE(client1, client2); |
115 | 115 |
116 widget->Close(); | 116 widget->Close(); |
117 RunPendingMessages(); | 117 RunPendingMessages(); |
118 } | 118 } |
119 | 119 |
120 } // namespace | 120 } // namespace |
OLD | NEW |