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

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

Issue 817983002: ozone: xkb: Load keymaps on worker thread & cache them (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months 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
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 "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
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
42 public: 48 public:
43 VkTestXkbKeyboardLayoutEngine(const XkbKeyCodeConverter& keycode_converter) 49 VkTestXkbKeyboardLayoutEngine(const XkbKeyCodeConverter& keycode_converter)
44 : XkbKeyboardLayoutEngine(keycode_converter), entry_(nullptr) { 50 : XkbKeyboardLayoutEngine(keycode_converter), entry_(nullptr) {
45 // For testing, use the same modifier values as ui::EventFlags. 51 // For testing, use the same modifier values as ui::EventFlags.
46 static const int kTestFlags[] = { 52 static const int kTestFlags[] = {
47 EF_SHIFT_DOWN, EF_ALTGR_DOWN, EF_MOD3_DOWN}; 53 EF_SHIFT_DOWN, EF_ALTGR_DOWN, EF_MOD3_DOWN};
48 xkb_flag_map_.clear(); 54 xkb_flag_map_.clear();
49 xkb_flag_map_.resize(arraysize(kTestFlags)); 55 xkb_flag_map_.resize(arraysize(kTestFlags));
50 for (size_t i = 0; i < arraysize(kTestFlags); ++i) { 56 for (size_t i = 0; i < arraysize(kTestFlags); ++i) {
51 XkbFlagMapEntry e = {kTestFlags[i], kTestFlags[i]}; 57 XkbFlagMapEntry e = {kTestFlags[i], kTestFlags[i]};
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 EXPECT_EQ(e->key_code, key_code); 742 EXPECT_EQ(e->key_code, key_code);
737 } 743 }
738 744
739 // Test with unrelated predetermined character. 745 // Test with unrelated predetermined character.
740 key_code = 746 key_code =
741 layout_engine_->GetKeyboardCode(e->dom_code, EF_MOD3_DOWN, 0xFFFFu); 747 layout_engine_->GetKeyboardCode(e->dom_code, EF_MOD3_DOWN, 0xFFFFu);
742 EXPECT_EQ(e->key_code, key_code); 748 EXPECT_EQ(e->key_code, key_code);
743 } 749 }
744 } 750 }
745 751
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
746 } // namespace ui 817 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698