diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-16 09:30:33 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-16 09:30:33 +0000 |
commit | 536f8082c8e8b492086e7f675bdb477005f770cb (patch) | |
tree | 5b22096c355bf4e8327bde51b7dcde0de2e5617b /ui/ui_controls/ui_controls.h | |
parent | 644a10733be94786e8169d035d7f527b105ee529 (diff) | |
download | chromium_src-536f8082c8e8b492086e7f675bdb477005f770cb.zip chromium_src-536f8082c8e8b492086e7f675bdb477005f770cb.tar.gz chromium_src-536f8082c8e8b492086e7f675bdb477005f770cb.tar.bz2 |
Original CL (http://codereview.chromium.org/9390038/) somehow got screwed and CQ couldn't patch it. This is exact copy of the original CL to land.
* Move automation/ui_controls to ui/ui_controls
* Refactored aura impl so that ui/ui_controls doesn't depend on
aura.
* Moved MoveMouseToCenterAndPress to ui_test_util.h as it depends on views and can't be declared in ui.
* a couple of cleanups:
- Renamed gtk_screen_utils.h to _util.h to match other util.h files.
- indent fix
- remove unnecessary includes.
This CL allows a test to use ui_controls without depending on chrome.
TBR=sky@chromium.org,erg@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/9699098
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127138 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/ui_controls/ui_controls.h')
-rw-r--r-- | ui/ui_controls/ui_controls.h | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/ui/ui_controls/ui_controls.h b/ui/ui_controls/ui_controls.h new file mode 100644 index 0000000..cbbeaba --- /dev/null +++ b/ui/ui_controls/ui_controls.h @@ -0,0 +1,96 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_UI_CONTROLS_UI_CONTROLS_H_ +#define UI_UI_CONTROLS_UI_CONTROLS_H_ +#pragma once + +#include "build/build_config.h" + +#if defined(OS_WIN) +#include <wtypes.h> +#endif + +#include "base/callback_forward.h" +#include "ui/base/keycodes/keyboard_codes.h" +#include "ui/gfx/native_widget_types.h" +#include "ui/base/ui_export.h" + +namespace ui_controls { + +// Many of the functions in this class include a variant that takes a Closure. +// The version that takes a Closure waits until the generated event is +// processed. Once the generated event is processed the Closure is Run (and +// deleted). Note that this is a somewhat fragile process in that any event of +// the correct type (key down, mouse click, etc.) will trigger the Closure to be +// run. Hence a usage such as +// +// SendKeyPress(...); +// SendKeyPressNotifyWhenDone(..., task); +// +// might trigger |task| early. +// +// Note: Windows does not currently do anything with the |window| argument for +// these functions, so passing NULL is ok. + +// Send a key press with/without modifier keys. +// +// If you're writing a test chances are you want the variant in ui_test_utils. +// See it for details. +UI_EXPORT bool SendKeyPress(gfx::NativeWindow window, + ui::KeyboardCode key, + bool control, + bool shift, + bool alt, + bool command); +UI_EXPORT bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, + ui::KeyboardCode key, + bool control, + bool shift, + bool alt, + bool command, + const base::Closure& task); + +// Simulate a mouse move. (x,y) are absolute screen coordinates. +UI_EXPORT bool SendMouseMove(long x, long y); +UI_EXPORT bool SendMouseMoveNotifyWhenDone(long x, + long y, + const base::Closure& task); + +enum MouseButton { + LEFT = 0, + MIDDLE, + RIGHT, +}; + +// Used to indicate the state of the button when generating events. +enum MouseButtonState { + UP = 1, + DOWN = 2 +}; + +// Sends a mouse down and/or up message. The click will be sent to wherever +// the cursor currently is, so be sure to move the cursor before calling this +// (and be sure the cursor has arrived!). +UI_EXPORT bool SendMouseEvents(MouseButton type, int state); +UI_EXPORT bool SendMouseEventsNotifyWhenDone( + MouseButton type, int state, + const base::Closure& task); +// Same as SendMouseEvents with UP | DOWN. +UI_EXPORT bool SendMouseClick(MouseButton type); + +#if defined(TOOLKIT_VIEWS) +// Runs |closure| after processing all pending ui events. +UI_EXPORT void RunClosureAfterAllPendingUIEvents( + const base::Closure& closure); +#endif + +#if defined(USE_AURA) +class UIControlsAura; +UI_EXPORT void InstallUIControlsAura(UIControlsAura* instance); +#endif + +} // namespace ui_controls + +#endif // UI_UI_CONTROLS_UI_CONTROLS_H_ |