Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: chrome/browser/global_keyboard_shortcuts_mac_unittest.cc

Issue 251069: Support cmd-left/right for history. (Closed)
Patch Set: comments Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
6
5 #include "chrome/browser/global_keyboard_shortcuts_mac.h" 7 #include "chrome/browser/global_keyboard_shortcuts_mac.h"
6 8
7 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
8 10
9 TEST(GlobalKeyboardShortcuts, ShortCutsToCommand) { 11 TEST(GlobalKeyboardShortcuts, ShortcutsToWindowCommand) {
10 // Test that an invalid shortcut translates into an invalid command id. 12 // Test that an invalid shortcut translates into an invalid command id.
11 ASSERT_EQ(CommandForKeyboardShortcut(false, false, false, 0), -1); 13 ASSERT_EQ(-1, CommandForWindowKeyboardShortcut(false, false, false, 0));
12 14
13 // Check that all known keyboard shortcuts return valid results. 15 // Check that all known keyboard shortcuts return valid results.
14 size_t num_shortcuts = 0; 16 size_t num_shortcuts = 0;
15 const KeyboardShortcutData *it = GetKeyboardShortCutTable(&num_shortcuts); 17 const KeyboardShortcutData *it =
18 GetWindowKeyboardShortcutTable(&num_shortcuts);
16 ASSERT_GT(num_shortcuts, 0U); 19 ASSERT_GT(num_shortcuts, 0U);
17 for (size_t i = 0; i < num_shortcuts; ++i, ++it) { 20 for (size_t i = 0; i < num_shortcuts; ++i, ++it) {
18 int cmd_num = CommandForKeyboardShortcut(it->command_key, it->shift_key, 21 int cmd_num = CommandForWindowKeyboardShortcut(
19 it->cntrl_key, it->vkey_code); 22 it->command_key, it->shift_key, it->cntrl_key, it->vkey_code);
23 ASSERT_EQ(cmd_num, it->chrome_command);
24 }
25
26 // Test that cmd-left and backspace are not window-level commands (else they
27 // would be invoked even if e.g. the omnibox had focus, where they really
28 // should have text editing functionality).
29 ASSERT_EQ(-1, CommandForWindowKeyboardShortcut(
30 true, false, false, kVK_LeftArrow));
31 ASSERT_EQ(-1, CommandForWindowKeyboardShortcut(
32 false, false, false, kVK_Delete));
33 }
34
35 TEST(GlobalKeyboardShortcuts, ShortcutsToBrowserCommand) {
36 // Test that an invalid shortcut translates into an invalid command id.
37 ASSERT_EQ(-1, CommandForBrowserKeyboardShortcut(false, false, false, 0));
38
39 // Check that all known keyboard shortcuts return valid results.
40 size_t num_shortcuts = 0;
41 const KeyboardShortcutData *it =
42 GetBrowserKeyboardShortcutTable(&num_shortcuts);
43 ASSERT_GT(num_shortcuts, 0U);
44 for (size_t i = 0; i < num_shortcuts; ++i, ++it) {
45 int cmd_num = CommandForBrowserKeyboardShortcut(
46 it->command_key, it->shift_key, it->cntrl_key, it->vkey_code);
20 ASSERT_EQ(cmd_num, it->chrome_command); 47 ASSERT_EQ(cmd_num, it->chrome_command);
21 } 48 }
22 } 49 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698