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

Side by Side Diff: chrome/browser/automation/ui_controls.h

Issue 8212006: base::Bind: Cleanup in automation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mac build fix. Created 9 years, 2 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #pragma once 7 #pragma once
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 10
11 #if defined(OS_WIN) 11 #if defined(OS_WIN)
12 #include <wtypes.h> 12 #include <wtypes.h>
13 #endif 13 #endif
14 14
15 #include "base/callback.h"
15 #include "ui/base/keycodes/keyboard_codes.h" 16 #include "ui/base/keycodes/keyboard_codes.h"
16 #include "ui/gfx/native_widget_types.h" 17 #include "ui/gfx/native_widget_types.h"
17 #include "ui/gfx/point.h" 18 #include "ui/gfx/point.h"
18 19
19 #if defined(TOOLKIT_VIEWS) 20 #if defined(TOOLKIT_VIEWS)
20 namespace views { 21 namespace views {
21 class View; 22 class View;
22 } 23 }
23 #endif 24 #endif
24 25
25 class Task;
26
27 namespace ui_controls { 26 namespace ui_controls {
28 27
29 // Many of the functions in this class include a variant that takes a Task. 28 // Many of the functions in this class include a variant that takes a Closure.
30 // The version that takes a Task waits until the generated event is processed. 29 // The version that takes a Closure waits until the generated event is
31 // Once the generated event is processed the Task is Run (and deleted). Note 30 // processed. Once the generated event is processed the Closure is Run (and
32 // that this is a somewhat fragile process in that any event of the correct 31 // deleted). Note that this is a somewhat fragile process in that any event of
33 // type (key down, mouse click, etc.) will trigger the Task to be run. Hence 32 // the correct type (key down, mouse click, etc.) will trigger the Closure to be
34 // a usage such as 33 // run. Hence a usage such as
35 // 34 //
36 // SendKeyPress(...); 35 // SendKeyPress(...);
37 // SendKeyPressNotifyWhenDone(..., task); 36 // SendKeyPressNotifyWhenDone(..., task);
38 // 37 //
39 // might trigger |task| early. 38 // might trigger |task| early.
40 // 39 //
41 // Note: Windows does not currently do anything with the |window| argument for 40 // Note: Windows does not currently do anything with the |window| argument for
42 // these functions, so passing NULL is ok. 41 // these functions, so passing NULL is ok.
43 42
44 // Send a key press with/without modifier keys. 43 // Send a key press with/without modifier keys.
45 // 44 //
46 // If you're writing a test chances are you want the variant in ui_test_utils. 45 // If you're writing a test chances are you want the variant in ui_test_utils.
47 // See it for details. 46 // See it for details.
48 bool SendKeyPress(gfx::NativeWindow window, 47 bool SendKeyPress(gfx::NativeWindow window,
49 ui::KeyboardCode key, 48 ui::KeyboardCode key,
50 bool control, 49 bool control,
51 bool shift, 50 bool shift,
52 bool alt, 51 bool alt,
53 bool command); 52 bool command);
54 bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, 53 bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window,
55 ui::KeyboardCode key, 54 ui::KeyboardCode key,
56 bool control, 55 bool control,
57 bool shift, 56 bool shift,
58 bool alt, 57 bool alt,
59 bool command, 58 bool command,
60 Task* task); 59 const base::Closure& task);
61 60
62 // Simulate a mouse move. (x,y) are absolute screen coordinates. 61 // Simulate a mouse move. (x,y) are absolute screen coordinates.
63 bool SendMouseMove(long x, long y); 62 bool SendMouseMove(long x, long y);
64 bool SendMouseMoveNotifyWhenDone(long x, long y, Task* task); 63 bool SendMouseMoveNotifyWhenDone(long x, long y, const base::Closure& task);
65 64
66 enum MouseButton { 65 enum MouseButton {
67 LEFT = 0, 66 LEFT = 0,
68 MIDDLE, 67 MIDDLE,
69 RIGHT, 68 RIGHT,
70 }; 69 };
71 70
72 // Used to indicate the state of the button when generating events. 71 // Used to indicate the state of the button when generating events.
73 enum MouseButtonState { 72 enum MouseButtonState {
74 UP = 1, 73 UP = 1,
75 DOWN = 2 74 DOWN = 2
76 }; 75 };
77 76
78 // Sends a mouse down and/or up message. The click will be sent to wherever 77 // Sends a mouse down and/or up message. The click will be sent to wherever
79 // the cursor currently is, so be sure to move the cursor before calling this 78 // the cursor currently is, so be sure to move the cursor before calling this
80 // (and be sure the cursor has arrived!). 79 // (and be sure the cursor has arrived!).
81 bool SendMouseEvents(MouseButton type, int state); 80 bool SendMouseEvents(MouseButton type, int state);
82 bool SendMouseEventsNotifyWhenDone(MouseButton type, int state, Task* task); 81 bool SendMouseEventsNotifyWhenDone(MouseButton type, int state,
82 const base::Closure& task);
83 // Same as SendMouseEvents with UP | DOWN. 83 // Same as SendMouseEvents with UP | DOWN.
84 bool SendMouseClick(MouseButton type); 84 bool SendMouseClick(MouseButton type);
85 85
86 // A combination of SendMouseMove to the middle of the view followed by 86 // A combination of SendMouseMove to the middle of the view followed by
87 // SendMouseEvents. 87 // SendMouseEvents.
88 void MoveMouseToCenterAndPress( 88 void MoveMouseToCenterAndPress(
89 #if defined(TOOLKIT_VIEWS) 89 #if defined(TOOLKIT_VIEWS)
90 views::View* view, 90 views::View* view,
91 #elif defined(TOOLKIT_GTK) 91 #elif defined(TOOLKIT_GTK)
92 GtkWidget* widget, 92 GtkWidget* widget,
93 #elif defined(OS_MACOSX) 93 #elif defined(OS_MACOSX)
94 NSView* view, 94 NSView* view,
95 #endif 95 #endif
96 MouseButton button, 96 MouseButton button,
97 int state, 97 int state,
98 Task* task); 98 const base::Closure& task);
99 99
100 } // ui_controls 100 } // ui_controls
101 101
102 #endif // CHROME_BROWSER_AUTOMATION_UI_CONTROLS_H_ 102 #endif // CHROME_BROWSER_AUTOMATION_UI_CONTROLS_H_
OLDNEW
« no previous file with comments | « chrome/browser/automation/testing_automation_provider_views.cc ('k') | chrome/browser/automation/ui_controls_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698