Chromium Code Reviews| Index: Source/web/tests/WebInputEventConversionTest.cpp |
| diff --git a/Source/web/tests/WebInputEventConversionTest.cpp b/Source/web/tests/WebInputEventConversionTest.cpp |
| index 810a1e4b84c3560f4727fa81d4f3490ae1bb7133..54ea3819c45d6f50547fd4f21d7a9f9343fa649b 100644 |
| --- a/Source/web/tests/WebInputEventConversionTest.cpp |
| +++ b/Source/web/tests/WebInputEventConversionTest.cpp |
| @@ -38,6 +38,7 @@ |
| #include "core/events/KeyboardEvent.h" |
| #include "core/events/MouseEvent.h" |
| #include "core/events/TouchEvent.h" |
| +#include "core/events/WheelEvent.h" |
| #include "core/frame/FrameHost.h" |
| #include "core/frame/FrameView.h" |
| #include "core/frame/LocalFrame.h" |
| @@ -713,4 +714,60 @@ TEST(WebInputEventConversionTest, PinchViewportOffset) |
| } |
| } |
| +TEST(WebInputEventConversionTest, WebMouseWheelEventBuilder) |
| +{ |
| + const std::string baseURL("http://www.test5.com/"); |
| + const std::string fileName("fixed_layout.html"); |
| + |
| + URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_str()), WebString::fromUTF8("fixed_layout.html")); |
| + FrameTestHelpers::WebViewHelper webViewHelper; |
| + WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileName, true); |
| + int pageWidth = 640; |
| + int pageHeight = 480; |
| + webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
| + webViewImpl->layout(); |
| + |
| + RefPtrWillBeRawPtr<Document> document = toLocalFrame(webViewImpl->page()->mainFrame())->document(); |
| + RefPtrWillBeRawPtr<WheelEvent> event = WheelEvent::create(FloatPoint(1, 1), FloatPoint(10, 10), |
| + 0, document.get()->domWindow(), IntPoint(1, 1), IntPoint(1, 1), true, false, false, false, true); |
| + WebMouseWheelEventBuilder webMouseWheel(toLocalFrame(webViewImpl->page()->mainFrame())->view(), document.get()->renderView(), *event); |
| + EXPECT_TRUE(webMouseWheel.canScroll); |
|
Rick Byers
2014/12/02 15:48:21
You should verify the other fields too while you'r
lanwei
2014/12/02 22:27:54
Done.
|
| +} |
| + |
| +TEST(WebInputEventConversionTest, PlatformWheelEventBuilder) |
| +{ |
| + const std::string baseURL("http://www.test6.com/"); |
| + const std::string fileName("fixed_layout.html"); |
| + |
| + URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_str()), WebString::fromUTF8("fixed_layout.html")); |
| + FrameTestHelpers::WebViewHelper webViewHelper; |
| + WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileName, true); |
| + int pageWidth = 640; |
| + int pageHeight = 480; |
| + webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
| + webViewImpl->layout(); |
| + |
| + FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); |
| + |
| + { |
| + WebMouseWheelEvent webMouseWheelEvent; |
| + webMouseWheelEvent.type = WebInputEvent::MouseWheel; |
| + webMouseWheelEvent.x = 10; |
| + webMouseWheelEvent.y = 10; |
|
Rick Byers
2014/12/02 15:48:21
nit: don't repeat values. That way your test woul
lanwei
2014/12/02 22:27:54
Done.
|
| + webMouseWheelEvent.deltaX = 5; |
| + webMouseWheelEvent.deltaY = 5; |
| + webMouseWheelEvent.modifiers = WebInputEvent::ControlKey; |
| + webMouseWheelEvent.hasPreciseScrollingDeltas = true; |
| + webMouseWheelEvent.canScroll = true; |
| + |
| + PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent); |
| + EXPECT_EQ(10, platformWheelBuilder.position().x()); |
| + EXPECT_EQ(10, platformWheelBuilder.position().y()); |
| + EXPECT_EQ(5, platformWheelBuilder.deltaX()); |
| + EXPECT_EQ(5, platformWheelBuilder.deltaY()); |
| + EXPECT_EQ(WebInputEvent::ControlKey, platformWheelBuilder.modifiers()); |
| + EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); |
| + EXPECT_TRUE(platformWheelBuilder.canScroll()); |
| + } |
| +} |
| } // anonymous namespace |