| 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/ozone/layout/keyboard_layout_engine_manager.h" | 9 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" |
| 10 #include "ui/events/ozone/layout/layout_util.h" | 10 #include "ui/events/ozone/layout/layout_util.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 class VkTestXkbKeyboardLayoutEngine : public XkbKeyboardLayoutEngine { | 32 class VkTestXkbKeyboardLayoutEngine : public XkbKeyboardLayoutEngine { |
| 33 public: | 33 public: |
| 34 struct Entry { | 34 struct Entry { |
| 35 base::char16 plain_character; | 35 base::char16 plain_character; |
| 36 base::char16 shift_character; | 36 base::char16 shift_character; |
| 37 base::char16 altgr_character; | 37 base::char16 altgr_character; |
| 38 ui::DomCode dom_code; | 38 ui::DomCode dom_code; |
| 39 ui::KeyboardCode key_code; | 39 ui::KeyboardCode key_code; |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 struct RuleNames { | |
| 43 std::string layout_name; | |
| 44 std::string layout; | |
| 45 std::string variant; | |
| 46 }; | |
| 47 | |
| 48 public: | 42 public: |
| 49 VkTestXkbKeyboardLayoutEngine(const XkbKeyCodeConverter& keycode_converter) | 43 VkTestXkbKeyboardLayoutEngine(const XkbKeyCodeConverter& keycode_converter) |
| 50 : XkbKeyboardLayoutEngine(keycode_converter), entry_(nullptr) { | 44 : XkbKeyboardLayoutEngine(keycode_converter), entry_(nullptr) { |
| 51 // For testing, use the same modifier values as ui::EventFlags. | 45 // For testing, use the same modifier values as ui::EventFlags. |
| 52 static const int kTestFlags[] = { | 46 static const int kTestFlags[] = { |
| 53 EF_SHIFT_DOWN, EF_ALTGR_DOWN, EF_MOD3_DOWN}; | 47 EF_SHIFT_DOWN, EF_ALTGR_DOWN, EF_MOD3_DOWN}; |
| 54 xkb_flag_map_.clear(); | 48 xkb_flag_map_.clear(); |
| 55 xkb_flag_map_.resize(arraysize(kTestFlags)); | 49 xkb_flag_map_.resize(arraysize(kTestFlags)); |
| 56 for (size_t i = 0; i < arraysize(kTestFlags); ++i) { | 50 for (size_t i = 0; i < arraysize(kTestFlags); ++i) { |
| 57 XkbFlagMapEntry e = {kTestFlags[i], kTestFlags[i]}; | 51 XkbFlagMapEntry e = {kTestFlags[i], kTestFlags[i]}; |
| (...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 EXPECT_EQ(e->key_code, key_code); | 736 EXPECT_EQ(e->key_code, key_code); |
| 743 } | 737 } |
| 744 | 738 |
| 745 // Test with unrelated predetermined character. | 739 // Test with unrelated predetermined character. |
| 746 key_code = | 740 key_code = |
| 747 layout_engine_->GetKeyboardCode(e->dom_code, EF_MOD3_DOWN, 0xFFFFu); | 741 layout_engine_->GetKeyboardCode(e->dom_code, EF_MOD3_DOWN, 0xFFFFu); |
| 748 EXPECT_EQ(e->key_code, key_code); | 742 EXPECT_EQ(e->key_code, key_code); |
| 749 } | 743 } |
| 750 } | 744 } |
| 751 | 745 |
| 752 TEST_F(XkbLayoutEngineVkTest, XkbRuleNamesForLayoutName) { | |
| 753 static const VkTestXkbKeyboardLayoutEngine::RuleNames kVkeyTestCase[] = { | |
| 754 /* 0 */ {"us", "us", ""}, | |
| 755 /* 1 */ {"jp", "jp", ""}, | |
| 756 /* 2 */ {"us(intl)", "us", "intl"}, | |
| 757 /* 3 */ {"us(altgr-intl)", "us", "altgr-intl"}, | |
| 758 /* 4 */ {"us(dvorak)", "us", "dvorak"}, | |
| 759 /* 5 */ {"us(colemak)", "us", "colemak"}, | |
| 760 /* 6 */ {"be", "be", ""}, | |
| 761 /* 7 */ {"fr", "fr", ""}, | |
| 762 /* 8 */ {"ca", "ca", ""}, | |
| 763 /* 9 */ {"ch(fr)", "ch", "fr"}, | |
| 764 /* 10 */ {"ca(multix)", "ca", "multix"}, | |
| 765 /* 11 */ {"de", "de", ""}, | |
| 766 /* 12 */ {"de(neo)", "de", "neo"}, | |
| 767 /* 13 */ {"ch", "ch", ""}, | |
| 768 /* 14 */ {"ru", "ru", ""}, | |
| 769 /* 15 */ {"ru(phonetic)", "ru", "phonetic"}, | |
| 770 /* 16 */ {"br", "br", ""}, | |
| 771 /* 17 */ {"bg", "bg", ""}, | |
| 772 /* 18 */ {"bg(phonetic)", "bg", "phonetic"}, | |
| 773 /* 19 */ {"ca(eng)", "ca", "eng"}, | |
| 774 /* 20 */ {"cz", "cz", ""}, | |
| 775 /* 21 */ {"cz(qwerty)", "cz", "qwerty"}, | |
| 776 /* 22 */ {"ee", "ee", ""}, | |
| 777 /* 23 */ {"es", "es", ""}, | |
| 778 /* 24 */ {"es(cat)", "es", "cat"}, | |
| 779 /* 25 */ {"dk", "dk", ""}, | |
| 780 /* 26 */ {"gr", "gr", ""}, | |
| 781 /* 27 */ {"il", "il", ""}, | |
| 782 /* 28 */ {"latam", "latam", ""}, | |
| 783 /* 29 */ {"lt", "lt", ""}, | |
| 784 /* 30 */ {"lv(apostrophe)", "lv", "apostrophe"}, | |
| 785 /* 31 */ {"hr", "hr", ""}, | |
| 786 /* 32 */ {"gb(extd)", "gb", "extd"}, | |
| 787 /* 33 */ {"gb(dvorak)", "gb", "dvorak"}, | |
| 788 /* 34 */ {"fi", "fi", ""}, | |
| 789 /* 35 */ {"hu", "hu", ""}, | |
| 790 /* 36 */ {"it", "it", ""}, | |
| 791 /* 37 */ {"is", "is", ""}, | |
| 792 /* 38 */ {"no", "no", ""}, | |
| 793 /* 39 */ {"pl", "pl", ""}, | |
| 794 /* 40 */ {"pt", "pt", ""}, | |
| 795 /* 41 */ {"ro", "ro", ""}, | |
| 796 /* 42 */ {"se", "se", ""}, | |
| 797 /* 43 */ {"sk", "sk", ""}, | |
| 798 /* 44 */ {"si", "si", ""}, | |
| 799 /* 45 */ {"rs", "rs", ""}, | |
| 800 /* 46 */ {"tr", "tr", ""}, | |
| 801 /* 47 */ {"ua", "ua", ""}, | |
| 802 /* 48 */ {"by", "by", ""}, | |
| 803 /* 49 */ {"am", "am", ""}, | |
| 804 /* 50 */ {"ge", "ge", ""}, | |
| 805 /* 51 */ {"mn", "mn", ""}, | |
| 806 /* 52 */ {"ie", "ie", ""}}; | |
| 807 for (size_t i = 0; i < arraysize(kVkeyTestCase); ++i) { | |
| 808 SCOPED_TRACE(i); | |
| 809 const VkTestXkbKeyboardLayoutEngine::RuleNames* e = &kVkeyTestCase[i]; | |
| 810 scoped_ptr<xkb_rule_names> names = | |
| 811 layout_engine_->GetXkbRuleNames(e->layout_name); | |
| 812 EXPECT_EQ(names.get()->layout, e->layout); | |
| 813 EXPECT_EQ(names.get()->variant, e->variant); | |
| 814 } | |
| 815 } | |
| 816 | |
| 817 } // namespace ui | 746 } // namespace ui |
| OLD | NEW |