Index: content/browser/cocoa/system_hotkey_map_unittest.mm |
diff --git a/content/browser/cocoa/system_hotkey_map_unittest.mm b/content/browser/cocoa/system_hotkey_map_unittest.mm |
index b37549fdaddc8bc6b6c754c48fad8a7edeb12990..939ce2c7cd3dc1e2d76c38efa6dd068109f921b0 100644 |
--- a/content/browser/cocoa/system_hotkey_map_unittest.mm |
+++ b/content/browser/cocoa/system_hotkey_map_unittest.mm |
@@ -12,6 +12,23 @@ |
#import "content/browser/cocoa/system_hotkey_map.h" |
#include "content/public/common/content_paths.h" |
+namespace { |
+ |
+NSData* DataFromTestFile(const char* file) { |
Robert Sesek
2014/07/22 17:15:24
I'd put this as a method on SystemHotkeyMapTest.
erikchen
2014/07/22 18:30:57
Done.
|
+ base::FilePath test_data_dir; |
+ bool result = PathService::Get(content::DIR_TEST_DATA, &test_data_dir); |
+ if (!result) |
+ return nil; |
+ |
+ base::FilePath test_path = test_data_dir.AppendASCII(file); |
+ std::string test_path_string = test_path.AsUTF8Unsafe(); |
+ NSString* file_path = |
+ [NSString stringWithUTF8String:test_path_string.c_str()]; |
+ return [NSData dataWithContentsOfFile:file_path]; |
+} |
+ |
+} // namespace |
+ |
namespace content { |
class SystemHotkeyMapTest : public ::testing::Test { |
@@ -20,15 +37,9 @@ class SystemHotkeyMapTest : public ::testing::Test { |
}; |
TEST_F(SystemHotkeyMapTest, Parse) { |
- base::FilePath test_data_dir; |
- ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &test_data_dir)); |
- |
- base::FilePath test_path = |
- test_data_dir.AppendASCII("mac/mac_system_hotkeys.plist"); |
- std::string test_path_string = test_path.AsUTF8Unsafe(); |
- NSString* file_path = |
- [NSString stringWithUTF8String:test_path_string.c_str()]; |
- NSData* data = [NSData dataWithContentsOfFile:file_path]; |
+ // This plist was pulled from a real machine. It is extensively populated, |
+ // and has no missing or incomplete entries. |
+ NSData* data = DataFromTestFile("mac/mac_system_hotkeys.plist"); |
ASSERT_TRUE(data); |
NSDictionary* dictionary = SystemHotkeyMap::DictionaryFromData(data); |
@@ -65,4 +76,41 @@ TEST_F(SystemHotkeyMapTest, ParseNil) { |
EXPECT_FALSE(result); |
} |
+TEST_F(SystemHotkeyMapTest, ParseMouse) { |
+ // This plist was pulled from a real machine. It has missing entries, |
+ // incomplete entries, and mouse hotkeys. |
+ NSData* data = DataFromTestFile("mac/mac_system_hotkeys_sparse.plist"); |
+ ASSERT_TRUE(data); |
+ |
+ NSDictionary* dictionary = SystemHotkeyMap::DictionaryFromData(data); |
+ ASSERT_TRUE(dictionary); |
+ |
+ SystemHotkeyMap map; |
+ bool result = map.ParseDictionary(dictionary); |
+ EXPECT_TRUE(result); |
+ |
+ // Command + ` is a common key binding. It is missing. |
+ // TODO(erikchen): OSX uses the default value when the keybinding is missing, |
+ // so the hotkey should still be reserved. |
+ // http://crbug.com/383558 |
+ int key_code = kVK_ANSI_Grave; |
Robert Sesek
2014/07/22 17:15:24
Use the right types here, and on line 97.
erikchen
2014/07/22 18:30:57
Done.
|
+ int modifiers = NSCommandKeyMask; |
+ EXPECT_FALSE(map.IsHotkeyReserved(key_code, modifiers)); |
+ |
+ // There is a mouse keybinding for 0x08. It should not apply to keyboard |
+ // hotkeys. |
+ key_code = kVK_ANSI_C; |
+ modifiers = 0; |
+ EXPECT_FALSE(map.IsHotkeyReserved(key_code, modifiers)); |
+ |
+ // Command + Alt + = is an accessibility shortcut. Its entry in the plist is |
+ // incomplete. |
+ // TODO(erikchen): OSX uses the default bindings, so this hotkey should still |
+ // be reserved. |
+ // http://crbug.com/383558 |
+ key_code = kVK_ANSI_Equal; |
+ modifiers = NSCommandKeyMask | NSAlternateKeyMask; |
+ EXPECT_FALSE(map.IsHotkeyReserved(key_code, modifiers)); |
+} |
+ |
} // namespace content |