OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/events/test/event_generator.h" | 5 #include "ui/events/test/event_generator.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 if (window_context) | 533 if (window_context) |
534 current_location_ = delegate()->CenterOfWindow(window_context); | 534 current_location_ = delegate()->CenterOfWindow(window_context); |
535 current_target_ = delegate()->GetTargetAt(current_location_); | 535 current_target_ = delegate()->GetTargetAt(current_location_); |
536 } | 536 } |
537 | 537 |
538 void EventGenerator::DispatchKeyEvent(bool is_press, | 538 void EventGenerator::DispatchKeyEvent(bool is_press, |
539 ui::KeyboardCode key_code, | 539 ui::KeyboardCode key_code, |
540 int flags) { | 540 int flags) { |
541 #if defined(OS_WIN) | 541 #if defined(OS_WIN) |
542 UINT key_press = WM_KEYDOWN; | 542 UINT key_press = WM_KEYDOWN; |
543 uint16 character = ui::GetCharacterFromKeyCode(key_code, flags); | 543 DomCode code = ui::KeyboardCodeToDomCode(key_code); |
| 544 uint16 character = ui::DomCodeToCharacter(code, flags); |
544 if (is_press && character) { | 545 if (is_press && character) { |
545 MSG native_event = { NULL, WM_KEYDOWN, key_code, 0 }; | 546 MSG native_event = { NULL, WM_KEYDOWN, key_code, 0 }; |
546 TestKeyEvent keyev(native_event, flags); | 547 TestKeyEvent keyev(native_event, flags); |
547 Dispatch(&keyev); | 548 Dispatch(&keyev); |
548 // On Windows, WM_KEYDOWN event is followed by WM_CHAR with a character | 549 // On Windows, WM_KEYDOWN event is followed by WM_CHAR with a character |
549 // if the key event cooresponds to a real character. | 550 // if the key event cooresponds to a real character. |
550 key_press = WM_CHAR; | 551 key_press = WM_CHAR; |
551 key_code = static_cast<ui::KeyboardCode>(character); | 552 key_code = static_cast<ui::KeyboardCode>(character); |
552 } | 553 } |
553 MSG native_event = | 554 MSG native_event = |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 return default_delegate; | 659 return default_delegate; |
659 } | 660 } |
660 | 661 |
661 EventGeneratorDelegate* EventGenerator::delegate() { | 662 EventGeneratorDelegate* EventGenerator::delegate() { |
662 return const_cast<EventGeneratorDelegate*>( | 663 return const_cast<EventGeneratorDelegate*>( |
663 const_cast<const EventGenerator*>(this)->delegate()); | 664 const_cast<const EventGenerator*>(this)->delegate()); |
664 } | 665 } |
665 | 666 |
666 } // namespace test | 667 } // namespace test |
667 } // namespace ui | 668 } // namespace ui |
OLD | NEW |