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

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

Issue 954943003: [KeyboardEvent] Use DOM |code| rather than Windows-based key code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing VKEY in windows for brightness and power Created 5 years, 10 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"
11 #include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h" 10 #include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h"
12 11
13 namespace ui { 12 namespace ui {
14 13
15 namespace { 14 namespace {
16 15
17 // This XkbKeyCodeConverter simply uses the numeric value of the DomCode. 16 // This XkbKeyCodeConverter simply uses the numeric value of the DomCode.
18 class VkTestXkbKeyCodeConverter : public XkbKeyCodeConverter { 17 class VkTestXkbKeyCodeConverter : public XkbKeyCodeConverter {
19 public: 18 public:
20 VkTestXkbKeyCodeConverter() { 19 VkTestXkbKeyCodeConverter() {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 xkb_keysym_t CharacterToKeySym(base::char16 c) const { 64 xkb_keysym_t CharacterToKeySym(base::char16 c) const {
66 return 0x01000000u + c; 65 return 0x01000000u + c;
67 } 66 }
68 67
69 KeyboardCode GetKeyboardCode(DomCode dom_code, 68 KeyboardCode GetKeyboardCode(DomCode dom_code,
70 int flags, 69 int flags,
71 base::char16 character) const { 70 base::char16 character) const {
72 KeyboardCode key_code = DifficultKeyboardCode( 71 KeyboardCode key_code = DifficultKeyboardCode(
73 dom_code, flags, key_code_converter_.DomCodeToXkbKeyCode(dom_code), 72 dom_code, flags, key_code_converter_.DomCodeToXkbKeyCode(dom_code),
74 flags, CharacterToKeySym(character), DomKey::CHARACTER, character); 73 flags, CharacterToKeySym(character), DomKey::CHARACTER, character);
75 if (key_code == VKEY_UNKNOWN) 74 if (key_code == VKEY_UNKNOWN) {
76 key_code = DomCodeToNonLocatedKeyboardCode(dom_code); 75 DomCode code = DomCodeToKeyboardCode(dom_code);
76 key_code = LocatedToNonLocatedKeyboardCode(code);
77 }
77 return key_code; 78 return key_code;
78 } 79 }
79 80
80 // XkbKeyboardLayoutEngine overrides: 81 // XkbKeyboardLayoutEngine overrides:
81 bool XkbLookup(xkb_keycode_t xkb_keycode, 82 bool XkbLookup(xkb_keycode_t xkb_keycode,
82 xkb_mod_mask_t xkb_flags, 83 xkb_mod_mask_t xkb_flags,
83 xkb_keysym_t* xkb_keysym, 84 xkb_keysym_t* xkb_keysym,
84 base::char16* character) const override { 85 base::char16* character) const override {
85 if (!entry_ || 86 if (!entry_ ||
86 (xkb_keycode != static_cast<xkb_keycode_t>(entry_->dom_code))) 87 (xkb_keycode != static_cast<xkb_keycode_t>(entry_->dom_code)))
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 std::string layout_id; 811 std::string layout_id;
811 std::string layout_variant; 812 std::string layout_variant;
812 XkbKeyboardLayoutEngine::ParseLayoutName(e->layout_name, &layout_id, 813 XkbKeyboardLayoutEngine::ParseLayoutName(e->layout_name, &layout_id,
813 &layout_variant); 814 &layout_variant);
814 EXPECT_EQ(layout_id, e->layout); 815 EXPECT_EQ(layout_id, e->layout);
815 EXPECT_EQ(layout_variant, e->variant); 816 EXPECT_EQ(layout_variant, e->variant);
816 } 817 }
817 } 818 }
818 819
819 } // namespace ui 820 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.cc ('k') | ui/events/test/event_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698