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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 #include "ui/events/event_constants.h" | 6 #include "ui/events/event_constants.h" |
7 #include "ui/events/keycodes/dom3/dom_code.h" | 7 #include "ui/events/keycodes/dom3/dom_code.h" |
8 #include "ui/events/keycodes/dom3/dom_key.h" | 8 #include "ui/events/keycodes/dom3/dom_key.h" |
| 9 #include "ui/events/keycodes/keyboard_code_conversion.h" |
9 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" | 10 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" |
10 #include "ui/events/ozone/layout/layout_util.h" | |
11 #include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h" | 11 #include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h" |
12 | 12 |
13 namespace ui { | 13 namespace ui { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 // This XkbKeyCodeConverter simply uses the numeric value of the DomCode. | 17 // This XkbKeyCodeConverter simply uses the numeric value of the DomCode. |
18 class VkTestXkbKeyCodeConverter : public XkbKeyCodeConverter { | 18 class VkTestXkbKeyCodeConverter : public XkbKeyCodeConverter { |
19 public: | 19 public: |
20 VkTestXkbKeyCodeConverter() { | 20 VkTestXkbKeyCodeConverter() { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 xkb_keysym_t CharacterToKeySym(base::char16 c) const { | 65 xkb_keysym_t CharacterToKeySym(base::char16 c) const { |
66 return 0x01000000u + c; | 66 return 0x01000000u + c; |
67 } | 67 } |
68 | 68 |
69 KeyboardCode GetKeyboardCode(DomCode dom_code, | 69 KeyboardCode GetKeyboardCode(DomCode dom_code, |
70 int flags, | 70 int flags, |
71 base::char16 character) const { | 71 base::char16 character) const { |
72 KeyboardCode key_code = DifficultKeyboardCode( | 72 KeyboardCode key_code = DifficultKeyboardCode( |
73 dom_code, flags, key_code_converter_.DomCodeToXkbKeyCode(dom_code), | 73 dom_code, flags, key_code_converter_.DomCodeToXkbKeyCode(dom_code), |
74 flags, CharacterToKeySym(character), DomKey::CHARACTER, character); | 74 flags, CharacterToKeySym(character), DomKey::CHARACTER, character); |
75 if (key_code == VKEY_UNKNOWN) | 75 if (key_code == VKEY_UNKNOWN) { |
76 key_code = DomCodeToNonLocatedKeyboardCode(dom_code); | 76 key_code = |
| 77 LocatedToNonLocatedKeyboardCode(DomCodeToKeyboardCode(dom_code)); |
| 78 } |
77 return key_code; | 79 return key_code; |
78 } | 80 } |
79 | 81 |
80 // XkbKeyboardLayoutEngine overrides: | 82 // XkbKeyboardLayoutEngine overrides: |
81 bool XkbLookup(xkb_keycode_t xkb_keycode, | 83 bool XkbLookup(xkb_keycode_t xkb_keycode, |
82 xkb_mod_mask_t xkb_flags, | 84 xkb_mod_mask_t xkb_flags, |
83 xkb_keysym_t* xkb_keysym, | 85 xkb_keysym_t* xkb_keysym, |
84 base::char16* character) const override { | 86 base::char16* character) const override { |
85 if (!entry_ || | 87 if (!entry_ || |
86 (xkb_keycode != static_cast<xkb_keycode_t>(entry_->dom_code))) | 88 (xkb_keycode != static_cast<xkb_keycode_t>(entry_->dom_code))) |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 std::string layout_id; | 812 std::string layout_id; |
811 std::string layout_variant; | 813 std::string layout_variant; |
812 XkbKeyboardLayoutEngine::ParseLayoutName(e->layout_name, &layout_id, | 814 XkbKeyboardLayoutEngine::ParseLayoutName(e->layout_name, &layout_id, |
813 &layout_variant); | 815 &layout_variant); |
814 EXPECT_EQ(layout_id, e->layout); | 816 EXPECT_EQ(layout_id, e->layout); |
815 EXPECT_EQ(layout_variant, e->variant); | 817 EXPECT_EQ(layout_variant, e->variant); |
816 } | 818 } |
817 } | 819 } |
818 | 820 |
819 } // namespace ui | 821 } // namespace ui |
OLD | NEW |