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::DomCodeToUsLayoutCharacter( | 543 uint16 character = ui::GetCharacterFromKeyCode(key_code, flags); |
544 ui::UsLayoutKeyboardCodeToDomCode(key_code), flags); | |
545 if (is_press && character) { | 544 if (is_press && character) { |
546 MSG native_event = { NULL, WM_KEYDOWN, key_code, 0 }; | 545 MSG native_event = { NULL, WM_KEYDOWN, key_code, 0 }; |
547 TestKeyEvent keyev(native_event, flags); | 546 TestKeyEvent keyev(native_event, flags); |
548 Dispatch(&keyev); | 547 Dispatch(&keyev); |
549 // On Windows, WM_KEYDOWN event is followed by WM_CHAR with a character | 548 // On Windows, WM_KEYDOWN event is followed by WM_CHAR with a character |
550 // if the key event cooresponds to a real character. | 549 // if the key event cooresponds to a real character. |
551 key_press = WM_CHAR; | 550 key_press = WM_CHAR; |
552 key_code = static_cast<ui::KeyboardCode>(character); | 551 key_code = static_cast<ui::KeyboardCode>(character); |
553 } | 552 } |
554 MSG native_event = | 553 MSG native_event = |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 return default_delegate; | 658 return default_delegate; |
660 } | 659 } |
661 | 660 |
662 EventGeneratorDelegate* EventGenerator::delegate() { | 661 EventGeneratorDelegate* EventGenerator::delegate() { |
663 return const_cast<EventGeneratorDelegate*>( | 662 return const_cast<EventGeneratorDelegate*>( |
664 const_cast<const EventGenerator*>(this)->delegate()); | 663 const_cast<const EventGenerator*>(this)->delegate()); |
665 } | 664 } |
666 | 665 |
667 } // namespace test | 666 } // namespace test |
668 } // namespace ui | 667 } // namespace ui |
OLD | NEW |