Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / ui / aura / test / ui_controls_factory_aurawin.cc
blob36953eb9eab78dfc032c480c4c8ae74037168d9b
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"
14 namespace aura {
15 namespace test {
17 namespace {
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 {
29 public:
30 UIControlsWin() {}
32 // UIControlsAura overrides:
33 bool SendKeyPress(gfx::NativeWindow native_window,
34 ui::KeyboardCode key,
35 bool control,
36 bool shift,
37 bool alt,
38 bool command) override {
39 DCHECK(!command); // No command key on Aura
40 HWND window =
41 native_window->GetHost()->GetAcceleratedWidget();
42 return SendKeyPressImpl(
43 window, key, control, shift, alt, base::Closure());
45 bool SendKeyPressNotifyWhenDone(gfx::NativeWindow native_window,
46 ui::KeyboardCode key,
47 bool control,
48 bool shift,
49 bool alt,
50 bool command,
51 const base::Closure& task) override {
52 DCHECK(!command); // No command key on Aura
53 HWND window =
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,
61 long screen_y,
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,
69 int state,
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);
82 private:
83 DISALLOW_COPY_AND_ASSIGN(UIControlsWin);
86 } // namespace
88 UIControlsAura* CreateUIControlsAura(WindowTreeHost* host) {
89 return new UIControlsWin();
92 } // namespace test
93 } // namespace aura