OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/memory/singleton.h" | 5 #include "base/memory/singleton.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 8 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
9 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" | 9 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" |
10 #include "content/browser/browser_plugin/test_browser_plugin_embedder.h" | 10 #include "content/browser/browser_plugin/test_browser_plugin_embedder.h" |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
439 EXPECT_EQ(expected_title, actual_title); | 439 EXPECT_EQ(expected_title, actual_title); |
440 LOG(INFO) << "Done navigating to second page"; | 440 LOG(INFO) << "Done navigating to second page"; |
441 | 441 |
442 TestBrowserPluginEmbedder* test_embedder_after_nav = | 442 TestBrowserPluginEmbedder* test_embedder_after_nav = |
443 static_cast<TestBrowserPluginEmbedder*>( | 443 static_cast<TestBrowserPluginEmbedder*>( |
444 embedder_web_contents->GetBrowserPluginEmbedder()); | 444 embedder_web_contents->GetBrowserPluginEmbedder()); |
445 // Embedder must not change in web_contents. | 445 // Embedder must not change in web_contents. |
446 ASSERT_EQ(test_embedder_after_nav, test_embedder_); | 446 ASSERT_EQ(test_embedder_after_nav, test_embedder_); |
447 } | 447 } |
448 | 448 |
449 // This test verifies that calling the reload method reloads the guest. | |
450 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, ReloadGuest) { | |
451 ASSERT_TRUE(test_server()->Start()); | |
452 GURL test_url(test_server()->GetURL( | |
453 "files/browser_plugin_embedder.html")); | |
454 NavigateToURL(shell(), test_url); | |
455 | |
456 WebContentsImpl* embedder_web_contents = static_cast<WebContentsImpl*>( | |
457 shell()->web_contents()); | |
458 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | |
459 embedder_web_contents->GetRenderViewHost()); | |
460 | |
461 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16( | |
462 StringPrintf("SetSrc('%s');", kHTMLForGuest))); | |
463 | |
464 // Wait to make sure embedder is created/attached to WebContents. | |
465 ASSERT_TRUE( | |
466 TestBrowserPluginHostFactory::GetInstance()->WaitForEmbedderCreation()); | |
467 | |
468 TestBrowserPluginEmbedder* test_embedder = | |
469 static_cast<TestBrowserPluginEmbedder*>( | |
470 embedder_web_contents->GetBrowserPluginEmbedder()); | |
471 ASSERT_TRUE(test_embedder); | |
472 ASSERT_TRUE(test_embedder->WaitForGuestAdded()); | |
473 | |
474 // Verify that we have exactly one guest. | |
475 const BrowserPluginEmbedder::ContainerInstanceMap& instance_map = | |
476 test_embedder->guest_web_contents_for_testing(); | |
477 EXPECT_EQ(1u, instance_map.size()); | |
478 | |
479 WebContentsImpl* test_guest_web_contents = static_cast<WebContentsImpl*>( | |
480 instance_map.begin()->second); | |
481 TestBrowserPluginGuest* test_guest = static_cast<TestBrowserPluginGuest*>( | |
482 test_guest_web_contents->GetBrowserPluginGuest()); | |
483 ASSERT_TRUE(test_guest->WaitForUpdateRectMsg()); | |
484 test_guest->ResetUpdateRectCount(); | |
485 | |
486 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16( | |
487 "document.getElementById('plugin').reload()")); | |
488 ASSERT_TRUE(test_guest->WaitForUpdateRectMsg()); | |
lazyboy
2012/09/13 19:14:15
Add a comment saying that a successful reload woul
Fady Samuel
2012/09/19 14:38:09
Done.
| |
489 | |
lazyboy
2012/09/13 19:14:15
nit: rm empty line at the end.
Fady Samuel
2012/09/19 14:38:09
Done.
Fady Samuel
2012/09/19 14:38:09
Done.
| |
490 } | |
491 | |
449 } // namespace content | 492 } // namespace content |
OLD | NEW |