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

Side by Side Diff: chrome/browser/chromeos/events/event_rewriter_unittest.cc

Issue 378503007: Fix some surprising reverse key mappings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments (derat) Created 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/chromeos/events/event_rewriter.h" 5 #include "chrome/browser/chromeos/events/event_rewriter.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/sticky_keys/sticky_keys_controller.h" 10 #include "ash/sticky_keys/sticky_keys_controller.h"
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 // Remap Alt to Control. 809 // Remap Alt to Control.
810 IntegerPrefMember alt; 810 IntegerPrefMember alt;
811 alt.Init(prefs::kLanguageRemapAltKeyTo, &prefs); 811 alt.Init(prefs::kLanguageRemapAltKeyTo, &prefs);
812 alt.SetValue(chromeos::input_method::kControlKey); 812 alt.SetValue(chromeos::input_method::kControlKey);
813 813
814 KeyTestCase a2c_tests[] = { 814 KeyTestCase a2c_tests[] = {
815 // Press left Alt. Confirm the event is now VKEY_CONTROL. 815 // Press left Alt. Confirm the event is now VKEY_CONTROL.
816 {KeyTestCase::TEST_ALL, ui::ET_KEY_PRESSED, 816 {KeyTestCase::TEST_ALL, ui::ET_KEY_PRESSED,
817 {ui::VKEY_MENU, ui::EF_ALT_DOWN}, 817 {ui::VKEY_MENU, ui::EF_ALT_DOWN},
818 {ui::VKEY_CONTROL, ui::EF_CONTROL_DOWN}}, 818 {ui::VKEY_CONTROL, ui::EF_CONTROL_DOWN}},
819 // Press Shift+comma. Verify that only the flags are changed.
820 // The X11 portion of the test addresses crbug.com/390263 by verifying
821 // that the X keycode remains that for ',<' and not for 105-key '<>'.
822 {KeyTestCase::TEST_ALL, ui::ET_KEY_PRESSED,
823 {ui::VKEY_OEM_COMMA, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN},
824 {ui::VKEY_OEM_COMMA, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN}},
825 // Press Shift+9. Verify that only the flags are changed.
826 {KeyTestCase::TEST_ALL, ui::ET_KEY_PRESSED,
827 {ui::VKEY_9, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN},
828 {ui::VKEY_9, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN}},
819 }; 829 };
820 830
821 for (size_t i = 0; i < arraysize(a2c_tests); ++i) { 831 for (size_t i = 0; i < arraysize(a2c_tests); ++i) {
822 CheckKeyTestCase(2000 + i, &rewriter, a2c_tests[i]); 832 CheckKeyTestCase(2000 + i, &rewriter, a2c_tests[i]);
823 } 833 }
824 834
825 // Remap Control to Search. 835 // Remap Control to Search.
826 IntegerPrefMember control; 836 IntegerPrefMember control;
827 control.Init(prefs::kLanguageRemapControlKeyTo, &prefs); 837 control.Init(prefs::kLanguageRemapControlKeyTo, &prefs);
828 control.SetValue(chromeos::input_method::kSearchKey); 838 control.SetValue(chromeos::input_method::kSearchKey);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 {KeyTestCase::TEST_VKEY, 985 {KeyTestCase::TEST_VKEY,
976 ui::ET_KEY_PRESSED, 986 ui::ET_KEY_PRESSED,
977 {ui::VKEY_A, ui::EF_NONE}, 987 {ui::VKEY_A, ui::EF_NONE},
978 {ui::VKEY_A, ui::EF_NONE}}, 988 {ui::VKEY_A, ui::EF_NONE}},
979 }; 989 };
980 990
981 for (size_t i = 0; i < arraysize(tests); ++i) { 991 for (size_t i = 0; i < arraysize(tests); ++i) {
982 CheckKeyTestCase(1000 + i, &rewriter, tests[i]); 992 CheckKeyTestCase(1000 + i, &rewriter, tests[i]);
983 } 993 }
984 } 994 }
995
985 TEST_F(EventRewriterTest, TestRewriteDiamondKeyWithFlag) { 996 TEST_F(EventRewriterTest, TestRewriteDiamondKeyWithFlag) {
986 const CommandLine original_cl(*CommandLine::ForCurrentProcess()); 997 const CommandLine original_cl(*CommandLine::ForCurrentProcess());
987 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 998 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
988 chromeos::switches::kHasChromeOSDiamondKey, ""); 999 chromeos::switches::kHasChromeOSDiamondKey, "");
989 1000
990 TestingPrefServiceSyncable prefs; 1001 TestingPrefServiceSyncable prefs;
991 chromeos::Preferences::RegisterProfilePrefs(prefs.registry()); 1002 chromeos::Preferences::RegisterProfilePrefs(prefs.registry());
992 1003
993 chromeos::input_method::FakeImeKeyboard ime_keyboard; 1004 chromeos::input_method::FakeImeKeyboard ime_keyboard;
994 EventRewriter rewriter(NULL); 1005 EventRewriter rewriter(NULL);
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after
2178 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_ALTGR_DOWN)); 2189 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_ALTGR_DOWN));
2179 EXPECT_TRUE(overlay_->GetModifierVisible(ui::EF_MOD3_DOWN)); 2190 EXPECT_TRUE(overlay_->GetModifierVisible(ui::EF_MOD3_DOWN));
2180 2191
2181 // Turn off AltGr and Mod3. 2192 // Turn off AltGr and Mod3.
2182 sticky_keys_controller_->SetModifiersEnabled(false, false); 2193 sticky_keys_controller_->SetModifiersEnabled(false, false);
2183 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_ALTGR_DOWN)); 2194 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_ALTGR_DOWN));
2184 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_MOD3_DOWN)); 2195 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_MOD3_DOWN));
2185 } 2196 }
2186 2197
2187 } // namespace chromeos 2198 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698