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

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

Issue 600733002: Revert of EventSender: Added checks for missing arguments (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « no previous file | 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 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1633 // need/want that. 1633 // need/want that.
1634 is_drag_mode_ = false; 1634 is_drag_mode_ = false;
1635 1635
1636 // Make the rest of eventSender think a drag is in progress. 1636 // Make the rest of eventSender think a drag is in progress.
1637 pressed_button_ = WebMouseEvent::ButtonLeft; 1637 pressed_button_ = WebMouseEvent::ButtonLeft;
1638 } 1638 }
1639 1639
1640 void EventSender::AddTouchPoint(gin::Arguments* args) { 1640 void EventSender::AddTouchPoint(gin::Arguments* args) {
1641 double x; 1641 double x;
1642 double y; 1642 double y;
1643 if (!args->GetNext(&x) || !args->GetNext(&y)) { 1643 args->GetNext(&x);
1644 args->ThrowError(); 1644 args->GetNext(&y);
1645 return;
1646 }
1647 1645
1648 WebTouchPoint touch_point; 1646 WebTouchPoint touch_point;
1649 touch_point.state = WebTouchPoint::StatePressed; 1647 touch_point.state = WebTouchPoint::StatePressed;
1650 touch_point.position = WebFloatPoint(static_cast<float>(x), 1648 touch_point.position = WebFloatPoint(static_cast<float>(x),
1651 static_cast<float>(y)); 1649 static_cast<float>(y));
1652 touch_point.screenPosition = touch_point.position; 1650 touch_point.screenPosition = touch_point.position;
1653 1651
1654 if (!args->PeekNext().IsEmpty()) { 1652 if (!args->PeekNext().IsEmpty()) {
1655 double radius_x; 1653 double radius_x;
1656 if (!args->GetNext(&radius_x)) { 1654 if (!args->GetNext(&radius_x)) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 InitMouseWheelEvent(args, true, &event); 1754 InitMouseWheelEvent(args, true, &event);
1757 view_->handleInputEvent(event); 1755 view_->handleInputEvent(event);
1758 } 1756 }
1759 1757
1760 void EventSender::MouseMoveTo(gin::Arguments* args) { 1758 void EventSender::MouseMoveTo(gin::Arguments* args) {
1761 if (force_layout_on_events_) 1759 if (force_layout_on_events_)
1762 view_->layout(); 1760 view_->layout();
1763 1761
1764 double x; 1762 double x;
1765 double y; 1763 double y;
1766 if (!args->GetNext(&x) || !args->GetNext(&y)) { 1764 args->GetNext(&x);
1767 args->ThrowError(); 1765 args->GetNext(&y);
1768 return;
1769 }
1770 WebPoint mouse_pos(static_cast<int>(x), static_cast<int>(y)); 1766 WebPoint mouse_pos(static_cast<int>(x), static_cast<int>(y));
1771 1767
1772 int modifiers = 0; 1768 int modifiers = 0;
1773 if (!args->PeekNext().IsEmpty()) 1769 if (!args->PeekNext().IsEmpty())
1774 modifiers = GetKeyModifiersFromV8(args->PeekNext()); 1770 modifiers = GetKeyModifiersFromV8(args->PeekNext());
1775 1771
1776 if (is_drag_mode_ && pressed_button_ == WebMouseEvent::ButtonLeft && 1772 if (is_drag_mode_ && pressed_button_ == WebMouseEvent::ButtonLeft &&
1777 !replaying_saved_events_) { 1773 !replaying_saved_events_) {
1778 SavedEvent saved_event; 1774 SavedEvent saved_event;
1779 saved_event.type = SavedEvent::TYPE_MOUSE_MOVE; 1775 saved_event.type = SavedEvent::TYPE_MOUSE_MOVE;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1921 --i; 1917 --i;
1922 } else 1918 } else
1923 touch_point->state = WebTouchPoint::StateStationary; 1919 touch_point->state = WebTouchPoint::StateStationary;
1924 } 1920 }
1925 } 1921 }
1926 1922
1927 void EventSender::GestureEvent(WebInputEvent::Type type, 1923 void EventSender::GestureEvent(WebInputEvent::Type type,
1928 gin::Arguments* args) { 1924 gin::Arguments* args) {
1929 double x; 1925 double x;
1930 double y; 1926 double y;
1931 if (!args->GetNext(&x) || !args->GetNext(&y)) { 1927 args->GetNext(&x);
1932 args->ThrowError(); 1928 args->GetNext(&y);
1933 return; 1929 WebPoint point(x, y);
1934 }
1935 1930
1936 WebGestureEvent event; 1931 WebGestureEvent event;
1937 event.type = type; 1932 event.type = type;
1938 1933
1939 switch (type) { 1934 switch (type) {
1940 case WebInputEvent::GestureScrollUpdate: 1935 case WebInputEvent::GestureScrollUpdate:
1941 case WebInputEvent::GestureScrollUpdateWithoutPropagation: 1936 case WebInputEvent::GestureScrollUpdateWithoutPropagation:
1942 event.data.scrollUpdate.deltaX = static_cast<float>(x); 1937 event.data.scrollUpdate.deltaX = static_cast<float>(x);
1943 event.data.scrollUpdate.deltaY = static_cast<float>(y); 1938 event.data.scrollUpdate.deltaY = static_cast<float>(y);
1944 event.x = current_gesture_location_.x; 1939 event.x = current_gesture_location_.x;
1945 event.y = current_gesture_location_.y; 1940 event.y = current_gesture_location_.y;
1946 current_gesture_location_.x = 1941 current_gesture_location_.x =
1947 current_gesture_location_.x + event.data.scrollUpdate.deltaX; 1942 current_gesture_location_.x + event.data.scrollUpdate.deltaX;
1948 current_gesture_location_.y = 1943 current_gesture_location_.y =
1949 current_gesture_location_.y + event.data.scrollUpdate.deltaY; 1944 current_gesture_location_.y + event.data.scrollUpdate.deltaY;
1950 break; 1945 break;
1951 case WebInputEvent::GestureScrollBegin: 1946 case WebInputEvent::GestureScrollBegin:
1952 current_gesture_location_ = WebPoint(x, y); 1947 current_gesture_location_ = WebPoint(point.x, point.y);
1953 event.x = current_gesture_location_.x; 1948 event.x = current_gesture_location_.x;
1954 event.y = current_gesture_location_.y; 1949 event.y = current_gesture_location_.y;
1955 break; 1950 break;
1956 case WebInputEvent::GestureScrollEnd: 1951 case WebInputEvent::GestureScrollEnd:
1957 case WebInputEvent::GestureFlingStart: 1952 case WebInputEvent::GestureFlingStart:
1958 event.x = current_gesture_location_.x; 1953 event.x = current_gesture_location_.x;
1959 event.y = current_gesture_location_.y; 1954 event.y = current_gesture_location_.y;
1960 break; 1955 break;
1961 case WebInputEvent::GestureTap: 1956 case WebInputEvent::GestureTap:
1962 { 1957 {
(...skipping 14 matching lines...) Expand all
1977 } 1972 }
1978 if (!args->PeekNext().IsEmpty()) { 1973 if (!args->PeekNext().IsEmpty()) {
1979 if (!args->GetNext(&height)) { 1974 if (!args->GetNext(&height)) {
1980 args->ThrowError(); 1975 args->ThrowError();
1981 return; 1976 return;
1982 } 1977 }
1983 } 1978 }
1984 event.data.tap.tapCount = tap_count; 1979 event.data.tap.tapCount = tap_count;
1985 event.data.tap.width = width; 1980 event.data.tap.width = width;
1986 event.data.tap.height = height; 1981 event.data.tap.height = height;
1987 event.x = x; 1982 event.x = point.x;
1988 event.y = y; 1983 event.y = point.y;
1989 break; 1984 break;
1990 } 1985 }
1991 case WebInputEvent::GestureTapUnconfirmed: 1986 case WebInputEvent::GestureTapUnconfirmed:
1992 if (!args->PeekNext().IsEmpty()) { 1987 if (!args->PeekNext().IsEmpty()) {
1993 float tap_count; 1988 float tap_count;
1994 if (!args->GetNext(&tap_count)) { 1989 if (!args->GetNext(&tap_count)) {
1995 args->ThrowError(); 1990 args->ThrowError();
1996 return; 1991 return;
1997 } 1992 }
1998 event.data.tap.tapCount = tap_count; 1993 event.data.tap.tapCount = tap_count;
1999 } else { 1994 } else {
2000 event.data.tap.tapCount = 1; 1995 event.data.tap.tapCount = 1;
2001 } 1996 }
2002 event.x = x; 1997 event.x = point.x;
2003 event.y = y; 1998 event.y = point.y;
2004 break; 1999 break;
2005 case WebInputEvent::GestureTapDown: 2000 case WebInputEvent::GestureTapDown:
2006 { 2001 {
2007 float width = 30; 2002 float width = 30;
2008 float height = 30; 2003 float height = 30;
2009 if (!args->PeekNext().IsEmpty()) { 2004 if (!args->PeekNext().IsEmpty()) {
2010 if (!args->GetNext(&width)) { 2005 if (!args->GetNext(&width)) {
2011 args->ThrowError(); 2006 args->ThrowError();
2012 return; 2007 return;
2013 } 2008 }
2014 } 2009 }
2015 if (!args->PeekNext().IsEmpty()) { 2010 if (!args->PeekNext().IsEmpty()) {
2016 if (!args->GetNext(&height)) { 2011 if (!args->GetNext(&height)) {
2017 args->ThrowError(); 2012 args->ThrowError();
2018 return; 2013 return;
2019 } 2014 }
2020 } 2015 }
2021 event.x = x; 2016 event.x = point.x;
2022 event.y = y; 2017 event.y = point.y;
2023 event.data.tapDown.width = width; 2018 event.data.tapDown.width = width;
2024 event.data.tapDown.height = height; 2019 event.data.tapDown.height = height;
2025 break; 2020 break;
2026 } 2021 }
2027 case WebInputEvent::GestureShowPress: 2022 case WebInputEvent::GestureShowPress:
2028 { 2023 {
2029 float width = 30; 2024 float width = 30;
2030 float height = 30; 2025 float height = 30;
2031 if (!args->PeekNext().IsEmpty()) { 2026 if (!args->PeekNext().IsEmpty()) {
2032 if (!args->GetNext(&width)) { 2027 if (!args->GetNext(&width)) {
2033 args->ThrowError(); 2028 args->ThrowError();
2034 return; 2029 return;
2035 } 2030 }
2036 if (!args->PeekNext().IsEmpty()) { 2031 if (!args->PeekNext().IsEmpty()) {
2037 if (!args->GetNext(&height)) { 2032 if (!args->GetNext(&height)) {
2038 args->ThrowError(); 2033 args->ThrowError();
2039 return; 2034 return;
2040 } 2035 }
2041 } 2036 }
2042 } 2037 }
2043 event.x = x; 2038 event.x = point.x;
2044 event.y = y; 2039 event.y = point.y;
2045 event.data.showPress.width = width; 2040 event.data.showPress.width = width;
2046 event.data.showPress.height = height; 2041 event.data.showPress.height = height;
2047 break; 2042 break;
2048 } 2043 }
2049 case WebInputEvent::GestureTapCancel: 2044 case WebInputEvent::GestureTapCancel:
2050 event.x = x; 2045 event.x = point.x;
2051 event.y = y; 2046 event.y = point.y;
2052 break; 2047 break;
2053 case WebInputEvent::GestureLongPress: 2048 case WebInputEvent::GestureLongPress:
2054 event.x = x; 2049 event.x = point.x;
2055 event.y = y; 2050 event.y = point.y;
2056 if (!args->PeekNext().IsEmpty()) { 2051 if (!args->PeekNext().IsEmpty()) {
2057 float width; 2052 float width;
2058 if (!args->GetNext(&width)) { 2053 if (!args->GetNext(&width)) {
2059 args->ThrowError(); 2054 args->ThrowError();
2060 return; 2055 return;
2061 } 2056 }
2062 event.data.longPress.width = width; 2057 event.data.longPress.width = width;
2063 if (!args->PeekNext().IsEmpty()) { 2058 if (!args->PeekNext().IsEmpty()) {
2064 float height; 2059 float height;
2065 if (!args->GetNext(&height)) { 2060 if (!args->GetNext(&height)) {
2066 args->ThrowError(); 2061 args->ThrowError();
2067 return; 2062 return;
2068 } 2063 }
2069 event.data.longPress.height = height; 2064 event.data.longPress.height = height;
2070 } 2065 }
2071 } 2066 }
2072 break; 2067 break;
2073 case WebInputEvent::GestureLongTap: 2068 case WebInputEvent::GestureLongTap:
2074 event.x = x; 2069 event.x = point.x;
2075 event.y = y; 2070 event.y = point.y;
2076 if (!args->PeekNext().IsEmpty()) { 2071 if (!args->PeekNext().IsEmpty()) {
2077 float width; 2072 float width;
2078 if (!args->GetNext(&width)) { 2073 if (!args->GetNext(&width)) {
2079 args->ThrowError(); 2074 args->ThrowError();
2080 return; 2075 return;
2081 } 2076 }
2082 event.data.longPress.width = width; 2077 event.data.longPress.width = width;
2083 if (!args->PeekNext().IsEmpty()) { 2078 if (!args->PeekNext().IsEmpty()) {
2084 float height; 2079 float height;
2085 if (!args->GetNext(&height)) { 2080 if (!args->GetNext(&height)) {
2086 args->ThrowError(); 2081 args->ThrowError();
2087 return; 2082 return;
2088 } 2083 }
2089 event.data.longPress.height = height; 2084 event.data.longPress.height = height;
2090 } 2085 }
2091 } 2086 }
2092 break; 2087 break;
2093 case WebInputEvent::GestureTwoFingerTap: 2088 case WebInputEvent::GestureTwoFingerTap:
2094 event.x = x; 2089 event.x = point.x;
2095 event.y = y; 2090 event.y = point.y;
2096 if (!args->PeekNext().IsEmpty()) { 2091 if (!args->PeekNext().IsEmpty()) {
2097 float first_finger_width; 2092 float first_finger_width;
2098 if (!args->GetNext(&first_finger_width)) { 2093 if (!args->GetNext(&first_finger_width)) {
2099 args->ThrowError(); 2094 args->ThrowError();
2100 return; 2095 return;
2101 } 2096 }
2102 event.data.twoFingerTap.firstFingerWidth = first_finger_width; 2097 event.data.twoFingerTap.firstFingerWidth = first_finger_width;
2103 if (!args->PeekNext().IsEmpty()) { 2098 if (!args->PeekNext().IsEmpty()) {
2104 float first_finger_height; 2099 float first_finger_height;
2105 if (!args->GetNext(&first_finger_height)) { 2100 if (!args->GetNext(&first_finger_height)) {
(...skipping 15 matching lines...) Expand all
2121 if (force_layout_on_events_) 2116 if (force_layout_on_events_)
2122 view_->layout(); 2117 view_->layout();
2123 2118
2124 bool result = view_->handleInputEvent(event); 2119 bool result = view_->handleInputEvent(event);
2125 2120
2126 // Long press might start a drag drop session. Complete it if so. 2121 // Long press might start a drag drop session. Complete it if so.
2127 if (type == WebInputEvent::GestureLongPress && !current_drag_data_.isNull()) { 2122 if (type == WebInputEvent::GestureLongPress && !current_drag_data_.isNull()) {
2128 WebMouseEvent mouse_event; 2123 WebMouseEvent mouse_event;
2129 InitMouseEvent(WebInputEvent::MouseDown, 2124 InitMouseEvent(WebInputEvent::MouseDown,
2130 pressed_button_, 2125 pressed_button_,
2131 WebPoint(x, y), 2126 point,
2132 GetCurrentEventTimeSec(), 2127 GetCurrentEventTimeSec(),
2133 click_count_, 2128 click_count_,
2134 0, 2129 0,
2135 &mouse_event); 2130 &mouse_event);
2136 2131
2137 FinishDragAndDrop(mouse_event, blink::WebDragOperationNone); 2132 FinishDragAndDrop(mouse_event, blink::WebDragOperationNone);
2138 } 2133 }
2139 args->Return(result); 2134 args->Return(result);
2140 } 2135 }
2141 2136
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
2296 } 2291 }
2297 default: 2292 default:
2298 NOTREACHED(); 2293 NOTREACHED();
2299 } 2294 }
2300 } 2295 }
2301 2296
2302 replaying_saved_events_ = false; 2297 replaying_saved_events_ = false;
2303 } 2298 }
2304 2299
2305 } // namespace content 2300 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698