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

Side by Side Diff: ui/events/keycodes/platform_key_map_win_unittest.cc

Issue 2046193002: [DomKey] Expose Korean special keys on Korean keyboard layout only (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Wez's review Created 4 years, 6 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
« no previous file with comments | « ui/events/keycodes/platform_key_map_win.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 (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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/keycodes/platform_key_map_win.h" 5 #include "ui/events/keycodes/platform_key_map_win.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.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"
11 #include "ui/events/keycodes/dom/dom_code.h" 11 #include "ui/events/keycodes/dom/dom_code.h"
12 #include "ui/events/keycodes/dom/dom_key.h" 12 #include "ui/events/keycodes/dom/dom_key.h"
13 #include "ui/events/keycodes/dom/keycode_converter.h" 13 #include "ui/events/keycodes/dom/keycode_converter.h"
14 #include "ui/events/keycodes/dom_us_layout_data.h" 14 #include "ui/events/keycodes/dom_us_layout_data.h"
15 15
16 namespace ui { 16 namespace ui {
17 17
18 namespace { 18 namespace {
19 19
20 const wchar_t* LAYOUT_US = L"00000409"; 20 const wchar_t* LAYOUT_US = L"00000409";
21 const wchar_t* LAYOUT_FR = L"0000040c"; 21 const wchar_t* LAYOUT_FR = L"0000040c";
22 const wchar_t* LAYOUT_KO = L"00000412";
22 23
23 struct TestKey { 24 struct TestKey {
24 // Have to use KeyboardCode instead of DomCode because we don't know the 25 // Have to use KeyboardCode instead of DomCode because we don't know the
25 // physical keyboard layout for try bots. 26 // physical keyboard layout for try bots.
26 KeyboardCode key_code; 27 KeyboardCode key_code;
27 const char* normal; 28 const char* normal;
28 const char* shift; 29 const char* shift;
29 const char* capslock; 30 const char* capslock;
30 const char* altgr; 31 const char* altgr;
31 const char* shift_capslock; 32 const char* shift_capslock;
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 test_case.dom_key, 281 test_case.dom_key,
281 DomKeyFromNativeImpl(keymap, DomCode::NONE, key_code, EF_CONTROL_DOWN)) 282 DomKeyFromNativeImpl(keymap, DomCode::NONE, key_code, EF_CONTROL_DOWN))
282 << key_code << ", " << scan_code; 283 << key_code << ", " << scan_code;
283 EXPECT_EQ(test_case.dom_key, 284 EXPECT_EQ(test_case.dom_key,
284 DomKeyFromNativeImpl(keymap, DomCode::NONE, key_code, 285 DomKeyFromNativeImpl(keymap, DomCode::NONE, key_code,
285 EF_ALTGR_DOWN | EF_CONTROL_DOWN)) 286 EF_ALTGR_DOWN | EF_CONTROL_DOWN))
286 << key_code << ", " << scan_code; 287 << key_code << ", " << scan_code;
287 } 288 }
288 } 289 }
289 290
291 TEST_F(PlatformKeyMapTest, KoreanSpecificKeys) {
292 const struct TestCase {
293 KeyboardCode key_code;
294 DomKey key;
295 } kKoreanTestCases[] = {
296 {VKEY_HANGUL, DomKey::HANGUL_MODE}, {VKEY_HANJA, DomKey::HANJA_MODE},
297 };
298
299 // US English should not return values for these keys.
300 HKL us_layout = ::LoadKeyboardLayout(LAYOUT_US, 0);
301 PlatformKeyMap us_keymap(us_layout);
302 for (const auto& test_case : kKoreanTestCases) {
303 EXPECT_EQ(DomKey::NONE, DomKeyFromNativeImpl(us_keymap, DomCode::NONE,
304 test_case.key_code, EF_NONE))
305 << test_case.key_code;
306 }
307
308 // Korean layout should return specific DomKey.
309 HKL ko_layout = ::LoadKeyboardLayout(LAYOUT_KO, 0);
310 PlatformKeyMap ko_keymap(ko_layout);
311 for (const auto& test_case : kKoreanTestCases) {
312 EXPECT_EQ(test_case.key, DomKeyFromNativeImpl(ko_keymap, DomCode::NONE,
313 test_case.key_code, EF_NONE))
314 << test_case.key_code;
315 }
316 }
317
290 } // namespace ui 318 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/keycodes/platform_key_map_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698