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

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

Issue 1894383002: MacViews: Implement Full Keyboard Access. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@SetFocusBehavior
Patch Set: Rebased Created 4 years, 7 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 #ifndef UI_BASE_TEST_SCOPED_FAKE_FULL_KEYBOARD_ACCESS_H_
6 #define UI_BASE_TEST_SCOPED_FAKE_FULL_KEYBOARD_ACCESS_H_
7
8 #include <memory>
9
10 #include "base/macros.h"
11
12 namespace base {
13 namespace mac {
14 class ScopedObjCClassSwizzler;
15 }
16 }
17
18 namespace ui {
19 namespace test {
20
21 // A singleton class which swizzles [NSApp isFullKeyboardAccessEnabled] so
22 // that it returns the value set using set_full_keyboard_access_state().
23 class ScopedFakeFullKeyboardAccess {
24 public:
25 ScopedFakeFullKeyboardAccess();
26 ~ScopedFakeFullKeyboardAccess();
27
28 // Returns the ScopedFakeFullKeyboardAccess singleton or null if one hasn't
29 // been created yet.
30 static ScopedFakeFullKeyboardAccess* GetInstance();
31
32 bool full_keyboard_access_state() const {
33 return full_keyboard_access_state_;
34 }
35
36 // Set the value to be returned by [NSApp isFullKeyboardAccessEnabled].
37 void set_full_keyboard_access_state(bool new_state) {
38 full_keyboard_access_state_ = new_state;
39 }
40
41 private:
42 bool full_keyboard_access_state_;
43 std::unique_ptr<base::mac::ScopedObjCClassSwizzler> swizzler_;
44
45 DISALLOW_COPY_AND_ASSIGN(ScopedFakeFullKeyboardAccess);
46 };
47
48 } // namespace test
49 } // namespace ui
50
51 #endif // UI_BASE_TEST_SCOPED_FAKE_FULL_KEYBOARD_ACCESS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698