| OLD | NEW |
| 1 #import "chrome/browser/cocoa/nsmenuitem_additions.h" | 1 #import "chrome/browser/cocoa/nsmenuitem_additions.h" |
| 2 | 2 |
| 3 #include <iostream> | 3 #include <iostream> |
| 4 #include <Carbon/Carbon.h> | 4 #include <Carbon/Carbon.h> |
| 5 | 5 |
| 6 #include "base/scoped_nsobject.h" | 6 #include "base/scoped_nsobject.h" |
| 7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 NSEvent* KeyEvent(const NSUInteger modifierFlags, | 10 NSEvent* KeyEvent(const NSUInteger modifierFlags, |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 kUCKeyActionDown, | 289 kUCKeyActionDown, |
| 290 modifiers, | 290 modifiers, |
| 291 LMGetKbdType(), | 291 LMGetKbdType(), |
| 292 kUCKeyTranslateNoDeadKeysBit, | 292 kUCKeyTranslateNoDeadKeysBit, |
| 293 &deadKeyState, | 293 &deadKeyState, |
| 294 maxStringLength, | 294 maxStringLength, |
| 295 &actualStringLength, | 295 &actualStringLength, |
| 296 unicodeString); | 296 unicodeString); |
| 297 assert(err == noErr); | 297 assert(err == noErr); |
| 298 | 298 |
| 299 NSString* layoutId = (NSString*)TISGetInputSourceProperty( |
| 300 layout, kTISPropertyInputSourceID); |
| 301 EXPECT_GE(maxStringLength, 1u) << layoutId; |
| 302 |
| 299 CFStringRef temp = CFStringCreateWithCharacters( | 303 CFStringRef temp = CFStringCreateWithCharacters( |
| 300 kCFAllocatorDefault, unicodeString, 1); | 304 kCFAllocatorDefault, unicodeString, maxStringLength >= 1 ? 1 : 0); |
| 301 return [(NSString*)temp autorelease]; | 305 return [(NSString*)temp autorelease]; |
| 302 } | 306 } |
| 303 | 307 |
| 304 TEST(NSMenuItemAdditionsTest, TestMOnDifferentLayouts) { | 308 TEST(NSMenuItemAdditionsTest, TestMOnDifferentLayouts) { |
| 305 // There's one key -- "m" -- that has the same keycode on most keyboard | 309 // There's one key -- "m" -- that has the same keycode on most keyboard |
| 306 //layouts. This function tests a menu item with cmd-m as key equivalent | 310 //layouts. This function tests a menu item with cmd-m as key equivalent |
| 307 // can be fired on all layouts. | 311 // can be fired on all layouts. |
| 308 NSMenuItem* item = MenuItem(@"m", 0x100000); | 312 NSMenuItem* item = MenuItem(@"m", 0x100000); |
| 309 | 313 |
| 310 NSDictionary* filter = [NSDictionary | 314 NSDictionary* filter = [NSDictionary |
| (...skipping 21 matching lines...) Expand all Loading... |
| 332 keyCode = 0x28; | 336 keyCode = 0x28; |
| 333 | 337 |
| 334 EventModifiers modifiers = cmdKey >> 8; | 338 EventModifiers modifiers = cmdKey >> 8; |
| 335 NSString* chars = keyCodeToCharacter(keyCode, modifiers, ref); | 339 NSString* chars = keyCodeToCharacter(keyCode, modifiers, ref); |
| 336 NSString* charsIgnoringMods = keyCodeToCharacter(keyCode, 0, ref); | 340 NSString* charsIgnoringMods = keyCodeToCharacter(keyCode, 0, ref); |
| 337 NSEvent* key = KeyEvent(0x100000, chars, charsIgnoringMods, keyCode); | 341 NSEvent* key = KeyEvent(0x100000, chars, charsIgnoringMods, keyCode); |
| 338 ExpectKeyFiresItem(key, item, false); | 342 ExpectKeyFiresItem(key, item, false); |
| 339 } | 343 } |
| 340 CFRelease(list); | 344 CFRelease(list); |
| 341 } | 345 } |
| OLD | NEW |