Commit 1aa4e8e8 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Combine some code in WebPluginContainerTest.

Change-Id: Ie066edbabf38902768411c2fca5259560569cb95
Reviewed-on: https://chromium-review.googlesource.com/592695Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#490798}
parent 746a8e1c
...@@ -170,6 +170,14 @@ void TestPlugin::PrintPage(int page_number, WebCanvas* canvas) { ...@@ -170,6 +170,14 @@ void TestPlugin::PrintPage(int page_number, WebCanvas* canvas) {
test_client_->OnPrintPage(); test_client_->OnPrintPage();
} }
void EnablePlugins(WebView* web_view, const WebSize& size) {
DCHECK(web_view);
web_view->GetSettings()->SetPluginsEnabled(true);
web_view->Resize(size);
web_view->UpdateAllLifecyclePhases();
RunPendingTasks();
}
WebPluginContainer* GetWebPluginContainer(WebViewBase* web_view, WebPluginContainer* GetWebPluginContainer(WebViewBase* web_view,
const WebString& id) { const WebString& id) {
WebElement element = WebElement element =
...@@ -177,20 +185,22 @@ WebPluginContainer* GetWebPluginContainer(WebViewBase* web_view, ...@@ -177,20 +185,22 @@ WebPluginContainer* GetWebPluginContainer(WebViewBase* web_view,
return element.PluginContainer(); return element.PluginContainer();
} }
void ClearClipboardBuffer() {
Platform::Current()->Clipboard()->WritePlainText(WebString());
EXPECT_EQ(WebString(), Platform::Current()->Clipboard()->ReadPlainText(
WebClipboard::Buffer()));
}
} // namespace } // namespace
TEST_F(WebPluginContainerTest, WindowToLocalPointTest) { TEST_F(WebPluginContainerTest, WindowToLocalPointTest) {
RegisterMockedURL("plugin_container.html"); RegisterMockedURL("plugin_container.html");
TestPluginWebFrameClient // Must outlive |web_view_helper|.
plugin_web_frame_client; // Must outlive webViewHelper. TestPluginWebFrameClient plugin_web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "plugin_container.html", &plugin_web_frame_client); base_url_ + "plugin_container.html", &plugin_web_frame_client);
DCHECK(web_view); EnablePlugins(web_view, WebSize(300, 300));
web_view->GetSettings()->SetPluginsEnabled(true);
web_view->Resize(WebSize(300, 300));
web_view->UpdateAllLifecyclePhases();
RunPendingTasks();
WebPluginContainer* plugin_container_one = WebPluginContainer* plugin_container_one =
GetWebPluginContainer(web_view, WebString::FromUTF8("translated-plugin")); GetWebPluginContainer(web_view, WebString::FromUTF8("translated-plugin"));
...@@ -220,8 +230,8 @@ TEST_F(WebPluginContainerTest, WindowToLocalPointTest) { ...@@ -220,8 +230,8 @@ TEST_F(WebPluginContainerTest, WindowToLocalPointTest) {
TEST_F(WebPluginContainerTest, PluginDocumentPluginIsFocused) { TEST_F(WebPluginContainerTest, PluginDocumentPluginIsFocused) {
RegisterMockedURL("test.pdf", "application/pdf"); RegisterMockedURL("test.pdf", "application/pdf");
TestPluginWebFrameClient // Must outlive |web_view_helper|.
plugin_web_frame_client; // Must outlive webViewHelper. TestPluginWebFrameClient plugin_web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "test.pdf", &plugin_web_frame_client); base_url_ + "test.pdf", &plugin_web_frame_client);
...@@ -239,8 +249,8 @@ TEST_F(WebPluginContainerTest, IFramePluginDocumentNotFocused) { ...@@ -239,8 +249,8 @@ TEST_F(WebPluginContainerTest, IFramePluginDocumentNotFocused) {
RegisterMockedURL("test.pdf", "application/pdf"); RegisterMockedURL("test.pdf", "application/pdf");
RegisterMockedURL("iframe_pdf.html", "text/html"); RegisterMockedURL("iframe_pdf.html", "text/html");
TestPluginWebFrameClient // Must outlive |web_view_helper|.
plugin_web_frame_client; // Must outlive webViewHelper. TestPluginWebFrameClient plugin_web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "iframe_pdf.html", &plugin_web_frame_client); base_url_ + "iframe_pdf.html", &plugin_web_frame_client);
...@@ -261,8 +271,8 @@ TEST_F(WebPluginContainerTest, IFramePluginDocumentNotFocused) { ...@@ -261,8 +271,8 @@ TEST_F(WebPluginContainerTest, IFramePluginDocumentNotFocused) {
TEST_F(WebPluginContainerTest, PrintOnePage) { TEST_F(WebPluginContainerTest, PrintOnePage) {
RegisterMockedURL("test.pdf", "application/pdf"); RegisterMockedURL("test.pdf", "application/pdf");
TestPluginWebFrameClient // Must outlive |web_view_helper|.
plugin_web_frame_client; // Must outlive webViewHelper. TestPluginWebFrameClient plugin_web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "test.pdf", &plugin_web_frame_client); base_url_ + "test.pdf", &plugin_web_frame_client);
...@@ -285,8 +295,8 @@ TEST_F(WebPluginContainerTest, PrintOnePage) { ...@@ -285,8 +295,8 @@ TEST_F(WebPluginContainerTest, PrintOnePage) {
TEST_F(WebPluginContainerTest, PrintAllPages) { TEST_F(WebPluginContainerTest, PrintAllPages) {
RegisterMockedURL("test.pdf", "application/pdf"); RegisterMockedURL("test.pdf", "application/pdf");
TestPluginWebFrameClient // Must outlive |web_view_helper|.
plugin_web_frame_client; // Must outlive webViewHelper. TestPluginWebFrameClient plugin_web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "test.pdf", &plugin_web_frame_client); base_url_ + "test.pdf", &plugin_web_frame_client);
...@@ -308,16 +318,12 @@ TEST_F(WebPluginContainerTest, PrintAllPages) { ...@@ -308,16 +318,12 @@ TEST_F(WebPluginContainerTest, PrintAllPages) {
TEST_F(WebPluginContainerTest, LocalToWindowPointTest) { TEST_F(WebPluginContainerTest, LocalToWindowPointTest) {
RegisterMockedURL("plugin_container.html"); RegisterMockedURL("plugin_container.html");
TestPluginWebFrameClient // Must outlive |web_view_helper|.
plugin_web_frame_client; // Must outlive webViewHelper. TestPluginWebFrameClient plugin_web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "plugin_container.html", &plugin_web_frame_client); base_url_ + "plugin_container.html", &plugin_web_frame_client);
DCHECK(web_view); EnablePlugins(web_view, WebSize(300, 300));
web_view->GetSettings()->SetPluginsEnabled(true);
web_view->Resize(WebSize(300, 300));
web_view->UpdateAllLifecyclePhases();
RunPendingTasks();
WebPluginContainer* plugin_container_one = WebPluginContainer* plugin_container_one =
GetWebPluginContainer(web_view, WebString::FromUTF8("translated-plugin")); GetWebPluginContainer(web_view, WebString::FromUTF8("translated-plugin"));
...@@ -346,16 +352,12 @@ TEST_F(WebPluginContainerTest, LocalToWindowPointTest) { ...@@ -346,16 +352,12 @@ TEST_F(WebPluginContainerTest, LocalToWindowPointTest) {
// Verifies executing the command 'Copy' results in copying to the clipboard. // Verifies executing the command 'Copy' results in copying to the clipboard.
TEST_F(WebPluginContainerTest, Copy) { TEST_F(WebPluginContainerTest, Copy) {
RegisterMockedURL("plugin_container.html"); RegisterMockedURL("plugin_container.html");
TestPluginWebFrameClient // Must outlive |web_view_helper|.
plugin_web_frame_client; // Must outlive webViewHelper. TestPluginWebFrameClient plugin_web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "plugin_container.html", &plugin_web_frame_client); base_url_ + "plugin_container.html", &plugin_web_frame_client);
DCHECK(web_view); EnablePlugins(web_view, WebSize(300, 300));
web_view->GetSettings()->SetPluginsEnabled(true);
web_view->Resize(WebSize(300, 300));
web_view->UpdateAllLifecyclePhases();
RunPendingTasks();
web_view->MainFrameImpl() web_view->MainFrameImpl()
->GetDocument() ->GetDocument()
...@@ -370,16 +372,12 @@ TEST_F(WebPluginContainerTest, Copy) { ...@@ -370,16 +372,12 @@ TEST_F(WebPluginContainerTest, Copy) {
TEST_F(WebPluginContainerTest, CopyFromContextMenu) { TEST_F(WebPluginContainerTest, CopyFromContextMenu) {
RegisterMockedURL("plugin_container.html"); RegisterMockedURL("plugin_container.html");
TestPluginWebFrameClient // Must outlive |web_view_helper|.
plugin_web_frame_client; // Must outlive webViewHelper. TestPluginWebFrameClient plugin_web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "plugin_container.html", &plugin_web_frame_client); base_url_ + "plugin_container.html", &plugin_web_frame_client);
DCHECK(web_view); EnablePlugins(web_view, WebSize(300, 300));
web_view->GetSettings()->SetPluginsEnabled(true);
web_view->Resize(WebSize(300, 300));
web_view->UpdateAllLifecyclePhases();
RunPendingTasks();
auto event = FrameTestHelpers::CreateMouseEvent(WebMouseEvent::kMouseDown, auto event = FrameTestHelpers::CreateMouseEvent(WebMouseEvent::kMouseDown,
WebMouseEvent::Button::kRight, WebMouseEvent::Button::kRight,
...@@ -392,10 +390,7 @@ TEST_F(WebPluginContainerTest, CopyFromContextMenu) { ...@@ -392,10 +390,7 @@ TEST_F(WebPluginContainerTest, CopyFromContextMenu) {
EXPECT_EQ(WebString("x"), Platform::Current()->Clipboard()->ReadPlainText( EXPECT_EQ(WebString("x"), Platform::Current()->Clipboard()->ReadPlainText(
WebClipboard::Buffer())); WebClipboard::Buffer()));
// Clear the clipboard buffer. ClearClipboardBuffer();
Platform::Current()->Clipboard()->WritePlainText(WebString(""));
EXPECT_EQ(WebString(""), Platform::Current()->Clipboard()->ReadPlainText(
WebClipboard::Buffer()));
// Now, let's try a more complex scenario: // Now, let's try a more complex scenario:
// 1) open the context menu. This will focus the plugin. // 1) open the context menu. This will focus the plugin.
...@@ -413,16 +408,12 @@ TEST_F(WebPluginContainerTest, CopyFromContextMenu) { ...@@ -413,16 +408,12 @@ TEST_F(WebPluginContainerTest, CopyFromContextMenu) {
// the clipboard. // the clipboard.
TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest) { TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest) {
RegisterMockedURL("plugin_container.html"); RegisterMockedURL("plugin_container.html");
TestPluginWebFrameClient // Must outlive |web_view_helper|.
plugin_web_frame_client; // Must outlive webViewHelper. TestPluginWebFrameClient plugin_web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "plugin_container.html", &plugin_web_frame_client); base_url_ + "plugin_container.html", &plugin_web_frame_client);
DCHECK(web_view); EnablePlugins(web_view, WebSize(300, 300));
web_view->GetSettings()->SetPluginsEnabled(true);
web_view->Resize(WebSize(300, 300));
web_view->UpdateAllLifecyclePhases();
RunPendingTasks();
WebElement plugin_container_one_element = WebElement plugin_container_one_element =
web_view->MainFrameImpl()->GetDocument().GetElementById( web_view->MainFrameImpl()->GetDocument().GetElementById(
...@@ -445,10 +436,7 @@ TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest) { ...@@ -445,10 +436,7 @@ TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest) {
EXPECT_EQ(WebString("x"), Platform::Current()->Clipboard()->ReadPlainText( EXPECT_EQ(WebString("x"), Platform::Current()->Clipboard()->ReadPlainText(
WebClipboard::Buffer())); WebClipboard::Buffer()));
// Clearing |Clipboard::Buffer()|. ClearClipboardBuffer();
Platform::Current()->Clipboard()->WritePlainText(WebString(""));
EXPECT_EQ(WebString(""), Platform::Current()->Clipboard()->ReadPlainText(
WebClipboard::Buffer()));
WebKeyboardEvent web_keyboard_event_insert( WebKeyboardEvent web_keyboard_event_insert(
WebInputEvent::kRawKeyDown, modifier_key, WebInputEvent::kRawKeyDown, modifier_key,
...@@ -512,16 +500,12 @@ class EventTestPlugin : public FakeWebPlugin { ...@@ -512,16 +500,12 @@ class EventTestPlugin : public FakeWebPlugin {
TEST_F(WebPluginContainerTest, GestureLongPressReachesPlugin) { TEST_F(WebPluginContainerTest, GestureLongPressReachesPlugin) {
RegisterMockedURL("plugin_container.html"); RegisterMockedURL("plugin_container.html");
CustomPluginWebFrameClient<EventTestPlugin> // Must outlive |web_view_helper|.
plugin_web_frame_client; // Must outlive webViewHelper. CustomPluginWebFrameClient<EventTestPlugin> plugin_web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "plugin_container.html", &plugin_web_frame_client); base_url_ + "plugin_container.html", &plugin_web_frame_client);
DCHECK(web_view); EnablePlugins(web_view, WebSize(300, 300));
web_view->GetSettings()->SetPluginsEnabled(true);
web_view->Resize(WebSize(300, 300));
web_view->UpdateAllLifecyclePhases();
RunPendingTasks();
WebElement plugin_container_one_element = WebElement plugin_container_one_element =
web_view->MainFrameImpl()->GetDocument().GetElementById( web_view->MainFrameImpl()->GetDocument().GetElementById(
...@@ -561,16 +545,12 @@ TEST_F(WebPluginContainerTest, GestureLongPressReachesPlugin) { ...@@ -561,16 +545,12 @@ TEST_F(WebPluginContainerTest, GestureLongPressReachesPlugin) {
TEST_F(WebPluginContainerTest, MouseWheelEventTranslated) { TEST_F(WebPluginContainerTest, MouseWheelEventTranslated) {
RegisterMockedURL("plugin_container.html"); RegisterMockedURL("plugin_container.html");
CustomPluginWebFrameClient<EventTestPlugin> // Must outlive |web_view_helper|.
plugin_web_frame_client; // Must outlive webViewHelper. CustomPluginWebFrameClient<EventTestPlugin> plugin_web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "plugin_container.html", &plugin_web_frame_client); base_url_ + "plugin_container.html", &plugin_web_frame_client);
DCHECK(web_view); EnablePlugins(web_view, WebSize(300, 300));
web_view->GetSettings()->SetPluginsEnabled(true);
web_view->Resize(WebSize(300, 300));
web_view->UpdateAllLifecyclePhases();
RunPendingTasks();
WebElement plugin_container_one_element = WebElement plugin_container_one_element =
web_view->MainFrameImpl()->GetDocument().GetElementById( web_view->MainFrameImpl()->GetDocument().GetElementById(
...@@ -597,16 +577,12 @@ TEST_F(WebPluginContainerTest, MouseWheelEventTranslated) { ...@@ -597,16 +577,12 @@ TEST_F(WebPluginContainerTest, MouseWheelEventTranslated) {
TEST_F(WebPluginContainerTest, TouchEventScrolled) { TEST_F(WebPluginContainerTest, TouchEventScrolled) {
RegisterMockedURL("plugin_scroll.html"); RegisterMockedURL("plugin_scroll.html");
CustomPluginWebFrameClient<EventTestPlugin> // Must outlive |web_view_helper|.
plugin_web_frame_client; // Must outlive webViewHelper. CustomPluginWebFrameClient<EventTestPlugin> plugin_web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "plugin_scroll.html", &plugin_web_frame_client); base_url_ + "plugin_scroll.html", &plugin_web_frame_client);
DCHECK(web_view); EnablePlugins(web_view, WebSize(300, 300));
web_view->GetSettings()->SetPluginsEnabled(true);
web_view->Resize(WebSize(300, 300));
web_view->UpdateAllLifecyclePhases();
RunPendingTasks();
web_view->SmoothScroll(0, 200, 0); web_view->SmoothScroll(0, 200, 0);
web_view->UpdateAllLifecyclePhases(); web_view->UpdateAllLifecyclePhases();
RunPendingTasks(); RunPendingTasks();
...@@ -639,16 +615,12 @@ TEST_F(WebPluginContainerTest, TouchEventScrolled) { ...@@ -639,16 +615,12 @@ TEST_F(WebPluginContainerTest, TouchEventScrolled) {
TEST_F(WebPluginContainerTest, TouchEventScrolledWithCoalescedTouches) { TEST_F(WebPluginContainerTest, TouchEventScrolledWithCoalescedTouches) {
RegisterMockedURL("plugin_scroll.html"); RegisterMockedURL("plugin_scroll.html");
CustomPluginWebFrameClient<EventTestPlugin> // Must outlive |web_view_helper|.
plugin_web_frame_client; // Must outlive webViewHelper. CustomPluginWebFrameClient<EventTestPlugin> plugin_web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "plugin_scroll.html", &plugin_web_frame_client); base_url_ + "plugin_scroll.html", &plugin_web_frame_client);
DCHECK(web_view); EnablePlugins(web_view, WebSize(300, 300));
web_view->GetSettings()->SetPluginsEnabled(true);
web_view->Resize(WebSize(300, 300));
web_view->UpdateAllLifecyclePhases();
RunPendingTasks();
web_view->SmoothScroll(0, 200, 0); web_view->SmoothScroll(0, 200, 0);
web_view->UpdateAllLifecyclePhases(); web_view->UpdateAllLifecyclePhases();
RunPendingTasks(); RunPendingTasks();
...@@ -721,16 +693,12 @@ TEST_F(WebPluginContainerTest, TouchEventScrolledWithCoalescedTouches) { ...@@ -721,16 +693,12 @@ TEST_F(WebPluginContainerTest, TouchEventScrolledWithCoalescedTouches) {
TEST_F(WebPluginContainerTest, MouseWheelEventScrolled) { TEST_F(WebPluginContainerTest, MouseWheelEventScrolled) {
RegisterMockedURL("plugin_scroll.html"); RegisterMockedURL("plugin_scroll.html");
CustomPluginWebFrameClient<EventTestPlugin> // Must outlive |web_view_helper|.
plugin_web_frame_client; // Must outlive webViewHelper. CustomPluginWebFrameClient<EventTestPlugin> plugin_web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "plugin_scroll.html", &plugin_web_frame_client); base_url_ + "plugin_scroll.html", &plugin_web_frame_client);
DCHECK(web_view); EnablePlugins(web_view, WebSize(300, 300));
web_view->GetSettings()->SetPluginsEnabled(true);
web_view->Resize(WebSize(300, 300));
web_view->UpdateAllLifecyclePhases();
RunPendingTasks();
web_view->SmoothScroll(0, 200, 0); web_view->SmoothScroll(0, 200, 0);
web_view->UpdateAllLifecyclePhases(); web_view->UpdateAllLifecyclePhases();
RunPendingTasks(); RunPendingTasks();
...@@ -762,16 +730,12 @@ TEST_F(WebPluginContainerTest, MouseWheelEventScrolled) { ...@@ -762,16 +730,12 @@ TEST_F(WebPluginContainerTest, MouseWheelEventScrolled) {
TEST_F(WebPluginContainerTest, MouseEventScrolled) { TEST_F(WebPluginContainerTest, MouseEventScrolled) {
RegisterMockedURL("plugin_scroll.html"); RegisterMockedURL("plugin_scroll.html");
CustomPluginWebFrameClient<EventTestPlugin> // Must outlive |web_view_helper|.
plugin_web_frame_client; // Must outlive webViewHelper. CustomPluginWebFrameClient<EventTestPlugin> plugin_web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "plugin_scroll.html", &plugin_web_frame_client); base_url_ + "plugin_scroll.html", &plugin_web_frame_client);
DCHECK(web_view); EnablePlugins(web_view, WebSize(300, 300));
web_view->GetSettings()->SetPluginsEnabled(true);
web_view->Resize(WebSize(300, 300));
web_view->UpdateAllLifecyclePhases();
RunPendingTasks();
web_view->SmoothScroll(0, 200, 0); web_view->SmoothScroll(0, 200, 0);
web_view->UpdateAllLifecyclePhases(); web_view->UpdateAllLifecyclePhases();
RunPendingTasks(); RunPendingTasks();
...@@ -802,8 +766,8 @@ TEST_F(WebPluginContainerTest, MouseEventScrolled) { ...@@ -802,8 +766,8 @@ TEST_F(WebPluginContainerTest, MouseEventScrolled) {
TEST_F(WebPluginContainerTest, MouseEventZoomed) { TEST_F(WebPluginContainerTest, MouseEventZoomed) {
RegisterMockedURL("plugin_scroll.html"); RegisterMockedURL("plugin_scroll.html");
CustomPluginWebFrameClient<EventTestPlugin> // Must outlive |web_view_helper|.
plugin_web_frame_client; // Must outlive webViewHelper. CustomPluginWebFrameClient<EventTestPlugin> plugin_web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "plugin_scroll.html", &plugin_web_frame_client); base_url_ + "plugin_scroll.html", &plugin_web_frame_client);
...@@ -843,8 +807,8 @@ TEST_F(WebPluginContainerTest, MouseEventZoomed) { ...@@ -843,8 +807,8 @@ TEST_F(WebPluginContainerTest, MouseEventZoomed) {
TEST_F(WebPluginContainerTest, MouseWheelEventZoomed) { TEST_F(WebPluginContainerTest, MouseWheelEventZoomed) {
RegisterMockedURL("plugin_scroll.html"); RegisterMockedURL("plugin_scroll.html");
CustomPluginWebFrameClient<EventTestPlugin> // Must outlive |web_view_helper|.
plugin_web_frame_client; // Must outlive webViewHelper. CustomPluginWebFrameClient<EventTestPlugin> plugin_web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "plugin_scroll.html", &plugin_web_frame_client); base_url_ + "plugin_scroll.html", &plugin_web_frame_client);
...@@ -885,8 +849,8 @@ TEST_F(WebPluginContainerTest, MouseWheelEventZoomed) { ...@@ -885,8 +849,8 @@ TEST_F(WebPluginContainerTest, MouseWheelEventZoomed) {
TEST_F(WebPluginContainerTest, TouchEventZoomed) { TEST_F(WebPluginContainerTest, TouchEventZoomed) {
RegisterMockedURL("plugin_scroll.html"); RegisterMockedURL("plugin_scroll.html");
CustomPluginWebFrameClient<EventTestPlugin> // Must outlive |web_view_helper|.
plugin_web_frame_client; // Must outlive webViewHelper. CustomPluginWebFrameClient<EventTestPlugin> plugin_web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "plugin_scroll.html", &plugin_web_frame_client); base_url_ + "plugin_scroll.html", &plugin_web_frame_client);
...@@ -930,16 +894,12 @@ TEST_F(WebPluginContainerTest, TouchEventZoomed) { ...@@ -930,16 +894,12 @@ TEST_F(WebPluginContainerTest, TouchEventZoomed) {
// Verify that isRectTopmost returns false when the document is detached. // Verify that isRectTopmost returns false when the document is detached.
TEST_F(WebPluginContainerTest, IsRectTopmostTest) { TEST_F(WebPluginContainerTest, IsRectTopmostTest) {
RegisterMockedURL("plugin_container.html"); RegisterMockedURL("plugin_container.html");
TestPluginWebFrameClient // Must outlive |web_view_helper|.
plugin_web_frame_client; // Must outlive webViewHelper. TestPluginWebFrameClient plugin_web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "plugin_container.html", &plugin_web_frame_client); base_url_ + "plugin_container.html", &plugin_web_frame_client);
DCHECK(web_view); EnablePlugins(web_view, WebSize(300, 300));
web_view->GetSettings()->SetPluginsEnabled(true);
web_view->Resize(WebSize(300, 300));
web_view->UpdateAllLifecyclePhases();
RunPendingTasks();
WebPluginContainerImpl* plugin_container_impl = WebPluginContainerImpl* plugin_container_impl =
ToWebPluginContainerImpl(GetWebPluginContainer( ToWebPluginContainerImpl(GetWebPluginContainer(
...@@ -968,16 +928,12 @@ TEST_F(WebPluginContainerTest, ClippedRectsForIframedElement) { ...@@ -968,16 +928,12 @@ TEST_F(WebPluginContainerTest, ClippedRectsForIframedElement) {
RegisterMockedURL("plugin_container.html"); RegisterMockedURL("plugin_container.html");
RegisterMockedURL("plugin_containing_page.html"); RegisterMockedURL("plugin_containing_page.html");
TestPluginWebFrameClient // Must outlive |web_view_helper|.
plugin_web_frame_client; // Must outlive webViewHelper. TestPluginWebFrameClient plugin_web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebView* web_view = web_view_helper.InitializeAndLoad( WebView* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "plugin_containing_page.html", &plugin_web_frame_client); base_url_ + "plugin_containing_page.html", &plugin_web_frame_client);
DCHECK(web_view); EnablePlugins(web_view, WebSize(300, 300));
web_view->GetSettings()->SetPluginsEnabled(true);
web_view->Resize(WebSize(300, 300));
web_view->UpdateAllLifecyclePhases();
RunPendingTasks();
WebElement plugin_element = web_view->MainFrame() WebElement plugin_element = web_view->MainFrame()
->FirstChild() ->FirstChild()
...@@ -1003,16 +959,12 @@ TEST_F(WebPluginContainerTest, ClippedRectsForIframedElement) { ...@@ -1003,16 +959,12 @@ TEST_F(WebPluginContainerTest, ClippedRectsForIframedElement) {
TEST_F(WebPluginContainerTest, ClippedRectsForSubpixelPositionedPlugin) { TEST_F(WebPluginContainerTest, ClippedRectsForSubpixelPositionedPlugin) {
RegisterMockedURL("plugin_container.html"); RegisterMockedURL("plugin_container.html");
TestPluginWebFrameClient // Must outlive |web_view_helper|.
plugin_web_frame_client; // Must outlive webViewHelper. TestPluginWebFrameClient plugin_web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "plugin_container.html", &plugin_web_frame_client); base_url_ + "plugin_container.html", &plugin_web_frame_client);
DCHECK(web_view); EnablePlugins(web_view, WebSize(300, 300));
web_view->GetSettings()->SetPluginsEnabled(true);
web_view->Resize(WebSize(300, 300));
web_view->UpdateAllLifecyclePhases();
RunPendingTasks();
WebElement plugin_element = WebElement plugin_element =
web_view->MainFrameImpl()->GetDocument().GetElementById( web_view->MainFrameImpl()->GetDocument().GetElementById(
...@@ -1060,11 +1012,7 @@ TEST_F(WebPluginContainerTest, TopmostAfterDetachTest) { ...@@ -1060,11 +1012,7 @@ TEST_F(WebPluginContainerTest, TopmostAfterDetachTest) {
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "plugin_container.html", &plugin_web_frame_client); base_url_ + "plugin_container.html", &plugin_web_frame_client);
DCHECK(web_view); EnablePlugins(web_view, WebSize(300, 300));
web_view->GetSettings()->SetPluginsEnabled(true);
web_view->Resize(WebSize(300, 300));
web_view->UpdateAllLifecyclePhases();
RunPendingTasks();
WebPluginContainerImpl* plugin_container_impl = WebPluginContainerImpl* plugin_container_impl =
ToWebPluginContainerImpl(GetWebPluginContainer( ToWebPluginContainerImpl(GetWebPluginContainer(
...@@ -1118,15 +1066,12 @@ class CompositedPlugin : public FakeWebPlugin { ...@@ -1118,15 +1066,12 @@ class CompositedPlugin : public FakeWebPlugin {
TEST_F(WebPluginContainerTest, CompositedPluginSPv2) { TEST_F(WebPluginContainerTest, CompositedPluginSPv2) {
ScopedSlimmingPaintV2ForTest enable_s_pv2(true); ScopedSlimmingPaintV2ForTest enable_s_pv2(true);
RegisterMockedURL("plugin.html"); RegisterMockedURL("plugin.html");
// Must outlive |web_view_helper|
CustomPluginWebFrameClient<CompositedPlugin> web_frame_client; CustomPluginWebFrameClient<CompositedPlugin> web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "plugin.html", &web_frame_client); base_url_ + "plugin.html", &web_frame_client);
ASSERT_TRUE(web_view); EnablePlugins(web_view, WebSize(800, 600));
web_view->GetSettings()->SetPluginsEnabled(true);
web_view->Resize(WebSize(800, 600));
web_view->UpdateAllLifecyclePhases();
RunPendingTasks();
WebPluginContainerImpl* container = static_cast<WebPluginContainerImpl*>( WebPluginContainerImpl* container = static_cast<WebPluginContainerImpl*>(
GetWebPluginContainer(web_view, WebString::FromUTF8("plugin"))); GetWebPluginContainer(web_view, WebString::FromUTF8("plugin")));
...@@ -1159,16 +1104,12 @@ TEST_F(WebPluginContainerTest, CompositedPluginSPv2) { ...@@ -1159,16 +1104,12 @@ TEST_F(WebPluginContainerTest, CompositedPluginSPv2) {
TEST_F(WebPluginContainerTest, NeedsWheelEvents) { TEST_F(WebPluginContainerTest, NeedsWheelEvents) {
RegisterMockedURL("plugin_container.html"); RegisterMockedURL("plugin_container.html");
TestPluginWebFrameClient // Must outlive |web_view_helper|
plugin_web_frame_client; // Must outlive webViewHelper TestPluginWebFrameClient plugin_web_frame_client;
FrameTestHelpers::WebViewHelper web_view_helper; FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad( WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "plugin_container.html", &plugin_web_frame_client); base_url_ + "plugin_container.html", &plugin_web_frame_client);
DCHECK(web_view); EnablePlugins(web_view, WebSize(300, 300));
web_view->GetSettings()->SetPluginsEnabled(true);
web_view->Resize(WebSize(300, 300));
web_view->UpdateAllLifecyclePhases();
RunPendingTasks();
WebElement plugin_container_one_element = WebElement plugin_container_one_element =
web_view->MainFrameImpl()->GetDocument().GetElementById( web_view->MainFrameImpl()->GetDocument().GetElementById(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment