OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/memory/scoped_ptr.h" |
8 #include "ui/aura/event.h" | 8 #include "ui/aura/event.h" |
9 #include "ui/aura/root_window.h" | 9 #include "ui/aura/root_window.h" |
10 | 10 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 208 } |
209 | 209 |
210 void EventGenerator::ReleaseKey(ui::KeyboardCode key_code, int flags) { | 210 void EventGenerator::ReleaseKey(ui::KeyboardCode key_code, int flags) { |
211 DispatchKeyEvent(false, key_code, flags); | 211 DispatchKeyEvent(false, key_code, flags); |
212 } | 212 } |
213 | 213 |
214 void EventGenerator::Dispatch(Event& event) { | 214 void EventGenerator::Dispatch(Event& event) { |
215 switch (event.type()) { | 215 switch (event.type()) { |
216 case ui::ET_KEY_PRESSED: | 216 case ui::ET_KEY_PRESSED: |
217 case ui::ET_KEY_RELEASED: | 217 case ui::ET_KEY_RELEASED: |
218 root_window_->DispatchKeyEvent(static_cast<KeyEvent*>(&event)); | 218 root_window_->AsRootWindowHostDelegate()->OnHostKeyEvent( |
| 219 static_cast<KeyEvent*>(&event)); |
219 break; | 220 break; |
220 case ui::ET_MOUSE_PRESSED: | 221 case ui::ET_MOUSE_PRESSED: |
221 case ui::ET_MOUSE_DRAGGED: | 222 case ui::ET_MOUSE_DRAGGED: |
222 case ui::ET_MOUSE_RELEASED: | 223 case ui::ET_MOUSE_RELEASED: |
223 case ui::ET_MOUSE_MOVED: | 224 case ui::ET_MOUSE_MOVED: |
224 case ui::ET_MOUSE_ENTERED: | 225 case ui::ET_MOUSE_ENTERED: |
225 case ui::ET_MOUSE_EXITED: | 226 case ui::ET_MOUSE_EXITED: |
226 case ui::ET_MOUSEWHEEL: | 227 case ui::ET_MOUSEWHEEL: |
227 root_window_->DispatchMouseEvent(static_cast<MouseEvent*>(&event)); | 228 root_window_->AsRootWindowHostDelegate()->OnHostMouseEvent( |
| 229 static_cast<MouseEvent*>(&event)); |
228 break; | 230 break; |
229 case ui::ET_TOUCH_RELEASED: | 231 case ui::ET_TOUCH_RELEASED: |
230 case ui::ET_TOUCH_PRESSED: | 232 case ui::ET_TOUCH_PRESSED: |
231 case ui::ET_TOUCH_MOVED: | 233 case ui::ET_TOUCH_MOVED: |
232 case ui::ET_TOUCH_STATIONARY: | 234 case ui::ET_TOUCH_STATIONARY: |
233 case ui::ET_TOUCH_CANCELLED: | 235 case ui::ET_TOUCH_CANCELLED: |
234 root_window_->DispatchTouchEvent(static_cast<TouchEvent*>(&event)); | 236 root_window_->AsRootWindowHostDelegate()->OnHostTouchEvent( |
| 237 static_cast<TouchEvent*>(&event)); |
235 break; | 238 break; |
236 default: | 239 default: |
237 NOTIMPLEMENTED(); | 240 NOTIMPLEMENTED(); |
238 break; | 241 break; |
239 } | 242 } |
240 } | 243 } |
241 | 244 |
242 void EventGenerator::DispatchKeyEvent(bool is_press, | 245 void EventGenerator::DispatchKeyEvent(bool is_press, |
243 ui::KeyboardCode key_code, | 246 ui::KeyboardCode key_code, |
244 int flags) { | 247 int flags) { |
245 #if defined(OS_WIN) | 248 #if defined(OS_WIN) |
246 MSG native_event = | 249 MSG native_event = |
247 { NULL, (is_press ? WM_KEYDOWN : WM_KEYUP), key_code, 0 }; | 250 { NULL, (is_press ? WM_KEYDOWN : WM_KEYUP), key_code, 0 }; |
248 TestKeyEvent keyev(native_event, flags); | 251 TestKeyEvent keyev(native_event, flags); |
249 #else | 252 #else |
250 ui::EventType type = is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED; | 253 ui::EventType type = is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED; |
251 #if defined(USE_X11) | 254 #if defined(USE_X11) |
252 scoped_ptr<XEvent> native_event(new XEvent); | 255 scoped_ptr<XEvent> native_event(new XEvent); |
253 ui::InitXKeyEventForTesting(type, key_code, flags, native_event.get()); | 256 ui::InitXKeyEventForTesting(type, key_code, flags, native_event.get()); |
254 TestKeyEvent keyev(native_event.get(), flags); | 257 TestKeyEvent keyev(native_event.get(), flags); |
255 #else | 258 #else |
256 KeyEvent keyev(type, key_code, flags); | 259 KeyEvent keyev(type, key_code, flags); |
257 #endif // USE_X11 | 260 #endif // USE_X11 |
258 #endif // OS_WIN | 261 #endif // OS_WIN |
259 Dispatch(keyev); | 262 Dispatch(keyev); |
260 } | 263 } |
261 | 264 |
262 } // namespace test | 265 } // namespace test |
263 } // namespace aura | 266 } // namespace aura |
OLD | NEW |