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

Side by Side Diff: ui/base/test/scoped_fake_full_keyboard_access.mm

Issue 1690543004: MacViews: Implement Full Keyboard Access. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 #import "ui/base/test/scoped_fake_full_keyboard_access.h"
6
7 #import <Cocoa/Cocoa.h>
8
9 #import "base/mac/scoped_objc_class_swizzler.h"
10
11 namespace {
12
13 bool g_full_keyboard_access_mode = false;
14
15 } // namespace
16
17 // Donates testing implementation of
18 // [NSApplication isFullKeyboardAccessEnabled].
19 @interface FakeNSAppKeyboardAccessDonor : NSObject
20 @end
21
22 @implementation FakeNSAppKeyboardAccessDonor
23
24 - (BOOL)isFullKeyboardAccessEnabled {
25 return g_full_keyboard_access_mode;
26 }
27
28 @end
29
30 namespace ui {
31 namespace test {
32
33 ScopedFakeFullKeyboardAccess::ScopedFakeFullKeyboardAccess()
34 : swizzler_(new base::mac::ScopedObjCClassSwizzler(
35 [NSApplication class],
36 [FakeNSAppKeyboardAccessDonor class],
37 @selector(isFullKeyboardAccessEnabled))) {}
38
39 ScopedFakeFullKeyboardAccess::~ScopedFakeFullKeyboardAccess() {}
40
41 void ScopedFakeFullKeyboardAccess::SetFullKeyboardAccessState(bool new_state) {
42 g_full_keyboard_access_mode = new_state;
43 }
44
45 } // namespace test
46 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698