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 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
906 { | 906 { |
907 WebMouseWheelEvent webMouseWheelEvent; | 907 WebMouseWheelEvent webMouseWheelEvent; |
908 webMouseWheelEvent.type = WebInputEvent::MouseWheel; | 908 webMouseWheelEvent.type = WebInputEvent::MouseWheel; |
909 webMouseWheelEvent.x = 10; | 909 webMouseWheelEvent.x = 10; |
910 webMouseWheelEvent.y = 10; | 910 webMouseWheelEvent.y = 10; |
911 webMouseWheelEvent.windowX = 10; | 911 webMouseWheelEvent.windowX = 10; |
912 webMouseWheelEvent.windowY = 10; | 912 webMouseWheelEvent.windowY = 10; |
913 webMouseWheelEvent.globalX = 10; | 913 webMouseWheelEvent.globalX = 10; |
914 webMouseWheelEvent.globalY = 10; | 914 webMouseWheelEvent.globalY = 10; |
915 | 915 |
916 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent); | 916 WebMouseWheelEvent scaledMouseWheelEvent = |
917 EXPECT_EQ(5 + visualOffset.x(), platformWheelBuilder.position().x()); | 917 TransformWebMouseWheelEvent(view, webMouseWheelEvent); |
918 EXPECT_EQ(5 + visualOffset.y(), platformWheelBuilder.position().y()); | 918 IntPoint position = |
919 EXPECT_EQ(10, platformWheelBuilder.globalPosition().x()); | 919 flooredIntPoint(scaledMouseWheelEvent.positionInRootFrame()); |
920 EXPECT_EQ(10, platformWheelBuilder.globalPosition().y()); | 920 EXPECT_EQ(5 + visualOffset.x(), position.x()); |
921 EXPECT_EQ(5 + visualOffset.y(), position.y()); | |
922 EXPECT_EQ(10, scaledMouseWheelEvent.globalX); | |
923 EXPECT_EQ(10, scaledMouseWheelEvent.globalY); | |
921 } | 924 } |
922 | 925 |
923 { | 926 { |
924 WebGestureEvent webGestureEvent; | 927 WebGestureEvent webGestureEvent; |
925 webGestureEvent.type = WebInputEvent::GestureScrollUpdate; | 928 webGestureEvent.type = WebInputEvent::GestureScrollUpdate; |
926 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 929 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
927 webGestureEvent.x = 10; | 930 webGestureEvent.x = 10; |
928 webGestureEvent.y = 10; | 931 webGestureEvent.y = 10; |
929 webGestureEvent.globalX = 10; | 932 webGestureEvent.globalX = 10; |
930 webGestureEvent.globalY = 10; | 933 webGestureEvent.globalY = 10; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1072 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); | 1075 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); |
1073 EXPECT_EQ(webMouseEvent.x + elasticOverscroll.width(), | 1076 EXPECT_EQ(webMouseEvent.x + elasticOverscroll.width(), |
1074 platformMouseBuilder.position().x()); | 1077 platformMouseBuilder.position().x()); |
1075 EXPECT_EQ(webMouseEvent.y + elasticOverscroll.height(), | 1078 EXPECT_EQ(webMouseEvent.y + elasticOverscroll.height(), |
1076 platformMouseBuilder.position().y()); | 1079 platformMouseBuilder.position().y()); |
1077 EXPECT_EQ(webMouseEvent.globalX, platformMouseBuilder.globalPosition().x()); | 1080 EXPECT_EQ(webMouseEvent.globalX, platformMouseBuilder.globalPosition().x()); |
1078 EXPECT_EQ(webMouseEvent.globalY, platformMouseBuilder.globalPosition().y()); | 1081 EXPECT_EQ(webMouseEvent.globalY, platformMouseBuilder.globalPosition().y()); |
1079 } | 1082 } |
1080 } | 1083 } |
1081 | 1084 |
1082 TEST(WebInputEventConversionTest, WebMouseWheelEventBuilder) { | |
majidvp
2016/12/20 17:30:15
I think we should replace this test with something
dtapuska
2017/01/03 20:19:14
Done; added to WebPluginContainerTest.cpp
| |
1083 const std::string baseURL("http://www.test7.com/"); | |
1084 const std::string fileName("fixed_layout.html"); | |
1085 | |
1086 URLTestHelpers::registerMockedURLFromBaseURL( | |
1087 WebString::fromUTF8(baseURL.c_str()), | |
1088 WebString::fromUTF8("fixed_layout.html")); | |
1089 FrameTestHelpers::WebViewHelper webViewHelper; | |
1090 WebViewImpl* webViewImpl = | |
1091 webViewHelper.initializeAndLoad(baseURL + fileName, true); | |
1092 int pageWidth = 640; | |
1093 int pageHeight = 480; | |
1094 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | |
1095 webViewImpl->updateAllLifecyclePhases(); | |
1096 | |
1097 Document* document = | |
1098 toLocalFrame(webViewImpl->page()->mainFrame())->document(); | |
1099 { | |
1100 WheelEvent* event = WheelEvent::create( | |
1101 FloatPoint(1, 3), FloatPoint(5, 10), WheelEvent::kDomDeltaPage, | |
1102 document->domWindow(), IntPoint(2, 6), IntPoint(10, 30), | |
1103 PlatformEvent::CtrlKey, 0, TimeTicks(), -1 /* null plugin id */, | |
1104 true /* hasPreciseScrollingDeltas */, Event::RailsModeHorizontal, | |
1105 true /*cancelable*/ | |
1106 #if OS(MACOSX) | |
1107 , | |
1108 WheelEventPhaseBegan, WheelEventPhaseChanged | |
1109 #endif | |
1110 ); | |
1111 WebMouseWheelEventBuilder webMouseWheel( | |
1112 toLocalFrame(webViewImpl->page()->mainFrame())->view(), | |
1113 document->layoutViewItem(), *event); | |
1114 EXPECT_EQ(1, webMouseWheel.wheelTicksX); | |
1115 EXPECT_EQ(3, webMouseWheel.wheelTicksY); | |
1116 EXPECT_EQ(5, webMouseWheel.deltaX); | |
1117 EXPECT_EQ(10, webMouseWheel.deltaY); | |
1118 EXPECT_EQ(2, webMouseWheel.globalX); | |
1119 EXPECT_EQ(6, webMouseWheel.globalY); | |
1120 EXPECT_EQ(10, webMouseWheel.windowX); | |
1121 EXPECT_EQ(30, webMouseWheel.windowY); | |
1122 EXPECT_TRUE(webMouseWheel.scrollByPage); | |
1123 EXPECT_EQ(WebInputEvent::ControlKey, webMouseWheel.modifiers); | |
1124 EXPECT_EQ(WebInputEvent::RailsModeHorizontal, webMouseWheel.railsMode); | |
1125 EXPECT_TRUE(webMouseWheel.hasPreciseScrollingDeltas); | |
1126 EXPECT_EQ(WebInputEvent::Blocking, webMouseWheel.dispatchType); | |
1127 #if OS(MACOSX) | |
1128 EXPECT_EQ(WebMouseWheelEvent::PhaseBegan, webMouseWheel.phase); | |
1129 EXPECT_EQ(WebMouseWheelEvent::PhaseChanged, webMouseWheel.momentumPhase); | |
1130 #endif | |
1131 } | |
1132 | |
1133 { | |
1134 WheelEvent* event = WheelEvent::create( | |
1135 FloatPoint(1, 3), FloatPoint(5, 10), WheelEvent::kDomDeltaPage, | |
1136 document->domWindow(), IntPoint(2, 6), IntPoint(10, 30), | |
1137 PlatformEvent::CtrlKey, 0, TimeTicks(), -1 /* null plugin id */, | |
1138 true /* hasPreciseScrollingDeltas */, Event::RailsModeHorizontal, false | |
1139 #if OS(MACOSX) | |
1140 , | |
1141 WheelEventPhaseNone, WheelEventPhaseNone | |
1142 #endif | |
1143 ); | |
1144 WebMouseWheelEventBuilder webMouseWheel( | |
1145 toLocalFrame(webViewImpl->page()->mainFrame())->view(), | |
1146 document->layoutViewItem(), *event); | |
1147 EXPECT_EQ(WebInputEvent::EventNonBlocking, webMouseWheel.dispatchType); | |
1148 } | |
1149 } | |
1150 | |
1151 TEST(WebInputEventConversionTest, PlatformWheelEventBuilder) { | |
1152 const std::string baseURL("http://www.test8.com/"); | |
1153 const std::string fileName("fixed_layout.html"); | |
1154 | |
1155 URLTestHelpers::registerMockedURLFromBaseURL( | |
1156 WebString::fromUTF8(baseURL.c_str()), | |
1157 WebString::fromUTF8("fixed_layout.html")); | |
1158 FrameTestHelpers::WebViewHelper webViewHelper; | |
1159 WebViewImpl* webViewImpl = | |
1160 webViewHelper.initializeAndLoad(baseURL + fileName, true); | |
1161 int pageWidth = 640; | |
1162 int pageHeight = 480; | |
1163 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | |
1164 webViewImpl->updateAllLifecyclePhases(); | |
1165 | |
1166 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); | |
1167 | |
1168 { | |
1169 WebMouseWheelEvent webMouseWheelEvent; | |
1170 webMouseWheelEvent.type = WebInputEvent::MouseWheel; | |
1171 webMouseWheelEvent.x = 0; | |
1172 webMouseWheelEvent.y = 5; | |
1173 webMouseWheelEvent.deltaX = 10; | |
1174 webMouseWheelEvent.deltaY = 15; | |
1175 webMouseWheelEvent.modifiers = WebInputEvent::ControlKey; | |
1176 webMouseWheelEvent.hasPreciseScrollingDeltas = true; | |
1177 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeHorizontal; | |
1178 webMouseWheelEvent.phase = WebMouseWheelEvent::PhaseBegan; | |
1179 webMouseWheelEvent.momentumPhase = WebMouseWheelEvent::PhaseChanged; | |
1180 | |
1181 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent); | |
1182 EXPECT_EQ(0, platformWheelBuilder.position().x()); | |
1183 EXPECT_EQ(5, platformWheelBuilder.position().y()); | |
1184 EXPECT_EQ(10, platformWheelBuilder.deltaX()); | |
1185 EXPECT_EQ(15, platformWheelBuilder.deltaY()); | |
1186 EXPECT_EQ(PlatformEvent::CtrlKey, platformWheelBuilder.getModifiers()); | |
1187 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); | |
1188 EXPECT_EQ(platformWheelBuilder.getRailsMode(), | |
1189 PlatformEvent::RailsModeHorizontal); | |
1190 #if OS(MACOSX) | |
1191 EXPECT_EQ(PlatformWheelEventPhaseBegan, platformWheelBuilder.phase()); | |
1192 EXPECT_EQ(PlatformWheelEventPhaseChanged, | |
1193 platformWheelBuilder.momentumPhase()); | |
1194 #endif | |
1195 } | |
1196 | |
1197 { | |
1198 WebMouseWheelEvent webMouseWheelEvent; | |
1199 webMouseWheelEvent.type = WebInputEvent::MouseWheel; | |
1200 webMouseWheelEvent.x = 5; | |
1201 webMouseWheelEvent.y = 0; | |
1202 webMouseWheelEvent.deltaX = 15; | |
1203 webMouseWheelEvent.deltaY = 10; | |
1204 webMouseWheelEvent.modifiers = WebInputEvent::ShiftKey; | |
1205 webMouseWheelEvent.hasPreciseScrollingDeltas = false; | |
1206 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeFree; | |
1207 webMouseWheelEvent.phase = WebMouseWheelEvent::PhaseNone; | |
1208 webMouseWheelEvent.momentumPhase = WebMouseWheelEvent::PhaseNone; | |
1209 | |
1210 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent); | |
1211 EXPECT_EQ(5, platformWheelBuilder.position().x()); | |
1212 EXPECT_EQ(0, platformWheelBuilder.position().y()); | |
1213 EXPECT_EQ(15, platformWheelBuilder.deltaX()); | |
1214 EXPECT_EQ(10, platformWheelBuilder.deltaY()); | |
1215 EXPECT_EQ(PlatformEvent::ShiftKey, platformWheelBuilder.getModifiers()); | |
1216 EXPECT_FALSE(platformWheelBuilder.hasPreciseScrollingDeltas()); | |
1217 EXPECT_EQ(platformWheelBuilder.getRailsMode(), | |
1218 PlatformEvent::RailsModeFree); | |
1219 #if OS(MACOSX) | |
1220 EXPECT_EQ(PlatformWheelEventPhaseNone, platformWheelBuilder.phase()); | |
1221 EXPECT_EQ(PlatformWheelEventPhaseNone, | |
1222 platformWheelBuilder.momentumPhase()); | |
1223 #endif | |
1224 } | |
1225 | |
1226 { | |
1227 WebMouseWheelEvent webMouseWheelEvent; | |
1228 webMouseWheelEvent.type = WebInputEvent::MouseWheel; | |
1229 webMouseWheelEvent.x = 5; | |
1230 webMouseWheelEvent.y = 0; | |
1231 webMouseWheelEvent.deltaX = 15; | |
1232 webMouseWheelEvent.deltaY = 10; | |
1233 webMouseWheelEvent.modifiers = WebInputEvent::AltKey; | |
1234 webMouseWheelEvent.hasPreciseScrollingDeltas = true; | |
1235 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeVertical; | |
1236 webMouseWheelEvent.phase = WebMouseWheelEvent::PhaseNone; | |
1237 webMouseWheelEvent.momentumPhase = WebMouseWheelEvent::PhaseNone; | |
1238 | |
1239 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent); | |
1240 EXPECT_EQ(5, platformWheelBuilder.position().x()); | |
1241 EXPECT_EQ(0, platformWheelBuilder.position().y()); | |
1242 EXPECT_EQ(15, platformWheelBuilder.deltaX()); | |
1243 EXPECT_EQ(10, platformWheelBuilder.deltaY()); | |
1244 EXPECT_EQ(PlatformEvent::AltKey, platformWheelBuilder.getModifiers()); | |
1245 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); | |
1246 EXPECT_EQ(platformWheelBuilder.getRailsMode(), | |
1247 PlatformEvent::RailsModeVertical); | |
1248 #if OS(MACOSX) | |
1249 EXPECT_EQ(PlatformWheelEventPhaseNone, platformWheelBuilder.phase()); | |
1250 EXPECT_EQ(PlatformWheelEventPhaseNone, | |
1251 platformWheelBuilder.momentumPhase()); | |
1252 #endif | |
1253 } | |
1254 } | |
1255 | |
1256 } // namespace blink | 1085 } // namespace blink |
OLD | NEW |