Revert of media-internals: Simplify the code path for creating a media log entry...
[chromium-blink-merge.git] / ui / base / test / ui_controls.h
blobe54f936ce25e082c4db90fb0e9a162b02bb365cd
1 // Copyright 2013 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.
5 #ifndef UI_BASE_TEST_UI_CONTROLS_H_
6 #define UI_BASE_TEST_UI_CONTROLS_H_
8 #include "base/callback_forward.h"
9 #include "build/build_config.h"
10 #include "ui/events/keycodes/keyboard_codes.h"
11 #include "ui/gfx/native_widget_types.h"
13 namespace ui_controls {
15 // A set of utility functions to generate native events in platform
16 // independent way. Note that since the implementations depend on a window being
17 // top level, these can only be called from test suites that are not sharded.
18 // For aura tests, please look into |aura::test:EventGenerator| first. This
19 // class provides a way to emulate events in synchronous way and it is often
20 // easier to write tests with this class than using |ui_controls|.
22 // Many of the functions in this class include a variant that takes a Closure.
23 // The version that takes a Closure waits until the generated event is
24 // processed. Once the generated event is processed the Closure is Run (and
25 // deleted). Note that this is a somewhat fragile process in that any event of
26 // the correct type (key down, mouse click, etc.) will trigger the Closure to be
27 // run. Hence a usage such as
29 // SendKeyPress(...);
30 // SendKeyPressNotifyWhenDone(..., task);
32 // might trigger |task| early.
34 // Note: Windows does not currently do anything with the |window| argument for
35 // these functions, so passing NULL is ok.
37 // Send a key press with/without modifier keys.
39 // If you're writing a test chances are you want the variant in ui_test_utils.
40 // See it for details.
42 // Per the above comment, these methods can only be called from non-sharded test
43 // suites. This method ensures that they're not accidently called by sharded
44 // tests.
45 void EnableUIControls();
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);
61 // Simulate a mouse move.
62 bool SendMouseMove(long screen_x, long screen_y);
63 bool SendMouseMoveNotifyWhenDone(long screen_x,
64 long screen_y,
65 const base::Closure& task);
67 enum MouseButton {
68 LEFT = 0,
69 MIDDLE,
70 RIGHT,
73 // Used to indicate the state of the button when generating events.
74 enum MouseButtonState {
75 UP = 1,
76 DOWN = 2
79 // Sends a mouse down and/or up message. The click will be sent to wherever
80 // the cursor currently is, so be sure to move the cursor before calling this
81 // (and be sure the cursor has arrived!).
82 bool SendMouseEvents(MouseButton type, int state);
83 bool SendMouseEventsNotifyWhenDone(MouseButton type,
84 int state,
85 const base::Closure& task);
87 // Same as SendMouseEvents with UP | DOWN.
88 bool SendMouseClick(MouseButton type);
90 #if defined(TOOLKIT_VIEWS)
91 // Runs |closure| after processing all pending ui events.
92 void RunClosureAfterAllPendingUIEvents(const base::Closure& closure);
93 #endif
95 #if defined(USE_AURA)
96 class UIControlsAura;
97 void InstallUIControlsAura(UIControlsAura* instance);
98 #endif
100 #if defined(OS_MACOSX)
101 // Returns true when tests need to use extra Tab and Shift-Tab key events
102 // to traverse to the desired item; because the application is configured to
103 // traverse more elements for accessibility reasons.
104 bool IsFullKeyboardAccessEnabled();
105 #endif
107 } // namespace ui_controls
109 #endif // UI_BASE_TEST_UI_CONTROLS_H_