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

Side by Side Diff: ui/events/test/keyboard_layout_mac.cc

Issue 2349253002: Revert of Force U.S. English keyboard layout for TextfieldTest.KeysWithModifiersTest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « ui/events/test/keyboard_layout.cc ('k') | ui/events/test/keyboard_layout_win.cc » ('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 2016 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 "ui/events/test/keyboard_layout.h"
6
7 #include "base/logging.h"
8
9 namespace ui {
10
11 PlatformKeyboardLayout GetPlatformKeyboardLayout(KeyboardLayout layout) {
12 // Right now tests only need US English. If other layouts need to be
13 // supported in the future this code should be extended.
14 DCHECK_EQ(KEYBOARD_LAYOUT_ENGLISH_US, layout);
15
16 const char kUsInputSourceId[] = "com.apple.keylayout.US";
17
18 base::ScopedCFTypeRef<CFMutableDictionaryRef> input_source_list_filter(
19 CFDictionaryCreateMutable(kCFAllocatorDefault, 1,
20 &kCFTypeDictionaryKeyCallBacks,
21 &kCFTypeDictionaryValueCallBacks));
22 base::ScopedCFTypeRef<CFStringRef> input_source_id_ref(
23 CFStringCreateWithCString(kCFAllocatorDefault, kUsInputSourceId,
24 kCFStringEncodingUTF8));
25 CFDictionaryAddValue(input_source_list_filter, kTISPropertyInputSourceID,
26 input_source_id_ref);
27 base::ScopedCFTypeRef<CFArrayRef> input_source_list(
28 TISCreateInputSourceList(input_source_list_filter, true));
29 if (CFArrayGetCount(input_source_list) != 1)
30 return PlatformKeyboardLayout();
31
32 return PlatformKeyboardLayout(
33 (TISInputSourceRef)CFArrayGetValueAtIndex(input_source_list, 0));
34 }
35
36 PlatformKeyboardLayout ScopedKeyboardLayout::GetActiveLayout() {
37 return PlatformKeyboardLayout(TISCopyCurrentKeyboardInputSource());
38 }
39
40 void ScopedKeyboardLayout::ActivateLayout(PlatformKeyboardLayout layout) {
41 DCHECK(layout);
42 OSStatus result = TISSelectInputSource(layout);
43 DCHECK_EQ(noErr, result);
44 }
45
46 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/test/keyboard_layout.cc ('k') | ui/events/test/keyboard_layout_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698