| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/events/event_constants.h" | 10 #include "ui/events/event_constants.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 enum class EntryType { NONE, PRINTABLE, KEYSYM }; | 38 enum class EntryType { NONE, PRINTABLE, KEYSYM }; |
| 39 struct PrintableEntry { | 39 struct PrintableEntry { |
| 40 base::char16 plain_character; | 40 base::char16 plain_character; |
| 41 base::char16 shift_character; | 41 base::char16 shift_character; |
| 42 base::char16 altgr_character; | 42 base::char16 altgr_character; |
| 43 DomCode dom_code; | 43 DomCode dom_code; |
| 44 }; | 44 }; |
| 45 struct KeysymEntry { | 45 struct KeysymEntry { |
| 46 DomCode dom_code; | 46 DomCode dom_code; |
| 47 xkb_keysym_t keysym; | 47 xkb_keysym_t keysym; |
| 48 base::char16 character; |
| 48 }; | 49 }; |
| 49 | 50 |
| 50 struct RuleNames { | 51 struct RuleNames { |
| 51 std::string layout_name; | 52 std::string layout_name; |
| 52 std::string layout; | 53 std::string layout; |
| 53 std::string variant; | 54 std::string variant; |
| 54 }; | 55 }; |
| 55 | 56 |
| 56 public: | 57 public: |
| 57 VkTestXkbKeyboardLayoutEngine(const XkbKeyCodeConverter& keycode_converter) | 58 VkTestXkbKeyboardLayoutEngine(const XkbKeyCodeConverter& keycode_converter) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 *character = printable_entry_->plain_character; | 122 *character = printable_entry_->plain_character; |
| 122 *xkb_keysym = CharacterToKeySym(*character); | 123 *xkb_keysym = CharacterToKeySym(*character); |
| 123 return *character != 0; | 124 return *character != 0; |
| 124 case EntryType::KEYSYM: | 125 case EntryType::KEYSYM: |
| 125 if (!keysym_entry_ || | 126 if (!keysym_entry_ || |
| 126 (xkb_keycode != | 127 (xkb_keycode != |
| 127 static_cast<xkb_keycode_t>(keysym_entry_->dom_code))) { | 128 static_cast<xkb_keycode_t>(keysym_entry_->dom_code))) { |
| 128 return false; | 129 return false; |
| 129 } | 130 } |
| 130 *xkb_keysym = keysym_entry_->keysym; | 131 *xkb_keysym = keysym_entry_->keysym; |
| 131 *character = 0; | 132 *character = keysym_entry_->character; |
| 132 return true; | 133 return true; |
| 133 } | 134 } |
| 134 return false; | 135 return false; |
| 135 } | 136 } |
| 136 | 137 |
| 137 private: | 138 private: |
| 138 EntryType entry_type_; | 139 EntryType entry_type_; |
| 139 const PrintableEntry* printable_entry_; | 140 const PrintableEntry* printable_entry_; |
| 140 const KeysymEntry* keysym_entry_; | 141 const KeysymEntry* keysym_entry_; |
| 141 }; | 142 }; |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 {{DomCode::OS_RIGHT, XKB_KEY_Super_R}, VKEY_LWIN}, | 809 {{DomCode::OS_RIGHT, XKB_KEY_Super_R}, VKEY_LWIN}, |
| 809 {{DomCode::ALT_LEFT, XKB_KEY_Alt_L}, VKEY_MENU}, | 810 {{DomCode::ALT_LEFT, XKB_KEY_Alt_L}, VKEY_MENU}, |
| 810 {{DomCode::ALT_RIGHT, XKB_KEY_Alt_R}, VKEY_MENU}, | 811 {{DomCode::ALT_RIGHT, XKB_KEY_Alt_R}, VKEY_MENU}, |
| 811 {{DomCode::ALT_RIGHT, XKB_KEY_ISO_Level3_Shift}, VKEY_ALTGR}, | 812 {{DomCode::ALT_RIGHT, XKB_KEY_ISO_Level3_Shift}, VKEY_ALTGR}, |
| 812 {{DomCode::DIGIT1, XKB_KEY_1}, VKEY_1}, | 813 {{DomCode::DIGIT1, XKB_KEY_1}, VKEY_1}, |
| 813 {{DomCode::NUMPAD1, XKB_KEY_KP_1}, VKEY_1}, | 814 {{DomCode::NUMPAD1, XKB_KEY_KP_1}, VKEY_1}, |
| 814 {{DomCode::CAPS_LOCK, XKB_KEY_Caps_Lock}, VKEY_CAPITAL}, | 815 {{DomCode::CAPS_LOCK, XKB_KEY_Caps_Lock}, VKEY_CAPITAL}, |
| 815 {{DomCode::ENTER, XKB_KEY_Return}, VKEY_RETURN}, | 816 {{DomCode::ENTER, XKB_KEY_Return}, VKEY_RETURN}, |
| 816 {{DomCode::NUMPAD_ENTER, XKB_KEY_KP_Enter}, VKEY_RETURN}, | 817 {{DomCode::NUMPAD_ENTER, XKB_KEY_KP_Enter}, VKEY_RETURN}, |
| 817 {{DomCode::SLEEP, XKB_KEY_XF86Sleep}, VKEY_SLEEP}, | 818 {{DomCode::SLEEP, XKB_KEY_XF86Sleep}, VKEY_SLEEP}, |
| 819 // Verify that number pad digits produce located VKEY codes. |
| 820 {{DomCode::NUMPAD0, XKB_KEY_KP_0, '0'}, VKEY_NUMPAD0}, |
| 821 {{DomCode::NUMPAD9, XKB_KEY_KP_9, '9'}, VKEY_NUMPAD9}, |
| 818 }; | 822 }; |
| 819 for (const auto& e : kVkeyTestCase) { | 823 for (const auto& e : kVkeyTestCase) { |
| 820 SCOPED_TRACE(static_cast<int>(e.test.dom_code)); | 824 SCOPED_TRACE(static_cast<int>(e.test.dom_code)); |
| 821 layout_engine_->SetEntry(&e.test); | 825 layout_engine_->SetEntry(&e.test); |
| 822 DomKey dom_key = DomKey::NONE; | 826 DomKey dom_key = DomKey::NONE; |
| 823 KeyboardCode key_code = VKEY_UNKNOWN; | 827 KeyboardCode key_code = VKEY_UNKNOWN; |
| 824 EXPECT_TRUE(layout_engine_->Lookup(e.test.dom_code, EF_NONE, &dom_key, | 828 EXPECT_TRUE(layout_engine_->Lookup(e.test.dom_code, EF_NONE, &dom_key, |
| 825 &key_code)); | 829 &key_code)); |
| 826 EXPECT_EQ(e.key_code, key_code); | 830 EXPECT_EQ(e.key_code, key_code); |
| 827 } | 831 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 std::string layout_id; | 893 std::string layout_id; |
| 890 std::string layout_variant; | 894 std::string layout_variant; |
| 891 XkbKeyboardLayoutEngine::ParseLayoutName(e->layout_name, &layout_id, | 895 XkbKeyboardLayoutEngine::ParseLayoutName(e->layout_name, &layout_id, |
| 892 &layout_variant); | 896 &layout_variant); |
| 893 EXPECT_EQ(layout_id, e->layout); | 897 EXPECT_EQ(layout_id, e->layout); |
| 894 EXPECT_EQ(layout_variant, e->variant); | 898 EXPECT_EQ(layout_variant, e->variant); |
| 895 } | 899 } |
| 896 } | 900 } |
| 897 | 901 |
| 898 } // namespace ui | 902 } // namespace ui |
| OLD | NEW |