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

Side by Side Diff: content/shell/renderer/test_runner/event_sender.cc

Issue 886633006: Enable sending gesture events from layout tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add optional argument for type Created 5 years, 10 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
« no previous file with comments | « content/shell/renderer/test_runner/event_sender.h ('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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/shell/renderer/test_runner/event_sender.h" 5 #include "content/shell/renderer/test_runner/event_sender.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "content/public/common/page_zoom.h" 10 #include "content/public/common/page_zoom.h"
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 void TouchCancel(); 389 void TouchCancel();
390 void TouchEnd(); 390 void TouchEnd();
391 void LeapForward(int milliseconds); 391 void LeapForward(int milliseconds);
392 void BeginDragWithFiles(const std::vector<std::string>& files); 392 void BeginDragWithFiles(const std::vector<std::string>& files);
393 void AddTouchPoint(gin::Arguments* args); 393 void AddTouchPoint(gin::Arguments* args);
394 void MouseDragBegin(); 394 void MouseDragBegin();
395 void MouseDragEnd(); 395 void MouseDragEnd();
396 void GestureScrollBegin(gin::Arguments* args); 396 void GestureScrollBegin(gin::Arguments* args);
397 void GestureScrollEnd(gin::Arguments* args); 397 void GestureScrollEnd(gin::Arguments* args);
398 void GestureScrollUpdate(gin::Arguments* args); 398 void GestureScrollUpdate(gin::Arguments* args);
399 void GesturePinchBegin(gin::Arguments* args);
400 void GesturePinchEnd(gin::Arguments* args);
401 void GesturePinchUpdate(gin::Arguments* args);
399 void GestureTap(gin::Arguments* args); 402 void GestureTap(gin::Arguments* args);
400 void GestureTapDown(gin::Arguments* args); 403 void GestureTapDown(gin::Arguments* args);
401 void GestureShowPress(gin::Arguments* args); 404 void GestureShowPress(gin::Arguments* args);
402 void GestureTapCancel(gin::Arguments* args); 405 void GestureTapCancel(gin::Arguments* args);
403 void GestureLongPress(gin::Arguments* args); 406 void GestureLongPress(gin::Arguments* args);
404 void GestureLongTap(gin::Arguments* args); 407 void GestureLongTap(gin::Arguments* args);
405 void GestureTwoFingerTap(gin::Arguments* args); 408 void GestureTwoFingerTap(gin::Arguments* args);
406 void ContinuousMouseScrollBy(gin::Arguments* args); 409 void ContinuousMouseScrollBy(gin::Arguments* args);
407 void MouseMoveTo(gin::Arguments* args); 410 void MouseMoveTo(gin::Arguments* args);
408 void TrackpadScrollBegin(); 411 void TrackpadScrollBegin();
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 .SetMethod("touchEnd", &EventSenderBindings::TouchEnd) 522 .SetMethod("touchEnd", &EventSenderBindings::TouchEnd)
520 .SetMethod("leapForward", &EventSenderBindings::LeapForward) 523 .SetMethod("leapForward", &EventSenderBindings::LeapForward)
521 .SetMethod("beginDragWithFiles", &EventSenderBindings::BeginDragWithFiles) 524 .SetMethod("beginDragWithFiles", &EventSenderBindings::BeginDragWithFiles)
522 .SetMethod("addTouchPoint", &EventSenderBindings::AddTouchPoint) 525 .SetMethod("addTouchPoint", &EventSenderBindings::AddTouchPoint)
523 .SetMethod("mouseDragBegin", &EventSenderBindings::MouseDragBegin) 526 .SetMethod("mouseDragBegin", &EventSenderBindings::MouseDragBegin)
524 .SetMethod("mouseDragEnd", &EventSenderBindings::MouseDragEnd) 527 .SetMethod("mouseDragEnd", &EventSenderBindings::MouseDragEnd)
525 .SetMethod("gestureScrollBegin", &EventSenderBindings::GestureScrollBegin) 528 .SetMethod("gestureScrollBegin", &EventSenderBindings::GestureScrollBegin)
526 .SetMethod("gestureScrollEnd", &EventSenderBindings::GestureScrollEnd) 529 .SetMethod("gestureScrollEnd", &EventSenderBindings::GestureScrollEnd)
527 .SetMethod("gestureScrollUpdate", 530 .SetMethod("gestureScrollUpdate",
528 &EventSenderBindings::GestureScrollUpdate) 531 &EventSenderBindings::GestureScrollUpdate)
532 .SetMethod("gesturePinchBegin", &EventSenderBindings::GesturePinchBegin)
533 .SetMethod("gesturePinchEnd", &EventSenderBindings::GesturePinchEnd)
534 .SetMethod("gesturePinchUpdate", &EventSenderBindings::GesturePinchUpdate)
529 .SetMethod("gestureTap", &EventSenderBindings::GestureTap) 535 .SetMethod("gestureTap", &EventSenderBindings::GestureTap)
530 .SetMethod("gestureTapDown", &EventSenderBindings::GestureTapDown) 536 .SetMethod("gestureTapDown", &EventSenderBindings::GestureTapDown)
531 .SetMethod("gestureShowPress", &EventSenderBindings::GestureShowPress) 537 .SetMethod("gestureShowPress", &EventSenderBindings::GestureShowPress)
532 .SetMethod("gestureTapCancel", &EventSenderBindings::GestureTapCancel) 538 .SetMethod("gestureTapCancel", &EventSenderBindings::GestureTapCancel)
533 .SetMethod("gestureLongPress", &EventSenderBindings::GestureLongPress) 539 .SetMethod("gestureLongPress", &EventSenderBindings::GestureLongPress)
534 .SetMethod("gestureLongTap", &EventSenderBindings::GestureLongTap) 540 .SetMethod("gestureLongTap", &EventSenderBindings::GestureLongTap)
535 .SetMethod("gestureTwoFingerTap", 541 .SetMethod("gestureTwoFingerTap",
536 &EventSenderBindings::GestureTwoFingerTap) 542 &EventSenderBindings::GestureTwoFingerTap)
537 .SetMethod("continuousMouseScrollBy", 543 .SetMethod("continuousMouseScrollBy",
538 &EventSenderBindings::ContinuousMouseScrollBy) 544 &EventSenderBindings::ContinuousMouseScrollBy)
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 void EventSenderBindings::GestureScrollEnd(gin::Arguments* args) { 784 void EventSenderBindings::GestureScrollEnd(gin::Arguments* args) {
779 if (sender_) 785 if (sender_)
780 sender_->GestureScrollEnd(args); 786 sender_->GestureScrollEnd(args);
781 } 787 }
782 788
783 void EventSenderBindings::GestureScrollUpdate(gin::Arguments* args) { 789 void EventSenderBindings::GestureScrollUpdate(gin::Arguments* args) {
784 if (sender_) 790 if (sender_)
785 sender_->GestureScrollUpdate(args); 791 sender_->GestureScrollUpdate(args);
786 } 792 }
787 793
794 void EventSenderBindings::GesturePinchBegin(gin::Arguments* args) {
795 if (sender_)
796 sender_->GesturePinchBegin(args);
797 }
798
799 void EventSenderBindings::GesturePinchEnd(gin::Arguments* args) {
800 if (sender_)
801 sender_->GesturePinchEnd(args);
802 }
803
804 void EventSenderBindings::GesturePinchUpdate(gin::Arguments* args) {
805 if (sender_)
806 sender_->GesturePinchUpdate(args);
807 }
808
788 void EventSenderBindings::GestureTap(gin::Arguments* args) { 809 void EventSenderBindings::GestureTap(gin::Arguments* args) {
789 if (sender_) 810 if (sender_)
790 sender_->GestureTap(args); 811 sender_->GestureTap(args);
791 } 812 }
792 813
793 void EventSenderBindings::GestureTapDown(gin::Arguments* args) { 814 void EventSenderBindings::GestureTapDown(gin::Arguments* args) {
794 if (sender_) 815 if (sender_)
795 sender_->GestureTapDown(args); 816 sender_->GestureTapDown(args);
796 } 817 }
797 818
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
1742 } 1763 }
1743 1764
1744 void EventSender::GestureScrollEnd(gin::Arguments* args) { 1765 void EventSender::GestureScrollEnd(gin::Arguments* args) {
1745 GestureEvent(WebInputEvent::GestureScrollEnd, args); 1766 GestureEvent(WebInputEvent::GestureScrollEnd, args);
1746 } 1767 }
1747 1768
1748 void EventSender::GestureScrollUpdate(gin::Arguments* args) { 1769 void EventSender::GestureScrollUpdate(gin::Arguments* args) {
1749 GestureEvent(WebInputEvent::GestureScrollUpdate, args); 1770 GestureEvent(WebInputEvent::GestureScrollUpdate, args);
1750 } 1771 }
1751 1772
1773 void EventSender::GesturePinchBegin(gin::Arguments* args) {
1774 GestureEvent(WebInputEvent::GesturePinchBegin, args);
1775 }
1776
1777 void EventSender::GesturePinchEnd(gin::Arguments* args) {
1778 GestureEvent(WebInputEvent::GesturePinchEnd, args);
1779 }
1780
1781 void EventSender::GesturePinchUpdate(gin::Arguments* args) {
1782 GestureEvent(WebInputEvent::GesturePinchUpdate, args);
1783 }
1784
1752 void EventSender::GestureTap(gin::Arguments* args) { 1785 void EventSender::GestureTap(gin::Arguments* args) {
1753 GestureEvent(WebInputEvent::GestureTap, args); 1786 GestureEvent(WebInputEvent::GestureTap, args);
1754 } 1787 }
1755 1788
1756 void EventSender::GestureTapDown(gin::Arguments* args) { 1789 void EventSender::GestureTapDown(gin::Arguments* args) {
1757 GestureEvent(WebInputEvent::GestureTapDown, args); 1790 GestureEvent(WebInputEvent::GestureTapDown, args);
1758 } 1791 }
1759 1792
1760 void EventSender::GestureShowPress(gin::Arguments* args) { 1793 void EventSender::GestureShowPress(gin::Arguments* args) {
1761 GestureEvent(WebInputEvent::GestureShowPress, args); 1794 GestureEvent(WebInputEvent::GestureShowPress, args);
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 if (touch_point->state == WebTouchPoint::StateReleased) { 1978 if (touch_point->state == WebTouchPoint::StateReleased) {
1946 touch_points_.erase(touch_points_.begin() + i); 1979 touch_points_.erase(touch_points_.begin() + i);
1947 --i; 1980 --i;
1948 } else 1981 } else
1949 touch_point->state = WebTouchPoint::StateStationary; 1982 touch_point->state = WebTouchPoint::StateStationary;
1950 } 1983 }
1951 } 1984 }
1952 1985
1953 void EventSender::GestureEvent(WebInputEvent::Type type, 1986 void EventSender::GestureEvent(WebInputEvent::Type type,
1954 gin::Arguments* args) { 1987 gin::Arguments* args) {
1988 WebGestureEvent event;
1989 event.type = type;
1990
1991 // If the first argument is a string, it is to specify the device, otherwise
1992 // the device is assumed to be a touchpad (this arrangement is because of
1993 // a number of of pre-existing tests that made this assumption before this
1994 // argument was added).
Rick Byers 2015/01/29 21:35:01 are you sure about this part in the parens? I bel
ccameron 2015/01/29 21:54:09 Oh -- I was going based on the undefined value's a
1995 event.sourceDevice = blink::WebGestureDeviceTouchpad;
1996 if (args->PeekNext()->IsString()) {
1997 std::string device_string;
1998 if (!args->GetNext(&device_string)) {
1999 args->ThrowError();
2000 return;
2001 }
2002 if (device_string == "touchpad") {
2003 event.sourceDevice = blink::WebGestureDeviceTouchpad;
2004 } else if (device_string == "touchscreen") {
2005 event.sourceDevice = blink::WebGestureDeviceTouchscreen;
2006 } else {
2007 args->ThrowError();
2008 return;
2009 }
2010 }
2011
1955 double x; 2012 double x;
1956 double y; 2013 double y;
1957 if (!args->GetNext(&x) || !args->GetNext(&y)) { 2014 if (!args->GetNext(&x) || !args->GetNext(&y)) {
1958 args->ThrowError(); 2015 args->ThrowError();
1959 return; 2016 return;
1960 } 2017 }
1961 2018
1962 WebGestureEvent event;
1963 event.type = type;
1964
1965 switch (type) { 2019 switch (type) {
1966 case WebInputEvent::GestureScrollUpdate: 2020 case WebInputEvent::GestureScrollUpdate:
1967 { 2021 {
1968 bool preventPropagation = false; 2022 bool preventPropagation = false;
1969 if (!args->PeekNext().IsEmpty()) { 2023 if (!args->PeekNext().IsEmpty()) {
1970 if (!args->GetNext(&preventPropagation)) { 2024 if (!args->GetNext(&preventPropagation)) {
1971 args->ThrowError(); 2025 args->ThrowError();
1972 return; 2026 return;
1973 } 2027 }
1974 } 2028 }
(...skipping 12 matching lines...) Expand all
1987 case WebInputEvent::GestureScrollBegin: 2041 case WebInputEvent::GestureScrollBegin:
1988 current_gesture_location_ = WebPoint(x, y); 2042 current_gesture_location_ = WebPoint(x, y);
1989 event.x = current_gesture_location_.x; 2043 event.x = current_gesture_location_.x;
1990 event.y = current_gesture_location_.y; 2044 event.y = current_gesture_location_.y;
1991 break; 2045 break;
1992 case WebInputEvent::GestureScrollEnd: 2046 case WebInputEvent::GestureScrollEnd:
1993 case WebInputEvent::GestureFlingStart: 2047 case WebInputEvent::GestureFlingStart:
1994 event.x = current_gesture_location_.x; 2048 event.x = current_gesture_location_.x;
1995 event.y = current_gesture_location_.y; 2049 event.y = current_gesture_location_.y;
1996 break; 2050 break;
2051 case WebInputEvent::GesturePinchBegin:
2052 case WebInputEvent::GesturePinchEnd:
2053 current_gesture_location_ = WebPoint(x, y);
2054 event.x = current_gesture_location_.x;
2055 event.y = current_gesture_location_.y;
2056 break;
2057 case WebInputEvent::GesturePinchUpdate:
2058 {
2059 float scale = 1;
2060 if (!args->PeekNext().IsEmpty()) {
2061 if (!args->GetNext(&scale)) {
2062 args->ThrowError();
2063 return;
2064 }
2065 }
2066 event.data.pinchUpdate.scale = scale;
2067 current_gesture_location_ = WebPoint(x, y);
2068 event.x = current_gesture_location_.x;
2069 event.y = current_gesture_location_.y;
2070 break;
2071 }
1997 case WebInputEvent::GestureTap: 2072 case WebInputEvent::GestureTap:
1998 { 2073 {
1999 float tap_count = 1; 2074 float tap_count = 1;
2000 float width = 30; 2075 float width = 30;
2001 float height = 30; 2076 float height = 30;
2002 if (!args->PeekNext().IsEmpty()) { 2077 if (!args->PeekNext().IsEmpty()) {
2003 if (!args->GetNext(&tap_count)) { 2078 if (!args->GetNext(&tap_count)) {
2004 args->ThrowError(); 2079 args->ThrowError();
2005 return; 2080 return;
2006 } 2081 }
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
2346 2421
2347 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) { 2422 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) {
2348 if (WebPagePopup* popup = view_->pagePopup()) { 2423 if (WebPagePopup* popup = view_->pagePopup()) {
2349 if (!WebInputEvent::isKeyboardEventType(event.type)) 2424 if (!WebInputEvent::isKeyboardEventType(event.type))
2350 return popup->handleInputEvent(event); 2425 return popup->handleInputEvent(event);
2351 } 2426 }
2352 return view_->handleInputEvent(event); 2427 return view_->handleInputEvent(event);
2353 } 2428 }
2354 2429
2355 } // namespace content 2430 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/renderer/test_runner/event_sender.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698