OLD | NEW |
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"; | |
23 | 22 |
24 struct TestKey { | 23 struct TestKey { |
25 // Have to use KeyboardCode instead of DomCode because we don't know the | 24 // Have to use KeyboardCode instead of DomCode because we don't know the |
26 // physical keyboard layout for try bots. | 25 // physical keyboard layout for try bots. |
27 KeyboardCode key_code; | 26 KeyboardCode key_code; |
28 const char* normal; | 27 const char* normal; |
29 const char* shift; | 28 const char* shift; |
30 const char* capslock; | 29 const char* capslock; |
31 const char* altgr; | 30 const char* altgr; |
32 const char* shift_capslock; | 31 const char* shift_capslock; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 test_case.dom_key, | 280 test_case.dom_key, |
282 DomKeyFromNativeImpl(keymap, DomCode::NONE, key_code, EF_CONTROL_DOWN)) | 281 DomKeyFromNativeImpl(keymap, DomCode::NONE, key_code, EF_CONTROL_DOWN)) |
283 << key_code << ", " << scan_code; | 282 << key_code << ", " << scan_code; |
284 EXPECT_EQ(test_case.dom_key, | 283 EXPECT_EQ(test_case.dom_key, |
285 DomKeyFromNativeImpl(keymap, DomCode::NONE, key_code, | 284 DomKeyFromNativeImpl(keymap, DomCode::NONE, key_code, |
286 EF_ALTGR_DOWN | EF_CONTROL_DOWN)) | 285 EF_ALTGR_DOWN | EF_CONTROL_DOWN)) |
287 << key_code << ", " << scan_code; | 286 << key_code << ", " << scan_code; |
288 } | 287 } |
289 } | 288 } |
290 | 289 |
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 | |
318 } // namespace ui | 290 } // namespace ui |
OLD | NEW |