| 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 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true); | 901 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true); |
| 902 int pageWidth = 640; | 902 int pageWidth = 640; |
| 903 int pageHeight = 480; | 903 int pageHeight = 480; |
| 904 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | 904 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
| 905 webViewImpl->updateAllLifecyclePhases(); | 905 webViewImpl->updateAllLifecyclePhases(); |
| 906 | 906 |
| 907 Document* document = toLocalFrame(webViewImpl->page()->mainFrame())->documen
t(); | 907 Document* document = toLocalFrame(webViewImpl->page()->mainFrame())->documen
t(); |
| 908 { | 908 { |
| 909 WheelEvent* event = WheelEvent::create(FloatPoint(1, 3), FloatPoint(5, 1
0), | 909 WheelEvent* event = WheelEvent::create(FloatPoint(1, 3), FloatPoint(5, 1
0), |
| 910 WheelEvent::DOM_DELTA_PAGE, document->domWindow(), IntPoint(2, 6), I
ntPoint(10, 30), | 910 WheelEvent::DOM_DELTA_PAGE, document->domWindow(), IntPoint(2, 6), I
ntPoint(10, 30), |
| 911 PlatformEvent::CtrlKey, 0, 0, true, -1 /* null plugin id */, | 911 PlatformEvent::CtrlKey, 0, 0, -1 /* null plugin id */, |
| 912 true /* hasPreciseScrollingDeltas */, Event::RailsModeHorizontal, tr
ue /*cancelable*/); | 912 true /* hasPreciseScrollingDeltas */, Event::RailsModeHorizontal, tr
ue /*cancelable*/); |
| 913 WebMouseWheelEventBuilder webMouseWheel(toLocalFrame(webViewImpl->page()
->mainFrame())->view(), document->layoutViewItem(), *event); | 913 WebMouseWheelEventBuilder webMouseWheel(toLocalFrame(webViewImpl->page()
->mainFrame())->view(), document->layoutViewItem(), *event); |
| 914 EXPECT_EQ(1, webMouseWheel.wheelTicksX); | 914 EXPECT_EQ(1, webMouseWheel.wheelTicksX); |
| 915 EXPECT_EQ(3, webMouseWheel.wheelTicksY); | 915 EXPECT_EQ(3, webMouseWheel.wheelTicksY); |
| 916 EXPECT_EQ(5, webMouseWheel.deltaX); | 916 EXPECT_EQ(5, webMouseWheel.deltaX); |
| 917 EXPECT_EQ(10, webMouseWheel.deltaY); | 917 EXPECT_EQ(10, webMouseWheel.deltaY); |
| 918 EXPECT_EQ(2, webMouseWheel.globalX); | 918 EXPECT_EQ(2, webMouseWheel.globalX); |
| 919 EXPECT_EQ(6, webMouseWheel.globalY); | 919 EXPECT_EQ(6, webMouseWheel.globalY); |
| 920 EXPECT_EQ(10, webMouseWheel.windowX); | 920 EXPECT_EQ(10, webMouseWheel.windowX); |
| 921 EXPECT_EQ(30, webMouseWheel.windowY); | 921 EXPECT_EQ(30, webMouseWheel.windowY); |
| 922 EXPECT_TRUE(webMouseWheel.scrollByPage); | 922 EXPECT_TRUE(webMouseWheel.scrollByPage); |
| 923 EXPECT_EQ(WebInputEvent::ControlKey, webMouseWheel.modifiers); | 923 EXPECT_EQ(WebInputEvent::ControlKey, webMouseWheel.modifiers); |
| 924 EXPECT_TRUE(webMouseWheel.canScroll); | |
| 925 EXPECT_EQ(WebInputEvent::RailsModeHorizontal, webMouseWheel.railsMode); | 924 EXPECT_EQ(WebInputEvent::RailsModeHorizontal, webMouseWheel.railsMode); |
| 926 EXPECT_TRUE(webMouseWheel.hasPreciseScrollingDeltas); | 925 EXPECT_TRUE(webMouseWheel.hasPreciseScrollingDeltas); |
| 927 EXPECT_EQ(WebInputEvent::Blocking, webMouseWheel.dispatchType); | 926 EXPECT_EQ(WebInputEvent::Blocking, webMouseWheel.dispatchType); |
| 928 } | 927 } |
| 929 | 928 |
| 930 { | 929 { |
| 931 WheelEvent* event = WheelEvent::create(FloatPoint(1, 3), FloatPoint(5, 1
0), | 930 WheelEvent* event = WheelEvent::create(FloatPoint(1, 3), FloatPoint(5, 1
0), |
| 932 WheelEvent::DOM_DELTA_PAGE, document->domWindow(), IntPoint(2, 6), I
ntPoint(10, 30), | 931 WheelEvent::DOM_DELTA_PAGE, document->domWindow(), IntPoint(2, 6), I
ntPoint(10, 30), |
| 933 PlatformEvent::CtrlKey, 0, 0, true, -1 /* null plugin id */, true /*
hasPreciseScrollingDeltas */, Event::RailsModeHorizontal, false); | 932 PlatformEvent::CtrlKey, 0, 0, -1 /* null plugin id */, true /* hasPr
eciseScrollingDeltas */, Event::RailsModeHorizontal, false); |
| 934 WebMouseWheelEventBuilder webMouseWheel(toLocalFrame(webViewImpl->page()
->mainFrame())->view(), document->layoutViewItem(), *event); | 933 WebMouseWheelEventBuilder webMouseWheel(toLocalFrame(webViewImpl->page()
->mainFrame())->view(), document->layoutViewItem(), *event); |
| 935 EXPECT_EQ(WebInputEvent::EventNonBlocking, webMouseWheel.dispatchType); | 934 EXPECT_EQ(WebInputEvent::EventNonBlocking, webMouseWheel.dispatchType); |
| 936 } | 935 } |
| 937 } | 936 } |
| 938 | 937 |
| 939 TEST(WebInputEventConversionTest, PlatformWheelEventBuilder) | 938 TEST(WebInputEventConversionTest, PlatformWheelEventBuilder) |
| 940 { | 939 { |
| 941 const std::string baseURL("http://www.test8.com/"); | 940 const std::string baseURL("http://www.test8.com/"); |
| 942 const std::string fileName("fixed_layout.html"); | 941 const std::string fileName("fixed_layout.html"); |
| 943 | 942 |
| 944 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); | 943 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); |
| 945 FrameTestHelpers::WebViewHelper webViewHelper; | 944 FrameTestHelpers::WebViewHelper webViewHelper; |
| 946 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true); | 945 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true); |
| 947 int pageWidth = 640; | 946 int pageWidth = 640; |
| 948 int pageHeight = 480; | 947 int pageHeight = 480; |
| 949 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | 948 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
| 950 webViewImpl->updateAllLifecyclePhases(); | 949 webViewImpl->updateAllLifecyclePhases(); |
| 951 | 950 |
| 952 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); | 951 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); |
| 953 | 952 |
| 954 { | 953 { |
| 955 WebMouseWheelEvent webMouseWheelEvent; | 954 WebMouseWheelEvent webMouseWheelEvent; |
| 956 webMouseWheelEvent.type = WebInputEvent::MouseWheel; | 955 webMouseWheelEvent.type = WebInputEvent::MouseWheel; |
| 957 webMouseWheelEvent.x = 0; | 956 webMouseWheelEvent.x = 0; |
| 958 webMouseWheelEvent.y = 5; | 957 webMouseWheelEvent.y = 5; |
| 959 webMouseWheelEvent.deltaX = 10; | 958 webMouseWheelEvent.deltaX = 10; |
| 960 webMouseWheelEvent.deltaY = 15; | 959 webMouseWheelEvent.deltaY = 15; |
| 961 webMouseWheelEvent.modifiers = WebInputEvent::ControlKey; | 960 webMouseWheelEvent.modifiers = WebInputEvent::ControlKey; |
| 962 webMouseWheelEvent.hasPreciseScrollingDeltas = true; | 961 webMouseWheelEvent.hasPreciseScrollingDeltas = true; |
| 963 webMouseWheelEvent.canScroll = true; | |
| 964 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeHorizontal; | 962 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeHorizontal; |
| 965 | 963 |
| 966 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent)
; | 964 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent)
; |
| 967 EXPECT_EQ(0, platformWheelBuilder.position().x()); | 965 EXPECT_EQ(0, platformWheelBuilder.position().x()); |
| 968 EXPECT_EQ(5, platformWheelBuilder.position().y()); | 966 EXPECT_EQ(5, platformWheelBuilder.position().y()); |
| 969 EXPECT_EQ(10, platformWheelBuilder.deltaX()); | 967 EXPECT_EQ(10, platformWheelBuilder.deltaX()); |
| 970 EXPECT_EQ(15, platformWheelBuilder.deltaY()); | 968 EXPECT_EQ(15, platformWheelBuilder.deltaY()); |
| 971 EXPECT_EQ(PlatformEvent::CtrlKey, platformWheelBuilder.getModifiers()); | 969 EXPECT_EQ(PlatformEvent::CtrlKey, platformWheelBuilder.getModifiers()); |
| 972 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); | 970 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); |
| 973 EXPECT_TRUE(platformWheelBuilder.canScroll()); | |
| 974 EXPECT_EQ(platformWheelBuilder.getRailsMode(), PlatformEvent::RailsModeH
orizontal); | 971 EXPECT_EQ(platformWheelBuilder.getRailsMode(), PlatformEvent::RailsModeH
orizontal); |
| 975 } | 972 } |
| 976 | 973 |
| 977 { | 974 { |
| 978 WebMouseWheelEvent webMouseWheelEvent; | 975 WebMouseWheelEvent webMouseWheelEvent; |
| 979 webMouseWheelEvent.type = WebInputEvent::MouseWheel; | 976 webMouseWheelEvent.type = WebInputEvent::MouseWheel; |
| 980 webMouseWheelEvent.x = 5; | 977 webMouseWheelEvent.x = 5; |
| 981 webMouseWheelEvent.y = 0; | 978 webMouseWheelEvent.y = 0; |
| 982 webMouseWheelEvent.deltaX = 15; | 979 webMouseWheelEvent.deltaX = 15; |
| 983 webMouseWheelEvent.deltaY = 10; | 980 webMouseWheelEvent.deltaY = 10; |
| 984 webMouseWheelEvent.modifiers = WebInputEvent::ShiftKey; | 981 webMouseWheelEvent.modifiers = WebInputEvent::ShiftKey; |
| 985 webMouseWheelEvent.hasPreciseScrollingDeltas = false; | 982 webMouseWheelEvent.hasPreciseScrollingDeltas = false; |
| 986 webMouseWheelEvent.canScroll = false; | |
| 987 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeFree; | 983 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeFree; |
| 988 | 984 |
| 989 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent)
; | 985 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent)
; |
| 990 EXPECT_EQ(5, platformWheelBuilder.position().x()); | 986 EXPECT_EQ(5, platformWheelBuilder.position().x()); |
| 991 EXPECT_EQ(0, platformWheelBuilder.position().y()); | 987 EXPECT_EQ(0, platformWheelBuilder.position().y()); |
| 992 EXPECT_EQ(15, platformWheelBuilder.deltaX()); | 988 EXPECT_EQ(15, platformWheelBuilder.deltaX()); |
| 993 EXPECT_EQ(10, platformWheelBuilder.deltaY()); | 989 EXPECT_EQ(10, platformWheelBuilder.deltaY()); |
| 994 EXPECT_EQ(PlatformEvent::ShiftKey, platformWheelBuilder.getModifiers()); | 990 EXPECT_EQ(PlatformEvent::ShiftKey, platformWheelBuilder.getModifiers()); |
| 995 EXPECT_FALSE(platformWheelBuilder.hasPreciseScrollingDeltas()); | 991 EXPECT_FALSE(platformWheelBuilder.hasPreciseScrollingDeltas()); |
| 996 EXPECT_FALSE(platformWheelBuilder.canScroll()); | |
| 997 EXPECT_EQ(platformWheelBuilder.getRailsMode(), PlatformEvent::RailsModeF
ree); | 992 EXPECT_EQ(platformWheelBuilder.getRailsMode(), PlatformEvent::RailsModeF
ree); |
| 998 } | 993 } |
| 999 | 994 |
| 1000 { | 995 { |
| 1001 WebMouseWheelEvent webMouseWheelEvent; | 996 WebMouseWheelEvent webMouseWheelEvent; |
| 1002 webMouseWheelEvent.type = WebInputEvent::MouseWheel; | 997 webMouseWheelEvent.type = WebInputEvent::MouseWheel; |
| 1003 webMouseWheelEvent.x = 5; | 998 webMouseWheelEvent.x = 5; |
| 1004 webMouseWheelEvent.y = 0; | 999 webMouseWheelEvent.y = 0; |
| 1005 webMouseWheelEvent.deltaX = 15; | 1000 webMouseWheelEvent.deltaX = 15; |
| 1006 webMouseWheelEvent.deltaY = 10; | 1001 webMouseWheelEvent.deltaY = 10; |
| 1007 webMouseWheelEvent.modifiers = WebInputEvent::AltKey; | 1002 webMouseWheelEvent.modifiers = WebInputEvent::AltKey; |
| 1008 webMouseWheelEvent.hasPreciseScrollingDeltas = true; | 1003 webMouseWheelEvent.hasPreciseScrollingDeltas = true; |
| 1009 webMouseWheelEvent.canScroll = false; | |
| 1010 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeVertical; | 1004 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeVertical; |
| 1011 | 1005 |
| 1012 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent)
; | 1006 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent)
; |
| 1013 EXPECT_EQ(5, platformWheelBuilder.position().x()); | 1007 EXPECT_EQ(5, platformWheelBuilder.position().x()); |
| 1014 EXPECT_EQ(0, platformWheelBuilder.position().y()); | 1008 EXPECT_EQ(0, platformWheelBuilder.position().y()); |
| 1015 EXPECT_EQ(15, platformWheelBuilder.deltaX()); | 1009 EXPECT_EQ(15, platformWheelBuilder.deltaX()); |
| 1016 EXPECT_EQ(10, platformWheelBuilder.deltaY()); | 1010 EXPECT_EQ(10, platformWheelBuilder.deltaY()); |
| 1017 EXPECT_EQ(PlatformEvent::AltKey, platformWheelBuilder.getModifiers()); | 1011 EXPECT_EQ(PlatformEvent::AltKey, platformWheelBuilder.getModifiers()); |
| 1018 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); | 1012 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); |
| 1019 EXPECT_FALSE(platformWheelBuilder.canScroll()); | |
| 1020 EXPECT_EQ(platformWheelBuilder.getRailsMode(), PlatformEvent::RailsModeV
ertical); | 1013 EXPECT_EQ(platformWheelBuilder.getRailsMode(), PlatformEvent::RailsModeV
ertical); |
| 1021 } | 1014 } |
| 1022 } | 1015 } |
| 1023 | 1016 |
| 1024 TEST(WebInputEventConversionTest, PlatformGestureEventBuilder) | 1017 TEST(WebInputEventConversionTest, PlatformGestureEventBuilder) |
| 1025 { | 1018 { |
| 1026 const std::string baseURL("http://www.test8.com/"); | 1019 const std::string baseURL("http://www.test8.com/"); |
| 1027 const std::string fileName("fixed_layout.html"); | 1020 const std::string fileName("fixed_layout.html"); |
| 1028 | 1021 |
| 1029 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); | 1022 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 EXPECT_EQ(5, platformGestureBuilder.position().y()); | 1078 EXPECT_EQ(5, platformGestureBuilder.position().y()); |
| 1086 EXPECT_EQ(10, platformGestureBuilder.globalPosition().x()); | 1079 EXPECT_EQ(10, platformGestureBuilder.globalPosition().x()); |
| 1087 EXPECT_EQ(15, platformGestureBuilder.globalPosition().y()); | 1080 EXPECT_EQ(15, platformGestureBuilder.globalPosition().y()); |
| 1088 EXPECT_EQ(ScrollInertialPhaseNonMomentum, platformGestureBuilder.inertia
lPhase()); | 1081 EXPECT_EQ(ScrollInertialPhaseNonMomentum, platformGestureBuilder.inertia
lPhase()); |
| 1089 EXPECT_TRUE(platformGestureBuilder.synthetic()); | 1082 EXPECT_TRUE(platformGestureBuilder.synthetic()); |
| 1090 EXPECT_EQ(ScrollGranularity::ScrollByPage, platformGestureBuilder.deltaU
nits()); | 1083 EXPECT_EQ(ScrollGranularity::ScrollByPage, platformGestureBuilder.deltaU
nits()); |
| 1091 } | 1084 } |
| 1092 } | 1085 } |
| 1093 | 1086 |
| 1094 } // namespace blink | 1087 } // namespace blink |
| OLD | NEW |