| 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 <Carbon/Carbon.h> | 5 #include <Carbon/Carbon.h> |
| 6 | 6 |
| 7 #include "chrome/browser/global_keyboard_shortcuts_mac.h" | 7 #include "chrome/browser/global_keyboard_shortcuts_mac.h" |
| 8 | 8 |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 // Test that cmd-left and backspace are not window-level commands (else they | 28 // Test that cmd-left and backspace are not window-level commands (else they |
| 29 // would be invoked even if e.g. the omnibox had focus, where they really | 29 // would be invoked even if e.g. the omnibox had focus, where they really |
| 30 // should have text editing functionality). | 30 // should have text editing functionality). |
| 31 ASSERT_EQ(-1, CommandForWindowKeyboardShortcut( | 31 ASSERT_EQ(-1, CommandForWindowKeyboardShortcut( |
| 32 true, false, false, false, kVK_LeftArrow)); | 32 true, false, false, false, kVK_LeftArrow)); |
| 33 ASSERT_EQ(-1, CommandForWindowKeyboardShortcut( | 33 ASSERT_EQ(-1, CommandForWindowKeyboardShortcut( |
| 34 false, false, false, false, kVK_Delete)); | 34 false, false, false, false, kVK_Delete)); |
| 35 } | 35 } |
| 36 | 36 |
| 37 TEST(GlobalKeyboardShortcuts, ShortcutsToDelayedWindowCommand) { |
| 38 // Test that an invalid shortcut translates into an invalid command id. |
| 39 ASSERT_EQ(-1, |
| 40 CommandForDelayedWindowKeyboardShortcut(false, false, false, false, 0)); |
| 41 |
| 42 // Check that all known keyboard shortcuts return valid results. |
| 43 size_t num_shortcuts = 0; |
| 44 const KeyboardShortcutData *it = |
| 45 GetDelayedWindowKeyboardShortcutTable(&num_shortcuts); |
| 46 ASSERT_GT(num_shortcuts, 0U); |
| 47 for (size_t i = 0; i < num_shortcuts; ++i, ++it) { |
| 48 int cmd_num = CommandForDelayedWindowKeyboardShortcut( |
| 49 it->command_key, it->shift_key, it->cntrl_key, it->opt_key, |
| 50 it->vkey_code); |
| 51 ASSERT_EQ(cmd_num, it->chrome_command); |
| 52 } |
| 53 } |
| 54 |
| 37 TEST(GlobalKeyboardShortcuts, ShortcutsToBrowserCommand) { | 55 TEST(GlobalKeyboardShortcuts, ShortcutsToBrowserCommand) { |
| 38 // Test that an invalid shortcut translates into an invalid command id. | 56 // Test that an invalid shortcut translates into an invalid command id. |
| 39 ASSERT_EQ( | 57 ASSERT_EQ( |
| 40 -1, CommandForBrowserKeyboardShortcut(false, false, false, false, 0)); | 58 -1, CommandForBrowserKeyboardShortcut(false, false, false, false, 0)); |
| 41 | 59 |
| 42 // Check that all known keyboard shortcuts return valid results. | 60 // Check that all known keyboard shortcuts return valid results. |
| 43 size_t num_shortcuts = 0; | 61 size_t num_shortcuts = 0; |
| 44 const KeyboardShortcutData *it = | 62 const KeyboardShortcutData *it = |
| 45 GetBrowserKeyboardShortcutTable(&num_shortcuts); | 63 GetBrowserKeyboardShortcutTable(&num_shortcuts); |
| 46 ASSERT_GT(num_shortcuts, 0U); | 64 ASSERT_GT(num_shortcuts, 0U); |
| 47 for (size_t i = 0; i < num_shortcuts; ++i, ++it) { | 65 for (size_t i = 0; i < num_shortcuts; ++i, ++it) { |
| 48 int cmd_num = CommandForBrowserKeyboardShortcut( | 66 int cmd_num = CommandForBrowserKeyboardShortcut( |
| 49 it->command_key, it->shift_key, it->cntrl_key, it->opt_key, | 67 it->command_key, it->shift_key, it->cntrl_key, it->opt_key, |
| 50 it->vkey_code); ASSERT_EQ(cmd_num, it->chrome_command); | 68 it->vkey_code); ASSERT_EQ(cmd_num, it->chrome_command); |
| 51 } | 69 } |
| 52 } | 70 } |
| OLD | NEW |