| 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 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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::kDomDeltaPage, document->domWindow(), IntPoint(2, 6), In
tPoint(10, 30), | 910 WheelEvent::kDomDeltaPage, document->domWindow(), IntPoint(2, 6), In
tPoint(10, 30), |
| 911 PlatformEvent::CtrlKey, 0, 0, -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 #if OS(MACOSX) |
| 914 , WheelEventPhaseBegan, WheelEventPhaseChanged, true, false |
| 915 #endif |
| 916 ); |
| 913 WebMouseWheelEventBuilder webMouseWheel(toLocalFrame(webViewImpl->page()
->mainFrame())->view(), document->layoutViewItem(), *event); | 917 WebMouseWheelEventBuilder webMouseWheel(toLocalFrame(webViewImpl->page()
->mainFrame())->view(), document->layoutViewItem(), *event); |
| 914 EXPECT_EQ(1, webMouseWheel.wheelTicksX); | 918 EXPECT_EQ(1, webMouseWheel.wheelTicksX); |
| 915 EXPECT_EQ(3, webMouseWheel.wheelTicksY); | 919 EXPECT_EQ(3, webMouseWheel.wheelTicksY); |
| 916 EXPECT_EQ(5, webMouseWheel.deltaX); | 920 EXPECT_EQ(5, webMouseWheel.deltaX); |
| 917 EXPECT_EQ(10, webMouseWheel.deltaY); | 921 EXPECT_EQ(10, webMouseWheel.deltaY); |
| 918 EXPECT_EQ(2, webMouseWheel.globalX); | 922 EXPECT_EQ(2, webMouseWheel.globalX); |
| 919 EXPECT_EQ(6, webMouseWheel.globalY); | 923 EXPECT_EQ(6, webMouseWheel.globalY); |
| 920 EXPECT_EQ(10, webMouseWheel.windowX); | 924 EXPECT_EQ(10, webMouseWheel.windowX); |
| 921 EXPECT_EQ(30, webMouseWheel.windowY); | 925 EXPECT_EQ(30, webMouseWheel.windowY); |
| 922 EXPECT_TRUE(webMouseWheel.scrollByPage); | 926 EXPECT_TRUE(webMouseWheel.scrollByPage); |
| 923 EXPECT_EQ(WebInputEvent::ControlKey, webMouseWheel.modifiers); | 927 EXPECT_EQ(WebInputEvent::ControlKey, webMouseWheel.modifiers); |
| 924 EXPECT_EQ(WebInputEvent::RailsModeHorizontal, webMouseWheel.railsMode); | 928 EXPECT_EQ(WebInputEvent::RailsModeHorizontal, webMouseWheel.railsMode); |
| 925 EXPECT_TRUE(webMouseWheel.hasPreciseScrollingDeltas); | 929 EXPECT_TRUE(webMouseWheel.hasPreciseScrollingDeltas); |
| 926 EXPECT_EQ(WebInputEvent::Blocking, webMouseWheel.dispatchType); | 930 EXPECT_EQ(WebInputEvent::Blocking, webMouseWheel.dispatchType); |
| 931 #if OS(MACOSX) |
| 932 EXPECT_EQ(WebMouseWheelEvent::PhaseBegan, webMouseWheel.phase); |
| 933 EXPECT_EQ(WebMouseWheelEvent::PhaseChanged, webMouseWheel.momentumPhase)
; |
| 934 EXPECT_TRUE(webMouseWheel.canRubberbandLeft); |
| 935 EXPECT_FALSE(webMouseWheel.canRubberbandRight); |
| 936 #endif |
| 927 } | 937 } |
| 928 | 938 |
| 929 { | 939 { |
| 930 WheelEvent* event = WheelEvent::create(FloatPoint(1, 3), FloatPoint(5, 1
0), | 940 WheelEvent* event = WheelEvent::create(FloatPoint(1, 3), FloatPoint(5, 1
0), |
| 931 WheelEvent::kDomDeltaPage, document->domWindow(), IntPoint(2, 6), In
tPoint(10, 30), | 941 WheelEvent::kDomDeltaPage, document->domWindow(), IntPoint(2, 6), In
tPoint(10, 30), |
| 932 PlatformEvent::CtrlKey, 0, 0, -1 /* null plugin id */, true /* hasPr
eciseScrollingDeltas */, Event::RailsModeHorizontal, false); | 942 PlatformEvent::CtrlKey, 0, 0, -1 /* null plugin id */, true /* hasPr
eciseScrollingDeltas */, Event::RailsModeHorizontal, false |
| 943 #if OS(MACOSX) |
| 944 , WheelEventPhaseNone, WheelEventPhaseNone, true, true |
| 945 #endif |
| 946 ); |
| 933 WebMouseWheelEventBuilder webMouseWheel(toLocalFrame(webViewImpl->page()
->mainFrame())->view(), document->layoutViewItem(), *event); | 947 WebMouseWheelEventBuilder webMouseWheel(toLocalFrame(webViewImpl->page()
->mainFrame())->view(), document->layoutViewItem(), *event); |
| 934 EXPECT_EQ(WebInputEvent::EventNonBlocking, webMouseWheel.dispatchType); | 948 EXPECT_EQ(WebInputEvent::EventNonBlocking, webMouseWheel.dispatchType); |
| 935 } | 949 } |
| 936 } | 950 } |
| 937 | 951 |
| 938 TEST(WebInputEventConversionTest, PlatformWheelEventBuilder) | 952 TEST(WebInputEventConversionTest, PlatformWheelEventBuilder) |
| 939 { | 953 { |
| 940 const std::string baseURL("http://www.test8.com/"); | 954 const std::string baseURL("http://www.test8.com/"); |
| 941 const std::string fileName("fixed_layout.html"); | 955 const std::string fileName("fixed_layout.html"); |
| 942 | 956 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 953 { | 967 { |
| 954 WebMouseWheelEvent webMouseWheelEvent; | 968 WebMouseWheelEvent webMouseWheelEvent; |
| 955 webMouseWheelEvent.type = WebInputEvent::MouseWheel; | 969 webMouseWheelEvent.type = WebInputEvent::MouseWheel; |
| 956 webMouseWheelEvent.x = 0; | 970 webMouseWheelEvent.x = 0; |
| 957 webMouseWheelEvent.y = 5; | 971 webMouseWheelEvent.y = 5; |
| 958 webMouseWheelEvent.deltaX = 10; | 972 webMouseWheelEvent.deltaX = 10; |
| 959 webMouseWheelEvent.deltaY = 15; | 973 webMouseWheelEvent.deltaY = 15; |
| 960 webMouseWheelEvent.modifiers = WebInputEvent::ControlKey; | 974 webMouseWheelEvent.modifiers = WebInputEvent::ControlKey; |
| 961 webMouseWheelEvent.hasPreciseScrollingDeltas = true; | 975 webMouseWheelEvent.hasPreciseScrollingDeltas = true; |
| 962 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeHorizontal; | 976 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeHorizontal; |
| 977 webMouseWheelEvent.phase = WebMouseWheelEvent::PhaseBegan; |
| 978 webMouseWheelEvent.momentumPhase = WebMouseWheelEvent::PhaseChanged; |
| 979 webMouseWheelEvent.canRubberbandLeft = true; |
| 980 webMouseWheelEvent.canRubberbandRight = false; |
| 963 | 981 |
| 964 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent)
; | 982 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent)
; |
| 965 EXPECT_EQ(0, platformWheelBuilder.position().x()); | 983 EXPECT_EQ(0, platformWheelBuilder.position().x()); |
| 966 EXPECT_EQ(5, platformWheelBuilder.position().y()); | 984 EXPECT_EQ(5, platformWheelBuilder.position().y()); |
| 967 EXPECT_EQ(10, platformWheelBuilder.deltaX()); | 985 EXPECT_EQ(10, platformWheelBuilder.deltaX()); |
| 968 EXPECT_EQ(15, platformWheelBuilder.deltaY()); | 986 EXPECT_EQ(15, platformWheelBuilder.deltaY()); |
| 969 EXPECT_EQ(PlatformEvent::CtrlKey, platformWheelBuilder.getModifiers()); | 987 EXPECT_EQ(PlatformEvent::CtrlKey, platformWheelBuilder.getModifiers()); |
| 970 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); | 988 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); |
| 971 EXPECT_EQ(platformWheelBuilder.getRailsMode(), PlatformEvent::RailsModeH
orizontal); | 989 EXPECT_EQ(platformWheelBuilder.getRailsMode(), PlatformEvent::RailsModeH
orizontal); |
| 990 #if OS(MACOSX) |
| 991 EXPECT_EQ(PlatformWheelEventPhaseBegan, platformWheelBuilder.phase()); |
| 992 EXPECT_EQ(PlatformWheelEventPhaseChanged, platformWheelBuilder.momentumP
hase()); |
| 993 EXPECT_TRUE(platformWheelBuilder.canRubberbandLeft()); |
| 994 EXPECT_FALSE(platformWheelBuilder.canRubberbandRight()); |
| 995 #endif |
| 972 } | 996 } |
| 973 | 997 |
| 974 { | 998 { |
| 975 WebMouseWheelEvent webMouseWheelEvent; | 999 WebMouseWheelEvent webMouseWheelEvent; |
| 976 webMouseWheelEvent.type = WebInputEvent::MouseWheel; | 1000 webMouseWheelEvent.type = WebInputEvent::MouseWheel; |
| 977 webMouseWheelEvent.x = 5; | 1001 webMouseWheelEvent.x = 5; |
| 978 webMouseWheelEvent.y = 0; | 1002 webMouseWheelEvent.y = 0; |
| 979 webMouseWheelEvent.deltaX = 15; | 1003 webMouseWheelEvent.deltaX = 15; |
| 980 webMouseWheelEvent.deltaY = 10; | 1004 webMouseWheelEvent.deltaY = 10; |
| 981 webMouseWheelEvent.modifiers = WebInputEvent::ShiftKey; | 1005 webMouseWheelEvent.modifiers = WebInputEvent::ShiftKey; |
| 982 webMouseWheelEvent.hasPreciseScrollingDeltas = false; | 1006 webMouseWheelEvent.hasPreciseScrollingDeltas = false; |
| 983 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeFree; | 1007 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeFree; |
| 1008 webMouseWheelEvent.phase = WebMouseWheelEvent::PhaseNone; |
| 1009 webMouseWheelEvent.momentumPhase = WebMouseWheelEvent::PhaseNone; |
| 1010 webMouseWheelEvent.canRubberbandLeft = true; |
| 1011 webMouseWheelEvent.canRubberbandRight = true; |
| 984 | 1012 |
| 985 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent)
; | 1013 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent)
; |
| 986 EXPECT_EQ(5, platformWheelBuilder.position().x()); | 1014 EXPECT_EQ(5, platformWheelBuilder.position().x()); |
| 987 EXPECT_EQ(0, platformWheelBuilder.position().y()); | 1015 EXPECT_EQ(0, platformWheelBuilder.position().y()); |
| 988 EXPECT_EQ(15, platformWheelBuilder.deltaX()); | 1016 EXPECT_EQ(15, platformWheelBuilder.deltaX()); |
| 989 EXPECT_EQ(10, platformWheelBuilder.deltaY()); | 1017 EXPECT_EQ(10, platformWheelBuilder.deltaY()); |
| 990 EXPECT_EQ(PlatformEvent::ShiftKey, platformWheelBuilder.getModifiers()); | 1018 EXPECT_EQ(PlatformEvent::ShiftKey, platformWheelBuilder.getModifiers()); |
| 991 EXPECT_FALSE(platformWheelBuilder.hasPreciseScrollingDeltas()); | 1019 EXPECT_FALSE(platformWheelBuilder.hasPreciseScrollingDeltas()); |
| 992 EXPECT_EQ(platformWheelBuilder.getRailsMode(), PlatformEvent::RailsModeF
ree); | 1020 EXPECT_EQ(platformWheelBuilder.getRailsMode(), PlatformEvent::RailsModeF
ree); |
| 1021 #if OS(MACOSX) |
| 1022 EXPECT_EQ(PlatformWheelEventPhaseNone, platformWheelBuilder.phase()); |
| 1023 EXPECT_EQ(PlatformWheelEventPhaseNone, platformWheelBuilder.momentumPhas
e()); |
| 1024 EXPECT_TRUE(platformWheelBuilder.canRubberbandLeft()); |
| 1025 EXPECT_TRUE(platformWheelBuilder.canRubberbandRight()); |
| 1026 #endif |
| 993 } | 1027 } |
| 994 | 1028 |
| 995 { | 1029 { |
| 996 WebMouseWheelEvent webMouseWheelEvent; | 1030 WebMouseWheelEvent webMouseWheelEvent; |
| 997 webMouseWheelEvent.type = WebInputEvent::MouseWheel; | 1031 webMouseWheelEvent.type = WebInputEvent::MouseWheel; |
| 998 webMouseWheelEvent.x = 5; | 1032 webMouseWheelEvent.x = 5; |
| 999 webMouseWheelEvent.y = 0; | 1033 webMouseWheelEvent.y = 0; |
| 1000 webMouseWheelEvent.deltaX = 15; | 1034 webMouseWheelEvent.deltaX = 15; |
| 1001 webMouseWheelEvent.deltaY = 10; | 1035 webMouseWheelEvent.deltaY = 10; |
| 1002 webMouseWheelEvent.modifiers = WebInputEvent::AltKey; | 1036 webMouseWheelEvent.modifiers = WebInputEvent::AltKey; |
| 1003 webMouseWheelEvent.hasPreciseScrollingDeltas = true; | 1037 webMouseWheelEvent.hasPreciseScrollingDeltas = true; |
| 1004 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeVertical; | 1038 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeVertical; |
| 1039 webMouseWheelEvent.phase = WebMouseWheelEvent::PhaseNone; |
| 1040 webMouseWheelEvent.momentumPhase = WebMouseWheelEvent::PhaseNone; |
| 1041 webMouseWheelEvent.canRubberbandLeft = true; |
| 1042 webMouseWheelEvent.canRubberbandRight = true; |
| 1005 | 1043 |
| 1006 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent)
; | 1044 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent)
; |
| 1007 EXPECT_EQ(5, platformWheelBuilder.position().x()); | 1045 EXPECT_EQ(5, platformWheelBuilder.position().x()); |
| 1008 EXPECT_EQ(0, platformWheelBuilder.position().y()); | 1046 EXPECT_EQ(0, platformWheelBuilder.position().y()); |
| 1009 EXPECT_EQ(15, platformWheelBuilder.deltaX()); | 1047 EXPECT_EQ(15, platformWheelBuilder.deltaX()); |
| 1010 EXPECT_EQ(10, platformWheelBuilder.deltaY()); | 1048 EXPECT_EQ(10, platformWheelBuilder.deltaY()); |
| 1011 EXPECT_EQ(PlatformEvent::AltKey, platformWheelBuilder.getModifiers()); | 1049 EXPECT_EQ(PlatformEvent::AltKey, platformWheelBuilder.getModifiers()); |
| 1012 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); | 1050 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); |
| 1013 EXPECT_EQ(platformWheelBuilder.getRailsMode(), PlatformEvent::RailsModeV
ertical); | 1051 EXPECT_EQ(platformWheelBuilder.getRailsMode(), PlatformEvent::RailsModeV
ertical); |
| 1052 #if OS(MACOSX) |
| 1053 EXPECT_EQ(PlatformWheelEventPhaseNone, platformWheelBuilder.phase()); |
| 1054 EXPECT_EQ(PlatformWheelEventPhaseNone, platformWheelBuilder.momentumPhas
e()); |
| 1055 EXPECT_TRUE(platformWheelBuilder.canRubberbandLeft()); |
| 1056 EXPECT_TRUE(platformWheelBuilder.canRubberbandRight()); |
| 1057 #endif |
| 1014 } | 1058 } |
| 1015 } | 1059 } |
| 1016 | 1060 |
| 1017 TEST(WebInputEventConversionTest, PlatformGestureEventBuilder) | 1061 TEST(WebInputEventConversionTest, PlatformGestureEventBuilder) |
| 1018 { | 1062 { |
| 1019 const std::string baseURL("http://www.test8.com/"); | 1063 const std::string baseURL("http://www.test8.com/"); |
| 1020 const std::string fileName("fixed_layout.html"); | 1064 const std::string fileName("fixed_layout.html"); |
| 1021 | 1065 |
| 1022 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); | 1066 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); |
| 1023 FrameTestHelpers::WebViewHelper webViewHelper; | 1067 FrameTestHelpers::WebViewHelper webViewHelper; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 EXPECT_EQ(10, platformGestureBuilder.globalPosition().x()); | 1126 EXPECT_EQ(10, platformGestureBuilder.globalPosition().x()); |
| 1083 EXPECT_EQ(15, platformGestureBuilder.globalPosition().y()); | 1127 EXPECT_EQ(15, platformGestureBuilder.globalPosition().y()); |
| 1084 EXPECT_EQ(ScrollInertialPhaseNonMomentum, platformGestureBuilder.inertia
lPhase()); | 1128 EXPECT_EQ(ScrollInertialPhaseNonMomentum, platformGestureBuilder.inertia
lPhase()); |
| 1085 EXPECT_TRUE(platformGestureBuilder.synthetic()); | 1129 EXPECT_TRUE(platformGestureBuilder.synthetic()); |
| 1086 EXPECT_EQ(ScrollGranularity::ScrollByPage, platformGestureBuilder.deltaU
nits()); | 1130 EXPECT_EQ(ScrollGranularity::ScrollByPage, platformGestureBuilder.deltaU
nits()); |
| 1087 EXPECT_EQ(12345U, platformGestureBuilder.uniqueTouchEventId()); | 1131 EXPECT_EQ(12345U, platformGestureBuilder.uniqueTouchEventId()); |
| 1088 } | 1132 } |
| 1089 } | 1133 } |
| 1090 | 1134 |
| 1091 } // namespace blink | 1135 } // namespace blink |
| OLD | NEW |