Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ui / base / test / ui_controls_win.cc
blobf70c4336a4852b6407258a66d611f54b0071a690
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 #include "ui/base/test/ui_controls.h"
7 #include "base/callback.h"
8 #include "base/message_loop/message_loop.h"
9 #include "ui/base/test/ui_controls_internal_win.h"
10 #include "ui/gfx/geometry/point.h"
12 namespace ui_controls {
13 bool g_ui_controls_enabled = false;
15 void EnableUIControls() {
16 g_ui_controls_enabled = true;
19 bool SendKeyPress(gfx::NativeWindow window,
20 ui::KeyboardCode key,
21 bool control,
22 bool shift,
23 bool alt,
24 bool command) {
25 CHECK(g_ui_controls_enabled);
26 DCHECK(!command); // No command key on Windows
27 return internal::SendKeyPressImpl(window, key, control, shift, alt,
28 base::Closure());
31 bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window,
32 ui::KeyboardCode key,
33 bool control,
34 bool shift,
35 bool alt,
36 bool command,
37 const base::Closure& task) {
38 CHECK(g_ui_controls_enabled);
39 DCHECK(!command); // No command key on Windows
40 return internal::SendKeyPressImpl(window, key, control, shift, alt, task);
43 bool SendMouseMove(long x, long y) {
44 CHECK(g_ui_controls_enabled);
45 return internal::SendMouseMoveImpl(x, y, base::Closure());
48 bool SendMouseMoveNotifyWhenDone(long x, long y, const base::Closure& task) {
49 CHECK(g_ui_controls_enabled);
50 return internal::SendMouseMoveImpl(x, y, task);
53 bool SendMouseEvents(MouseButton type, int state) {
54 CHECK(g_ui_controls_enabled);
55 return internal::SendMouseEventsImpl(type, state, base::Closure());
58 bool SendMouseEventsNotifyWhenDone(MouseButton type, int state,
59 const base::Closure& task) {
60 CHECK(g_ui_controls_enabled);
61 return internal::SendMouseEventsImpl(type, state, task);
64 bool SendMouseClick(MouseButton type) {
65 CHECK(g_ui_controls_enabled);
66 return internal::SendMouseEventsImpl(type, UP | DOWN, base::Closure());
69 void RunClosureAfterAllPendingUIEvents(const base::Closure& closure) {
70 // On windows, posting UI events is synchronous so just post the closure.
71 base::MessageLoopForUI::current()->PostTask(FROM_HERE, closure);
74 } // namespace ui_controls