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

Unified Diff: ui/events/keycodes/platform_key_map_win_unittest.cc

Issue 2349253002: Revert of Force U.S. English keyboard layout for TextfieldTest.KeysWithModifiersTest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/events/BUILD.gn ('k') | ui/events/test/keyboard_layout.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 98689d18300618eca5f18ef3aedf123e6df60c81..dd2f6888d22848937ba5e71083193bd462b83d12 100644
--- a/ui/events/keycodes/platform_key_map_win_unittest.cc
+++ b/ui/events/keycodes/platform_key_map_win_unittest.cc
@@ -12,11 +12,45 @@
#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;
@@ -92,7 +126,7 @@
};
TEST_F(PlatformKeyMapTest, USLayout) {
- PlatformKeyMap keymap(GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_ENGLISH_US));
+ PlatformKeyMap keymap(GetInputLocale(LAYOUT_US));
const TestKey kUSLayoutTestCases[] = {
// n s c a sc sa ac
@@ -140,7 +174,7 @@
}
TEST_F(PlatformKeyMapTest, FRLayout) {
- PlatformKeyMap keymap(GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_FRENCH));
+ PlatformKeyMap keymap(GetInputLocale(LAYOUT_FR));
const TestKey kFRLayoutTestCases[] = {
// n s c a sc sa ac
@@ -188,7 +222,7 @@
}
TEST_F(PlatformKeyMapTest, NumPad) {
- PlatformKeyMap keymap(GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_ENGLISH_US));
+ PlatformKeyMap keymap(GetInputLocale(LAYOUT_US));
const struct TestCase {
KeyboardCode key_code;
@@ -237,7 +271,7 @@
}
TEST_F(PlatformKeyMapTest, NonPrintableKey) {
- HKL layout = GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_ENGLISH_US);
+ HKL layout = GetInputLocale(LAYOUT_US);
PlatformKeyMap keymap(layout);
for (const auto& test_case : kNonPrintableCodeMap) {
@@ -283,9 +317,8 @@
{VKEY_HANJA, DomKey::HANJA_MODE, DomKey::UNIDENTIFIED},
};
- PlatformKeyMap us_keymap(
- GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_ENGLISH_US));
- PlatformKeyMap kr_keymap(GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_KOREAN));
+ PlatformKeyMap us_keymap(GetInputLocale(LAYOUT_US));
+ PlatformKeyMap kr_keymap(GetInputLocale(LAYOUT_KR));
for (const auto& test_case : kKoreanTestCases) {
EXPECT_EQ(test_case.us_key, DomKeyFromKeyboardCodeImpl(
us_keymap, test_case.key_code, EF_NONE))
@@ -313,9 +346,8 @@
{VKEY_ATTN, DomKey::KANA_MODE, DomKey::ATTN},
};
- PlatformKeyMap us_keymap(
- GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_ENGLISH_US));
- PlatformKeyMap jp_keymap(GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_JAPANESE));
+ PlatformKeyMap us_keymap(GetInputLocale(LAYOUT_US));
+ PlatformKeyMap jp_keymap(GetInputLocale(LAYOUT_JP));
for (const auto& test_case : kJapaneseTestCases) {
EXPECT_EQ(test_case.us_key, DomKeyFromKeyboardCodeImpl(
us_keymap, test_case.key_code, EF_NONE))
« no previous file with comments | « ui/events/BUILD.gn ('k') | ui/events/test/keyboard_layout.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698