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

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

Issue 585913004: mac: Fix key layout test on OSX 10.9+. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #import "chrome/browser/ui/cocoa/nsmenuitem_additions.h" 5 #import "chrome/browser/ui/cocoa/nsmenuitem_additions.h"
6 6
7 #include <Carbon/Carbon.h> 7 #include <Carbon/Carbon.h>
8 8
9 #include <ostream> 9 #include <ostream>
10 10
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 (CFDictionaryRef)filter, true); 322 (CFDictionaryRef)filter, true);
323 for (id layout in list) { 323 for (id layout in list) {
324 TISInputSourceRef ref = (TISInputSourceRef)layout; 324 TISInputSourceRef ref = (TISInputSourceRef)layout;
325 325
326 NSUInteger keyCode = 0x2e; // "m" on a US layout and most other layouts. 326 NSUInteger keyCode = 0x2e; // "m" on a US layout and most other layouts.
327 327
328 // On a few layouts, "m" has a different key code. 328 // On a few layouts, "m" has a different key code.
329 NSString* layoutId = (NSString*)TISGetInputSourceProperty( 329 NSString* layoutId = (NSString*)TISGetInputSourceProperty(
330 ref, kTISPropertyInputSourceID); 330 ref, kTISPropertyInputSourceID);
331 if ([layoutId isEqualToString:@"com.apple.keylayout.Belgian"] || 331 if ([layoutId isEqualToString:@"com.apple.keylayout.Belgian"] ||
332 [layoutId isEqualToString:@"com.apple.keylayout.French"] || 332 [layoutId isEqualToString:@"com.apple.keylayout.Italian"] ||
333 [layoutId isEqualToString:@"com.apple.keylayout.French-numerical"] || 333 [layoutId hasPrefix:@"com.apple.keylayout.French"]) {
334 [layoutId isEqualToString:@"com.apple.keylayout.Italian"]) {
335 keyCode = 0x29; 334 keyCode = 0x29;
336 } else if ([layoutId isEqualToString:@"com.apple.keylayout.Turkish"]) { 335 } else if ([layoutId isEqualToString:@"com.apple.keylayout.Turkish"]) {
337 keyCode = 0x28; 336 keyCode = 0x28;
338 } else if ([layoutId isEqualToString:@"com.apple.keylayout.Dvorak-Left"]) { 337 } else if ([layoutId isEqualToString:@"com.apple.keylayout.Dvorak-Left"]) {
339 keyCode = 0x16; 338 keyCode = 0x16;
340 } else if ([layoutId isEqualToString:@"com.apple.keylayout.Dvorak-Right"]) { 339 } else if ([layoutId isEqualToString:@"com.apple.keylayout.Dvorak-Right"]) {
341 keyCode = 0x1a; 340 keyCode = 0x1a;
342 } 341 }
343 342
344 EventModifiers modifiers = cmdKey >> 8; 343 EventModifiers modifiers = cmdKey >> 8;
345 NSString* chars = keyCodeToCharacter(keyCode, modifiers, ref); 344 NSString* chars = keyCodeToCharacter(keyCode, modifiers, ref);
346 NSString* charsIgnoringMods = keyCodeToCharacter(keyCode, 0, ref); 345 NSString* charsIgnoringMods = keyCodeToCharacter(keyCode, 0, ref);
347 NSEvent* key = KeyEvent(0x100000, chars, charsIgnoringMods, keyCode); 346 NSEvent* key = KeyEvent(0x100000, chars, charsIgnoringMods, keyCode);
348 ExpectKeyFiresItem(key, item, false); 347 ExpectKeyFiresItem(key, item, false);
349 } 348 }
350 CFRelease(list); 349 CFRelease(list);
351 } 350 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698