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

Side by Side Diff: content/test/layout_tests/runner/EventSender.h

Issue 110533009: Import TestRunner library into chromium. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 7 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 | Annotate | Revision Log
OLDNEW
(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 * Copyright (C) 2010 Google Inc. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following disclaimer
16 * in the documentation and/or other materials provided with the
17 * distribution.
18 * * Neither the name of Google Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived from
20 * this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 /*
36 EventSender class:
37 Bound to a JavaScript window.eventSender object using
38 CppBoundClass::bindToJavascript(), this allows layout tests to fire DOM events .
39 */
40
41 #ifndef EventSender_h
42 #define EventSender_h
43
44 #include "content/public/test/layout_tests/WebScopedPtr.h"
45 #include "content/public/test/layout_tests/WebTask.h"
46 #include "content/test/layout_tests/runner/CppBoundClass.h"
47 #include "third_party/WebKit/public/platform/WebPoint.h"
48 #include "third_party/WebKit/public/web/WebDragOperation.h"
49 #include "third_party/WebKit/public/web/WebInputEvent.h"
50
51 namespace blink {
52 class WebDragData;
53 class WebView;
54 struct WebContextMenuData;
55 }
56
57 namespace WebTestRunner {
58
59 class TestInterfaces;
60 class WebTestDelegate;
61
62 class EventSender : public CppBoundClass {
63 public:
64 explicit EventSender(TestInterfaces*);
65 ~EventSender();
66
67 void setDelegate(WebTestDelegate* delegate) { m_delegate = delegate; }
68 void setWebView(blink::WebView* webView) { m_webView = webView; }
69
70 void setContextMenuData(const blink::WebContextMenuData&);
71
72 // Resets some static variable state.
73 void reset();
74
75 // Simulate drag&drop system call.
76 void doDragDrop(const blink::WebDragData&, blink::WebDragOperationsMask);
77
78 // Test helper for dragging out images.
79 void dumpFilenameBeingDragged(const CppArgumentList&, CppVariant*);
80
81 // JS callback methods.
82 void contextClick(const CppArgumentList&, CppVariant*);
83 void mouseDown(const CppArgumentList&, CppVariant*);
84 void mouseUp(const CppArgumentList&, CppVariant*);
85 void mouseMoveTo(const CppArgumentList&, CppVariant*);
86 void leapForward(const CppArgumentList&, CppVariant*);
87 void keyDown(const CppArgumentList&, CppVariant*);
88 void dispatchMessage(const CppArgumentList&, CppVariant*);
89 // FIXME: These aren't really events. They should be moved to layout control ler.
90 void textZoomIn(const CppArgumentList&, CppVariant*);
91 void textZoomOut(const CppArgumentList&, CppVariant*);
92 void zoomPageIn(const CppArgumentList&, CppVariant*);
93 void zoomPageOut(const CppArgumentList&, CppVariant*);
94 void setPageScaleFactor(const CppArgumentList&, CppVariant*);
95
96 void mouseDragBegin(const CppArgumentList&, CppVariant*);
97 void mouseDragEnd(const CppArgumentList&, CppVariant*);
98 void mouseMomentumBegin(const CppArgumentList&, CppVariant*);
99 void mouseMomentumScrollBy(const CppArgumentList&, CppVariant*);
100 void mouseMomentumEnd(const CppArgumentList&, CppVariant*);
101 void mouseScrollBy(const CppArgumentList&, CppVariant*);
102 void continuousMouseScrollBy(const CppArgumentList&, CppVariant*);
103 void scheduleAsynchronousClick(const CppArgumentList&, CppVariant*);
104 void scheduleAsynchronousKeyDown(const CppArgumentList&, CppVariant*);
105 void beginDragWithFiles(const CppArgumentList&, CppVariant*);
106 CppVariant dragMode;
107
108 void addTouchPoint(const CppArgumentList&, CppVariant*);
109 void cancelTouchPoint(const CppArgumentList&, CppVariant*);
110 void clearTouchPoints(const CppArgumentList&, CppVariant*);
111 void releaseTouchPoint(const CppArgumentList&, CppVariant*);
112 void setTouchModifier(const CppArgumentList&, CppVariant*);
113 void touchCancel(const CppArgumentList&, CppVariant*);
114 void touchEnd(const CppArgumentList&, CppVariant*);
115 void touchMove(const CppArgumentList&, CppVariant*);
116 void touchStart(const CppArgumentList&, CppVariant*);
117 void updateTouchPoint(const CppArgumentList&, CppVariant*);
118
119 void gestureFlingCancel(const CppArgumentList&, CppVariant*);
120 void gestureFlingStart(const CppArgumentList&, CppVariant*);
121 void gestureScrollBegin(const CppArgumentList&, CppVariant*);
122 void gestureScrollEnd(const CppArgumentList&, CppVariant*);
123 void gestureScrollFirstPoint(const CppArgumentList&, CppVariant*);
124 void gestureScrollUpdate(const CppArgumentList&, CppVariant*);
125 void gestureScrollUpdateWithoutPropagation(const CppArgumentList&, CppVarian t*);
126 void gestureTap(const CppArgumentList&, CppVariant*);
127 void gestureTapDown(const CppArgumentList&, CppVariant*);
128 void gestureShowPress(const CppArgumentList&, CppVariant*);
129 void gestureTapCancel(const CppArgumentList&, CppVariant*);
130 void gestureLongPress(const CppArgumentList&, CppVariant*);
131 void gestureLongTap(const CppArgumentList&, CppVariant*);
132 void gestureTwoFingerTap(const CppArgumentList&, CppVariant*);
133 void gestureEvent(blink::WebInputEvent::Type, const CppArgumentList&);
134
135 // Setting this to false makes EventSender not force layout() calls.
136 // This makes it possible to test the standard WebCore event dispatch.
137 CppVariant forceLayoutOnEvents;
138
139 // Unimplemented stubs
140 void enableDOMUIEventLogging(const CppArgumentList&, CppVariant*);
141 void fireKeyboardEventsToElement(const CppArgumentList&, CppVariant*);
142 void clearKillRing(const CppArgumentList&, CppVariant*);
143
144 // Properties used in layout tests.
145 #if defined(OS_WIN)
146 CppVariant wmKeyDown;
147 CppVariant wmKeyUp;
148 CppVariant wmChar;
149 CppVariant wmDeadChar;
150 CppVariant wmSysKeyDown;
151 CppVariant wmSysKeyUp;
152 CppVariant wmSysChar;
153 CppVariant wmSysDeadChar;
154 #endif
155
156 WebTaskList* taskList() { return &m_taskList; }
157
158 private:
159 blink::WebView* webview() { return m_webView; }
160
161 // Returns true if dragMode is true.
162 bool isDragMode() { return dragMode.isBool() && dragMode.toBoolean(); }
163
164 bool shouldForceLayoutOnEvents() const { return forceLayoutOnEvents.isBool() && forceLayoutOnEvents.toBoolean(); }
165
166 // Sometimes we queue up mouse move and mouse up events for drag drop
167 // handling purposes. These methods dispatch the event.
168 void doMouseMove(const blink::WebMouseEvent&);
169 void doMouseUp(const blink::WebMouseEvent&);
170 static void doLeapForward(int milliseconds);
171 void replaySavedEvents();
172
173 // Helper to return the button type given a button code
174 static blink::WebMouseEvent::Button getButtonTypeFromButtonNumber(int);
175
176 // Helper to extract the button number from the optional argument in
177 // mouseDown and mouseUp
178 static int getButtonNumberFromSingleArg(const CppArgumentList&);
179
180 // Returns true if the specified key code passed in needs a shift key
181 // modifier to be passed into the generated event.
182 bool needsShiftModifier(int);
183
184 void finishDragAndDrop(const blink::WebMouseEvent&, blink::WebDragOperation) ;
185 void updateClickCountForButton(blink::WebMouseEvent::Button);
186
187 // Compose a touch event from the current touch points and send it.
188 void sendCurrentTouchEvent(const blink::WebInputEvent::Type);
189
190 // Init a mouse wheel event from the given args.
191 void initMouseWheelEvent(const CppArgumentList&, CppVariant*, bool continuou s, blink::WebMouseWheelEvent*);
192
193 WebTaskList m_taskList;
194
195 TestInterfaces* m_testInterfaces;
196 WebTestDelegate* m_delegate;
197 blink::WebView* m_webView;
198
199 WebScopedPtr<blink::WebContextMenuData> m_lastContextMenuData;
200
201 // Location of the touch point that initiated a gesture.
202 blink::WebPoint m_currentGestureLocation;
203
204 // Location of last mouseMoveTo event.
205 static blink::WebPoint lastMousePos;
206
207 // Currently pressed mouse button (Left/Right/Middle or None)
208 static blink::WebMouseEvent::Button pressedButton;
209
210 // The last button number passed to mouseDown and mouseUp.
211 // Used to determine whether the click count continues to
212 // increment or not.
213 static blink::WebMouseEvent::Button lastButtonType;
214 };
215
216 }
217
218 #endif // EventSender_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698