| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/ash/event_rewriter.h" | 5 #include "chrome/browser/ui/ash/event_rewriter.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/prefs/pref_member.h" | 9 #include "base/prefs/pref_member.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 keycode_delete_(XKeysymToKeycode(display_, XK_Delete)), | 111 keycode_delete_(XKeysymToKeycode(display_, XK_Delete)), |
| 112 keycode_backspace_(XKeysymToKeycode(display_, XK_BackSpace)), | 112 keycode_backspace_(XKeysymToKeycode(display_, XK_BackSpace)), |
| 113 keycode_up_(XKeysymToKeycode(display_, XK_Up)), | 113 keycode_up_(XKeysymToKeycode(display_, XK_Up)), |
| 114 keycode_down_(XKeysymToKeycode(display_, XK_Down)), | 114 keycode_down_(XKeysymToKeycode(display_, XK_Down)), |
| 115 keycode_left_(XKeysymToKeycode(display_, XK_Left)), | 115 keycode_left_(XKeysymToKeycode(display_, XK_Left)), |
| 116 keycode_right_(XKeysymToKeycode(display_, XK_Right)), | 116 keycode_right_(XKeysymToKeycode(display_, XK_Right)), |
| 117 keycode_prior_(XKeysymToKeycode(display_, XK_Prior)), | 117 keycode_prior_(XKeysymToKeycode(display_, XK_Prior)), |
| 118 keycode_next_(XKeysymToKeycode(display_, XK_Next)), | 118 keycode_next_(XKeysymToKeycode(display_, XK_Next)), |
| 119 keycode_home_(XKeysymToKeycode(display_, XK_Home)), | 119 keycode_home_(XKeysymToKeycode(display_, XK_Home)), |
| 120 keycode_end_(XKeysymToKeycode(display_, XK_End)), | 120 keycode_end_(XKeysymToKeycode(display_, XK_End)), |
| 121 keycode_escape_(XKeysymToKeycode(display_, XK_Escape)), |
| 121 keycode_launch6_(XKeysymToKeycode(display_, XF86XK_Launch6)), | 122 keycode_launch6_(XKeysymToKeycode(display_, XF86XK_Launch6)), |
| 122 keycode_launch7_(XKeysymToKeycode(display_, XF86XK_Launch7)), | 123 keycode_launch7_(XKeysymToKeycode(display_, XF86XK_Launch7)), |
| 123 keycode_f1_(XKeysymToKeycode(display_, XK_F1)), | 124 keycode_f1_(XKeysymToKeycode(display_, XK_F1)), |
| 124 keycode_f2_(XKeysymToKeycode(display_, XK_F2)), | 125 keycode_f2_(XKeysymToKeycode(display_, XK_F2)), |
| 125 keycode_f3_(XKeysymToKeycode(display_, XK_F3)), | 126 keycode_f3_(XKeysymToKeycode(display_, XK_F3)), |
| 126 keycode_f4_(XKeysymToKeycode(display_, XK_F4)), | 127 keycode_f4_(XKeysymToKeycode(display_, XK_F4)), |
| 127 keycode_f5_(XKeysymToKeycode(display_, XK_F5)), | 128 keycode_f5_(XKeysymToKeycode(display_, XK_F5)), |
| 128 keycode_f6_(XKeysymToKeycode(display_, XK_F6)), | 129 keycode_f6_(XKeysymToKeycode(display_, XK_F6)), |
| 129 keycode_f7_(XKeysymToKeycode(display_, XK_F7)), | 130 keycode_f7_(XKeysymToKeycode(display_, XK_F7)), |
| 130 keycode_f8_(XKeysymToKeycode(display_, XK_F8)), | 131 keycode_f8_(XKeysymToKeycode(display_, XK_F8)), |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 const KeyCode keycode_delete_; | 225 const KeyCode keycode_delete_; |
| 225 const KeyCode keycode_backspace_; | 226 const KeyCode keycode_backspace_; |
| 226 const KeyCode keycode_up_; | 227 const KeyCode keycode_up_; |
| 227 const KeyCode keycode_down_; | 228 const KeyCode keycode_down_; |
| 228 const KeyCode keycode_left_; | 229 const KeyCode keycode_left_; |
| 229 const KeyCode keycode_right_; | 230 const KeyCode keycode_right_; |
| 230 const KeyCode keycode_prior_; | 231 const KeyCode keycode_prior_; |
| 231 const KeyCode keycode_next_; | 232 const KeyCode keycode_next_; |
| 232 const KeyCode keycode_home_; | 233 const KeyCode keycode_home_; |
| 233 const KeyCode keycode_end_; | 234 const KeyCode keycode_end_; |
| 235 const KeyCode keycode_escape_; |
| 234 const KeyCode keycode_launch6_; // F15 | 236 const KeyCode keycode_launch6_; // F15 |
| 235 const KeyCode keycode_launch7_; // F16 | 237 const KeyCode keycode_launch7_; // F16 |
| 236 const KeyCode keycode_f1_; | 238 const KeyCode keycode_f1_; |
| 237 const KeyCode keycode_f2_; | 239 const KeyCode keycode_f2_; |
| 238 const KeyCode keycode_f3_; | 240 const KeyCode keycode_f3_; |
| 239 const KeyCode keycode_f4_; | 241 const KeyCode keycode_f4_; |
| 240 const KeyCode keycode_f5_; | 242 const KeyCode keycode_f5_; |
| 241 const KeyCode keycode_f6_; | 243 const KeyCode keycode_f6_; |
| 242 const KeyCode keycode_f7_; | 244 const KeyCode keycode_f7_; |
| 243 const KeyCode keycode_f8_; | 245 const KeyCode keycode_f8_; |
| (...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 KeyPress), | 1374 KeyPress), |
| 1373 GetRewrittenEventAsString(&rewriter, | 1375 GetRewrittenEventAsString(&rewriter, |
| 1374 ui::VKEY_B, | 1376 ui::VKEY_B, |
| 1375 ui::EF_SHIFT_DOWN | | 1377 ui::EF_SHIFT_DOWN | |
| 1376 ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN, | 1378 ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN, |
| 1377 ui::ET_KEY_PRESSED, | 1379 ui::ET_KEY_PRESSED, |
| 1378 keycode_b_, | 1380 keycode_b_, |
| 1379 ShiftMask | ControlMask | Mod1Mask)); | 1381 ShiftMask | ControlMask | Mod1Mask)); |
| 1380 } | 1382 } |
| 1381 | 1383 |
| 1384 TEST_F(EventRewriterTest, TestRewriteModifiersRemapToEscape) { |
| 1385 // Remap Search to ESC. |
| 1386 TestingPrefServiceSyncable prefs; |
| 1387 chromeos::Preferences::RegisterProfilePrefs(prefs.registry()); |
| 1388 IntegerPrefMember search; |
| 1389 search.Init(prefs::kLanguageRemapSearchKeyTo, &prefs); |
| 1390 search.SetValue(chromeos::input_method::kEscapeKey); |
| 1391 |
| 1392 EventRewriter rewriter; |
| 1393 rewriter.set_pref_service_for_testing(&prefs); |
| 1394 |
| 1395 // Press Search. Confirm the event is now VKEY_ESCAPE. |
| 1396 EXPECT_EQ(GetExpectedResultAsString(ui::VKEY_ESCAPE, |
| 1397 ui::EF_NONE, |
| 1398 ui::ET_KEY_PRESSED, |
| 1399 keycode_escape_, |
| 1400 0U, |
| 1401 KeyPress), |
| 1402 GetRewrittenEventAsString(&rewriter, |
| 1403 ui::VKEY_LWIN, |
| 1404 0, |
| 1405 ui::ET_KEY_PRESSED, |
| 1406 keycode_super_l_, |
| 1407 0U)); |
| 1408 } |
| 1409 |
| 1382 TEST_F(EventRewriterTest, TestRewriteModifiersRemapMany) { | 1410 TEST_F(EventRewriterTest, TestRewriteModifiersRemapMany) { |
| 1383 // Remap Search to Alt. | 1411 // Remap Search to Alt. |
| 1384 TestingPrefServiceSyncable prefs; | 1412 TestingPrefServiceSyncable prefs; |
| 1385 chromeos::Preferences::RegisterProfilePrefs(prefs.registry()); | 1413 chromeos::Preferences::RegisterProfilePrefs(prefs.registry()); |
| 1386 IntegerPrefMember search; | 1414 IntegerPrefMember search; |
| 1387 search.Init(prefs::kLanguageRemapSearchKeyTo, &prefs); | 1415 search.Init(prefs::kLanguageRemapSearchKeyTo, &prefs); |
| 1388 search.SetValue(chromeos::input_method::kAltKey); | 1416 search.SetValue(chromeos::input_method::kAltKey); |
| 1389 | 1417 |
| 1390 EventRewriter rewriter; | 1418 EventRewriter rewriter; |
| 1391 rewriter.set_pref_service_for_testing(&prefs); | 1419 rewriter.set_pref_service_for_testing(&prefs); |
| (...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2290 // flag in the event is True. | 2318 // flag in the event is True. |
| 2291 EXPECT_EQ(GetExpectedResultAsString(ui::VKEY_CONTROL, | 2319 EXPECT_EQ(GetExpectedResultAsString(ui::VKEY_CONTROL, |
| 2292 ui::EF_CONTROL_DOWN, | 2320 ui::EF_CONTROL_DOWN, |
| 2293 ui::ET_KEY_PRESSED, | 2321 ui::ET_KEY_PRESSED, |
| 2294 keycode_control_l_, | 2322 keycode_control_l_, |
| 2295 0U, | 2323 0U, |
| 2296 KeyPress), | 2324 KeyPress), |
| 2297 rewritten_event); | 2325 rewritten_event); |
| 2298 } | 2326 } |
| 2299 #endif // OS_CHROMEOS | 2327 #endif // OS_CHROMEOS |
| OLD | NEW |