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/test/test_timeouts.h" | 7 #include "base/test/test_timeouts.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 9 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
10 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" | 10 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 // Wait for the guest to send an UpdateRectMsg, meaning it is ready. | 473 // Wait for the guest to send an UpdateRectMsg, meaning it is ready. |
474 test_guest->WaitForUpdateRectMsg(); | 474 test_guest->WaitForUpdateRectMsg(); |
475 | 475 |
476 // Hide the embedder. | 476 // Hide the embedder. |
477 embedder_web_contents->WasHidden(); | 477 embedder_web_contents->WasHidden(); |
478 | 478 |
479 // Make sure that hiding the embedder also hides the guest. | 479 // Make sure that hiding the embedder also hides the guest. |
480 test_guest->WaitUntilHidden(); | 480 test_guest->WaitUntilHidden(); |
481 } | 481 } |
482 | 482 |
| 483 // This test verifies that calling the reload method reloads the guest. |
| 484 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, ReloadGuest) { |
| 485 ASSERT_TRUE(test_server()->Start()); |
| 486 GURL test_url(test_server()->GetURL( |
| 487 "files/browser_plugin_embedder.html")); |
| 488 NavigateToURL(shell(), test_url); |
| 489 |
| 490 WebContentsImpl* embedder_web_contents = static_cast<WebContentsImpl*>( |
| 491 shell()->web_contents()); |
| 492 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 493 embedder_web_contents->GetRenderViewHost()); |
| 494 |
| 495 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16( |
| 496 StringPrintf("SetSrc('%s');", kHTMLForGuest))); |
| 497 |
| 498 // Wait to make sure embedder is created/attached to WebContents. |
| 499 TestBrowserPluginHostFactory::GetInstance()->WaitForEmbedderCreation(); |
| 500 |
| 501 TestBrowserPluginEmbedder* test_embedder = |
| 502 static_cast<TestBrowserPluginEmbedder*>( |
| 503 embedder_web_contents->GetBrowserPluginEmbedder()); |
| 504 ASSERT_TRUE(test_embedder); |
| 505 test_embedder->WaitForGuestAdded(); |
| 506 |
| 507 // Verify that we have exactly one guest. |
| 508 const BrowserPluginEmbedder::ContainerInstanceMap& instance_map = |
| 509 test_embedder->guest_web_contents_for_testing(); |
| 510 EXPECT_EQ(1u, instance_map.size()); |
| 511 |
| 512 WebContentsImpl* test_guest_web_contents = static_cast<WebContentsImpl*>( |
| 513 instance_map.begin()->second); |
| 514 TestBrowserPluginGuest* test_guest = static_cast<TestBrowserPluginGuest*>( |
| 515 test_guest_web_contents->GetBrowserPluginGuest()); |
| 516 test_guest->WaitForUpdateRectMsg(); |
| 517 test_guest->ResetUpdateRectCount(); |
| 518 |
| 519 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16( |
| 520 "document.getElementById('plugin').reload()")); |
| 521 // A successful reload will force the page to repaint itself as well, and |
| 522 // thereby issue a ViewHostMsg_UpdateRect message. |
| 523 test_guest->WaitForUpdateRectMsg(); |
| 524 } |
| 525 |
483 } // namespace content | 526 } // namespace content |
OLD | NEW |