OLD | NEW |
---|---|
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 KeyEvent; |
22 class MouseEvent; | |
23 class TouchEvent; | |
sky
2013/01/22 18:05:01
nit: sort
DaveMoore
2013/01/27 21:21:54
Done.
| |
24 class ScrollEvent; | |
19 } | 25 } |
20 | 26 |
21 namespace aura { | 27 namespace aura { |
22 class RootWindow; | 28 class RootWindow; |
23 class Window; | 29 class Window; |
24 | 30 |
25 namespace client { | 31 namespace client { |
26 class ScreenPositionClient; | 32 class ScreenPositionClient; |
27 } | 33 } |
28 | 34 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 virtual ~EventGenerator(); | 74 virtual ~EventGenerator(); |
69 | 75 |
70 // Explicitly sets the location used by mouse/touch events. This is set by the | 76 // 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, | 77 // various methods that take a location but can be manipulated directly, |
72 // typically for touch. | 78 // typically for touch. |
73 void set_current_location(const gfx::Point& location) { | 79 void set_current_location(const gfx::Point& location) { |
74 current_location_ = location; | 80 current_location_ = location; |
75 } | 81 } |
76 const gfx::Point& current_location() const { return current_location_; } | 82 const gfx::Point& current_location() const { return current_location_; } |
77 | 83 |
84 void set_post_events(bool post_events) { post_events_ = post_events; } | |
85 bool post_events() const { return post_events_; } | |
86 | |
78 // Resets the event flags bitmask. | 87 // Resets the event flags bitmask. |
79 void set_flags(int flags) { flags_ = flags; } | 88 void set_flags(int flags) { flags_ = flags; } |
80 | 89 |
81 // Generates a left button press event. | 90 // Generates a left button press event. |
82 void PressLeftButton(); | 91 void PressLeftButton(); |
83 | 92 |
84 // Generates a left button release event. | 93 // Generates a left button release event. |
85 void ReleaseLeftButton(); | 94 void ReleaseLeftButton(); |
86 | 95 |
87 // Generates events to click (press, release) left button. | 96 // Generates events to click (press, release) left button. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 // relevant when testing velocity/fling/swipe, otherwise these can be any | 191 // 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 | 192 // non-zero value. |delta_x| and |delta_y| are the amount that each finger |
184 // should be moved. | 193 // should be moved. |
185 void GestureMultiFingerScroll(int count, | 194 void GestureMultiFingerScroll(int count, |
186 const gfx::Point* start, | 195 const gfx::Point* start, |
187 int event_separation_time_ms, | 196 int event_separation_time_ms, |
188 int steps, | 197 int steps, |
189 int move_x, | 198 int move_x, |
190 int move_y); | 199 int move_y); |
191 | 200 |
201 // Generates scroll sequences of a FlingCancel, Scrolls, FlingStart, with | |
202 // constant deltas to |x_offset| and |y_offset| in |steps|. | |
203 void ScrollSequence(const gfx::Point& start, | |
204 const base::TimeDelta& step_delay, | |
205 float x_offset, | |
206 float y_offset, | |
207 int steps, | |
208 int num_fingers); | |
209 | |
210 // Generates scroll sequences of a FlingCancel, Scrolls, FlingStart, sending | |
211 // scrolls of each of the values in |offsets|. | |
212 void ScrollSequence(const gfx::Point& start, | |
213 const base::TimeDelta& step_delay, | |
sky
2013/01/22 18:05:01
no const & here (I know, confusing).
DaveMoore
2013/01/27 21:21:54
Done.
| |
214 const std::vector<gfx::Point> offsets, | |
sky
2013/01/22 18:05:01
const vector&
DaveMoore
2013/01/27 21:21:54
Done.
| |
215 int num_fingers); | |
216 | |
192 // Generates a key press event. On platforms except Windows and X11, a key | 217 // 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 | 218 // 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>. | 219 // be passed as |flags|, not the native ones like 'ShiftMask' in <X11/X.h>. |
195 // TODO(yusukes): Support native_event() on all platforms. | 220 // TODO(yusukes): Support native_event() on all platforms. |
196 void PressKey(ui::KeyboardCode key_code, int flags); | 221 void PressKey(ui::KeyboardCode key_code, int flags); |
197 | 222 |
198 // Generates a key release event. On platforms except Windows and X11, a key | 223 // 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 | 224 // 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>. | 225 // be passed as |flags|, not the native ones like 'ShiftMask' in <X11/X.h>. |
201 // TODO(yusukes): Support native_event() on all platforms. | 226 // TODO(yusukes): Support native_event() on all platforms. |
202 void ReleaseKey(ui::KeyboardCode key_code, int flags); | 227 void ReleaseKey(ui::KeyboardCode key_code, int flags); |
203 | 228 |
204 // Dispatch the |event| to the RootWindow. | 229 // Dispatch the event to the RootWindow. |
205 void Dispatch(ui::Event& event); | 230 void DispatchKeyEvent(ui::KeyEvent& key_event); |
sky
2013/01/22 18:05:01
const on all these args.
DaveMoore
2013/01/27 21:21:54
That ends up requiring a copy within the call to t
| |
231 void DispatchMouseEvent(ui::MouseEvent& mouse_event); | |
232 void DispatchTouchEvent(ui::TouchEvent& touch_event); | |
233 void DispatchScrollEvent(ui::ScrollEvent& scroll_event); | |
206 | 234 |
207 void set_current_root_window(RootWindow* root_window) { | 235 void set_current_root_window(RootWindow* root_window) { |
208 current_root_window_ = root_window; | 236 current_root_window_ = root_window; |
209 } | 237 } |
210 | 238 |
211 private: | 239 private: |
212 // Dispatch a key event to the RootWindow. | 240 // Dispatch a key event to the RootWindow. |
213 void DispatchKeyEvent(bool is_press, ui::KeyboardCode key_code, int flags); | 241 void DispatchKeyEvent(bool is_press, ui::KeyboardCode key_code, int flags); |
214 | 242 |
215 void UpdateCurrentRootWindow(const gfx::Point& point); | 243 void UpdateCurrentRootWindow(const gfx::Point& point); |
216 void PressButton(int flag); | 244 void PressButton(int flag); |
217 void ReleaseButton(int flag); | 245 void ReleaseButton(int flag); |
218 | 246 |
219 // Convert a point between API's coordinates and | 247 // Convert a point between API's coordinates and |
220 // |target|'s coordinates. | 248 // |target|'s coordinates. |
221 void ConvertPointFromTarget(const aura::Window* target, | 249 void ConvertPointFromTarget(const aura::Window* target, |
222 gfx::Point* point) const; | 250 gfx::Point* point) const; |
223 void ConvertPointToTarget(const aura::Window* target, | 251 void ConvertPointToTarget(const aura::Window* target, |
224 gfx::Point* point) const; | 252 gfx::Point* point) const; |
225 | 253 |
226 gfx::Point GetLocationInCurrentRoot() const; | 254 gfx::Point GetLocationInCurrentRoot() const; |
227 gfx::Point CenterOfWindow(const Window* window) const; | 255 gfx::Point CenterOfWindow(const Window* window) const; |
228 | 256 |
229 scoped_ptr<EventGeneratorDelegate> delegate_; | 257 scoped_ptr<EventGeneratorDelegate> delegate_; |
230 gfx::Point current_location_; | 258 gfx::Point current_location_; |
231 RootWindow* current_root_window_; | 259 RootWindow* current_root_window_; |
232 int flags_; | 260 int flags_; |
233 bool grab_; | 261 bool grab_; |
234 | 262 |
263 private: | |
264 void DoDispatchKeyEvent(); | |
265 void DoDispatchMouseEvent(); | |
266 void DoDispatchTouchEvent(); | |
267 void DoDispatchScrollEvent(); | |
268 std::list<ui::KeyEvent> pending_key_events_; | |
269 std::list<ui::MouseEvent> pending_mouse_events_; | |
270 std::list<ui::TouchEvent> pending_touch_events_; | |
271 std::list<ui::ScrollEvent> pending_scroll_events_; | |
272 // Set to true to cause events to be posted asynchronously. Event types | |
sky
2013/01/22 18:05:01
This second sentence isn't clear, please clarify i
DaveMoore
2013/01/27 21:21:54
Done.
| |
273 // can not be mixed and matched (must be all of one type). | |
274 bool post_events_; | |
275 | |
235 DISALLOW_COPY_AND_ASSIGN(EventGenerator); | 276 DISALLOW_COPY_AND_ASSIGN(EventGenerator); |
236 }; | 277 }; |
237 | 278 |
238 } // namespace test | 279 } // namespace test |
239 } // namespace aura | 280 } // namespace aura |
240 | 281 |
241 #endif // UI_AURA_TEST_EVENT_GENERATOR_H_ | 282 #endif // UI_AURA_TEST_EVENT_GENERATOR_H_ |
OLD | NEW |