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 and backspace are not window-level commands (else they | 32 // Test that cmd-left is not a window-level command (else it |
33 // would be invoked even if e.g. the omnibox had focus, where they really | 33 // would be invoked even if e.g. the omnibox had focus, where it 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)); | |
39 | 37 |
40 // Test that Cmd-'{' and Cmd-'}' are interpreted as IDC_SELECT_NEXT_TAB | 38 // Test that Cmd-'{' and Cmd-'}' are interpreted as IDC_SELECT_NEXT_TAB |
41 // and IDC_SELECT_PREVIOUS_TAB regardless of the virtual key code values. | 39 // and IDC_SELECT_PREVIOUS_TAB regardless of the virtual key code values. |
42 EXPECT_EQ(IDC_SELECT_NEXT_TAB, CommandForWindowKeyboardShortcut( | 40 EXPECT_EQ(IDC_SELECT_NEXT_TAB, CommandForWindowKeyboardShortcut( |
43 true, false, false, false, kVK_ANSI_Period, '}')); | 41 true, false, false, false, kVK_ANSI_Period, '}')); |
44 EXPECT_EQ(IDC_SELECT_PREVIOUS_TAB, CommandForWindowKeyboardShortcut( | 42 EXPECT_EQ(IDC_SELECT_PREVIOUS_TAB, CommandForWindowKeyboardShortcut( |
45 true, true, false, false, kVK_ANSI_Slash, '{')); | 43 true, true, false, false, kVK_ANSI_Slash, '{')); |
46 | 44 |
47 // One more test for Cmd-'{' / Alt-8 (on German keyboard layout). | 45 // One more test for Cmd-'{' / Alt-8 (on German keyboard layout). |
48 EXPECT_EQ(IDC_SELECT_PREVIOUS_TAB, CommandForWindowKeyboardShortcut( | 46 EXPECT_EQ(IDC_SELECT_PREVIOUS_TAB, CommandForWindowKeyboardShortcut( |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // cmd-shift-'[' in an RTL context pre 10.9. | 185 // cmd-shift-'[' in an RTL context pre 10.9. |
188 EXPECT_EQ('{', KeyCharacterForEvent( | 186 EXPECT_EQ('{', KeyCharacterForEvent( |
189 KeyEvent(true, true, false, false, @"{", @"}"))); | 187 KeyEvent(true, true, false, false, @"{", @"}"))); |
190 // cmd-shift-'[' in an RTL context on 10.9. | 188 // cmd-shift-'[' in an RTL context on 10.9. |
191 EXPECT_EQ('{', KeyCharacterForEvent( | 189 EXPECT_EQ('{', KeyCharacterForEvent( |
192 KeyEvent(true, true, false, false, @"[", @"}"))); | 190 KeyEvent(true, true, false, false, @"[", @"}"))); |
193 // Test if getting dead-key events return 0 and do not hang. | 191 // Test if getting dead-key events return 0 and do not hang. |
194 EXPECT_EQ(0, KeyCharacterForEvent( | 192 EXPECT_EQ(0, KeyCharacterForEvent( |
195 KeyEvent(false, false, false, false, @"", @""))); | 193 KeyEvent(false, false, false, false, @"", @""))); |
196 } | 194 } |
OLD | NEW |