Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(792)

Side by Side Diff: ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine_unittest.cc

Issue 2481413006: Checks the DomKey in the non-printable map to determine whether a key event is non-character. (Closed)
Patch Set: Checks the DomKey in the non-printable map to determine whether a key event is non-character. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ozone/layout/xkb/xkb_keyboard_layout_engine.h" 5 #include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 28 matching lines...) Expand all
39 public: 39 public:
40 enum class EntryType { NONE, PRINTABLE, KEYSYM }; 40 enum class EntryType { NONE, PRINTABLE, KEYSYM };
41 struct PrintableEntry { 41 struct PrintableEntry {
42 base::char16 plain_character; 42 base::char16 plain_character;
43 base::char16 shift_character; 43 base::char16 shift_character;
44 base::char16 altgr_character; 44 base::char16 altgr_character;
45 DomCode dom_code; 45 DomCode dom_code;
46 }; 46 };
47 struct KeysymEntry { 47 struct KeysymEntry {
48 DomCode dom_code; 48 DomCode dom_code;
49 int flags;
49 xkb_keysym_t keysym; 50 xkb_keysym_t keysym;
50 base::char16 character; 51 base::char16 character;
51 }; 52 };
52 53
53 struct RuleNames { 54 struct RuleNames {
54 std::string layout_name; 55 std::string layout_name;
55 std::string layout; 56 std::string layout;
56 std::string variant; 57 std::string variant;
57 }; 58 };
58 59
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 layout_engine_->GetKeyboardCode(e.test.dom_code, EF_MOD3_DOWN, 0xFFFFu); 797 layout_engine_->GetKeyboardCode(e.test.dom_code, EF_MOD3_DOWN, 0xFFFFu);
797 EXPECT_EQ(e.key_code, key_code); 798 EXPECT_EQ(e.key_code, key_code);
798 } 799 }
799 } 800 }
800 801
801 TEST_F(XkbLayoutEngineVkTest, KeyboardCodeForNonPrintable) { 802 TEST_F(XkbLayoutEngineVkTest, KeyboardCodeForNonPrintable) {
802 static const struct { 803 static const struct {
803 VkTestXkbKeyboardLayoutEngine::KeysymEntry test; 804 VkTestXkbKeyboardLayoutEngine::KeysymEntry test;
804 KeyboardCode key_code; 805 KeyboardCode key_code;
805 } kVkeyTestCase[] = { 806 } kVkeyTestCase[] = {
806 {{DomCode::CONTROL_LEFT, XKB_KEY_Control_L}, VKEY_CONTROL}, 807 {{DomCode::CONTROL_LEFT, EF_NONE, XKB_KEY_Control_L}, VKEY_CONTROL},
807 {{DomCode::CONTROL_RIGHT, XKB_KEY_Control_R}, VKEY_CONTROL}, 808 {{DomCode::CONTROL_RIGHT, EF_NONE, XKB_KEY_Control_R}, VKEY_CONTROL},
808 {{DomCode::SHIFT_LEFT, XKB_KEY_Shift_L}, VKEY_SHIFT}, 809 {{DomCode::SHIFT_LEFT, EF_NONE, XKB_KEY_Shift_L}, VKEY_SHIFT},
809 {{DomCode::SHIFT_RIGHT, XKB_KEY_Shift_R}, VKEY_SHIFT}, 810 {{DomCode::SHIFT_RIGHT, EF_NONE, XKB_KEY_Shift_R}, VKEY_SHIFT},
810 {{DomCode::META_LEFT, XKB_KEY_Super_L}, VKEY_LWIN}, 811 {{DomCode::META_LEFT, EF_NONE, XKB_KEY_Super_L}, VKEY_LWIN},
811 {{DomCode::META_RIGHT, XKB_KEY_Super_R}, VKEY_LWIN}, 812 {{DomCode::META_RIGHT, EF_NONE, XKB_KEY_Super_R}, VKEY_LWIN},
812 {{DomCode::ALT_LEFT, XKB_KEY_Alt_L}, VKEY_MENU}, 813 {{DomCode::ALT_LEFT, EF_NONE, XKB_KEY_Alt_L}, VKEY_MENU},
813 {{DomCode::ALT_RIGHT, XKB_KEY_Alt_R}, VKEY_MENU}, 814 {{DomCode::ALT_RIGHT, EF_NONE, XKB_KEY_Alt_R}, VKEY_MENU},
814 {{DomCode::ALT_RIGHT, XKB_KEY_ISO_Level3_Shift}, VKEY_ALTGR}, 815 {{DomCode::ALT_RIGHT, EF_NONE, XKB_KEY_ISO_Level3_Shift}, VKEY_ALTGR},
815 {{DomCode::DIGIT1, XKB_KEY_1}, VKEY_1}, 816 {{DomCode::DIGIT1, EF_NONE, XKB_KEY_1}, VKEY_1},
816 {{DomCode::NUMPAD1, XKB_KEY_KP_1}, VKEY_1}, 817 {{DomCode::NUMPAD1, EF_NONE, XKB_KEY_KP_1}, VKEY_1},
817 {{DomCode::CAPS_LOCK, XKB_KEY_Caps_Lock}, VKEY_CAPITAL}, 818 {{DomCode::CAPS_LOCK, EF_NONE, XKB_KEY_Caps_Lock}, VKEY_CAPITAL},
818 {{DomCode::ENTER, XKB_KEY_Return}, VKEY_RETURN}, 819 {{DomCode::ENTER, EF_NONE, XKB_KEY_Return}, VKEY_RETURN},
819 {{DomCode::NUMPAD_ENTER, XKB_KEY_KP_Enter}, VKEY_RETURN}, 820 {{DomCode::NUMPAD_ENTER, EF_NONE, XKB_KEY_KP_Enter}, VKEY_RETURN},
820 {{DomCode::SLEEP, XKB_KEY_XF86Sleep}, VKEY_SLEEP}, 821 {{DomCode::SLEEP, EF_NONE, XKB_KEY_XF86Sleep}, VKEY_SLEEP},
821 // Verify that number pad digits produce located VKEY codes. 822 // Verify that number pad digits produce located VKEY codes.
822 {{DomCode::NUMPAD0, XKB_KEY_KP_0, '0'}, VKEY_NUMPAD0}, 823 {{DomCode::NUMPAD0, EF_NONE, XKB_KEY_KP_0, '0'}, VKEY_NUMPAD0},
823 {{DomCode::NUMPAD9, XKB_KEY_KP_9, '9'}, VKEY_NUMPAD9}, 824 {{DomCode::NUMPAD9, EF_NONE, XKB_KEY_KP_9, '9'}, VKEY_NUMPAD9},
825 // Verify AltGr+V & AltGr+W on de(neo) layout.
826 {{DomCode::US_W, EF_ALTGR_DOWN, XKB_KEY_BackSpace, 8}, VKEY_BACKSPACE},
827 {{DomCode::US_V, EF_ALTGR_DOWN, XKB_KEY_Return, 13}, VKEY_ENTER},
824 }; 828 };
825 for (const auto& e : kVkeyTestCase) { 829 for (const auto& e : kVkeyTestCase) {
826 SCOPED_TRACE(static_cast<int>(e.test.dom_code)); 830 SCOPED_TRACE(static_cast<int>(e.test.dom_code));
827 layout_engine_->SetEntry(&e.test); 831 layout_engine_->SetEntry(&e.test);
828 DomKey dom_key = DomKey::NONE; 832 DomKey dom_key = DomKey::NONE;
829 KeyboardCode key_code = VKEY_UNKNOWN; 833 KeyboardCode key_code = VKEY_UNKNOWN;
830 EXPECT_TRUE(layout_engine_->Lookup(e.test.dom_code, EF_NONE, &dom_key, 834 EXPECT_TRUE(layout_engine_->Lookup(e.test.dom_code, e.test.flags, &dom_key,
831 &key_code)); 835 &key_code));
832 EXPECT_EQ(e.key_code, key_code); 836 EXPECT_EQ(e.key_code, key_code);
833 } 837 }
834 } 838 }
835 839
836 840
837 TEST_F(XkbLayoutEngineVkTest, XkbRuleNamesForLayoutName) { 841 TEST_F(XkbLayoutEngineVkTest, XkbRuleNamesForLayoutName) {
838 static const VkTestXkbKeyboardLayoutEngine::RuleNames kVkeyTestCase[] = { 842 static const VkTestXkbKeyboardLayoutEngine::RuleNames kVkeyTestCase[] = {
839 /* 0 */ {"us", "us", ""}, 843 /* 0 */ {"us", "us", ""},
840 /* 1 */ {"jp", "jp", ""}, 844 /* 1 */ {"jp", "jp", ""},
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 std::string layout_id; 899 std::string layout_id;
896 std::string layout_variant; 900 std::string layout_variant;
897 XkbKeyboardLayoutEngine::ParseLayoutName(e->layout_name, &layout_id, 901 XkbKeyboardLayoutEngine::ParseLayoutName(e->layout_name, &layout_id,
898 &layout_variant); 902 &layout_variant);
899 EXPECT_EQ(layout_id, e->layout); 903 EXPECT_EQ(layout_id, e->layout);
900 EXPECT_EQ(layout_variant, e->variant); 904 EXPECT_EQ(layout_variant, e->variant);
901 } 905 }
902 } 906 }
903 907
904 } // namespace ui 908 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698