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

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

Issue 2128573002: [DomKey] Support Japanese (JIS) layout special keys (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Wez's review 2 Created 4 years, 5 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/keycodes/platform_key_map_win.cc ('k') | no next file » | 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 8359ebecfd2ff01ef69a74a3eed80f6e34981eac..dd2f6888d22848937ba5e71083193bd462b83d12 100644
--- a/ui/events/keycodes/platform_key_map_win_unittest.cc
+++ b/ui/events/keycodes/platform_key_map_win_unittest.cc
@@ -21,6 +21,7 @@ enum Layout {
LAYOUT_US,
LAYOUT_FR,
LAYOUT_KR,
+ LAYOUT_JP,
};
// |LoadKeyboardLayout()| ensures the locale to be loaded into the system
@@ -44,6 +45,8 @@ HKL GetInputLocale(Layout layout) {
// 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;
}
@@ -69,8 +72,7 @@ class PlatformKeyMapTest : public testing::Test {
void CheckKeyboardCodeToKeyString(const char* label,
const PlatformKeyMap& keymap,
- const TestKey& test_case,
- HKL layout) {
+ const TestKey& test_case) {
KeyboardCode key_code = test_case.key_code;
EXPECT_STREQ(test_case.normal,
KeycodeConverter::DomKeyToKeyString(
@@ -112,6 +114,7 @@ class PlatformKeyMapTest : public testing::Test {
<< label;
}
+ // Need this helper function to access private methods of |PlatformKeyMap|.
DomKey DomKeyFromKeyboardCodeImpl(const PlatformKeyMap& keymap,
KeyboardCode key_code,
int flags) {
@@ -123,8 +126,7 @@ class PlatformKeyMapTest : public testing::Test {
};
TEST_F(PlatformKeyMapTest, USLayout) {
- HKL layout = GetInputLocale(LAYOUT_US);
- PlatformKeyMap keymap(layout);
+ PlatformKeyMap keymap(GetInputLocale(LAYOUT_US));
const TestKey kUSLayoutTestCases[] = {
// n s c a sc sa ac
@@ -167,13 +169,12 @@ TEST_F(PlatformKeyMapTest, USLayout) {
};
for (const auto& test_case : kUSLayoutTestCases) {
- CheckKeyboardCodeToKeyString("USLayout", keymap, test_case, layout);
+ CheckKeyboardCodeToKeyString("USLayout", keymap, test_case);
}
}
TEST_F(PlatformKeyMapTest, FRLayout) {
- HKL layout = GetInputLocale(LAYOUT_FR);
- PlatformKeyMap keymap(layout);
+ PlatformKeyMap keymap(GetInputLocale(LAYOUT_FR));
const TestKey kFRLayoutTestCases[] = {
// n s c a sc sa ac
@@ -216,13 +217,12 @@ TEST_F(PlatformKeyMapTest, FRLayout) {
};
for (const auto& test_case : kFRLayoutTestCases) {
- CheckKeyboardCodeToKeyString("FRLayout", keymap, test_case, layout);
+ CheckKeyboardCodeToKeyString("FRLayout", keymap, test_case);
}
}
TEST_F(PlatformKeyMapTest, NumPad) {
- HKL layout = GetInputLocale(LAYOUT_US);
- PlatformKeyMap keymap(layout);
+ PlatformKeyMap keymap(GetInputLocale(LAYOUT_US));
const struct TestCase {
KeyboardCode key_code;
@@ -310,26 +310,50 @@ TEST_F(PlatformKeyMapTest, NonPrintableKey) {
TEST_F(PlatformKeyMapTest, KoreanSpecificKeys) {
const struct TestCase {
KeyboardCode key_code;
- DomKey key;
+ DomKey kr_key;
+ DomKey us_key;
} kKoreanTestCases[] = {
- {VKEY_HANGUL, DomKey::HANGUL_MODE}, {VKEY_HANJA, DomKey::HANJA_MODE},
+ {VKEY_HANGUL, DomKey::HANGUL_MODE, DomKey::UNIDENTIFIED},
+ {VKEY_HANJA, DomKey::HANJA_MODE, DomKey::UNIDENTIFIED},
};
- // US English should not return values for these keys.
- HKL us_layout = GetInputLocale(LAYOUT_US);
- PlatformKeyMap us_keymap(us_layout);
+ PlatformKeyMap us_keymap(GetInputLocale(LAYOUT_US));
+ PlatformKeyMap kr_keymap(GetInputLocale(LAYOUT_KR));
for (const auto& test_case : kKoreanTestCases) {
- EXPECT_EQ(DomKey::NONE, DomKeyFromKeyboardCodeImpl(
- us_keymap, test_case.key_code, EF_NONE))
+ EXPECT_EQ(test_case.us_key, DomKeyFromKeyboardCodeImpl(
+ us_keymap, test_case.key_code, EF_NONE))
+ << test_case.key_code;
+ EXPECT_EQ(test_case.kr_key, DomKeyFromKeyboardCodeImpl(
+ kr_keymap, test_case.key_code, EF_NONE))
<< test_case.key_code;
}
+}
- // Korean layout should return specific DomKey.
- HKL ko_layout = GetInputLocale(LAYOUT_KR);
- PlatformKeyMap ko_keymap(ko_layout);
- for (const auto& test_case : kKoreanTestCases) {
- EXPECT_EQ(test_case.key, DomKeyFromKeyboardCodeImpl(
- ko_keymap, test_case.key_code, EF_NONE))
+TEST_F(PlatformKeyMapTest, JapaneseSpecificKeys) {
+ const struct TestCase {
+ KeyboardCode key_code;
+ DomKey jp_key;
+ DomKey us_key;
+ } kJapaneseTestCases[] = {
+ {VKEY_KANA, DomKey::KANA_MODE, DomKey::UNIDENTIFIED},
+ {VKEY_KANJI, DomKey::KANJI_MODE, DomKey::UNIDENTIFIED},
+ {VKEY_OEM_ATTN, DomKey::ALPHANUMERIC, DomKey::UNIDENTIFIED},
+ {VKEY_OEM_FINISH, DomKey::KATAKANA, DomKey::UNIDENTIFIED},
+ {VKEY_OEM_COPY, DomKey::HIRAGANA, DomKey::UNIDENTIFIED},
+ {VKEY_DBE_SBCSCHAR, DomKey::HANKAKU, DomKey::UNIDENTIFIED},
+ {VKEY_DBE_DBCSCHAR, DomKey::ZENKAKU, DomKey::UNIDENTIFIED},
+ {VKEY_OEM_BACKTAB, DomKey::ROMAJI, DomKey::UNIDENTIFIED},
+ {VKEY_ATTN, DomKey::KANA_MODE, DomKey::ATTN},
+ };
+
+ 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))
+ << test_case.key_code;
+ EXPECT_EQ(test_case.jp_key, DomKeyFromKeyboardCodeImpl(
+ jp_keymap, test_case.key_code, EF_NONE))
<< test_case.key_code;
}
}
« 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