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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "ui/base/keycodes/keyboard_codes.h" | 10 #include "ui/base/keycodes/keyboard_codes.h" |
11 #include "ui/gfx/point.h" | 11 #include "ui/gfx/point.h" |
12 | 12 |
13 namespace aura { | 13 namespace aura { |
14 class Event; | 14 class Event; |
| 15 class RootWindow; |
15 class Window; | 16 class Window; |
16 | 17 |
17 namespace test { | 18 namespace test { |
18 | 19 |
19 // EventGenerator is a tool that generates and dispatch events. | 20 // EventGenerator is a tool that generates and dispatch events. |
20 class EventGenerator { | 21 class EventGenerator { |
21 public: | 22 public: |
22 // Creates an EventGenerator with the mouse/touch location (0,0). | 23 // Creates an EventGenerator with the mouse/touch location (0,0). |
23 EventGenerator(); | 24 explicit EventGenerator(RootWindow* root_window); |
24 | 25 |
25 // Creates an EventGenerator with the mouse/touch location | 26 // Creates an EventGenerator with the mouse/touch location |
26 // at |initial_location|. | 27 // at |initial_location|. |
27 explicit EventGenerator(const gfx::Point& initial_location); | 28 EventGenerator(RootWindow* root_window, const gfx::Point& initial_location); |
28 | 29 |
29 // Creates an EventGenerator with the mouse/touch location | 30 // Creates an EventGenerator with the mouse/touch location |
30 // centered over |window|. | 31 // centered over |window|. |
31 explicit EventGenerator(Window* window); | 32 EventGenerator(RootWindow* root_window, Window* window); |
32 | 33 |
33 virtual ~EventGenerator(); | 34 virtual ~EventGenerator(); |
34 | 35 |
35 const gfx::Point& current_location() const { return current_location_; } | 36 const gfx::Point& current_location() const { return current_location_; } |
36 | 37 |
37 // Generates a left button press event. | 38 // Generates a left button press event. |
38 void PressLeftButton(); | 39 void PressLeftButton(); |
39 | 40 |
40 // Generates a left button release event. | 41 // Generates a left button release event. |
41 void ReleaseLeftButton(); | 42 void ReleaseLeftButton(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // be passed as |flags|, not the native ones like 'ShiftMask' in <X11/X.h>. | 114 // be passed as |flags|, not the native ones like 'ShiftMask' in <X11/X.h>. |
114 // TODO(yusukes): Support native_event() on all platforms. | 115 // TODO(yusukes): Support native_event() on all platforms. |
115 void ReleaseKey(ui::KeyboardCode key_code, int flags); | 116 void ReleaseKey(ui::KeyboardCode key_code, int flags); |
116 | 117 |
117 private: | 118 private: |
118 // Dispatch the |event| to the RootWindow. | 119 // Dispatch the |event| to the RootWindow. |
119 void Dispatch(Event& event); | 120 void Dispatch(Event& event); |
120 // Dispatch a key event to the RootWindow. | 121 // Dispatch a key event to the RootWindow. |
121 void DispatchKeyEvent(bool is_press, ui::KeyboardCode key_code, int flags); | 122 void DispatchKeyEvent(bool is_press, ui::KeyboardCode key_code, int flags); |
122 | 123 |
| 124 RootWindow* root_window_; |
123 int flags_; | 125 int flags_; |
124 gfx::Point current_location_; | 126 gfx::Point current_location_; |
125 | 127 |
126 DISALLOW_COPY_AND_ASSIGN(EventGenerator); | 128 DISALLOW_COPY_AND_ASSIGN(EventGenerator); |
127 }; | 129 }; |
128 | 130 |
129 } // namespace test | 131 } // namespace test |
130 } // namespace aura | 132 } // namespace aura |
131 | 133 |
132 #endif // UI_AURA_TEST_EVENT_GENERATOR_H_ | 134 #endif // UI_AURA_TEST_EVENT_GENERATOR_H_ |
OLD | NEW |