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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_host_browsertest.cc

Issue 261363002: Rename BrowserPluginGuestManagerDelegate to BrowserPluginGuestManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@guestview_manager_cleanupguestmanager
Patch Set: Fixed Android Build (Hopefully) Created 6 years, 7 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "base/memory/singleton.h" 6 #include "base/memory/singleton.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/string_split.h" 8 #include "base/strings/string_split.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "base/test/test_timeouts.h" 11 #include "base/test/test_timeouts.h"
12 #include "content/browser/browser_plugin/browser_plugin_embedder.h" 12 #include "content/browser/browser_plugin/browser_plugin_embedder.h"
13 #include "content/browser/browser_plugin/browser_plugin_guest.h" 13 #include "content/browser/browser_plugin/browser_plugin_guest.h"
14 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" 14 #include "content/browser/browser_plugin/browser_plugin_host_factory.h"
15 #include "content/browser/browser_plugin/test_browser_plugin_guest.h" 15 #include "content/browser/browser_plugin/test_browser_plugin_guest.h"
16 #include "content/browser/browser_plugin/test_browser_plugin_guest_delegate.h" 16 #include "content/browser/browser_plugin/test_browser_plugin_guest_delegate.h"
17 #include "content/browser/browser_plugin/test_guest_manager_delegate.h" 17 #include "content/browser/browser_plugin/test_guest_manager.h"
18 #include "content/browser/child_process_security_policy_impl.h" 18 #include "content/browser/child_process_security_policy_impl.h"
19 #include "content/browser/frame_host/render_frame_host_impl.h" 19 #include "content/browser/frame_host/render_frame_host_impl.h"
20 #include "content/browser/frame_host/render_widget_host_view_guest.h" 20 #include "content/browser/frame_host/render_widget_host_view_guest.h"
21 #include "content/browser/renderer_host/render_view_host_impl.h" 21 #include "content/browser/renderer_host/render_view_host_impl.h"
22 #include "content/browser/web_contents/web_contents_impl.h" 22 #include "content/browser/web_contents/web_contents_impl.h"
23 #include "content/common/browser_plugin/browser_plugin_messages.h" 23 #include "content/common/browser_plugin/browser_plugin_messages.h"
24 #include "content/common/view_messages.h" 24 #include "content/common/view_messages.h"
25 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
26 #include "content/public/browser/notification_types.h" 26 #include "content/public/browser/notification_types.h"
27 #include "content/public/browser/render_frame_host.h" 27 #include "content/public/browser/render_frame_host.h"
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 bool is_guest_data_url, 259 bool is_guest_data_url,
260 const std::string& embedder_code) { 260 const std::string& embedder_code) {
261 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 261 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
262 GURL test_url(embedded_test_server()->GetURL(embedder_url)); 262 GURL test_url(embedded_test_server()->GetURL(embedder_url));
263 NavigateToURL(shell(), test_url); 263 NavigateToURL(shell(), test_url);
264 264
265 WebContentsImpl* embedder_web_contents = static_cast<WebContentsImpl*>( 265 WebContentsImpl* embedder_web_contents = static_cast<WebContentsImpl*>(
266 shell()->web_contents()); 266 shell()->web_contents());
267 static_cast<ShellBrowserContext*>( 267 static_cast<ShellBrowserContext*>(
268 embedder_web_contents->GetBrowserContext())-> 268 embedder_web_contents->GetBrowserContext())->
269 set_guest_manager_delegate_for_testing( 269 set_guest_manager_for_testing(
270 TestGuestManagerDelegate::GetInstance()); 270 TestGuestManager::GetInstance());
271 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( 271 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
272 embedder_web_contents->GetRenderViewHost()); 272 embedder_web_contents->GetRenderViewHost());
273 RenderFrameHost* rfh = embedder_web_contents->GetMainFrame(); 273 RenderFrameHost* rfh = embedder_web_contents->GetMainFrame();
274 // Focus the embedder. 274 // Focus the embedder.
275 rvh->Focus(); 275 rvh->Focus();
276 // Activative IME. 276 // Activative IME.
277 rvh->SetInputMethodActive(true); 277 rvh->SetInputMethodActive(true);
278 278
279 // Allow the test to do some operations on the embedder before we perform 279 // Allow the test to do some operations on the embedder before we perform
280 // the first navigation of the guest. 280 // the first navigation of the guest.
281 if (!embedder_code.empty()) 281 if (!embedder_code.empty())
282 ExecuteSyncJSFunction(rfh, embedder_code); 282 ExecuteSyncJSFunction(rfh, embedder_code);
283 283
284 if (!is_guest_data_url) { 284 if (!is_guest_data_url) {
285 test_url = embedded_test_server()->GetURL(guest_url); 285 test_url = embedded_test_server()->GetURL(guest_url);
286 ExecuteSyncJSFunction( 286 ExecuteSyncJSFunction(
287 rfh, base::StringPrintf("SetSrc('%s');", test_url.spec().c_str())); 287 rfh, base::StringPrintf("SetSrc('%s');", test_url.spec().c_str()));
288 } else { 288 } else {
289 ExecuteSyncJSFunction( 289 ExecuteSyncJSFunction(
290 rfh, base::StringPrintf("SetSrc('%s');", guest_url.c_str())); 290 rfh, base::StringPrintf("SetSrc('%s');", guest_url.c_str()));
291 } 291 }
292 292
293 test_embedder_ = static_cast<TestBrowserPluginEmbedder*>( 293 test_embedder_ = static_cast<TestBrowserPluginEmbedder*>(
294 embedder_web_contents->GetBrowserPluginEmbedder()); 294 embedder_web_contents->GetBrowserPluginEmbedder());
295 ASSERT_TRUE(test_embedder_); 295 ASSERT_TRUE(test_embedder_);
296 296
297 test_guest_manager_ = 297 test_guest_manager_ =
298 static_cast<TestGuestManagerDelegate*>( 298 static_cast<TestGuestManager*>(
299 embedder_web_contents->GetBrowserContext()-> 299 embedder_web_contents->GetBrowserContext()->GetGuestManager());
300 GetGuestManagerDelegate());
301 300
302 WebContentsImpl* test_guest_web_contents = 301 WebContentsImpl* test_guest_web_contents =
303 test_guest_manager_->WaitForGuestAdded(); 302 test_guest_manager_->WaitForGuestAdded();
304 303
305 test_guest_ = static_cast<TestBrowserPluginGuest*>( 304 test_guest_ = static_cast<TestBrowserPluginGuest*>(
306 test_guest_web_contents->GetBrowserPluginGuest()); 305 test_guest_web_contents->GetBrowserPluginGuest());
307 test_guest_->WaitForLoadStop(); 306 test_guest_->WaitForLoadStop();
308 } 307 }
309 308
310 TestBrowserPluginEmbedder* test_embedder() const { return test_embedder_; } 309 TestBrowserPluginEmbedder* test_embedder() const { return test_embedder_; }
311 TestBrowserPluginGuest* test_guest() const { return test_guest_; } 310 TestBrowserPluginGuest* test_guest() const { return test_guest_; }
312 TestGuestManagerDelegate* test_guest_manager() const { 311 TestGuestManager* test_guest_manager() const {
313 return test_guest_manager_; 312 return test_guest_manager_;
314 } 313 }
315 314
316 private: 315 private:
317 TestBrowserPluginEmbedder* test_embedder_; 316 TestBrowserPluginEmbedder* test_embedder_;
318 TestBrowserPluginGuest* test_guest_; 317 TestBrowserPluginGuest* test_guest_;
319 TestGuestManagerDelegate* test_guest_manager_; 318 TestGuestManager* test_guest_manager_;
320 DISALLOW_COPY_AND_ASSIGN(BrowserPluginHostTest); 319 DISALLOW_COPY_AND_ASSIGN(BrowserPluginHostTest);
321 }; 320 };
322 321
323 // This test ensures that if guest isn't there and we resize the guest (from 322 // This test ensures that if guest isn't there and we resize the guest (from
324 // js), it remembers the size correctly. 323 // js), it remembers the size correctly.
325 // 324 //
326 // Initially we load an embedder with a guest without a src attribute (which has 325 // Initially we load an embedder with a guest without a src attribute (which has
327 // dimension 640x480), resize it to 100x200, and then we set the source to a 326 // dimension 640x480), resize it to 100x200, and then we set the source to a
328 // sample guest. In the end we verify that the correct size has been set. 327 // sample guest. In the end we verify that the correct size has been set.
329 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, NavigateAfterResize) { 328 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, NavigateAfterResize) {
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 scoped_ptr<base::Value> value = 997 scoped_ptr<base::Value> value =
999 content::ExecuteScriptAndGetValue( 998 content::ExecuteScriptAndGetValue(
1000 guest_rfh, "document.getElementById('input1').value"); 999 guest_rfh, "document.getElementById('input1').value");
1001 std::string actual_value; 1000 std::string actual_value;
1002 ASSERT_TRUE(value->GetAsString(&actual_value)); 1001 ASSERT_TRUE(value->GetAsString(&actual_value));
1003 EXPECT_EQ(base::UTF16ToUTF8(expected_value), actual_value); 1002 EXPECT_EQ(base::UTF16ToUTF8(expected_value), actual_value);
1004 } 1003 }
1005 } 1004 }
1006 1005
1007 } // namespace content 1006 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698