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

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

Issue 2510133002: Add getCoalescedEvents API to PointerEvent (Closed)
Patch Set: rebase Created 4 years 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
« no previous file with comments | « third_party/WebKit/Source/web/tests/WebFrameTest.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 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); 610 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent);
611 EXPECT_EQ(30, platformMouseBuilder.position().x()); 611 EXPECT_EQ(30, platformMouseBuilder.position().x());
612 EXPECT_EQ(30, platformMouseBuilder.position().y()); 612 EXPECT_EQ(30, platformMouseBuilder.position().y());
613 EXPECT_EQ(100, platformMouseBuilder.globalPosition().x()); 613 EXPECT_EQ(100, platformMouseBuilder.globalPosition().x());
614 EXPECT_EQ(110, platformMouseBuilder.globalPosition().y()); 614 EXPECT_EQ(110, platformMouseBuilder.globalPosition().y());
615 EXPECT_EQ(20, platformMouseBuilder.movementDelta().x()); 615 EXPECT_EQ(20, platformMouseBuilder.movementDelta().x());
616 EXPECT_EQ(20, platformMouseBuilder.movementDelta().y()); 616 EXPECT_EQ(20, platformMouseBuilder.movementDelta().y());
617 } 617 }
618 618
619 { 619 {
620 WebMouseEvent webMouseEvent1;
621 webMouseEvent1.type = WebInputEvent::MouseMove;
622 webMouseEvent1.x = 100;
623 webMouseEvent1.y = 110;
624 webMouseEvent1.windowX = 100;
625 webMouseEvent1.windowY = 110;
626 webMouseEvent1.globalX = 100;
627 webMouseEvent1.globalY = 110;
628 webMouseEvent1.movementX = 60;
629 webMouseEvent1.movementY = 60;
630
631 WebMouseEvent webMouseEvent2 = webMouseEvent1;
632 webMouseEvent2.y = 140;
633 webMouseEvent2.windowY = 140;
634 webMouseEvent2.globalY = 140;
635 webMouseEvent2.movementY = 30;
636
637 std::vector<const WebInputEvent*> events;
638 events.push_back(&webMouseEvent1);
639 events.push_back(&webMouseEvent2);
640
641 Vector<PlatformMouseEvent> coalescedevents =
642 createPlatformMouseEventVector(view, events);
643 EXPECT_EQ(events.size(), coalescedevents.size());
644
645 EXPECT_EQ(30, coalescedevents[0].position().x());
646 EXPECT_EQ(30, coalescedevents[0].position().y());
647 EXPECT_EQ(100, coalescedevents[0].globalPosition().x());
648 EXPECT_EQ(110, coalescedevents[0].globalPosition().y());
649 EXPECT_EQ(20, coalescedevents[0].movementDelta().x());
650 EXPECT_EQ(20, coalescedevents[0].movementDelta().y());
651
652 EXPECT_EQ(30, coalescedevents[1].position().x());
653 EXPECT_EQ(40, coalescedevents[1].position().y());
654 EXPECT_EQ(100, coalescedevents[1].globalPosition().x());
655 EXPECT_EQ(140, coalescedevents[1].globalPosition().y());
656 EXPECT_EQ(20, coalescedevents[1].movementDelta().x());
657 EXPECT_EQ(10, coalescedevents[1].movementDelta().y());
658 }
659
660 {
620 WebGestureEvent webGestureEvent; 661 WebGestureEvent webGestureEvent;
621 webGestureEvent.type = WebInputEvent::GestureScrollUpdate; 662 webGestureEvent.type = WebInputEvent::GestureScrollUpdate;
622 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; 663 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen;
623 webGestureEvent.x = 100; 664 webGestureEvent.x = 100;
624 webGestureEvent.y = 110; 665 webGestureEvent.y = 110;
625 webGestureEvent.globalX = 100; 666 webGestureEvent.globalX = 100;
626 webGestureEvent.globalY = 110; 667 webGestureEvent.globalY = 110;
627 webGestureEvent.data.scrollUpdate.deltaX = 60; 668 webGestureEvent.data.scrollUpdate.deltaX = 60;
628 webGestureEvent.data.scrollUpdate.deltaY = 60; 669 webGestureEvent.data.scrollUpdate.deltaY = 60;
629 670
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 763
723 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); 764 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent);
724 EXPECT_FLOAT_EQ(100, platformTouchBuilder.touchPoints()[0].screenPos().x()); 765 EXPECT_FLOAT_EQ(100, platformTouchBuilder.touchPoints()[0].screenPos().x());
725 EXPECT_FLOAT_EQ(110, platformTouchBuilder.touchPoints()[0].screenPos().y()); 766 EXPECT_FLOAT_EQ(110, platformTouchBuilder.touchPoints()[0].screenPos().y());
726 EXPECT_FLOAT_EQ(30, platformTouchBuilder.touchPoints()[0].pos().x()); 767 EXPECT_FLOAT_EQ(30, platformTouchBuilder.touchPoints()[0].pos().x());
727 EXPECT_FLOAT_EQ(30, platformTouchBuilder.touchPoints()[0].pos().y()); 768 EXPECT_FLOAT_EQ(30, platformTouchBuilder.touchPoints()[0].pos().y());
728 EXPECT_FLOAT_EQ(10, platformTouchBuilder.touchPoints()[0].radius().width()); 769 EXPECT_FLOAT_EQ(10, platformTouchBuilder.touchPoints()[0].radius().width());
729 EXPECT_FLOAT_EQ(10, 770 EXPECT_FLOAT_EQ(10,
730 platformTouchBuilder.touchPoints()[0].radius().height()); 771 platformTouchBuilder.touchPoints()[0].radius().height());
731 } 772 }
773
774 {
775 WebTouchEvent webTouchEvent1;
776 webTouchEvent1.type = WebInputEvent::TouchMove;
777 webTouchEvent1.touchesLength = 1;
778 webTouchEvent1.touches[0].state = WebTouchPoint::StateMoved;
779 webTouchEvent1.touches[0].screenPosition.x = 100;
780 webTouchEvent1.touches[0].screenPosition.y = 110;
781 webTouchEvent1.touches[0].position.x = 100;
782 webTouchEvent1.touches[0].position.y = 110;
783 webTouchEvent1.touches[0].radiusX = 30;
784 webTouchEvent1.touches[0].radiusY = 30;
785
786 WebTouchEvent webTouchEvent2 = webTouchEvent1;
787 webTouchEvent2.touches[0].screenPosition.x = 130;
788 webTouchEvent2.touches[0].position.x = 130;
789 webTouchEvent2.touches[0].radiusX = 60;
790
791 std::vector<const WebInputEvent*> events;
792 events.push_back(&webTouchEvent1);
793 events.push_back(&webTouchEvent2);
794
795 Vector<PlatformTouchEvent> coalescedevents =
796 createPlatformTouchEventVector(view, events);
797 EXPECT_EQ(events.size(), coalescedevents.size());
798
799 EXPECT_FLOAT_EQ(100, coalescedevents[0].touchPoints()[0].screenPos().x());
800 EXPECT_FLOAT_EQ(110, coalescedevents[0].touchPoints()[0].screenPos().y());
801 EXPECT_FLOAT_EQ(30, coalescedevents[0].touchPoints()[0].pos().x());
802 EXPECT_FLOAT_EQ(30, coalescedevents[0].touchPoints()[0].pos().y());
803 EXPECT_FLOAT_EQ(10, coalescedevents[0].touchPoints()[0].radius().width());
804 EXPECT_FLOAT_EQ(10, coalescedevents[0].touchPoints()[0].radius().height());
805
806 EXPECT_FLOAT_EQ(130, coalescedevents[1].touchPoints()[0].screenPos().x());
807 EXPECT_FLOAT_EQ(110, coalescedevents[1].touchPoints()[0].screenPos().y());
808 EXPECT_FLOAT_EQ(40, coalescedevents[1].touchPoints()[0].pos().x());
809 EXPECT_FLOAT_EQ(30, coalescedevents[1].touchPoints()[0].pos().y());
810 EXPECT_FLOAT_EQ(20, coalescedevents[1].touchPoints()[0].radius().width());
811 EXPECT_FLOAT_EQ(10, coalescedevents[1].touchPoints()[0].radius().height());
812 }
732 } 813 }
733 814
734 TEST(WebInputEventConversionTest, InputEventsConversions) { 815 TEST(WebInputEventConversionTest, InputEventsConversions) {
735 const std::string baseURL("http://www.test3.com/"); 816 const std::string baseURL("http://www.test3.com/");
736 const std::string fileName("fixed_layout.html"); 817 const std::string fileName("fixed_layout.html");
737 818
738 URLTestHelpers::registerMockedURLFromBaseURL( 819 URLTestHelpers::registerMockedURLFromBaseURL(
739 WebString::fromUTF8(baseURL.c_str()), 820 WebString::fromUTF8(baseURL.c_str()),
740 WebString::fromUTF8("fixed_layout.html")); 821 WebString::fromUTF8("fixed_layout.html"));
741 FrameTestHelpers::WebViewHelper webViewHelper; 822 FrameTestHelpers::WebViewHelper webViewHelper;
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 EXPECT_EQ(ScrollInertialPhaseNonMomentum, 1328 EXPECT_EQ(ScrollInertialPhaseNonMomentum,
1248 platformGestureBuilder.inertialPhase()); 1329 platformGestureBuilder.inertialPhase());
1249 EXPECT_TRUE(platformGestureBuilder.synthetic()); 1330 EXPECT_TRUE(platformGestureBuilder.synthetic());
1250 EXPECT_EQ(ScrollGranularity::ScrollByPage, 1331 EXPECT_EQ(ScrollGranularity::ScrollByPage,
1251 platformGestureBuilder.deltaUnits()); 1332 platformGestureBuilder.deltaUnits());
1252 EXPECT_EQ(12345U, platformGestureBuilder.uniqueTouchEventId()); 1333 EXPECT_EQ(12345U, platformGestureBuilder.uniqueTouchEventId());
1253 } 1334 }
1254 } 1335 }
1255 1336
1256 } // namespace blink 1337 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/WebFrameTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698