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

Side by Side Diff: ui/aura/test/event_generator.h

Issue 12088015: Add ability for EventGenerator to generate Scroll events asynchronously (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef UI_AURA_TEST_EVENT_GENERATOR_H_ 5 #ifndef UI_AURA_TEST_EVENT_GENERATOR_H_
6 #define UI_AURA_TEST_EVENT_GENERATOR_H_ 6 #define UI_AURA_TEST_EVENT_GENERATOR_H_
7 7
8 #include <list>
9 #include <vector>
10
8 #include "base/basictypes.h" 11 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
10 #include "ui/base/keycodes/keyboard_codes.h" 13 #include "ui/base/keycodes/keyboard_codes.h"
11 #include "ui/gfx/point.h" 14 #include "ui/gfx/point.h"
12 15
13 namespace base { 16 namespace base {
14 class TimeDelta; 17 class TimeDelta;
15 } 18 }
16 19
17 namespace ui { 20 namespace ui {
18 class Event; 21 class Event;
22 class KeyEvent;
23 class MouseEvent;
24 class ScrollEvent;
25 class TouchEvent;
19 } 26 }
20 27
21 namespace aura { 28 namespace aura {
22 class RootWindow; 29 class RootWindow;
23 class Window; 30 class Window;
24 31
25 namespace client { 32 namespace client {
26 class ScreenPositionClient; 33 class ScreenPositionClient;
27 } 34 }
28 35
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 virtual ~EventGenerator(); 75 virtual ~EventGenerator();
69 76
70 // Explicitly sets the location used by mouse/touch events. This is set by the 77 // Explicitly sets the location used by mouse/touch events. This is set by the
71 // various methods that take a location but can be manipulated directly, 78 // various methods that take a location but can be manipulated directly,
72 // typically for touch. 79 // typically for touch.
73 void set_current_location(const gfx::Point& location) { 80 void set_current_location(const gfx::Point& location) {
74 current_location_ = location; 81 current_location_ = location;
75 } 82 }
76 const gfx::Point& current_location() const { return current_location_; } 83 const gfx::Point& current_location() const { return current_location_; }
77 84
85 void set_post_events(bool post_events) { post_events_ = post_events; }
sadrul 2013/01/28 17:51:18 Perhaps 'async' would be clearer than 'post'
sky 2013/01/28 19:10:55 +1 here. I was about to write the same comment.
DaveMoore 2013/01/28 23:25:20 Done.
86 bool post_events() const { return post_events_; }
87
78 // Resets the event flags bitmask. 88 // Resets the event flags bitmask.
79 void set_flags(int flags) { flags_ = flags; } 89 void set_flags(int flags) { flags_ = flags; }
80 90
81 // Generates a left button press event. 91 // Generates a left button press event.
82 void PressLeftButton(); 92 void PressLeftButton();
83 93
84 // Generates a left button release event. 94 // Generates a left button release event.
85 void ReleaseLeftButton(); 95 void ReleaseLeftButton();
86 96
87 // Generates events to click (press, release) left button. 97 // Generates events to click (press, release) left button.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 // relevant when testing velocity/fling/swipe, otherwise these can be any 192 // relevant when testing velocity/fling/swipe, otherwise these can be any
183 // non-zero value. |delta_x| and |delta_y| are the amount that each finger 193 // non-zero value. |delta_x| and |delta_y| are the amount that each finger
184 // should be moved. 194 // should be moved.
185 void GestureMultiFingerScroll(int count, 195 void GestureMultiFingerScroll(int count,
186 const gfx::Point* start, 196 const gfx::Point* start,
187 int event_separation_time_ms, 197 int event_separation_time_ms,
188 int steps, 198 int steps,
189 int move_x, 199 int move_x,
190 int move_y); 200 int move_y);
191 201
202 // Generates scroll sequences of a FlingCancel, Scrolls, FlingStart, with
203 // constant deltas to |x_offset| and |y_offset| in |steps|.
204 void ScrollSequence(const gfx::Point& start,
205 const base::TimeDelta& step_delay,
206 float x_offset,
207 float y_offset,
208 int steps,
209 int num_fingers);
210
211 // Generates scroll sequences of a FlingCancel, Scrolls, FlingStart, sending
212 // scrolls of each of the values in |offsets|.
213 void ScrollSequence(const gfx::Point& start,
214 const base::TimeDelta& step_delay,
215 const std::vector<gfx::Point>& offsets,
216 int num_fingers);
217
192 // Generates a key press event. On platforms except Windows and X11, a key 218 // Generates a key press event. On platforms except Windows and X11, a key
193 // event without native_event() is generated. Note that ui::EF_ flags should 219 // event without native_event() is generated. Note that ui::EF_ flags should
194 // be passed as |flags|, not the native ones like 'ShiftMask' in <X11/X.h>. 220 // be passed as |flags|, not the native ones like 'ShiftMask' in <X11/X.h>.
195 // TODO(yusukes): Support native_event() on all platforms. 221 // TODO(yusukes): Support native_event() on all platforms.
196 void PressKey(ui::KeyboardCode key_code, int flags); 222 void PressKey(ui::KeyboardCode key_code, int flags);
197 223
198 // Generates a key release event. On platforms except Windows and X11, a key 224 // Generates a key release event. On platforms except Windows and X11, a key
199 // event without native_event() is generated. Note that ui::EF_ flags should 225 // event without native_event() is generated. Note that ui::EF_ flags should
200 // be passed as |flags|, not the native ones like 'ShiftMask' in <X11/X.h>. 226 // be passed as |flags|, not the native ones like 'ShiftMask' in <X11/X.h>.
201 // TODO(yusukes): Support native_event() on all platforms. 227 // TODO(yusukes): Support native_event() on all platforms.
202 void ReleaseKey(ui::KeyboardCode key_code, int flags); 228 void ReleaseKey(ui::KeyboardCode key_code, int flags);
203 229
204 // Dispatch the |event| to the RootWindow. 230 // Dispatch the event to the RootWindow.
205 void Dispatch(ui::Event& event); 231 void Dispatch(ui::Event* event);
206 232
207 void set_current_root_window(RootWindow* root_window) { 233 void set_current_root_window(RootWindow* root_window) {
208 current_root_window_ = root_window; 234 current_root_window_ = root_window;
209 } 235 }
210 236
211 private: 237 private:
212 // Dispatch a key event to the RootWindow. 238 // Dispatch a key event to the RootWindow.
213 void DispatchKeyEvent(bool is_press, ui::KeyboardCode key_code, int flags); 239 void DispatchKeyEvent(bool is_press, ui::KeyboardCode key_code, int flags);
214 240
215 void UpdateCurrentRootWindow(const gfx::Point& point); 241 void UpdateCurrentRootWindow(const gfx::Point& point);
216 void PressButton(int flag); 242 void PressButton(int flag);
217 void ReleaseButton(int flag); 243 void ReleaseButton(int flag);
218 244
219 // Convert a point between API's coordinates and 245 // Convert a point between API's coordinates and
220 // |target|'s coordinates. 246 // |target|'s coordinates.
221 void ConvertPointFromTarget(const aura::Window* target, 247 void ConvertPointFromTarget(const aura::Window* target,
222 gfx::Point* point) const; 248 gfx::Point* point) const;
223 void ConvertPointToTarget(const aura::Window* target, 249 void ConvertPointToTarget(const aura::Window* target,
224 gfx::Point* point) const; 250 gfx::Point* point) const;
225 251
226 gfx::Point GetLocationInCurrentRoot() const; 252 gfx::Point GetLocationInCurrentRoot() const;
227 gfx::Point CenterOfWindow(const Window* window) const; 253 gfx::Point CenterOfWindow(const Window* window) const;
228 254
255 void DispatchNextPendingEvent();
256 void DoDispatchEvent(ui::Event* event, bool post_event);
257
229 scoped_ptr<EventGeneratorDelegate> delegate_; 258 scoped_ptr<EventGeneratorDelegate> delegate_;
230 gfx::Point current_location_; 259 gfx::Point current_location_;
231 RootWindow* current_root_window_; 260 RootWindow* current_root_window_;
232 int flags_; 261 int flags_;
233 bool grab_; 262 bool grab_;
263 std::list<ui::Event*> pending_events_;
264 // Set to true to cause events to be posted asynchronously.
265 bool post_events_;
234 266
235 DISALLOW_COPY_AND_ASSIGN(EventGenerator); 267 DISALLOW_COPY_AND_ASSIGN(EventGenerator);
236 }; 268 };
237 269
238 } // namespace test 270 } // namespace test
239 } // namespace aura 271 } // namespace aura
240 272
241 #endif // UI_AURA_TEST_EVENT_GENERATOR_H_ 273 #endif // UI_AURA_TEST_EVENT_GENERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698