Chromium Code Reviews| Index: chrome/browser/ui/ash/event_rewriter_unittest.cc |
| diff --git a/chrome/browser/ui/ash/event_rewriter_unittest.cc b/chrome/browser/ui/ash/event_rewriter_unittest.cc |
| index 488788446a398c31dddd4cd022c03a0bec5d5df7..4bb1fbbf78f3cc00b97de23b0773779293d33f0b 100644 |
| --- a/chrome/browser/ui/ash/event_rewriter_unittest.cc |
| +++ b/chrome/browser/ui/ash/event_rewriter_unittest.cc |
| @@ -117,6 +117,7 @@ class EventRewriterTest : public testing::Test { |
| keycode_next_(XKeysymToKeycode(display_, XK_Next)), |
| keycode_home_(XKeysymToKeycode(display_, XK_Home)), |
| keycode_end_(XKeysymToKeycode(display_, XK_End)), |
| + keycode_launch6_(XKeysymToKeycode(display_, XF86XK_Launch6)), |
| keycode_launch7_(XKeysymToKeycode(display_, XF86XK_Launch7)), |
| keycode_f1_(XKeysymToKeycode(display_, XK_F1)), |
| keycode_f2_(XKeysymToKeycode(display_, XK_F2)), |
| @@ -179,6 +180,9 @@ class EventRewriterTest : public testing::Test { |
| } |
| protected: |
| + void TestRewriteNumPadKeys(); |
| + void TestRewriteNumPadKeysOnAppleKeyboard(); |
| + |
| Display* display_; |
| const KeyCode keycode_a_; |
| const KeyCode keycode_alt_l_; |
| @@ -224,6 +228,7 @@ class EventRewriterTest : public testing::Test { |
| const KeyCode keycode_next_; |
| const KeyCode keycode_home_; |
| const KeyCode keycode_end_; |
| + const KeyCode keycode_launch6_; // F15 |
| const KeyCode keycode_launch7_; // F16 |
| const KeyCode keycode_f1_; |
| const KeyCode keycode_f2_; |
| @@ -545,7 +550,7 @@ TEST_F(EventRewriterTest, TestRewriteCommandToControlWithControlRemapped) { |
| Mod1Mask)); |
| } |
| -TEST_F(EventRewriterTest, TestRewriteNumPadKeys) { |
| +void EventRewriterTest::TestRewriteNumPadKeys() { |
| TestingPrefServiceSyncable prefs; |
| EventRewriter rewriter; |
| rewriter.set_pref_service_for_testing(&prefs); |
| @@ -873,8 +878,21 @@ TEST_F(EventRewriterTest, TestRewriteNumPadKeys) { |
| Mod2Mask)); |
| } |
| +TEST_F(EventRewriterTest, TestRewriteNumPadKeys) { |
| + TestRewriteNumPadKeys(); |
| +} |
| + |
| +TEST_F(EventRewriterTest, TestRewriteNumPadKeysWithDiamondKeyFlag) { |
| + // Makes sure the num lock works correctly even when Diamond key exists. |
|
Yusuke Sato
2013/01/25 06:19:53
Make
yoshiki
2013/01/25 06:43:36
Done.
|
| + const CommandLine original_cl(*CommandLine::ForCurrentProcess()); |
| + CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| + switches::kHasChromeOSDiamondKey, ""); |
| + |
| + TestRewriteNumPadKeys(); |
| +} |
| + |
| // Tests if the rewriter can handle a Command + Num Pad event. |
| -TEST_F(EventRewriterTest, TestRewriteNumPadKeysOnAppleKeyboard) { |
| +void EventRewriterTest::TestRewriteNumPadKeysOnAppleKeyboard() { |
| TestingPrefServiceSyncable prefs; |
| EventRewriter rewriter; |
| rewriter.DeviceAddedForTesting(0, "Apple Keyboard"); |
| @@ -912,6 +930,19 @@ TEST_F(EventRewriterTest, TestRewriteNumPadKeysOnAppleKeyboard) { |
| Mod4Mask)); |
| } |
| +TEST_F(EventRewriterTest, TestRewriteNumPadKeysOnAppleKeyboard) { |
| + TestRewriteNumPadKeysOnAppleKeyboard(); |
| +} |
| + |
| +TEST_F(EventRewriterTest, TestRewriteNumPadKeysOnAppleKeyboardWithDiamondKeyFlag) { |
|
Yusuke Sato
2013/01/25 06:19:53
80col
yoshiki
2013/01/25 06:43:36
Done.
|
| + // Makes sure the num lock works correctly even when Diamond key exists. |
| + const CommandLine original_cl(*CommandLine::ForCurrentProcess()); |
| + CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| + switches::kHasChromeOSDiamondKey, ""); |
| + |
| + TestRewriteNumPadKeysOnAppleKeyboard(); |
| +} |
| + |
| TEST_F(EventRewriterTest, TestRewriteModifiersNoRemap) { |
| TestingPrefServiceSyncable prefs; |
| EventRewriter rewriter; |
| @@ -1629,6 +1660,124 @@ TEST_F(EventRewriterTest, DISABLED_TestRewriteCapsLockWithFlag) { |
| *CommandLine::ForCurrentProcess() = original_cl; |
| } |
| +TEST_F(EventRewriterTest, DISABLED_TestRewriteDiamondKey) { |
| + // TODO(yusukes): Reenable the test once build servers are upgraded. |
| + |
| + TestingPrefServiceSyncable prefs; |
| + chromeos::Preferences::RegisterUserPrefs(&prefs); |
| + |
| + chromeos::input_method::MockXKeyboard xkeyboard; |
| + EventRewriter rewriter; |
| + rewriter.set_pref_service_for_testing(&prefs); |
| + rewriter.set_xkeyboard_for_testing(&xkeyboard); |
| + |
| + // F15 should work as Ctrl when --has-chromeos-diamond-key is not specified. |
| + EXPECT_EQ(GetExpectedResultAsString(ui::VKEY_CONTROL, |
| + ui::EF_CONTROL_DOWN, |
| + ui::ET_KEY_PRESSED, |
| + keycode_control_l_, |
| + 0U, |
| + KeyPress), |
| + GetRewrittenEventAsString(&rewriter, |
| + ui::VKEY_F15, |
| + 0, |
| + ui::ET_KEY_PRESSED, |
| + keycode_launch6_, |
| + 0U)); |
| +} |
| + |
| +TEST_F(EventRewriterTest, DISABLED_TestRewriteDiamondKeyWithFlag) { |
| + // TODO(yusukes): Reenable the test once build servers are upgraded. |
| + |
| + const CommandLine original_cl(*CommandLine::ForCurrentProcess()); |
| + CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| + switches::kHasChromeOSDiamondKey, ""); |
| + |
| + TestingPrefServiceSyncable prefs; |
| + chromeos::Preferences::RegisterUserPrefs(&prefs); |
| + |
| + chromeos::input_method::MockXKeyboard xkeyboard; |
| + EventRewriter rewriter; |
| + rewriter.set_pref_service_for_testing(&prefs); |
| + rewriter.set_xkeyboard_for_testing(&xkeyboard); |
| + |
| + // By default, F15 should work as Control. |
| + EXPECT_EQ(GetExpectedResultAsString(ui::VKEY_CONTROL, |
| + ui::EF_CONTROL_DOWN, |
| + ui::ET_KEY_PRESSED, |
| + keycode_control_l_, |
| + 0U, |
| + KeyPress), |
| + GetRewrittenEventAsString(&rewriter, |
| + ui::VKEY_F15, |
| + 0, |
| + ui::ET_KEY_PRESSED, |
| + keycode_launch6_, |
| + 0U)); |
| + |
| + IntegerPrefMember diamond; |
| + diamond.Init(prefs::kLanguageRemapDiamondKeyTo, &prefs); |
| + diamond.SetValue(chromeos::input_method::kVoidKey); |
| + |
| + EXPECT_EQ(GetExpectedResultAsString(ui::VKEY_UNKNOWN, |
| + 0, |
| + ui::ET_KEY_PRESSED, |
| + keycode_void_symbol_, |
| + 0U, |
| + KeyPress), |
| + GetRewrittenEventAsString(&rewriter, |
| + ui::VKEY_F15, |
| + 0, |
| + ui::ET_KEY_PRESSED, |
| + keycode_launch6_, |
| + 0U)); |
| + |
| + diamond.SetValue(chromeos::input_method::kControlKey); |
| + |
| + EXPECT_EQ(GetExpectedResultAsString(ui::VKEY_CONTROL, |
| + ui::EF_CONTROL_DOWN, |
| + ui::ET_KEY_PRESSED, |
| + keycode_control_l_, |
| + 0U, |
| + KeyPress), |
| + GetRewrittenEventAsString(&rewriter, |
| + ui::VKEY_F15, |
| + 0, |
| + ui::ET_KEY_PRESSED, |
| + keycode_launch6_, |
| + 0U)); |
| + |
| + diamond.SetValue(chromeos::input_method::kAltKey); |
| + |
| + EXPECT_EQ(GetExpectedResultAsString(ui::VKEY_MENU, |
| + ui::EF_ALT_DOWN, |
| + ui::ET_KEY_PRESSED, |
| + keycode_alt_l_, |
| + 0, |
| + KeyPress), |
| + GetRewrittenEventAsString(&rewriter, |
| + ui::VKEY_F15, |
| + 0, |
| + ui::ET_KEY_PRESSED, |
| + keycode_launch6_, |
| + 0U)); |
| + |
| + diamond.SetValue(chromeos::input_method::kCapsLockKey); |
| + |
| + EXPECT_EQ(GetExpectedResultAsString(ui::VKEY_CAPITAL, |
| + ui::EF_CAPS_LOCK_DOWN, |
| + ui::ET_KEY_PRESSED, |
| + keycode_caps_lock_, |
| + 0U, |
| + KeyPress), |
| + GetRewrittenEventAsString(&rewriter, |
| + ui::VKEY_F15, |
| + 0, |
| + ui::ET_KEY_PRESSED, |
| + keycode_launch6_, |
| + 0U)); |
| +} |
| + |
| TEST_F(EventRewriterTest, TestRewriteCapsLockToControl) { |
| TestingPrefServiceSyncable prefs; |
| chromeos::Preferences::RegisterUserPrefs(&prefs); |