OLD | NEW |
(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 |
OLD | NEW |