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

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

Issue 2197113002: Force U.S. English keyboard layout for TextfieldTest.KeysWithModifiersTest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build issues on Mac, iOS and Linux 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
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);
Wez 2016/09/13 20:03:16 nit: I generally recommend leaving a blank-line be
Tomasz Moniuszko 2016/09/14 13:56:06 Done.
15 const char input_source_id[] = "com.apple.keylayout.US";
Wez 2016/09/13 20:03:16 kInputSourceId? Or kUsInputSourceId?
Tomasz Moniuszko 2016/09/14 13:56:06 Done.
16
17 base::ScopedCFTypeRef<CFMutableDictionaryRef> filter_dict(
Wez 2016/09/13 20:03:16 Can we give the variables in this section more hel
Tomasz Moniuszko 2016/09/14 13:56:06 I moved this code from chrome/test/chromedriver/te
Wez 2016/09/16 00:57:18 Thanks!
18 CFDictionaryCreateMutable(kCFAllocatorDefault, 1,
19 &kCFTypeDictionaryKeyCallBacks,
20 &kCFTypeDictionaryValueCallBacks));
21 base::ScopedCFTypeRef<CFStringRef> id_ref(CFStringCreateWithCString(
22 kCFAllocatorDefault, input_source_id, kCFStringEncodingUTF8));
23 CFDictionaryAddValue(filter_dict, kTISPropertyInputSourceID, id_ref);
24 base::ScopedCFTypeRef<CFArrayRef> sources(
25 TISCreateInputSourceList(filter_dict, true));
26 if (CFArrayGetCount(sources) != 1)
27 return PlatformKeyboardLayout();
28
29 return PlatformKeyboardLayout(
30 (TISInputSourceRef)CFArrayGetValueAtIndex(sources, 0));
31 }
32
33 PlatformKeyboardLayout ScopedKeyboardLayout::GetActiveLayout() {
34 return PlatformKeyboardLayout(TISCopyCurrentKeyboardInputSource());
35 }
36
37 void ScopedKeyboardLayout::ActivateLayout(PlatformKeyboardLayout layout) {
38 DCHECK(layout);
39 OSStatus result = TISSelectInputSource(layout);
40 DCHECK_EQ(noErr, result);
41 }
42
43 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698