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