Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: third_party/WebKit/Source/web/tests/WebInputEventConversionTest.cpp

Issue 2586133003: Remove PlatformWheelEvent and use WebMouseWheelEvent instead (Closed)
Patch Set: Address comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 WebMouseWheelEvent webMouseWheelEvent(WebInputEvent::MouseWheel, 930 WebMouseWheelEvent webMouseWheelEvent(WebInputEvent::MouseWheel,
931 WebInputEvent::NoModifiers, 931 WebInputEvent::NoModifiers,
932 WebInputEvent::TimeStampForTesting); 932 WebInputEvent::TimeStampForTesting);
933 webMouseWheelEvent.x = 10; 933 webMouseWheelEvent.x = 10;
934 webMouseWheelEvent.y = 10; 934 webMouseWheelEvent.y = 10;
935 webMouseWheelEvent.windowX = 10; 935 webMouseWheelEvent.windowX = 10;
936 webMouseWheelEvent.windowY = 10; 936 webMouseWheelEvent.windowY = 10;
937 webMouseWheelEvent.globalX = 10; 937 webMouseWheelEvent.globalX = 10;
938 webMouseWheelEvent.globalY = 10; 938 webMouseWheelEvent.globalY = 10;
939 939
940 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent); 940 WebMouseWheelEvent scaledMouseWheelEvent =
941 EXPECT_EQ(5 + visualOffset.x(), platformWheelBuilder.position().x()); 941 TransformWebMouseWheelEvent(view, webMouseWheelEvent);
942 EXPECT_EQ(5 + visualOffset.y(), platformWheelBuilder.position().y()); 942 IntPoint position =
943 EXPECT_EQ(10, platformWheelBuilder.globalPosition().x()); 943 flooredIntPoint(scaledMouseWheelEvent.positionInRootFrame());
944 EXPECT_EQ(10, platformWheelBuilder.globalPosition().y()); 944 EXPECT_EQ(5 + visualOffset.x(), position.x());
945 EXPECT_EQ(5 + visualOffset.y(), position.y());
946 EXPECT_EQ(10, scaledMouseWheelEvent.globalX);
947 EXPECT_EQ(10, scaledMouseWheelEvent.globalY);
945 } 948 }
946 949
947 { 950 {
948 WebGestureEvent webGestureEvent(WebInputEvent::GestureScrollUpdate, 951 WebGestureEvent webGestureEvent(WebInputEvent::GestureScrollUpdate,
949 WebInputEvent::NoModifiers, 952 WebInputEvent::NoModifiers,
950 WebInputEvent::TimeStampForTesting); 953 WebInputEvent::TimeStampForTesting);
951 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; 954 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen;
952 webGestureEvent.x = 10; 955 webGestureEvent.x = 10;
953 webGestureEvent.y = 10; 956 webGestureEvent.y = 10;
954 webGestureEvent.globalX = 10; 957 webGestureEvent.globalX = 10;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); 1104 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent);
1102 EXPECT_EQ(webMouseEvent.x + elasticOverscroll.width(), 1105 EXPECT_EQ(webMouseEvent.x + elasticOverscroll.width(),
1103 platformMouseBuilder.position().x()); 1106 platformMouseBuilder.position().x());
1104 EXPECT_EQ(webMouseEvent.y + elasticOverscroll.height(), 1107 EXPECT_EQ(webMouseEvent.y + elasticOverscroll.height(),
1105 platformMouseBuilder.position().y()); 1108 platformMouseBuilder.position().y());
1106 EXPECT_EQ(webMouseEvent.globalX, platformMouseBuilder.globalPosition().x()); 1109 EXPECT_EQ(webMouseEvent.globalX, platformMouseBuilder.globalPosition().x());
1107 EXPECT_EQ(webMouseEvent.globalY, platformMouseBuilder.globalPosition().y()); 1110 EXPECT_EQ(webMouseEvent.globalY, platformMouseBuilder.globalPosition().y());
1108 } 1111 }
1109 } 1112 }
1110 1113
1111 TEST(WebInputEventConversionTest, WebMouseWheelEventBuilder) {
1112 const std::string baseURL("http://www.test7.com/");
1113 const std::string fileName("fixed_layout.html");
1114
1115 URLTestHelpers::registerMockedURLFromBaseURL(
1116 WebString::fromUTF8(baseURL.c_str()),
1117 WebString::fromUTF8("fixed_layout.html"));
1118 FrameTestHelpers::WebViewHelper webViewHelper;
1119 WebViewImpl* webViewImpl =
1120 webViewHelper.initializeAndLoad(baseURL + fileName, true);
1121 int pageWidth = 640;
1122 int pageHeight = 480;
1123 webViewImpl->resize(WebSize(pageWidth, pageHeight));
1124 webViewImpl->updateAllLifecyclePhases();
1125
1126 Document* document =
1127 toLocalFrame(webViewImpl->page()->mainFrame())->document();
1128 {
1129 WheelEvent* event = WheelEvent::create(
1130 FloatPoint(1, 3), FloatPoint(5, 10), WheelEvent::kDomDeltaPage,
1131 document->domWindow(), IntPoint(2, 6), IntPoint(10, 30),
1132 PlatformEvent::CtrlKey, 0, TimeTicks(), -1 /* null plugin id */,
1133 true /* hasPreciseScrollingDeltas */, Event::RailsModeHorizontal,
1134 true /*cancelable*/
1135 #if OS(MACOSX)
1136 ,
1137 WheelEventPhaseBegan, WheelEventPhaseChanged
1138 #endif
1139 );
1140 WebMouseWheelEventBuilder webMouseWheel(
1141 toLocalFrame(webViewImpl->page()->mainFrame())->view(),
1142 document->layoutViewItem(), *event);
1143 EXPECT_EQ(1, webMouseWheel.wheelTicksX);
1144 EXPECT_EQ(3, webMouseWheel.wheelTicksY);
1145 EXPECT_EQ(5, webMouseWheel.deltaX);
1146 EXPECT_EQ(10, webMouseWheel.deltaY);
1147 EXPECT_EQ(2, webMouseWheel.globalX);
1148 EXPECT_EQ(6, webMouseWheel.globalY);
1149 EXPECT_EQ(10, webMouseWheel.windowX);
1150 EXPECT_EQ(30, webMouseWheel.windowY);
1151 EXPECT_TRUE(webMouseWheel.scrollByPage);
1152 EXPECT_EQ(WebInputEvent::ControlKey, webMouseWheel.modifiers);
1153 EXPECT_EQ(WebInputEvent::RailsModeHorizontal, webMouseWheel.railsMode);
1154 EXPECT_TRUE(webMouseWheel.hasPreciseScrollingDeltas);
1155 EXPECT_EQ(WebInputEvent::Blocking, webMouseWheel.dispatchType);
1156 #if OS(MACOSX)
1157 EXPECT_EQ(WebMouseWheelEvent::PhaseBegan, webMouseWheel.phase);
1158 EXPECT_EQ(WebMouseWheelEvent::PhaseChanged, webMouseWheel.momentumPhase);
1159 #endif
1160 }
1161
1162 {
1163 WheelEvent* event = WheelEvent::create(
1164 FloatPoint(1, 3), FloatPoint(5, 10), WheelEvent::kDomDeltaPage,
1165 document->domWindow(), IntPoint(2, 6), IntPoint(10, 30),
1166 PlatformEvent::CtrlKey, 0, TimeTicks(), -1 /* null plugin id */,
1167 true /* hasPreciseScrollingDeltas */, Event::RailsModeHorizontal, false
1168 #if OS(MACOSX)
1169 ,
1170 WheelEventPhaseNone, WheelEventPhaseNone
1171 #endif
1172 );
1173 WebMouseWheelEventBuilder webMouseWheel(
1174 toLocalFrame(webViewImpl->page()->mainFrame())->view(),
1175 document->layoutViewItem(), *event);
1176 EXPECT_EQ(WebInputEvent::EventNonBlocking, webMouseWheel.dispatchType);
1177 }
1178 }
1179
1180 TEST(WebInputEventConversionTest, PlatformWheelEventBuilder) {
1181 const std::string baseURL("http://www.test8.com/");
1182 const std::string fileName("fixed_layout.html");
1183
1184 URLTestHelpers::registerMockedURLFromBaseURL(
1185 WebString::fromUTF8(baseURL.c_str()),
1186 WebString::fromUTF8("fixed_layout.html"));
1187 FrameTestHelpers::WebViewHelper webViewHelper;
1188 WebViewImpl* webViewImpl =
1189 webViewHelper.initializeAndLoad(baseURL + fileName, true);
1190 int pageWidth = 640;
1191 int pageHeight = 480;
1192 webViewImpl->resize(WebSize(pageWidth, pageHeight));
1193 webViewImpl->updateAllLifecyclePhases();
1194
1195 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view();
1196
1197 {
1198 WebMouseWheelEvent webMouseWheelEvent(WebInputEvent::MouseWheel,
1199 WebInputEvent::ControlKey,
1200 WebInputEvent::TimeStampForTesting);
1201 webMouseWheelEvent.x = 0;
1202 webMouseWheelEvent.y = 5;
1203 webMouseWheelEvent.deltaX = 10;
1204 webMouseWheelEvent.deltaY = 15;
1205 webMouseWheelEvent.hasPreciseScrollingDeltas = true;
1206 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeHorizontal;
1207 webMouseWheelEvent.phase = WebMouseWheelEvent::PhaseBegan;
1208 webMouseWheelEvent.momentumPhase = WebMouseWheelEvent::PhaseChanged;
1209
1210 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent);
1211 EXPECT_EQ(0, platformWheelBuilder.position().x());
1212 EXPECT_EQ(5, platformWheelBuilder.position().y());
1213 EXPECT_EQ(10, platformWheelBuilder.deltaX());
1214 EXPECT_EQ(15, platformWheelBuilder.deltaY());
1215 EXPECT_EQ(PlatformEvent::CtrlKey, platformWheelBuilder.getModifiers());
1216 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas());
1217 EXPECT_EQ(platformWheelBuilder.getRailsMode(),
1218 PlatformEvent::RailsModeHorizontal);
1219 #if OS(MACOSX)
1220 EXPECT_EQ(PlatformWheelEventPhaseBegan, platformWheelBuilder.phase());
1221 EXPECT_EQ(PlatformWheelEventPhaseChanged,
1222 platformWheelBuilder.momentumPhase());
1223 #endif
1224 }
1225
1226 {
1227 WebMouseWheelEvent webMouseWheelEvent(WebInputEvent::MouseWheel,
1228 WebInputEvent::ShiftKey,
1229 WebInputEvent::TimeStampForTesting);
1230 webMouseWheelEvent.x = 5;
1231 webMouseWheelEvent.y = 0;
1232 webMouseWheelEvent.deltaX = 15;
1233 webMouseWheelEvent.deltaY = 10;
1234 webMouseWheelEvent.hasPreciseScrollingDeltas = false;
1235 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeFree;
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::ShiftKey, platformWheelBuilder.getModifiers());
1245 EXPECT_FALSE(platformWheelBuilder.hasPreciseScrollingDeltas());
1246 EXPECT_EQ(platformWheelBuilder.getRailsMode(),
1247 PlatformEvent::RailsModeFree);
1248 #if OS(MACOSX)
1249 EXPECT_EQ(PlatformWheelEventPhaseNone, platformWheelBuilder.phase());
1250 EXPECT_EQ(PlatformWheelEventPhaseNone,
1251 platformWheelBuilder.momentumPhase());
1252 #endif
1253 }
1254
1255 {
1256 WebMouseWheelEvent webMouseWheelEvent(WebInputEvent::MouseWheel,
1257 WebInputEvent::AltKey,
1258 WebInputEvent::TimeStampForTesting);
1259 webMouseWheelEvent.x = 5;
1260 webMouseWheelEvent.y = 0;
1261 webMouseWheelEvent.deltaX = 15;
1262 webMouseWheelEvent.deltaY = 10;
1263 webMouseWheelEvent.hasPreciseScrollingDeltas = true;
1264 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeVertical;
1265 webMouseWheelEvent.phase = WebMouseWheelEvent::PhaseNone;
1266 webMouseWheelEvent.momentumPhase = WebMouseWheelEvent::PhaseNone;
1267
1268 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent);
1269 EXPECT_EQ(5, platformWheelBuilder.position().x());
1270 EXPECT_EQ(0, platformWheelBuilder.position().y());
1271 EXPECT_EQ(15, platformWheelBuilder.deltaX());
1272 EXPECT_EQ(10, platformWheelBuilder.deltaY());
1273 EXPECT_EQ(PlatformEvent::AltKey, platformWheelBuilder.getModifiers());
1274 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas());
1275 EXPECT_EQ(platformWheelBuilder.getRailsMode(),
1276 PlatformEvent::RailsModeVertical);
1277 #if OS(MACOSX)
1278 EXPECT_EQ(PlatformWheelEventPhaseNone, platformWheelBuilder.phase());
1279 EXPECT_EQ(PlatformWheelEventPhaseNone,
1280 platformWheelBuilder.momentumPhase());
1281 #endif
1282 }
1283 }
1284
1285 } // namespace blink 1114 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698