Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 | 32 |
| 33 #include "web/WebInputEventConversion.h" | 33 #include "web/WebInputEventConversion.h" |
| 34 | 34 |
| 35 #include "core/dom/Touch.h" | 35 #include "core/dom/Touch.h" |
| 36 #include "core/dom/TouchList.h" | 36 #include "core/dom/TouchList.h" |
| 37 #include "core/events/GestureEvent.h" | 37 #include "core/events/GestureEvent.h" |
| 38 #include "core/events/KeyboardEvent.h" | 38 #include "core/events/KeyboardEvent.h" |
| 39 #include "core/events/MouseEvent.h" | 39 #include "core/events/MouseEvent.h" |
| 40 #include "core/events/TouchEvent.h" | 40 #include "core/events/TouchEvent.h" |
| 41 #include "core/events/WheelEvent.h" | |
| 41 #include "core/frame/FrameHost.h" | 42 #include "core/frame/FrameHost.h" |
| 42 #include "core/frame/FrameView.h" | 43 #include "core/frame/FrameView.h" |
| 43 #include "core/frame/LocalFrame.h" | 44 #include "core/frame/LocalFrame.h" |
| 44 #include "core/page/Page.h" | 45 #include "core/page/Page.h" |
| 45 #include "core/rendering/RenderView.h" | 46 #include "core/rendering/RenderView.h" |
| 46 #include "core/testing/URLTestHelpers.h" | 47 #include "core/testing/URLTestHelpers.h" |
| 47 #include "public/web/WebFrame.h" | 48 #include "public/web/WebFrame.h" |
| 48 #include "public/web/WebSettings.h" | 49 #include "public/web/WebSettings.h" |
| 49 #include "web/WebViewImpl.h" | 50 #include "web/WebViewImpl.h" |
| 50 #include "web/tests/FrameTestHelpers.h" | 51 #include "web/tests/FrameTestHelpers.h" |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 706 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].position.y); | 707 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].position.y); |
| 707 | 708 |
| 708 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); | 709 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); |
| 709 EXPECT_FLOAT_EQ(10.6f, platformTouchBuilder.touchPoints()[0].screenPos() .x()); | 710 EXPECT_FLOAT_EQ(10.6f, platformTouchBuilder.touchPoints()[0].screenPos() .x()); |
| 710 EXPECT_FLOAT_EQ(10.4f, platformTouchBuilder.touchPoints()[0].screenPos() .y()); | 711 EXPECT_FLOAT_EQ(10.4f, platformTouchBuilder.touchPoints()[0].screenPos() .y()); |
| 711 EXPECT_FLOAT_EQ(5.3f + pinchOffset.x(), platformTouchBuilder.touchPoints ()[0].pos().x()); | 712 EXPECT_FLOAT_EQ(5.3f + pinchOffset.x(), platformTouchBuilder.touchPoints ()[0].pos().x()); |
| 712 EXPECT_FLOAT_EQ(5.2f + pinchOffset.y(), platformTouchBuilder.touchPoints ()[0].pos().y()); | 713 EXPECT_FLOAT_EQ(5.2f + pinchOffset.y(), platformTouchBuilder.touchPoints ()[0].pos().y()); |
| 713 } | 714 } |
| 714 } | 715 } |
| 715 | 716 |
| 717 TEST(WebInputEventConversionTest, WebMouseWheelEventBuilder) | |
| 718 { | |
| 719 const std::string baseURL("http://www.test5.com/"); | |
| 720 const std::string fileName("fixed_layout.html"); | |
| 721 | |
| 722 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("fixed_layout.html")); | |
| 723 FrameTestHelpers::WebViewHelper webViewHelper; | |
| 724 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam e, true); | |
| 725 int pageWidth = 640; | |
| 726 int pageHeight = 480; | |
| 727 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | |
| 728 webViewImpl->layout(); | |
| 729 | |
| 730 RefPtrWillBeRawPtr<Document> document = toLocalFrame(webViewImpl->page()->ma inFrame())->document(); | |
| 731 RefPtrWillBeRawPtr<WheelEvent> event = WheelEvent::create(FloatPoint(1, 3), FloatPoint(5, 10), | |
| 732 WheelEvent::DOM_DELTA_PAGE, document.get()->domWindow(), IntPoint(2, 6) , IntPoint(10, 30), | |
| 733 true, false, false, false, true); | |
| 734 WebMouseWheelEventBuilder webMouseWheel(toLocalFrame(webViewImpl->page()->ma inFrame())->view(), document.get()->renderView(), *event); | |
| 735 EXPECT_EQ(1, webMouseWheel.wheelTicksX); | |
| 736 EXPECT_EQ(3, webMouseWheel.wheelTicksY); | |
| 737 EXPECT_EQ(5, webMouseWheel.deltaX); | |
| 738 EXPECT_EQ(10, webMouseWheel.deltaY); | |
| 739 EXPECT_EQ(2, webMouseWheel.globalX); | |
| 740 EXPECT_EQ(6, webMouseWheel.globalY); | |
| 741 EXPECT_EQ(10, webMouseWheel.windowX); | |
| 742 EXPECT_EQ(30, webMouseWheel.windowY); | |
| 743 EXPECT_TRUE(webMouseWheel.scrollByPage); | |
| 744 EXPECT_EQ(WebInputEvent::ControlKey, webMouseWheel.modifiers); | |
| 745 EXPECT_NE(WebInputEvent::AltKey, webMouseWheel.modifiers); | |
| 746 EXPECT_NE(WebInputEvent::ShiftKey, webMouseWheel.modifiers); | |
| 747 EXPECT_NE(WebInputEvent::MetaKey, webMouseWheel.modifiers); | |
|
Rick Byers
2014/12/03 14:03:04
nit: these three EXPECT_NE are unnecessary. modif
lanwei
2014/12/09 05:16:49
Done.
| |
| 748 EXPECT_TRUE(webMouseWheel.canScroll); | |
| 749 } | |
| 750 | |
| 751 TEST(WebInputEventConversionTest, PlatformWheelEventBuilder) | |
| 752 { | |
| 753 const std::string baseURL("http://www.test6.com/"); | |
| 754 const std::string fileName("fixed_layout.html"); | |
| 755 | |
| 756 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("fixed_layout.html")); | |
| 757 FrameTestHelpers::WebViewHelper webViewHelper; | |
| 758 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam e, true); | |
| 759 int pageWidth = 640; | |
| 760 int pageHeight = 480; | |
| 761 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | |
| 762 webViewImpl->layout(); | |
| 763 | |
| 764 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); | |
| 765 | |
| 766 { | |
| 767 WebMouseWheelEvent webMouseWheelEvent; | |
| 768 webMouseWheelEvent.type = WebInputEvent::MouseWheel; | |
| 769 webMouseWheelEvent.x = 0; | |
| 770 webMouseWheelEvent.y = 5; | |
| 771 webMouseWheelEvent.deltaX = 10; | |
| 772 webMouseWheelEvent.deltaY = 15; | |
| 773 webMouseWheelEvent.modifiers = WebInputEvent::ControlKey; | |
| 774 webMouseWheelEvent.hasPreciseScrollingDeltas = true; | |
| 775 webMouseWheelEvent.canScroll = true; | |
| 776 | |
| 777 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent) ; | |
| 778 EXPECT_EQ(0, platformWheelBuilder.position().x()); | |
| 779 EXPECT_EQ(5, platformWheelBuilder.position().y()); | |
| 780 EXPECT_EQ(10, platformWheelBuilder.deltaX()); | |
| 781 EXPECT_EQ(15, platformWheelBuilder.deltaY()); | |
| 782 EXPECT_EQ(WebInputEvent::ControlKey, platformWheelBuilder.modifiers()); | |
| 783 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); | |
| 784 EXPECT_TRUE(platformWheelBuilder.canScroll()); | |
| 785 } | |
| 786 } | |
| 716 } // anonymous namespace | 787 } // anonymous namespace |
| OLD | NEW |