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

Side by Side Diff: chrome/browser/ui/cocoa/system_hotkey_map_unittest.mm

Issue 408973002: mac: Load the system hotkeys after launch. (reland) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add more unit tests. Created 6 years, 5 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
« no previous file with comments | « chrome/browser/ui/cocoa/system_hotkey_map.mm ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <gtest/gtest.h>
6
7 #import <Carbon/Carbon.h>
8 #import <Cocoa/Cocoa.h>
9
10 #import "chrome/browser/ui/cocoa/system_hotkey_map.h"
11 #include "chrome/test/base/ui_test_utils.h"
12
13 namespace {
14
15 class SystemHotkeyMapTest : public ::testing::Test {
16 public:
17 SystemHotkeyMapTest() {}
18 };
19
20 TEST_F(SystemHotkeyMapTest, Parse) {
21 std::string path = ui_test_utils::GetTestUrl(
22 base::FilePath(base::FilePath::kCurrentDirectory),
23 base::FilePath("mac/mac_system_hotkeys.plist")).path();
24 NSString* file_path = [NSString stringWithUTF8String:path.c_str()];
25 NSData* data = [NSData dataWithContentsOfFile:file_path];
26 ASSERT_TRUE(data);
27
28 SystemHotkeyMap map;
29 bool result = map.ParseData(data);
30 EXPECT_TRUE(result);
31
32 // Command + ` is a common key binding. It should exist.
33 int key_code = kVK_ANSI_Grave;
34 int modifiers = NSCommandKeyMask;
35 EXPECT_TRUE(map.IsHotkeyReserved(key_code, modifiers));
36
37 // Command + Shift + ` is a common key binding. It should exist.
38 modifiers = NSCommandKeyMask | NSShiftKeyMask;
39 EXPECT_TRUE(map.IsHotkeyReserved(key_code, modifiers));
40
41 // Command + Shift + Ctr + ` is not a common key binding.
42 modifiers = NSCommandKeyMask | NSShiftKeyMask | NSControlKeyMask;
43 EXPECT_FALSE(map.IsHotkeyReserved(key_code, modifiers));
44
45 // Command + L is not a common key binding.
46 key_code = kVK_ANSI_L;
47 modifiers = NSCommandKeyMask;
48 EXPECT_FALSE(map.IsHotkeyReserved(key_code, modifiers));
49 }
50
51 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/system_hotkey_map.mm ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698