Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: ui/aura/test/event_generator.cc

Issue 8576005: IME (input method editor) support for Aura, part 3 of 3: Use ui::InputMethod in ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, review Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/aura/test/event_generator.h" 5 #include "ui/aura/test/event_generator.h"
6 6
7 #include "base/memory/scoped_ptr.h"
7 #include "ui/aura/event.h" 8 #include "ui/aura/event.h"
8 #include "ui/aura/root_window.h" 9 #include "ui/aura/root_window.h"
9 10
11 #if defined(USE_X11)
12 #include <X11/Xlib.h>
13 #include "ui/base/x/x11_util.h"
14 #endif
15
10 namespace { 16 namespace {
11 17
12 gfx::Point CenterOfWindowInRootWindowCoordinate(aura::Window* window) { 18 gfx::Point CenterOfWindowInRootWindowCoordinate(aura::Window* window) {
13 gfx::Point center = window->bounds().CenterPoint(); 19 gfx::Point center = window->bounds().CenterPoint();
14 aura::RootWindow* root_window = aura::RootWindow::GetInstance(); 20 aura::RootWindow* root_window = aura::RootWindow::GetInstance();
15 aura::Window::ConvertPointToWindow(window->parent(), root_window, &center); 21 aura::Window::ConvertPointToWindow(window->parent(), root_window, &center);
16 return center; 22 return center;
17 } 23 }
18 24
19 } // namespace 25 } // namespace
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 89 }
84 current_location_ = point; 90 current_location_ = point;
85 } 91 }
86 92
87 void EventGenerator::DragMouseTo(const gfx::Point& point) { 93 void EventGenerator::DragMouseTo(const gfx::Point& point) {
88 PressLeftButton(); 94 PressLeftButton();
89 MoveMouseTo(point); 95 MoveMouseTo(point);
90 ReleaseLeftButton(); 96 ReleaseLeftButton();
91 } 97 }
92 98
99 void EventGenerator::PressKey(ui::KeyboardCode key_code, int flags) {
100 DispatchKeyEvent(true, key_code, flags);
101 }
102
103 void EventGenerator::ReleaseKey(ui::KeyboardCode key_code, int flags) {
104 DispatchKeyEvent(false, key_code, flags);
105 }
106
93 void EventGenerator::Dispatch(Event& event) { 107 void EventGenerator::Dispatch(Event& event) {
94 switch (event.type()) { 108 switch (event.type()) {
95 case ui::ET_KEY_PRESSED: 109 case ui::ET_KEY_PRESSED:
96 case ui::ET_KEY_RELEASED: 110 case ui::ET_KEY_RELEASED:
97 aura::RootWindow::GetInstance()->DispatchKeyEvent( 111 aura::RootWindow::GetInstance()->DispatchKeyEvent(
98 static_cast<KeyEvent*>(&event)); 112 static_cast<KeyEvent*>(&event));
99 break; 113 break;
100 case ui::ET_MOUSE_PRESSED: 114 case ui::ET_MOUSE_PRESSED:
101 case ui::ET_MOUSE_DRAGGED: 115 case ui::ET_MOUSE_DRAGGED:
102 case ui::ET_MOUSE_RELEASED: 116 case ui::ET_MOUSE_RELEASED:
103 case ui::ET_MOUSE_MOVED: 117 case ui::ET_MOUSE_MOVED:
104 case ui::ET_MOUSE_ENTERED: 118 case ui::ET_MOUSE_ENTERED:
105 case ui::ET_MOUSE_EXITED: 119 case ui::ET_MOUSE_EXITED:
106 case ui::ET_MOUSEWHEEL: 120 case ui::ET_MOUSEWHEEL:
107 aura::RootWindow::GetInstance()->DispatchMouseEvent( 121 aura::RootWindow::GetInstance()->DispatchMouseEvent(
108 static_cast<MouseEvent*>(&event)); 122 static_cast<MouseEvent*>(&event));
109 break; 123 break;
110 default: 124 default:
111 NOTIMPLEMENTED(); 125 NOTIMPLEMENTED();
112 break; 126 break;
113 } 127 }
114 } 128 }
115 129
130 void EventGenerator::DispatchKeyEvent(bool is_press,
131 ui::KeyboardCode key_code,
132 int flags) {
133 ui::EventType type = is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED;
134 #if defined(USE_X11)
135 scoped_ptr<XEvent> native_event(new XEvent);
136 ui::InitXKeyEventForTesting(type, key_code, flags, native_event.get());
137 KeyEvent keyev(native_event.get(), false /* is_char */);
138 #else
139 KeyEvent keyev(type, key_code, flags);
140 #endif
141 Dispatch(keyev);
142 }
143
116 void EventGenerator::MoveMouseToCenterOf(Window* window) { 144 void EventGenerator::MoveMouseToCenterOf(Window* window) {
117 MoveMouseTo(CenterOfWindowInRootWindowCoordinate(window)); 145 MoveMouseTo(CenterOfWindowInRootWindowCoordinate(window));
118 } 146 }
119 147
120 } // namespace test 148 } // namespace test
121 } // namespace aura 149 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698