Home | History | Annotate | Download | only in test
      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 "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"
     13 
     14 namespace aura {
     15 namespace test {
     16 
     17 namespace {
     18 
     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;
     27 
     28 class UIControlsWin : public UIControlsAura {
     29  public:
     30   UIControlsWin() {}
     31 
     32   // UIControlsAura overrides:
     33   virtual bool SendKeyPress(gfx::NativeWindow native_window,
     34                             ui::KeyboardCode key,
     35                             bool control,
     36                             bool shift,
     37                             bool alt,
     38                             bool command) {
     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());
     44   }
     45   virtual 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) {
     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);
     56   }
     57   virtual bool SendMouseMove(long screen_x, long screen_y) {
     58     return SendMouseMoveImpl(screen_x, screen_y, base::Closure());
     59   }
     60   virtual bool SendMouseMoveNotifyWhenDone(long screen_x,
     61                                            long screen_y,
     62                                            const base::Closure& task) {
     63     return SendMouseMoveImpl(screen_x, screen_y, task);
     64   }
     65   virtual bool SendMouseEvents(MouseButton type, int state) {
     66     return SendMouseEventsImpl(type, state, base::Closure());
     67   }
     68   virtual bool SendMouseEventsNotifyWhenDone(MouseButton type,
     69                                              int state,
     70                                              const base::Closure& task) {
     71     return SendMouseEventsImpl(type, state, task);
     72   }
     73   virtual bool SendMouseClick(MouseButton type) {
     74     return SendMouseEvents(type, UP | DOWN);
     75   }
     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);
     79   }
     80 
     81  private:
     82   DISALLOW_COPY_AND_ASSIGN(UIControlsWin);
     83 };
     84 
     85 }  // namespace
     86 
     87 UIControlsAura* CreateUIControlsAura(WindowTreeHost* host) {
     88   return new UIControlsWin();
     89 }
     90 
     91 }  // namespace test
     92 }  // namespace aura
     93