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 bool SendKeyPress(gfx::NativeWindow native_window
,
38 bool command
) override
{
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 bool SendKeyPressNotifyWhenDone(gfx::NativeWindow native_window
,
51 const base::Closure
& task
) override
{
52 DCHECK(!command
); // No command key on Aura
54 native_window
->GetHost()->GetAcceleratedWidget();
55 return SendKeyPressImpl(window
, key
, control
, shift
, alt
, task
);
57 bool SendMouseMove(long screen_x
, long screen_y
) override
{
58 return SendMouseMoveImpl(screen_x
, screen_y
, base::Closure());
60 bool SendMouseMoveNotifyWhenDone(long screen_x
,
62 const base::Closure
& task
) override
{
63 return SendMouseMoveImpl(screen_x
, screen_y
, task
);
65 bool SendMouseEvents(MouseButton type
, int state
) override
{
66 return SendMouseEventsImpl(type
, state
, base::Closure());
68 bool SendMouseEventsNotifyWhenDone(MouseButton type
,
70 const base::Closure
& task
) override
{
71 return SendMouseEventsImpl(type
, state
, task
);
73 bool SendMouseClick(MouseButton type
) override
{
74 return SendMouseEvents(type
, UP
| DOWN
);
76 void RunClosureAfterAllPendingUIEvents(
77 const base::Closure
& closure
) override
{
78 // On windows, posting UI events is synchronous so just post the closure.
79 base::MessageLoopForUI::current()->PostTask(FROM_HERE
, closure
);
83 DISALLOW_COPY_AND_ASSIGN(UIControlsWin
);
88 UIControlsAura
* CreateUIControlsAura(WindowTreeHost
* host
) {
89 return new UIControlsWin();