OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <AppKit/NSEvent.h> | 5 #include <AppKit/NSEvent.h> |
6 #include <Carbon/Carbon.h> | 6 #include <Carbon/Carbon.h> |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "chrome/browser/global_keyboard_shortcuts_mac.h" | 9 #include "chrome/browser/global_keyboard_shortcuts_mac.h" |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 const KeyboardShortcutData *it = | 22 const KeyboardShortcutData *it = |
23 GetWindowKeyboardShortcutTable(&num_shortcuts); | 23 GetWindowKeyboardShortcutTable(&num_shortcuts); |
24 ASSERT_GT(num_shortcuts, 0U); | 24 ASSERT_GT(num_shortcuts, 0U); |
25 for (size_t i = 0; i < num_shortcuts; ++i, ++it) { | 25 for (size_t i = 0; i < num_shortcuts; ++i, ++it) { |
26 int cmd_num = CommandForWindowKeyboardShortcut( | 26 int cmd_num = CommandForWindowKeyboardShortcut( |
27 it->command_key, it->shift_key, it->cntrl_key, it->opt_key, | 27 it->command_key, it->shift_key, it->cntrl_key, it->opt_key, |
28 it->vkey_code, it->key_char); | 28 it->vkey_code, it->key_char); |
29 EXPECT_EQ(cmd_num, it->chrome_command); | 29 EXPECT_EQ(cmd_num, it->chrome_command); |
30 } | 30 } |
31 | 31 |
32 // Test that cmd-left is not a window-level command (else it | 32 // Test that cmd-left and backspace are not window-level commands (else they |
33 // would be invoked even if e.g. the omnibox had focus, where it really | 33 // would be invoked even if e.g. the omnibox had focus, where they really |
34 // should have text editing functionality). | 34 // should have text editing functionality). |
35 EXPECT_EQ(-1, CommandForWindowKeyboardShortcut( | 35 EXPECT_EQ(-1, CommandForWindowKeyboardShortcut( |
36 true, false, false, false, kVK_LeftArrow, 0)); | 36 true, false, false, false, kVK_LeftArrow, 0)); |
| 37 EXPECT_EQ(-1, CommandForWindowKeyboardShortcut( |
| 38 false, false, false, false, kVK_Delete, 0)); |
37 | 39 |
38 // Test that Cmd-'{' and Cmd-'}' are interpreted as IDC_SELECT_NEXT_TAB | 40 // Test that Cmd-'{' and Cmd-'}' are interpreted as IDC_SELECT_NEXT_TAB |
39 // and IDC_SELECT_PREVIOUS_TAB regardless of the virtual key code values. | 41 // and IDC_SELECT_PREVIOUS_TAB regardless of the virtual key code values. |
40 EXPECT_EQ(IDC_SELECT_NEXT_TAB, CommandForWindowKeyboardShortcut( | 42 EXPECT_EQ(IDC_SELECT_NEXT_TAB, CommandForWindowKeyboardShortcut( |
41 true, false, false, false, kVK_ANSI_Period, '}')); | 43 true, false, false, false, kVK_ANSI_Period, '}')); |
42 EXPECT_EQ(IDC_SELECT_PREVIOUS_TAB, CommandForWindowKeyboardShortcut( | 44 EXPECT_EQ(IDC_SELECT_PREVIOUS_TAB, CommandForWindowKeyboardShortcut( |
43 true, true, false, false, kVK_ANSI_Slash, '{')); | 45 true, true, false, false, kVK_ANSI_Slash, '{')); |
44 | 46 |
45 // One more test for Cmd-'{' / Alt-8 (on German keyboard layout). | 47 // One more test for Cmd-'{' / Alt-8 (on German keyboard layout). |
46 EXPECT_EQ(IDC_SELECT_PREVIOUS_TAB, CommandForWindowKeyboardShortcut( | 48 EXPECT_EQ(IDC_SELECT_PREVIOUS_TAB, CommandForWindowKeyboardShortcut( |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 // cmd-shift-'[' in an RTL context pre 10.9. | 187 // cmd-shift-'[' in an RTL context pre 10.9. |
186 EXPECT_EQ('{', KeyCharacterForEvent( | 188 EXPECT_EQ('{', KeyCharacterForEvent( |
187 KeyEvent(true, true, false, false, @"{", @"}"))); | 189 KeyEvent(true, true, false, false, @"{", @"}"))); |
188 // cmd-shift-'[' in an RTL context on 10.9. | 190 // cmd-shift-'[' in an RTL context on 10.9. |
189 EXPECT_EQ('{', KeyCharacterForEvent( | 191 EXPECT_EQ('{', KeyCharacterForEvent( |
190 KeyEvent(true, true, false, false, @"[", @"}"))); | 192 KeyEvent(true, true, false, false, @"[", @"}"))); |
191 // Test if getting dead-key events return 0 and do not hang. | 193 // Test if getting dead-key events return 0 and do not hang. |
192 EXPECT_EQ(0, KeyCharacterForEvent( | 194 EXPECT_EQ(0, KeyCharacterForEvent( |
193 KeyEvent(false, false, false, false, @"", @""))); | 195 KeyEvent(false, false, false, false, @"", @""))); |
194 } | 196 } |
OLD | NEW |