Index: ui/events/keycodes/platform_key_map_win_unittest.cc |
diff --git a/ui/events/keycodes/platform_key_map_win_unittest.cc b/ui/events/keycodes/platform_key_map_win_unittest.cc |
index dd2f6888d22848937ba5e71083193bd462b83d12..98689d18300618eca5f18ef3aedf123e6df60c81 100644 |
--- a/ui/events/keycodes/platform_key_map_win_unittest.cc |
+++ b/ui/events/keycodes/platform_key_map_win_unittest.cc |
@@ -12,46 +12,12 @@ |
#include "ui/events/keycodes/dom/dom_key.h" |
#include "ui/events/keycodes/dom/keycode_converter.h" |
#include "ui/events/keycodes/dom_us_layout_data.h" |
+#include "ui/events/test/keyboard_layout.h" |
namespace ui { |
namespace { |
-enum Layout { |
- LAYOUT_US, |
- LAYOUT_FR, |
- LAYOUT_KR, |
- LAYOUT_JP, |
-}; |
- |
-// |LoadKeyboardLayout()| ensures the locale to be loaded into the system |
-// (Similar to temporarily adding a locale in Control Panel), otherwise |
-// |ToUnicodeEx()| will fall-back to the default locale. |
-// See MSDN LoadKeyboardLayout(): |
-// https://msdn.microsoft.com/en-us/library/windows/desktop/ms646305(v=vs.85).aspx |
-// And language constants and strings: |
-// https://msdn.microsoft.com/en-us/library/windows/desktop/dd318693(v=vs.85).aspx |
-HKL GetInputLocale(Layout layout) { |
- switch (layout) { |
- case LAYOUT_US: |
- return ::LoadKeyboardLayout(L"00000409", KLF_ACTIVATE); |
- case LAYOUT_FR: |
- return ::LoadKeyboardLayout(L"0000040c", KLF_ACTIVATE); |
- case LAYOUT_KR: |
- // |LoadKeyboardLayout(L"00000412", KLF_ACTIVATE)| returns the correct |
- // Korean locale, but it will fail on DrMemory tests. |
- // See https://crbug.com/612736#c6 |
- // However we could bypass it since we are only testing non-printable keys |
- // on Korean locale. |
- // (This issue only happens on Korean and Japanese). |
- return reinterpret_cast<HKL>(0x04120412); |
- case LAYOUT_JP: |
- return reinterpret_cast<HKL>(0x04110411); |
- default: |
- return 0; |
- } |
-} |
- |
struct TestKey { |
KeyboardCode key_code; |
const char* normal; |
@@ -126,7 +92,7 @@ class PlatformKeyMapTest : public testing::Test { |
}; |
TEST_F(PlatformKeyMapTest, USLayout) { |
- PlatformKeyMap keymap(GetInputLocale(LAYOUT_US)); |
+ PlatformKeyMap keymap(GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_ENGLISH_US)); |
const TestKey kUSLayoutTestCases[] = { |
// n s c a sc sa ac |
@@ -174,7 +140,7 @@ TEST_F(PlatformKeyMapTest, USLayout) { |
} |
TEST_F(PlatformKeyMapTest, FRLayout) { |
- PlatformKeyMap keymap(GetInputLocale(LAYOUT_FR)); |
+ PlatformKeyMap keymap(GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_FRENCH)); |
const TestKey kFRLayoutTestCases[] = { |
// n s c a sc sa ac |
@@ -222,7 +188,7 @@ TEST_F(PlatformKeyMapTest, FRLayout) { |
} |
TEST_F(PlatformKeyMapTest, NumPad) { |
- PlatformKeyMap keymap(GetInputLocale(LAYOUT_US)); |
+ PlatformKeyMap keymap(GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_ENGLISH_US)); |
const struct TestCase { |
KeyboardCode key_code; |
@@ -271,7 +237,7 @@ TEST_F(PlatformKeyMapTest, NumPad) { |
} |
TEST_F(PlatformKeyMapTest, NonPrintableKey) { |
- HKL layout = GetInputLocale(LAYOUT_US); |
+ HKL layout = GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_ENGLISH_US); |
PlatformKeyMap keymap(layout); |
for (const auto& test_case : kNonPrintableCodeMap) { |
@@ -317,8 +283,9 @@ TEST_F(PlatformKeyMapTest, KoreanSpecificKeys) { |
{VKEY_HANJA, DomKey::HANJA_MODE, DomKey::UNIDENTIFIED}, |
}; |
- PlatformKeyMap us_keymap(GetInputLocale(LAYOUT_US)); |
- PlatformKeyMap kr_keymap(GetInputLocale(LAYOUT_KR)); |
+ PlatformKeyMap us_keymap( |
+ GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_ENGLISH_US)); |
+ PlatformKeyMap kr_keymap(GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_KOREAN)); |
for (const auto& test_case : kKoreanTestCases) { |
EXPECT_EQ(test_case.us_key, DomKeyFromKeyboardCodeImpl( |
us_keymap, test_case.key_code, EF_NONE)) |
@@ -346,8 +313,9 @@ TEST_F(PlatformKeyMapTest, JapaneseSpecificKeys) { |
{VKEY_ATTN, DomKey::KANA_MODE, DomKey::ATTN}, |
}; |
- PlatformKeyMap us_keymap(GetInputLocale(LAYOUT_US)); |
- PlatformKeyMap jp_keymap(GetInputLocale(LAYOUT_JP)); |
+ PlatformKeyMap us_keymap( |
+ GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_ENGLISH_US)); |
+ PlatformKeyMap jp_keymap(GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_JAPANESE)); |
for (const auto& test_case : kJapaneseTestCases) { |
EXPECT_EQ(test_case.us_key, DomKeyFromKeyboardCodeImpl( |
us_keymap, test_case.key_code, EF_NONE)) |