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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 if (window_context) | 515 if (window_context) |
516 current_location_ = delegate()->CenterOfWindow(window_context); | 516 current_location_ = delegate()->CenterOfWindow(window_context); |
517 current_target_ = delegate()->GetTargetAt(current_location_); | 517 current_target_ = delegate()->GetTargetAt(current_location_); |
518 } | 518 } |
519 | 519 |
520 void EventGenerator::DispatchKeyEvent(bool is_press, | 520 void EventGenerator::DispatchKeyEvent(bool is_press, |
521 ui::KeyboardCode key_code, | 521 ui::KeyboardCode key_code, |
522 int flags) { | 522 int flags) { |
523 #if defined(OS_WIN) | 523 #if defined(OS_WIN) |
524 UINT key_press = WM_KEYDOWN; | 524 UINT key_press = WM_KEYDOWN; |
525 uint16 character = ui::GetCharacterFromKeyCode(key_code, flags); | 525 DomCode code = ui::KeyboardCodeToDomCode(key_code); |
| 526 uint16 character = ui::DomCodeToCharacter(code, flags); |
526 if (is_press && character) { | 527 if (is_press && character) { |
527 MSG native_event = { NULL, WM_KEYDOWN, key_code, 0 }; | 528 MSG native_event = { NULL, WM_KEYDOWN, key_code, 0 }; |
528 TestKeyEvent keyev(native_event, flags); | 529 TestKeyEvent keyev(native_event, flags); |
529 Dispatch(&keyev); | 530 Dispatch(&keyev); |
530 // On Windows, WM_KEYDOWN event is followed by WM_CHAR with a character | 531 // On Windows, WM_KEYDOWN event is followed by WM_CHAR with a character |
531 // if the key event cooresponds to a real character. | 532 // if the key event cooresponds to a real character. |
532 key_press = WM_CHAR; | 533 key_press = WM_CHAR; |
533 key_code = static_cast<ui::KeyboardCode>(character); | 534 key_code = static_cast<ui::KeyboardCode>(character); |
534 } | 535 } |
535 MSG native_event = | 536 MSG native_event = |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 return default_delegate; | 639 return default_delegate; |
639 } | 640 } |
640 | 641 |
641 EventGeneratorDelegate* EventGenerator::delegate() { | 642 EventGeneratorDelegate* EventGenerator::delegate() { |
642 return const_cast<EventGeneratorDelegate*>( | 643 return const_cast<EventGeneratorDelegate*>( |
643 const_cast<const EventGenerator*>(this)->delegate()); | 644 const_cast<const EventGenerator*>(this)->delegate()); |
644 } | 645 } |
645 | 646 |
646 } // namespace test | 647 } // namespace test |
647 } // namespace ui | 648 } // namespace ui |
OLD | NEW |