| Index: chrome/browser/global_keyboard_shortcuts_mac_unittest.cc
|
| diff --git a/chrome/browser/global_keyboard_shortcuts_mac_unittest.cc b/chrome/browser/global_keyboard_shortcuts_mac_unittest.cc
|
| index 0b13e00e10504ec93c42cfb563060ee7e6830fa7..8ab7237dce67ef021f4cdff3efce59c33748f3a4 100644
|
| --- a/chrome/browser/global_keyboard_shortcuts_mac_unittest.cc
|
| +++ b/chrome/browser/global_keyboard_shortcuts_mac_unittest.cc
|
| @@ -2,21 +2,48 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include <Carbon/Carbon.h>
|
| +
|
| #include "chrome/browser/global_keyboard_shortcuts_mac.h"
|
|
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| -TEST(GlobalKeyboardShortcuts, ShortCutsToCommand) {
|
| +TEST(GlobalKeyboardShortcuts, ShortcutsToWindowCommand) {
|
| + // Test that an invalid shortcut translates into an invalid command id.
|
| + ASSERT_EQ(-1, CommandForWindowKeyboardShortcut(false, false, false, 0));
|
| +
|
| + // Check that all known keyboard shortcuts return valid results.
|
| + size_t num_shortcuts = 0;
|
| + const KeyboardShortcutData *it =
|
| + GetWindowKeyboardShortcutTable(&num_shortcuts);
|
| + ASSERT_GT(num_shortcuts, 0U);
|
| + for (size_t i = 0; i < num_shortcuts; ++i, ++it) {
|
| + int cmd_num = CommandForWindowKeyboardShortcut(
|
| + it->command_key, it->shift_key, it->cntrl_key, it->vkey_code);
|
| + ASSERT_EQ(cmd_num, it->chrome_command);
|
| + }
|
| +
|
| + // Test that cmd-left and backspace are not window-level commands (else they
|
| + // would be invoked even if e.g. the omnibox had focus, where they really
|
| + // should have text editing functionality).
|
| + ASSERT_EQ(-1, CommandForWindowKeyboardShortcut(
|
| + true, false, false, kVK_LeftArrow));
|
| + ASSERT_EQ(-1, CommandForWindowKeyboardShortcut(
|
| + false, false, false, kVK_Delete));
|
| +}
|
| +
|
| +TEST(GlobalKeyboardShortcuts, ShortcutsToBrowserCommand) {
|
| // Test that an invalid shortcut translates into an invalid command id.
|
| - ASSERT_EQ(CommandForKeyboardShortcut(false, false, false, 0), -1);
|
| + ASSERT_EQ(-1, CommandForBrowserKeyboardShortcut(false, false, false, 0));
|
|
|
| // Check that all known keyboard shortcuts return valid results.
|
| size_t num_shortcuts = 0;
|
| - const KeyboardShortcutData *it = GetKeyboardShortCutTable(&num_shortcuts);
|
| + const KeyboardShortcutData *it =
|
| + GetBrowserKeyboardShortcutTable(&num_shortcuts);
|
| ASSERT_GT(num_shortcuts, 0U);
|
| for (size_t i = 0; i < num_shortcuts; ++i, ++it) {
|
| - int cmd_num = CommandForKeyboardShortcut(it->command_key, it->shift_key,
|
| - it->cntrl_key, it->vkey_code);
|
| + int cmd_num = CommandForBrowserKeyboardShortcut(
|
| + it->command_key, it->shift_key, it->cntrl_key, it->vkey_code);
|
| ASSERT_EQ(cmd_num, it->chrome_command);
|
| }
|
| }
|
|
|