OLD | NEW |
| (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 | |
OLD | NEW |