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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ui/base/test/scoped_fake_full_keyboard_access.h
diff --git a/ui/base/test/scoped_fake_full_keyboard_access.h b/ui/base/test/scoped_fake_full_keyboard_access.h
new file mode 100644
index 0000000000000000000000000000000000000000..0fe450db1bf43e5891faffb66edf765bf9389850
--- /dev/null
+++ b/ui/base/test/scoped_fake_full_keyboard_access.h
@@ -0,0 +1,51 @@
+// 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.
+
+#ifndef UI_BASE_TEST_SCOPED_FAKE_FULL_KEYBOARD_ACCESS_H_
+#define UI_BASE_TEST_SCOPED_FAKE_FULL_KEYBOARD_ACCESS_H_
+
+#include <memory>
+
+#include "base/macros.h"
+
+namespace base {
+namespace mac {
+class ScopedObjCClassSwizzler;
+}
+}
+
+namespace ui {
+namespace test {
+
+// A singleton class which swizzles [NSApp isFullKeyboardAccessEnabled] so
+// that it returns the value set using set_full_keyboard_access_state().
+class ScopedFakeFullKeyboardAccess {
+ public:
+ ScopedFakeFullKeyboardAccess();
+ ~ScopedFakeFullKeyboardAccess();
+
+ // Returns the ScopedFakeFullKeyboardAccess singleton or null if one hasn't
+ // been created yet.
+ static ScopedFakeFullKeyboardAccess* GetInstance();
+
+ bool full_keyboard_access_state() const {
+ return full_keyboard_access_state_;
+ }
+
+ // Set the value to be returned by [NSApp isFullKeyboardAccessEnabled].
+ void set_full_keyboard_access_state(bool new_state) {
+ full_keyboard_access_state_ = new_state;
+ }
+
+ private:
+ bool full_keyboard_access_state_;
+ std::unique_ptr<base::mac::ScopedObjCClassSwizzler> swizzler_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedFakeFullKeyboardAccess);
+};
+
+} // namespace test
+} // namespace ui
+
+#endif // UI_BASE_TEST_SCOPED_FAKE_FULL_KEYBOARD_ACCESS_H_

Powered by Google App Engine
This is Rietveld 408576698