OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_BROWSER_AUTOMATION_UI_CONTROLS_H_ | 5 #ifndef CHROME_BROWSER_AUTOMATION_UI_CONTROLS_H_ |
6 #define CHROME_BROWSER_AUTOMATION_UI_CONTROLS_H_ | 6 #define CHROME_BROWSER_AUTOMATION_UI_CONTROLS_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
13 #include <wtypes.h> | 13 #include <wtypes.h> |
14 #endif | 14 #endif |
15 | 15 |
16 #include "base/gfx/native_widget_types.h" | 16 #include "base/gfx/native_widget_types.h" |
17 #include "base/gfx/point.h" | 17 #include "base/gfx/point.h" |
18 | 18 |
19 namespace views { | 19 namespace views { |
20 class View; | 20 class View; |
21 } | 21 } |
22 | 22 |
23 class Task; | 23 class Task; |
24 | 24 |
25 namespace ui_controls { | 25 namespace ui_controls { |
26 | 26 |
27 // Many of the functions in this class include a variant that takes a Task. | 27 // Many of the functions in this class include a variant that takes a Task. |
28 // The version that takes a Task waits until the generated event is processed. | 28 // The version that takes a Task waits until the generated event is processed. |
29 // Once the generated event is processed the Task is Run (and deleted). | 29 // Once the generated event is processed the Task is Run (and deleted). Note |
| 30 // that this is a somewhat fragile process in that any event of the correct |
| 31 // type (key down, mouse click, etc.) will trigger the Task to be run. Hence |
| 32 // a usage such as |
| 33 // |
| 34 // SendKeyPress(...); |
| 35 // SendKeyPressNotifyWhenDone(..., task); |
| 36 // |
| 37 // might trigger |task| early. |
| 38 // |
| 39 // Note: Windows does not currently do anything with the |window| argument for |
| 40 // these functions, so passing NULL is ok. |
30 | 41 |
31 // Send a key press with/without modifier keys. | 42 // Send a key press with/without modifier keys. |
32 bool SendKeyPress(gfx::NativeWindow window, wchar_t key, bool control, | 43 bool SendKeyPress(gfx::NativeWindow window, wchar_t key, bool control, |
33 bool shift, bool alt); | 44 bool shift, bool alt); |
34 bool SendKeyPressNotifyWhenDone(wchar_t key, bool control, bool shift, | 45 bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, wchar_t key, |
| 46 bool control, bool shift, |
35 bool alt, Task* task); | 47 bool alt, Task* task); |
36 | 48 |
37 // Send a key down event. Use VK_CONTROL for ctrl key, | 49 // Send a key down event. Use VK_CONTROL for ctrl key, |
38 // VK_MENU for alt key and VK_SHIFT for shift key. | 50 // VK_MENU for alt key and VK_SHIFT for shift key. |
39 // Refer MSDN for more virtual key codes. | 51 // Refer MSDN for more virtual key codes. |
40 bool SendKeyDown(wchar_t key); | 52 bool SendKeyDown(wchar_t key); |
41 bool SendKeyUp(wchar_t key); | 53 bool SendKeyUp(wchar_t key); |
42 | 54 |
43 // Simulate a mouse move. (x,y) are absolute screen coordinates. | 55 // Simulate a mouse move. (x,y) are absolute screen coordinates. |
44 bool SendMouseMove(long x, long y); | 56 bool SendMouseMove(long x, long y); |
(...skipping 22 matching lines...) Expand all Loading... |
67 // A combination of SendMouseMove to the middle of the view followed by | 79 // A combination of SendMouseMove to the middle of the view followed by |
68 // SendMouseEvents. | 80 // SendMouseEvents. |
69 void MoveMouseToCenterAndPress(views::View* view, | 81 void MoveMouseToCenterAndPress(views::View* view, |
70 MouseButton button, | 82 MouseButton button, |
71 int state, | 83 int state, |
72 Task* task); | 84 Task* task); |
73 | 85 |
74 } // ui_controls | 86 } // ui_controls |
75 | 87 |
76 #endif // CHROME_BROWSER_AUTOMATION_UI_CONTROLS_H_ | 88 #endif // CHROME_BROWSER_AUTOMATION_UI_CONTROLS_H_ |
OLD | NEW |