Index: ui/base/test/scoped_fake_full_keyboard_access.mm |
diff --git a/ui/base/test/scoped_fake_full_keyboard_access.mm b/ui/base/test/scoped_fake_full_keyboard_access.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..eac55f261e0ae35a58e2cce8bd54d52ce26f1ed1 |
--- /dev/null |
+++ b/ui/base/test/scoped_fake_full_keyboard_access.mm |
@@ -0,0 +1,45 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#import "ui/base/test/scoped_fake_full_keyboard_access.h" |
+ |
+#import <Cocoa/Cocoa.h> |
+ |
+#import "base/mac/scoped_objc_class_swizzler.h" |
+ |
+namespace { |
+ |
+bool g_full_keyboard_access_mode = false; |
tapted
2016/04/20 06:05:57
A lot of tests depend on traversing or setting foc
karandeepb
2016/05/03 02:54:12
Yeah I didn't take into account that these tests m
|
+ |
+} // namespace |
+ |
+// Donates testing implementation of [NSApp isFullKeyboardAccessEnabled]. |
tapted
2016/04/20 06:05:57
nit: testing -> a testing
karandeepb
2016/05/03 02:54:12
Done.
|
+@interface FakeNSAppKeyboardAccessDonor : NSObject |
+@end |
+ |
+@implementation FakeNSAppKeyboardAccessDonor |
+ |
+- (BOOL)isFullKeyboardAccessEnabled { |
+ return g_full_keyboard_access_mode; |
+} |
+ |
+@end |
+ |
+namespace ui { |
+namespace test { |
+ |
+ScopedFakeFullKeyboardAccess::ScopedFakeFullKeyboardAccess() |
+ : swizzler_(new base::mac::ScopedObjCClassSwizzler( |
+ [NSApplication class], |
+ [FakeNSAppKeyboardAccessDonor class], |
+ @selector(isFullKeyboardAccessEnabled))) {} |
+ |
+ScopedFakeFullKeyboardAccess::~ScopedFakeFullKeyboardAccess() {} |
+ |
+void ScopedFakeFullKeyboardAccess::SetFullKeyboardAccessState(bool new_state) { |
+ g_full_keyboard_access_mode = new_state; |
tapted
2016/04/20 06:05:57
we need to test the notifications too. That is, wh
karandeepb
2016/05/03 02:54:12
I can't get broadcasting notifications to NSDistri
tapted
2016/05/03 08:08:25
Hum - that starts to get into the realms of things
|
+} |
+ |
+} // namespace test |
+} // namespace ui |