OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /* |
| 6 EventSender class: |
| 7 Bound to a JavaScript window.eventSender object using |
| 8 CppBoundClass::bindToJavascript(), this allows layout tests to fire DOM events
. |
| 9 */ |
| 10 |
| 11 #ifndef EventSender_h |
| 12 #define EventSender_h |
| 13 |
| 14 #include "content/shell/renderer/test_runner/CppBoundClass.h" |
| 15 #include "content/shell/renderer/test_runner/WebScopedPtr.h" |
| 16 #include "content/shell/renderer/test_runner/WebTask.h" |
| 17 #include "third_party/WebKit/public/platform/WebPoint.h" |
| 18 #include "third_party/WebKit/public/web/WebDragOperation.h" |
| 19 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 20 |
| 21 namespace blink { |
| 22 class WebDragData; |
| 23 class WebView; |
| 24 struct WebContextMenuData; |
| 25 } |
| 26 |
| 27 namespace WebTestRunner { |
| 28 |
| 29 class TestInterfaces; |
| 30 class WebTestDelegate; |
| 31 |
| 32 class EventSender : public CppBoundClass { |
| 33 public: |
| 34 explicit EventSender(TestInterfaces*); |
| 35 ~EventSender(); |
| 36 |
| 37 void setDelegate(WebTestDelegate* delegate) { m_delegate = delegate; } |
| 38 void setWebView(blink::WebView* webView) { m_webView = webView; } |
| 39 |
| 40 void setContextMenuData(const blink::WebContextMenuData&); |
| 41 |
| 42 // Resets some static variable state. |
| 43 void reset(); |
| 44 |
| 45 // Simulate drag&drop system call. |
| 46 void doDragDrop(const blink::WebDragData&, blink::WebDragOperationsMask); |
| 47 |
| 48 // Test helper for dragging out images. |
| 49 void dumpFilenameBeingDragged(const CppArgumentList&, CppVariant*); |
| 50 |
| 51 // JS callback methods. |
| 52 void contextClick(const CppArgumentList&, CppVariant*); |
| 53 void mouseDown(const CppArgumentList&, CppVariant*); |
| 54 void mouseUp(const CppArgumentList&, CppVariant*); |
| 55 void mouseMoveTo(const CppArgumentList&, CppVariant*); |
| 56 void leapForward(const CppArgumentList&, CppVariant*); |
| 57 void keyDown(const CppArgumentList&, CppVariant*); |
| 58 void dispatchMessage(const CppArgumentList&, CppVariant*); |
| 59 // FIXME: These aren't really events. They should be moved to layout control
ler. |
| 60 void textZoomIn(const CppArgumentList&, CppVariant*); |
| 61 void textZoomOut(const CppArgumentList&, CppVariant*); |
| 62 void zoomPageIn(const CppArgumentList&, CppVariant*); |
| 63 void zoomPageOut(const CppArgumentList&, CppVariant*); |
| 64 void setPageScaleFactor(const CppArgumentList&, CppVariant*); |
| 65 |
| 66 void mouseDragBegin(const CppArgumentList&, CppVariant*); |
| 67 void mouseDragEnd(const CppArgumentList&, CppVariant*); |
| 68 void mouseMomentumBegin(const CppArgumentList&, CppVariant*); |
| 69 void mouseMomentumScrollBy(const CppArgumentList&, CppVariant*); |
| 70 void mouseMomentumEnd(const CppArgumentList&, CppVariant*); |
| 71 void mouseScrollBy(const CppArgumentList&, CppVariant*); |
| 72 void continuousMouseScrollBy(const CppArgumentList&, CppVariant*); |
| 73 void scheduleAsynchronousClick(const CppArgumentList&, CppVariant*); |
| 74 void scheduleAsynchronousKeyDown(const CppArgumentList&, CppVariant*); |
| 75 void beginDragWithFiles(const CppArgumentList&, CppVariant*); |
| 76 CppVariant dragMode; |
| 77 |
| 78 void addTouchPoint(const CppArgumentList&, CppVariant*); |
| 79 void cancelTouchPoint(const CppArgumentList&, CppVariant*); |
| 80 void clearTouchPoints(const CppArgumentList&, CppVariant*); |
| 81 void releaseTouchPoint(const CppArgumentList&, CppVariant*); |
| 82 void setTouchModifier(const CppArgumentList&, CppVariant*); |
| 83 void touchCancel(const CppArgumentList&, CppVariant*); |
| 84 void touchEnd(const CppArgumentList&, CppVariant*); |
| 85 void touchMove(const CppArgumentList&, CppVariant*); |
| 86 void touchStart(const CppArgumentList&, CppVariant*); |
| 87 void updateTouchPoint(const CppArgumentList&, CppVariant*); |
| 88 |
| 89 void gestureFlingCancel(const CppArgumentList&, CppVariant*); |
| 90 void gestureFlingStart(const CppArgumentList&, CppVariant*); |
| 91 void gestureScrollBegin(const CppArgumentList&, CppVariant*); |
| 92 void gestureScrollEnd(const CppArgumentList&, CppVariant*); |
| 93 void gestureScrollFirstPoint(const CppArgumentList&, CppVariant*); |
| 94 void gestureScrollUpdate(const CppArgumentList&, CppVariant*); |
| 95 void gestureScrollUpdateWithoutPropagation(const CppArgumentList&, CppVarian
t*); |
| 96 void gestureTap(const CppArgumentList&, CppVariant*); |
| 97 void gestureTapDown(const CppArgumentList&, CppVariant*); |
| 98 void gestureShowPress(const CppArgumentList&, CppVariant*); |
| 99 void gestureTapCancel(const CppArgumentList&, CppVariant*); |
| 100 void gestureLongPress(const CppArgumentList&, CppVariant*); |
| 101 void gestureLongTap(const CppArgumentList&, CppVariant*); |
| 102 void gestureTwoFingerTap(const CppArgumentList&, CppVariant*); |
| 103 void gestureEvent(blink::WebInputEvent::Type, const CppArgumentList&); |
| 104 |
| 105 // Setting this to false makes EventSender not force layout() calls. |
| 106 // This makes it possible to test the standard WebCore event dispatch. |
| 107 CppVariant forceLayoutOnEvents; |
| 108 |
| 109 // Unimplemented stubs |
| 110 void enableDOMUIEventLogging(const CppArgumentList&, CppVariant*); |
| 111 void fireKeyboardEventsToElement(const CppArgumentList&, CppVariant*); |
| 112 void clearKillRing(const CppArgumentList&, CppVariant*); |
| 113 |
| 114 // Properties used in layout tests. |
| 115 #if defined(OS_WIN) |
| 116 CppVariant wmKeyDown; |
| 117 CppVariant wmKeyUp; |
| 118 CppVariant wmChar; |
| 119 CppVariant wmDeadChar; |
| 120 CppVariant wmSysKeyDown; |
| 121 CppVariant wmSysKeyUp; |
| 122 CppVariant wmSysChar; |
| 123 CppVariant wmSysDeadChar; |
| 124 #endif |
| 125 |
| 126 WebTaskList* taskList() { return &m_taskList; } |
| 127 |
| 128 private: |
| 129 blink::WebView* webview() { return m_webView; } |
| 130 |
| 131 // Returns true if dragMode is true. |
| 132 bool isDragMode() { return dragMode.isBool() && dragMode.toBoolean(); } |
| 133 |
| 134 bool shouldForceLayoutOnEvents() const { return forceLayoutOnEvents.isBool()
&& forceLayoutOnEvents.toBoolean(); } |
| 135 |
| 136 // Sometimes we queue up mouse move and mouse up events for drag drop |
| 137 // handling purposes. These methods dispatch the event. |
| 138 void doMouseMove(const blink::WebMouseEvent&); |
| 139 void doMouseUp(const blink::WebMouseEvent&); |
| 140 static void doLeapForward(int milliseconds); |
| 141 void replaySavedEvents(); |
| 142 |
| 143 // Helper to return the button type given a button code |
| 144 static blink::WebMouseEvent::Button getButtonTypeFromButtonNumber(int); |
| 145 |
| 146 // Helper to extract the button number from the optional argument in |
| 147 // mouseDown and mouseUp |
| 148 static int getButtonNumberFromSingleArg(const CppArgumentList&); |
| 149 |
| 150 // Returns true if the specified key code passed in needs a shift key |
| 151 // modifier to be passed into the generated event. |
| 152 bool needsShiftModifier(int); |
| 153 |
| 154 void finishDragAndDrop(const blink::WebMouseEvent&, blink::WebDragOperation)
; |
| 155 void updateClickCountForButton(blink::WebMouseEvent::Button); |
| 156 |
| 157 // Compose a touch event from the current touch points and send it. |
| 158 void sendCurrentTouchEvent(const blink::WebInputEvent::Type); |
| 159 |
| 160 // Init a mouse wheel event from the given args. |
| 161 void initMouseWheelEvent(const CppArgumentList&, CppVariant*, bool continuou
s, blink::WebMouseWheelEvent*); |
| 162 |
| 163 WebTaskList m_taskList; |
| 164 |
| 165 TestInterfaces* m_testInterfaces; |
| 166 WebTestDelegate* m_delegate; |
| 167 blink::WebView* m_webView; |
| 168 |
| 169 WebScopedPtr<blink::WebContextMenuData> m_lastContextMenuData; |
| 170 |
| 171 // Location of the touch point that initiated a gesture. |
| 172 blink::WebPoint m_currentGestureLocation; |
| 173 |
| 174 // Location of last mouseMoveTo event. |
| 175 static blink::WebPoint lastMousePos; |
| 176 |
| 177 // Currently pressed mouse button (Left/Right/Middle or None) |
| 178 static blink::WebMouseEvent::Button pressedButton; |
| 179 |
| 180 // The last button number passed to mouseDown and mouseUp. |
| 181 // Used to determine whether the click count continues to |
| 182 // increment or not. |
| 183 static blink::WebMouseEvent::Button lastButtonType; |
| 184 }; |
| 185 |
| 186 } |
| 187 |
| 188 #endif // EventSender_h |
OLD | NEW |