| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "ui/base/test/ui_controls.h" | |
| 6 | |
| 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/point.h" | |
| 11 | |
| 12 namespace ui_controls { | |
| 13 bool g_ui_controls_enabled = false; | |
| 14 | |
| 15 void EnableUIControls() { | |
| 16 g_ui_controls_enabled = true; | |
| 17 } | |
| 18 | |
| 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()); | |
| 29 } | |
| 30 | |
| 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); | |
| 41 } | |
| 42 | |
| 43 bool SendMouseMove(long x, long y) { | |
| 44 CHECK(g_ui_controls_enabled); | |
| 45 return internal::SendMouseMoveImpl(x, y, base::Closure()); | |
| 46 } | |
| 47 | |
| 48 bool SendMouseMoveNotifyWhenDone(long x, long y, const base::Closure& task) { | |
| 49 CHECK(g_ui_controls_enabled); | |
| 50 return internal::SendMouseMoveImpl(x, y, task); | |
| 51 } | |
| 52 | |
| 53 bool SendMouseEvents(MouseButton type, int state) { | |
| 54 CHECK(g_ui_controls_enabled); | |
| 55 return internal::SendMouseEventsImpl(type, state, base::Closure()); | |
| 56 } | |
| 57 | |
| 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); | |
| 62 } | |
| 63 | |
| 64 bool SendMouseClick(MouseButton type) { | |
| 65 CHECK(g_ui_controls_enabled); | |
| 66 return internal::SendMouseEventsImpl(type, UP | DOWN, base::Closure()); | |
| 67 } | |
| 68 | |
| 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); | |
| 72 } | |
| 73 | |
| 74 } // namespace ui_controls | |
| OLD | NEW |