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

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

Issue 2475443004: Add use counter when touch-action isn't used when preventDefault'd. (Closed)
Patch Set: Rebase Created 4 years, 1 month 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 document, p1.id, p1.screenPosition, p1.position, 142 document, p1.id, p1.screenPosition, p1.position,
143 FloatSize(p1.radiusX, p1.radiusY), 143 FloatSize(p1.radiusX, p1.radiusY),
144 p1.rotationAngle, p1.force, String()); 144 p1.rotationAngle, p1.force, String());
145 145
146 // Test touchstart. 146 // Test touchstart.
147 { 147 {
148 TouchList* touchList = TouchList::create(); 148 TouchList* touchList = TouchList::create();
149 touchList->append(touch0); 149 touchList->append(touch0);
150 TouchEvent* touchEvent = TouchEvent::create( 150 TouchEvent* touchEvent = TouchEvent::create(
151 touchList, touchList, touchList, EventTypeNames::touchstart, domWindow, 151 touchList, touchList, touchList, EventTypeNames::touchstart, domWindow,
152 PlatformEvent::NoModifiers, false, false, true, 0); 152 PlatformEvent::NoModifiers, false, false, true, 0, TouchActionAuto);
153 153
154 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); 154 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent);
155 ASSERT_EQ(1u, webTouchBuilder.touchesLength); 155 ASSERT_EQ(1u, webTouchBuilder.touchesLength);
156 EXPECT_EQ(WebInputEvent::TouchStart, webTouchBuilder.type); 156 EXPECT_EQ(WebInputEvent::TouchStart, webTouchBuilder.type);
157 EXPECT_EQ(WebTouchPoint::StatePressed, webTouchBuilder.touches[0].state); 157 EXPECT_EQ(WebTouchPoint::StatePressed, webTouchBuilder.touches[0].state);
158 EXPECT_FLOAT_EQ(p0.screenPosition.x, 158 EXPECT_FLOAT_EQ(p0.screenPosition.x,
159 webTouchBuilder.touches[0].screenPosition.x); 159 webTouchBuilder.touches[0].screenPosition.x);
160 EXPECT_FLOAT_EQ(p0.screenPosition.y, 160 EXPECT_FLOAT_EQ(p0.screenPosition.y,
161 webTouchBuilder.touches[0].screenPosition.y); 161 webTouchBuilder.touches[0].screenPosition.y);
162 EXPECT_FLOAT_EQ(p0.position.x, webTouchBuilder.touches[0].position.x); 162 EXPECT_FLOAT_EQ(p0.position.x, webTouchBuilder.touches[0].position.x);
163 EXPECT_FLOAT_EQ(p0.position.y, webTouchBuilder.touches[0].position.y); 163 EXPECT_FLOAT_EQ(p0.position.y, webTouchBuilder.touches[0].position.y);
164 EXPECT_FLOAT_EQ(p0.radiusX, webTouchBuilder.touches[0].radiusX); 164 EXPECT_FLOAT_EQ(p0.radiusX, webTouchBuilder.touches[0].radiusX);
165 EXPECT_FLOAT_EQ(p0.radiusY, webTouchBuilder.touches[0].radiusY); 165 EXPECT_FLOAT_EQ(p0.radiusY, webTouchBuilder.touches[0].radiusY);
166 EXPECT_FLOAT_EQ(p0.rotationAngle, webTouchBuilder.touches[0].rotationAngle); 166 EXPECT_FLOAT_EQ(p0.rotationAngle, webTouchBuilder.touches[0].rotationAngle);
167 EXPECT_FLOAT_EQ(p0.force, webTouchBuilder.touches[0].force); 167 EXPECT_FLOAT_EQ(p0.force, webTouchBuilder.touches[0].force);
168 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType); 168 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType);
169 } 169 }
170 170
171 // Test cancelable touchstart. 171 // Test cancelable touchstart.
172 { 172 {
173 TouchList* touchList = TouchList::create(); 173 TouchList* touchList = TouchList::create();
174 touchList->append(touch0); 174 touchList->append(touch0);
175 TouchEvent* touchEvent = TouchEvent::create( 175 TouchEvent* touchEvent = TouchEvent::create(
176 touchList, touchList, touchList, EventTypeNames::touchstart, domWindow, 176 touchList, touchList, touchList, EventTypeNames::touchstart, domWindow,
177 PlatformEvent::NoModifiers, true, false, true, 0); 177 PlatformEvent::NoModifiers, true, false, true, 0, TouchActionAuto);
178 178
179 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); 179 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent);
180 EXPECT_EQ(WebInputEvent::Blocking, webTouchBuilder.dispatchType); 180 EXPECT_EQ(WebInputEvent::Blocking, webTouchBuilder.dispatchType);
181 } 181 }
182 182
183 // Test touchmove. 183 // Test touchmove.
184 { 184 {
185 TouchList* activeTouchList = TouchList::create(); 185 TouchList* activeTouchList = TouchList::create();
186 TouchList* movedTouchList = TouchList::create(); 186 TouchList* movedTouchList = TouchList::create();
187 activeTouchList->append(touch0); 187 activeTouchList->append(touch0);
188 activeTouchList->append(touch1); 188 activeTouchList->append(touch1);
189 movedTouchList->append(touch0); 189 movedTouchList->append(touch0);
190 TouchEvent* touchEvent = 190 TouchEvent* touchEvent = TouchEvent::create(
191 TouchEvent::create(activeTouchList, activeTouchList, movedTouchList, 191 activeTouchList, activeTouchList, movedTouchList,
192 EventTypeNames::touchmove, domWindow, 192 EventTypeNames::touchmove, domWindow, PlatformEvent::NoModifiers, false,
193 PlatformEvent::NoModifiers, false, false, true, 0); 193 false, true, 0, TouchActionAuto);
194 194
195 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); 195 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent);
196 ASSERT_EQ(2u, webTouchBuilder.touchesLength); 196 ASSERT_EQ(2u, webTouchBuilder.touchesLength);
197 EXPECT_EQ(WebInputEvent::TouchMove, webTouchBuilder.type); 197 EXPECT_EQ(WebInputEvent::TouchMove, webTouchBuilder.type);
198 EXPECT_EQ(WebTouchPoint::StateMoved, webTouchBuilder.touches[0].state); 198 EXPECT_EQ(WebTouchPoint::StateMoved, webTouchBuilder.touches[0].state);
199 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[1].state); 199 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[1].state);
200 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); 200 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id);
201 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); 201 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id);
202 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType); 202 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType);
203 } 203 }
204 204
205 // Test touchmove, different point yields same ordering. 205 // Test touchmove, different point yields same ordering.
206 { 206 {
207 TouchList* activeTouchList = TouchList::create(); 207 TouchList* activeTouchList = TouchList::create();
208 TouchList* movedTouchList = TouchList::create(); 208 TouchList* movedTouchList = TouchList::create();
209 activeTouchList->append(touch0); 209 activeTouchList->append(touch0);
210 activeTouchList->append(touch1); 210 activeTouchList->append(touch1);
211 movedTouchList->append(touch1); 211 movedTouchList->append(touch1);
212 TouchEvent* touchEvent = 212 TouchEvent* touchEvent = TouchEvent::create(
213 TouchEvent::create(activeTouchList, activeTouchList, movedTouchList, 213 activeTouchList, activeTouchList, movedTouchList,
214 EventTypeNames::touchmove, domWindow, 214 EventTypeNames::touchmove, domWindow, PlatformEvent::NoModifiers, false,
215 PlatformEvent::NoModifiers, false, false, true, 0); 215 false, true, 0, TouchActionAuto);
216 216
217 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); 217 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent);
218 ASSERT_EQ(2u, webTouchBuilder.touchesLength); 218 ASSERT_EQ(2u, webTouchBuilder.touchesLength);
219 EXPECT_EQ(WebInputEvent::TouchMove, webTouchBuilder.type); 219 EXPECT_EQ(WebInputEvent::TouchMove, webTouchBuilder.type);
220 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[0].state); 220 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[0].state);
221 EXPECT_EQ(WebTouchPoint::StateMoved, webTouchBuilder.touches[1].state); 221 EXPECT_EQ(WebTouchPoint::StateMoved, webTouchBuilder.touches[1].state);
222 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); 222 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id);
223 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); 223 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id);
224 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType); 224 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType);
225 } 225 }
226 226
227 // Test touchend. 227 // Test touchend.
228 { 228 {
229 TouchList* activeTouchList = TouchList::create(); 229 TouchList* activeTouchList = TouchList::create();
230 TouchList* releasedTouchList = TouchList::create(); 230 TouchList* releasedTouchList = TouchList::create();
231 activeTouchList->append(touch0); 231 activeTouchList->append(touch0);
232 releasedTouchList->append(touch1); 232 releasedTouchList->append(touch1);
233 TouchEvent* touchEvent = 233 TouchEvent* touchEvent = TouchEvent::create(
234 TouchEvent::create(activeTouchList, activeTouchList, releasedTouchList, 234 activeTouchList, activeTouchList, releasedTouchList,
235 EventTypeNames::touchend, domWindow, 235 EventTypeNames::touchend, domWindow, PlatformEvent::NoModifiers, false,
236 PlatformEvent::NoModifiers, false, false, false, 0); 236 false, false, 0, TouchActionAuto);
237 237
238 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); 238 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent);
239 ASSERT_EQ(2u, webTouchBuilder.touchesLength); 239 ASSERT_EQ(2u, webTouchBuilder.touchesLength);
240 EXPECT_EQ(WebInputEvent::TouchEnd, webTouchBuilder.type); 240 EXPECT_EQ(WebInputEvent::TouchEnd, webTouchBuilder.type);
241 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[0].state); 241 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[0].state);
242 EXPECT_EQ(WebTouchPoint::StateReleased, webTouchBuilder.touches[1].state); 242 EXPECT_EQ(WebTouchPoint::StateReleased, webTouchBuilder.touches[1].state);
243 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); 243 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id);
244 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); 244 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id);
245 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType); 245 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType);
246 } 246 }
247 247
248 // Test touchcancel. 248 // Test touchcancel.
249 { 249 {
250 TouchList* activeTouchList = TouchList::create(); 250 TouchList* activeTouchList = TouchList::create();
251 TouchList* cancelledTouchList = TouchList::create(); 251 TouchList* cancelledTouchList = TouchList::create();
252 cancelledTouchList->append(touch0); 252 cancelledTouchList->append(touch0);
253 cancelledTouchList->append(touch1); 253 cancelledTouchList->append(touch1);
254 TouchEvent* touchEvent = 254 TouchEvent* touchEvent = TouchEvent::create(
255 TouchEvent::create(activeTouchList, activeTouchList, cancelledTouchList, 255 activeTouchList, activeTouchList, cancelledTouchList,
256 EventTypeNames::touchcancel, domWindow, 256 EventTypeNames::touchcancel, domWindow, PlatformEvent::NoModifiers,
257 PlatformEvent::NoModifiers, false, false, false, 0); 257 false, false, false, 0, TouchActionAuto);
258 258
259 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); 259 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent);
260 ASSERT_EQ(2u, webTouchBuilder.touchesLength); 260 ASSERT_EQ(2u, webTouchBuilder.touchesLength);
261 EXPECT_EQ(WebInputEvent::TouchCancel, webTouchBuilder.type); 261 EXPECT_EQ(WebInputEvent::TouchCancel, webTouchBuilder.type);
262 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[0].state); 262 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[0].state);
263 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[1].state); 263 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[1].state);
264 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); 264 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id);
265 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); 265 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id);
266 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType); 266 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType);
267 } 267 }
268 268
269 // Test max point limit. 269 // Test max point limit.
270 { 270 {
271 TouchList* touchList = TouchList::create(); 271 TouchList* touchList = TouchList::create();
272 TouchList* changedTouchList = TouchList::create(); 272 TouchList* changedTouchList = TouchList::create();
273 for (int i = 0; i <= static_cast<int>(WebTouchEvent::kTouchesLengthCap) * 2; 273 for (int i = 0; i <= static_cast<int>(WebTouchEvent::kTouchesLengthCap) * 2;
274 ++i) { 274 ++i) {
275 Touch* touch = Touch::create( 275 Touch* touch = Touch::create(
276 toLocalFrame(webViewImpl->page()->mainFrame()), document, i, 276 toLocalFrame(webViewImpl->page()->mainFrame()), document, i,
277 p0.screenPosition, p0.position, FloatSize(p0.radiusX, p0.radiusY), 277 p0.screenPosition, p0.position, FloatSize(p0.radiusX, p0.radiusY),
278 p0.rotationAngle, p0.force, String()); 278 p0.rotationAngle, p0.force, String());
279 touchList->append(touch); 279 touchList->append(touch);
280 changedTouchList->append(touch); 280 changedTouchList->append(touch);
281 } 281 }
282 TouchEvent* touchEvent = TouchEvent::create( 282 TouchEvent* touchEvent = TouchEvent::create(
283 touchList, touchList, touchList, EventTypeNames::touchstart, domWindow, 283 touchList, touchList, touchList, EventTypeNames::touchstart, domWindow,
284 PlatformEvent::NoModifiers, false, false, true, 0); 284 PlatformEvent::NoModifiers, false, false, true, 0, TouchActionAuto);
285 285
286 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); 286 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent);
287 ASSERT_EQ(static_cast<unsigned>(WebTouchEvent::kTouchesLengthCap), 287 ASSERT_EQ(static_cast<unsigned>(WebTouchEvent::kTouchesLengthCap),
288 webTouchBuilder.touchesLength); 288 webTouchBuilder.touchesLength);
289 } 289 }
290 } 290 }
291 291
292 TEST(WebInputEventConversionTest, InputEventsScaling) { 292 TEST(WebInputEventConversionTest, InputEventsScaling) {
293 const std::string baseURL("http://www.test1.com/"); 293 const std::string baseURL("http://www.test1.com/");
294 const std::string fileName("fixed_layout.html"); 294 const std::string fileName("fixed_layout.html");
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 552
553 { 553 {
554 Touch* touch = 554 Touch* touch =
555 Touch::create(toLocalFrame(webViewImpl->page()->mainFrame()), document, 555 Touch::create(toLocalFrame(webViewImpl->page()->mainFrame()), document,
556 0, FloatPoint(10, 9.5), FloatPoint(3.5, 2), 556 0, FloatPoint(10, 9.5), FloatPoint(3.5, 2),
557 FloatSize(4, 4.5), 0, 0, String()); 557 FloatSize(4, 4.5), 0, 0, String());
558 TouchList* touchList = TouchList::create(); 558 TouchList* touchList = TouchList::create();
559 touchList->append(touch); 559 touchList->append(touch);
560 TouchEvent* touchEvent = TouchEvent::create( 560 TouchEvent* touchEvent = TouchEvent::create(
561 touchList, touchList, touchList, EventTypeNames::touchmove, domWindow, 561 touchList, touchList, touchList, EventTypeNames::touchmove, domWindow,
562 PlatformEvent::NoModifiers, false, false, true, 0); 562 PlatformEvent::NoModifiers, false, false, true, 0, TouchActionAuto);
563 563
564 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); 564 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent);
565 ASSERT_EQ(1u, webTouchBuilder.touchesLength); 565 ASSERT_EQ(1u, webTouchBuilder.touchesLength);
566 EXPECT_EQ(10, webTouchBuilder.touches[0].screenPosition.x); 566 EXPECT_EQ(10, webTouchBuilder.touches[0].screenPosition.x);
567 EXPECT_FLOAT_EQ(9.5, webTouchBuilder.touches[0].screenPosition.y); 567 EXPECT_FLOAT_EQ(9.5, webTouchBuilder.touches[0].screenPosition.y);
568 EXPECT_FLOAT_EQ(3.5, webTouchBuilder.touches[0].position.x); 568 EXPECT_FLOAT_EQ(3.5, webTouchBuilder.touches[0].position.x);
569 EXPECT_FLOAT_EQ(2, webTouchBuilder.touches[0].position.y); 569 EXPECT_FLOAT_EQ(2, webTouchBuilder.touches[0].position.y);
570 EXPECT_FLOAT_EQ(4, webTouchBuilder.touches[0].radiusX); 570 EXPECT_FLOAT_EQ(4, webTouchBuilder.touches[0].radiusX);
571 EXPECT_FLOAT_EQ(4.5, webTouchBuilder.touches[0].radiusY); 571 EXPECT_FLOAT_EQ(4.5, webTouchBuilder.touches[0].radiusY);
572 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType); 572 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType);
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 EXPECT_EQ(ScrollInertialPhaseNonMomentum, 1247 EXPECT_EQ(ScrollInertialPhaseNonMomentum,
1248 platformGestureBuilder.inertialPhase()); 1248 platformGestureBuilder.inertialPhase());
1249 EXPECT_TRUE(platformGestureBuilder.synthetic()); 1249 EXPECT_TRUE(platformGestureBuilder.synthetic());
1250 EXPECT_EQ(ScrollGranularity::ScrollByPage, 1250 EXPECT_EQ(ScrollGranularity::ScrollByPage,
1251 platformGestureBuilder.deltaUnits()); 1251 platformGestureBuilder.deltaUnits());
1252 EXPECT_EQ(12345U, platformGestureBuilder.uniqueTouchEventId()); 1252 EXPECT_EQ(12345U, platformGestureBuilder.uniqueTouchEventId());
1253 } 1253 }
1254 } 1254 }
1255 1255
1256 } // namespace blink 1256 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/input/TouchEventManager.cpp ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698