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 "base/basictypes.h"
6 #include "base/logging.h"
7 #include "base/message_loop/message_loop.h"
8 #include "ui/aura/test/ui_controls_factory_aura.h"
9 #include "ui/aura/window.h"
10 #include "ui/aura/window_tree_host.h"
11 #include "ui/base/test/ui_controls_aura.h"
12 #include "ui/base/test/ui_controls_internal_win.h"
19 using ui_controls::DOWN
;
20 using ui_controls::LEFT
;
21 using ui_controls::MIDDLE
;
22 using ui_controls::MouseButton
;
23 using ui_controls::RIGHT
;
24 using ui_controls::UIControlsAura
;
25 using ui_controls::UP
;
26 using namespace ui_controls::internal
;
28 class UIControlsWin
: public UIControlsAura
{
32 // UIControlsAura overrides:
33 virtual bool SendKeyPress(gfx::NativeWindow native_window
,
39 DCHECK(!command
); // No command key on Aura
41 native_window
->GetHost()->GetAcceleratedWidget();
42 return SendKeyPressImpl(
43 window
, key
, control
, shift
, alt
, base::Closure());
45 virtual bool SendKeyPressNotifyWhenDone(gfx::NativeWindow native_window
,
51 const base::Closure
& task
) {
52 DCHECK(!command
); // No command key on Aura
54 native_window
->GetHost()->GetAcceleratedWidget();
55 return SendKeyPressImpl(window
, key
, control
, shift
, alt
, task
);
57 virtual bool SendMouseMove(long screen_x
, long screen_y
) {
58 return SendMouseMoveImpl(screen_x
, screen_y
, base::Closure());
60 virtual bool SendMouseMoveNotifyWhenDone(long screen_x
,
62 const base::Closure
& task
) {
63 return SendMouseMoveImpl(screen_x
, screen_y
, task
);
65 virtual bool SendMouseEvents(MouseButton type
, int state
) {
66 return SendMouseEventsImpl(type
, state
, base::Closure());
68 virtual bool SendMouseEventsNotifyWhenDone(MouseButton type
,
70 const base::Closure
& task
) {
71 return SendMouseEventsImpl(type
, state
, task
);
73 virtual bool SendMouseClick(MouseButton type
) {
74 return SendMouseEvents(type
, UP
| DOWN
);
76 virtual void RunClosureAfterAllPendingUIEvents(const base::Closure
& closure
) {
77 // On windows, posting UI events is synchronous so just post the closure.
78 base::MessageLoopForUI::current()->PostTask(FROM_HERE
, closure
);
82 DISALLOW_COPY_AND_ASSIGN(UIControlsWin
);
87 UIControlsAura
* CreateUIControlsAura(WindowTreeHost
* host
) {
88 return new UIControlsWin();