Index: third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp |
diff --git a/third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp b/third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp |
index 566324a2f79252f364c24cdad03af5f233463b2f..0d41df291038ec32a64ca9c9e12b7f445fe353e3 100644 |
--- a/third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp |
+++ b/third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp |
@@ -48,6 +48,7 @@ |
#include "public/platform/WebClipboard.h" |
#include "public/platform/WebCompositorSupport.h" |
#include "public/platform/WebLayer.h" |
+#include "public/platform/WebMouseWheelEvent.h" |
#include "public/platform/WebThread.h" |
#include "public/platform/WebURLLoaderMockFactory.h" |
#include "public/web/WebCache.h" |
@@ -456,12 +457,22 @@ class EventTestPlugin : public FakeWebPlugin { |
WebInputEventResult handleInputEvent(const WebInputEvent& event, |
WebCursorInfo&) override { |
m_lastEventType = event.type; |
+ if (WebInputEvent::isMouseEventType(event.type) || |
+ event.type == WebInputEvent::MouseWheel) { |
+ const WebMouseEvent& mouseEvent = |
+ static_cast<const WebMouseEvent&>(event); |
+ m_lastMouseEventLocation = IntPoint(mouseEvent.x, mouseEvent.y); |
+ } |
+ |
return WebInputEventResult::HandledSystem; |
} |
WebInputEvent::Type getLastInputEventType() { return m_lastEventType; } |
+ IntPoint getLastMouseEventLocation() { return m_lastMouseEventLocation; } |
+ |
private: |
WebInputEvent::Type m_lastEventType; |
+ IntPoint m_lastMouseEventLocation; |
}; |
TEST_F(WebPluginContainerTest, GestureLongPressReachesPlugin) { |
@@ -515,6 +526,45 @@ TEST_F(WebPluginContainerTest, GestureLongPressReachesPlugin) { |
testPlugin->getLastInputEventType()); |
} |
+TEST_F(WebPluginContainerTest, MouseWheelEventTranslated) { |
+ URLTestHelpers::registerMockedURLFromBaseURL( |
+ WebString::fromUTF8(m_baseURL.c_str()), |
+ WebString::fromUTF8("plugin_container.html")); |
+ CustomPluginWebFrameClient<EventTestPlugin> |
+ pluginWebFrameClient; // Must outlive webViewHelper. |
+ FrameTestHelpers::WebViewHelper webViewHelper; |
+ WebView* webView = webViewHelper.initializeAndLoad( |
+ m_baseURL + "plugin_container.html", true, &pluginWebFrameClient); |
+ DCHECK(webView); |
+ webView->settings()->setPluginsEnabled(true); |
+ webView->resize(WebSize(300, 300)); |
+ webView->updateAllLifecyclePhases(); |
+ runPendingTasks(); |
+ |
+ WebElement pluginContainerOneElement = |
+ webView->mainFrame()->document().getElementById( |
+ WebString::fromUTF8("translated-plugin")); |
+ WebPlugin* plugin = static_cast<WebPluginContainerImpl*>( |
+ pluginContainerOneElement.pluginContainer()) |
+ ->plugin(); |
+ EventTestPlugin* testPlugin = static_cast<EventTestPlugin*>(plugin); |
+ |
+ WebMouseWheelEvent event(WebInputEvent::MouseWheel, |
+ WebInputEvent::NoModifiers, |
+ WebInputEvent::TimeStampForTesting); |
+ |
+ WebRect rect = pluginContainerOneElement.boundsInViewport(); |
+ event.x = rect.x + rect.width / 2; |
+ event.y = rect.y + rect.height / 2; |
+ |
+ webView->handleInputEvent(event); |
+ runPendingTasks(); |
+ |
+ EXPECT_EQ(WebInputEvent::MouseWheel, testPlugin->getLastInputEventType()); |
+ EXPECT_EQ(rect.width / 2, testPlugin->getLastMouseEventLocation().x()); |
+ EXPECT_EQ(rect.height / 2, testPlugin->getLastMouseEventLocation().y()); |
+} |
+ |
// Verify that isRectTopmost returns false when the document is detached. |
TEST_F(WebPluginContainerTest, IsRectTopmostTest) { |
URLTestHelpers::registerMockedURLFromBaseURL( |