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

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

Issue 298133003: Expose fractional TouchEvent coordinates (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Make layout test output stable across platforms Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/web/WebInputEventConversion.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 webTouchEvent.touches[0].radiusY = 10.4f; 232 webTouchEvent.touches[0].radiusY = 10.4f;
233 233
234 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].screenPosition.x); 234 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].screenPosition.x);
235 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].screenPosition.y); 235 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].screenPosition.y);
236 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].position.x); 236 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].position.x);
237 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].position.y); 237 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].position.y);
238 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].radiusX); 238 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].radiusX);
239 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].radiusY); 239 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].radiusY);
240 240
241 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); 241 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent);
242 EXPECT_EQ(10, platformTouchBuilder.touchPoints()[0].screenPos().x()); 242 EXPECT_FLOAT_EQ(10.6f, platformTouchBuilder.touchPoints()[0].screenPos() .x());
243 EXPECT_EQ(10, platformTouchBuilder.touchPoints()[0].screenPos().y()); 243 EXPECT_FLOAT_EQ(10.4f, platformTouchBuilder.touchPoints()[0].screenPos() .y());
244 EXPECT_EQ(5, platformTouchBuilder.touchPoints()[0].pos().x()); 244 EXPECT_FLOAT_EQ(5.3f, platformTouchBuilder.touchPoints()[0].pos().x());
245 EXPECT_EQ(5, platformTouchBuilder.touchPoints()[0].pos().y()); 245 EXPECT_FLOAT_EQ(5.2f, platformTouchBuilder.touchPoints()[0].pos().y());
246 EXPECT_EQ(5, platformTouchBuilder.touchPoints()[0].radiusX()); 246 EXPECT_FLOAT_EQ(5.3f, platformTouchBuilder.touchPoints()[0].radius().wid th());
247 EXPECT_EQ(5, platformTouchBuilder.touchPoints()[0].radiusY()); 247 EXPECT_FLOAT_EQ(5.2f, platformTouchBuilder.touchPoints()[0].radius().hei ght());
248 } 248 }
249 249
250 // Reverse builders should *not* go back to physical pixels, as they are use d for plugins 250 // Reverse builders should *not* go back to physical pixels, as they are use d for plugins
251 // which expect CSS pixel coordinates. 251 // which expect CSS pixel coordinates.
252 { 252 {
253 PlatformMouseEvent platformMouseEvent(IntPoint(10, 10), IntPoint(10, 10) , LeftButton, PlatformEvent::MouseMoved, 1, false, false, false, false, 0); 253 PlatformMouseEvent platformMouseEvent(IntPoint(10, 10), IntPoint(10, 10) , LeftButton, PlatformEvent::MouseMoved, 1, false, false, false, false, 0);
254 RefPtrWillBeRawPtr<MouseEvent> mouseEvent = MouseEvent::create(WebCore:: EventTypeNames::mousemove, domWindow, platformMouseEvent, 0, document); 254 RefPtrWillBeRawPtr<MouseEvent> mouseEvent = MouseEvent::create(WebCore:: EventTypeNames::mousemove, domWindow, platformMouseEvent, 0, document);
255 WebMouseEventBuilder webMouseBuilder(view, documentRenderView, *mouseEve nt); 255 WebMouseEventBuilder webMouseBuilder(view, documentRenderView, *mouseEve nt);
256 256
257 EXPECT_EQ(10, webMouseBuilder.x); 257 EXPECT_EQ(10, webMouseBuilder.x);
(...skipping 18 matching lines...) Expand all
276 276
277 EXPECT_EQ(10, webGestureBuilder.x); 277 EXPECT_EQ(10, webGestureBuilder.x);
278 EXPECT_EQ(10, webGestureBuilder.y); 278 EXPECT_EQ(10, webGestureBuilder.y);
279 EXPECT_EQ(10, webGestureBuilder.globalX); 279 EXPECT_EQ(10, webGestureBuilder.globalX);
280 EXPECT_EQ(10, webGestureBuilder.globalY); 280 EXPECT_EQ(10, webGestureBuilder.globalY);
281 EXPECT_EQ(10, webGestureBuilder.data.scrollUpdate.deltaX); 281 EXPECT_EQ(10, webGestureBuilder.data.scrollUpdate.deltaX);
282 EXPECT_EQ(10, webGestureBuilder.data.scrollUpdate.deltaY); 282 EXPECT_EQ(10, webGestureBuilder.data.scrollUpdate.deltaY);
283 } 283 }
284 284
285 { 285 {
286 RefPtrWillBeRawPtr<Touch> touch = Touch::create(webViewImpl->page()->mai nFrame(), document.get(), 0, 10, 10, 10, 10, 10, 10, 0, 0); 286 RefPtrWillBeRawPtr<Touch> touch = Touch::create(webViewImpl->page()->mai nFrame(), document.get(), 0, FloatPoint(10, 9.5), FloatPoint(3.5, 2), FloatSize( 4, 4.5), 0, 0);
287 RefPtrWillBeRawPtr<TouchList> touchList = TouchList::create(); 287 RefPtrWillBeRawPtr<TouchList> touchList = TouchList::create();
288 touchList->append(touch); 288 touchList->append(touch);
289 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(touchList .get(), touchList.get(), touchList.get(), WebCore::EventTypeNames::touchmove, do mWindow, false, false, false, false, false); 289 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(touchList .get(), touchList.get(), touchList.get(), WebCore::EventTypeNames::touchmove, do mWindow, false, false, false, false, false);
290 290
291 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve nt); 291 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve nt);
292 ASSERT_EQ(1u, webTouchBuilder.touchesLength); 292 ASSERT_EQ(1u, webTouchBuilder.touchesLength);
293 EXPECT_EQ(10, webTouchBuilder.touches[0].screenPosition.x); 293 EXPECT_EQ(10, webTouchBuilder.touches[0].screenPosition.x);
294 EXPECT_EQ(10, webTouchBuilder.touches[0].screenPosition.y); 294 EXPECT_FLOAT_EQ(9.5, webTouchBuilder.touches[0].screenPosition.y);
295 EXPECT_EQ(10, webTouchBuilder.touches[0].position.x); 295 EXPECT_FLOAT_EQ(3.5, webTouchBuilder.touches[0].position.x);
296 EXPECT_EQ(10, webTouchBuilder.touches[0].position.y); 296 EXPECT_FLOAT_EQ(2, webTouchBuilder.touches[0].position.y);
297 EXPECT_EQ(10, webTouchBuilder.touches[0].radiusX); 297 EXPECT_FLOAT_EQ(4, webTouchBuilder.touches[0].radiusX);
298 EXPECT_EQ(10, webTouchBuilder.touches[0].radiusY); 298 EXPECT_FLOAT_EQ(4.5, webTouchBuilder.touches[0].radiusY);
299 EXPECT_FALSE(webTouchBuilder.cancelable); 299 EXPECT_FALSE(webTouchBuilder.cancelable);
300 } 300 }
301 } 301 }
302 302
303 TEST(WebInputEventConversionTest, InputEventsTransform) 303 TEST(WebInputEventConversionTest, InputEventsTransform)
304 { 304 {
305 const std::string baseURL("http://www.test2.com/"); 305 const std::string baseURL("http://www.test2.com/");
306 const std::string fileName("fixed_layout.html"); 306 const std::string fileName("fixed_layout.html");
307 307
308 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("fixed_layout.html")); 308 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("fixed_layout.html"));
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 webTouchEvent.touchesLength = 1; 431 webTouchEvent.touchesLength = 1;
432 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved; 432 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved;
433 webTouchEvent.touches[0].screenPosition.x = 100; 433 webTouchEvent.touches[0].screenPosition.x = 100;
434 webTouchEvent.touches[0].screenPosition.y = 110; 434 webTouchEvent.touches[0].screenPosition.y = 110;
435 webTouchEvent.touches[0].position.x = 100; 435 webTouchEvent.touches[0].position.x = 100;
436 webTouchEvent.touches[0].position.y = 110; 436 webTouchEvent.touches[0].position.y = 110;
437 webTouchEvent.touches[0].radiusX = 30; 437 webTouchEvent.touches[0].radiusX = 30;
438 webTouchEvent.touches[0].radiusY = 30; 438 webTouchEvent.touches[0].radiusY = 30;
439 439
440 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); 440 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent);
441 EXPECT_EQ(100, platformTouchBuilder.touchPoints()[0].screenPos().x()); 441 EXPECT_FLOAT_EQ(100, platformTouchBuilder.touchPoints()[0].screenPos().x ());
442 EXPECT_EQ(110, platformTouchBuilder.touchPoints()[0].screenPos().y()); 442 EXPECT_FLOAT_EQ(110, platformTouchBuilder.touchPoints()[0].screenPos().y ());
443 EXPECT_EQ(30, platformTouchBuilder.touchPoints()[0].pos().x()); 443 EXPECT_FLOAT_EQ(30, platformTouchBuilder.touchPoints()[0].pos().x());
444 EXPECT_EQ(30, platformTouchBuilder.touchPoints()[0].pos().y()); 444 EXPECT_FLOAT_EQ(30, platformTouchBuilder.touchPoints()[0].pos().y());
445 EXPECT_EQ(10, platformTouchBuilder.touchPoints()[0].radiusX()); 445 EXPECT_FLOAT_EQ(10, platformTouchBuilder.touchPoints()[0].radius().width ());
446 EXPECT_EQ(10, platformTouchBuilder.touchPoints()[0].radiusY()); 446 EXPECT_FLOAT_EQ(10, platformTouchBuilder.touchPoints()[0].radius().heigh t());
447 } 447 }
448 } 448 }
449 449
450 TEST(WebInputEventConversionTest, InputEventsConversions) 450 TEST(WebInputEventConversionTest, InputEventsConversions)
451 { 451 {
452 const std::string baseURL("http://www.test3.com/"); 452 const std::string baseURL("http://www.test3.com/");
453 const std::string fileName("fixed_layout.html"); 453 const std::string fileName("fixed_layout.html");
454 454
455 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("fixed_layout.html")); 455 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("fixed_layout.html"));
456 FrameTestHelpers::WebViewHelper webViewHelper; 456 FrameTestHelpers::WebViewHelper webViewHelper;
(...skipping 13 matching lines...) Expand all
470 webGestureEvent.type = WebInputEvent::GestureTap; 470 webGestureEvent.type = WebInputEvent::GestureTap;
471 webGestureEvent.x = 10; 471 webGestureEvent.x = 10;
472 webGestureEvent.y = 10; 472 webGestureEvent.y = 10;
473 webGestureEvent.globalX = 10; 473 webGestureEvent.globalX = 10;
474 webGestureEvent.globalY = 10; 474 webGestureEvent.globalY = 10;
475 webGestureEvent.data.tap.tapCount = 1; 475 webGestureEvent.data.tap.tapCount = 1;
476 webGestureEvent.data.tap.width = 10; 476 webGestureEvent.data.tap.width = 10;
477 webGestureEvent.data.tap.height = 10; 477 webGestureEvent.data.tap.height = 10;
478 478
479 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent ); 479 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent );
480 EXPECT_EQ(10, platformGestureBuilder.position().x()); 480 EXPECT_EQ(10.f, platformGestureBuilder.position().x());
481 EXPECT_EQ(10, platformGestureBuilder.position().y()); 481 EXPECT_EQ(10.f, platformGestureBuilder.position().y());
482 EXPECT_EQ(10, platformGestureBuilder.globalPosition().x()); 482 EXPECT_EQ(10.f, platformGestureBuilder.globalPosition().x());
483 EXPECT_EQ(10, platformGestureBuilder.globalPosition().y()); 483 EXPECT_EQ(10.f, platformGestureBuilder.globalPosition().y());
484 EXPECT_EQ(1, platformGestureBuilder.tapCount()); 484 EXPECT_EQ(1, platformGestureBuilder.tapCount());
485 485
486 RefPtrWillBeRawPtr<WebCore::GestureEvent> coreGestureEvent = WebCore::Ge stureEvent::create(domWindow, platformGestureBuilder); 486 RefPtrWillBeRawPtr<WebCore::GestureEvent> coreGestureEvent = WebCore::Ge stureEvent::create(domWindow, platformGestureBuilder);
487 WebGestureEventBuilder recreatedWebGestureEvent(view, documentRenderView , *coreGestureEvent); 487 WebGestureEventBuilder recreatedWebGestureEvent(view, documentRenderView , *coreGestureEvent);
488 EXPECT_EQ(webGestureEvent.type, recreatedWebGestureEvent.type); 488 EXPECT_EQ(webGestureEvent.type, recreatedWebGestureEvent.type);
489 EXPECT_EQ(webGestureEvent.x, recreatedWebGestureEvent.x); 489 EXPECT_EQ(webGestureEvent.x, recreatedWebGestureEvent.x);
490 EXPECT_EQ(webGestureEvent.y, recreatedWebGestureEvent.y); 490 EXPECT_EQ(webGestureEvent.y, recreatedWebGestureEvent.y);
491 EXPECT_EQ(webGestureEvent.globalX, recreatedWebGestureEvent.globalX); 491 EXPECT_EQ(webGestureEvent.globalX, recreatedWebGestureEvent.globalX);
492 EXPECT_EQ(webGestureEvent.globalY, recreatedWebGestureEvent.globalY); 492 EXPECT_EQ(webGestureEvent.globalY, recreatedWebGestureEvent.globalY);
493 EXPECT_EQ(webGestureEvent.data.tap.tapCount, recreatedWebGestureEvent.da ta.tap.tapCount); 493 EXPECT_EQ(webGestureEvent.data.tap.tapCount, recreatedWebGestureEvent.da ta.tap.tapCount);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 webTouchEvent.touches[0].screenPosition.y = 10.4f; 578 webTouchEvent.touches[0].screenPosition.y = 10.4f;
579 webTouchEvent.touches[0].position.x = 10.6f; 579 webTouchEvent.touches[0].position.x = 10.6f;
580 webTouchEvent.touches[0].position.y = 10.4f; 580 webTouchEvent.touches[0].position.y = 10.4f;
581 581
582 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].screenPosition.x); 582 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].screenPosition.x);
583 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].screenPosition.y); 583 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].screenPosition.y);
584 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].position.x); 584 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].position.x);
585 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].position.y); 585 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].position.y);
586 586
587 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); 587 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent);
588 EXPECT_EQ(10, platformTouchBuilder.touchPoints()[0].screenPos().x()); 588 EXPECT_FLOAT_EQ(10.6f, platformTouchBuilder.touchPoints()[0].screenPos() .x());
589 EXPECT_EQ(10, platformTouchBuilder.touchPoints()[0].screenPos().y()); 589 EXPECT_FLOAT_EQ(10.4f, platformTouchBuilder.touchPoints()[0].screenPos() .y());
590 EXPECT_EQ(5 + pinchOffset.x(), platformTouchBuilder.touchPoints()[0].pos ().x()); 590 EXPECT_FLOAT_EQ(5.3f + pinchOffset.x(), platformTouchBuilder.touchPoints ()[0].pos().x());
591 EXPECT_EQ(5 + pinchOffset.y(), platformTouchBuilder.touchPoints()[0].pos ().y()); 591 EXPECT_FLOAT_EQ(5.2f + pinchOffset.y(), platformTouchBuilder.touchPoints ()[0].pos().y());
592 } 592 }
593 } 593 }
594 594
595 } // anonymous namespace 595 } // anonymous namespace
OLDNEW
« no previous file with comments | « Source/web/WebInputEventConversion.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698