OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gfx/point.h" | 11 #include "ui/gfx/point.h" |
11 | 12 |
12 namespace aura { | 13 namespace aura { |
13 class Event; | 14 class Event; |
14 class Window; | 15 class Window; |
15 | 16 |
16 namespace test { | 17 namespace test { |
17 | 18 |
18 // EventGenerator is a tool that generates and dispatch events. | 19 // EventGenerator is a tool that generates and dispatch events. |
19 // TODO(oshima): Support key events. | |
20 class EventGenerator { | 20 class EventGenerator { |
21 public: | 21 public: |
22 // Creates an EventGenerator with the mouse/touch location (0,0). | 22 // Creates an EventGenerator with the mouse/touch location (0,0). |
23 EventGenerator(); | 23 EventGenerator(); |
24 | 24 |
25 // Creates an EventGenerator with the mouse/touch location | 25 // Creates an EventGenerator with the mouse/touch location |
26 // at |initial_location|. | 26 // at |initial_location|. |
27 explicit EventGenerator(const gfx::Point& initial_location); | 27 explicit EventGenerator(const gfx::Point& initial_location); |
28 | 28 |
29 // Creates an EventGenerator with the mouse/touch location | 29 // Creates an EventGenerator with the mouse/touch location |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 } | 86 } |
87 | 87 |
88 void PressMoveAndReleaseTouchBy(int x, int y) { | 88 void PressMoveAndReleaseTouchBy(int x, int y) { |
89 PressMoveAndReleaseTouchTo(current_location_.Add(gfx::Point(x, y))); | 89 PressMoveAndReleaseTouchTo(current_location_.Add(gfx::Point(x, y))); |
90 } | 90 } |
91 | 91 |
92 // Generates press, move and release events to move touch | 92 // Generates press, move and release events to move touch |
93 // to the center of the window. | 93 // to the center of the window. |
94 void PressMoveAndReleaseTouchToCenterOf(Window* window); | 94 void PressMoveAndReleaseTouchToCenterOf(Window* window); |
95 | 95 |
| 96 // Generates a key press event. On platforms except Windows and X11, a key |
| 97 // event without native_event() is generated. |
| 98 // TODO(yusukes): Support native_event() on all platforms. |
| 99 void PressKey(ui::KeyboardCode key_code, int flags); |
| 100 |
| 101 // Generates a key release event. On platforms except Windows and X11, a key |
| 102 // event without native_event() is generated. |
| 103 // TODO(yusukes): Support native_event() on all platforms. |
| 104 void ReleaseKey(ui::KeyboardCode key_code, int flags); |
| 105 |
96 private: | 106 private: |
97 // Dispatch the |event| to the Desktop. | 107 // Dispatch the |event| to the RootWindow. |
98 void Dispatch(Event& event); | 108 void Dispatch(Event& event); |
| 109 // Dispatch a key event to the RootWindow. |
| 110 void DispatchKeyEvent(bool is_press, ui::KeyboardCode key_code, int flags); |
99 | 111 |
100 int flags_; | 112 int flags_; |
101 gfx::Point current_location_; | 113 gfx::Point current_location_; |
102 | 114 |
103 DISALLOW_COPY_AND_ASSIGN(EventGenerator); | 115 DISALLOW_COPY_AND_ASSIGN(EventGenerator); |
104 }; | 116 }; |
105 | 117 |
106 } // namespace test | 118 } // namespace test |
107 } // namespace aura | 119 } // namespace aura |
108 | 120 |
109 #endif // UI_AURA_TEST_EVENT_GENERATOR_H_ | 121 #endif // UI_AURA_TEST_EVENT_GENERATOR_H_ |
OLD | NEW |