OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/views/test/views_test_helper_mac.h" | 5 #include "ui/views/test/views_test_helper_mac.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #import "base/mac/scoped_nsautorelease_pool.h" | 9 #import "base/mac/scoped_nsautorelease_pool.h" |
10 #include "ui/base/test/scoped_fake_full_keyboard_access.h" | 10 #include "ui/base/test/scoped_fake_full_keyboard_access.h" |
11 #include "ui/base/test/scoped_fake_nswindow_focus.h" | 11 #include "ui/base/test/scoped_fake_nswindow_focus.h" |
12 #include "ui/base/test/scoped_fake_nswindow_fullscreen.h" | 12 #include "ui/base/test/scoped_fake_nswindow_fullscreen.h" |
13 #include "ui/base/test/ui_controls.h" | 13 #include "ui/base/test/ui_controls.h" |
14 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 14 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 15 #include "ui/views/cocoa/bridged_content_view.h" |
| 16 #include "ui/views/cocoa/bridged_native_widget.h" |
15 #include "ui/views/test/event_generator_delegate_mac.h" | 17 #include "ui/views/test/event_generator_delegate_mac.h" |
| 18 #include "ui/views/widget/native_widget_mac.h" |
16 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
17 | 20 |
18 namespace views { | 21 namespace views { |
19 | 22 |
20 // static | 23 // static |
21 ViewsTestHelper* ViewsTestHelper::Create( | 24 ViewsTestHelper* ViewsTestHelper::Create( |
22 base::MessageLoopForUI* message_loop, | 25 base::MessageLoopForUI* message_loop, |
23 ui::ContextFactory* context_factory, | 26 ui::ContextFactory* context_factory, |
24 ui::ContextFactoryPrivate* context_factory_private) { | 27 ui::ContextFactoryPrivate* context_factory_private) { |
25 return new ViewsTestHelperMac; | 28 return new ViewsTestHelperMac; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // then a lot of confusing use-after-free errors result. In browser tests, | 61 // then a lot of confusing use-after-free errors result. In browser tests, |
59 // this is handled automatically by views::Widget::CloseAllSecondaryWidgets(). | 62 // this is handled automatically by views::Widget::CloseAllSecondaryWidgets(). |
60 // Unit tests on Aura may create Widgets owned by a RootWindow that gets torn | 63 // Unit tests on Aura may create Widgets owned by a RootWindow that gets torn |
61 // down, but on Mac we need to be more explicit. | 64 // down, but on Mac we need to be more explicit. |
62 base::mac::ScopedNSAutoreleasePool pool; // Ensure the NSArray is released. | 65 base::mac::ScopedNSAutoreleasePool pool; // Ensure the NSArray is released. |
63 NSArray* native_windows = [NSApp windows]; | 66 NSArray* native_windows = [NSApp windows]; |
64 for (NSWindow* window : native_windows) | 67 for (NSWindow* window : native_windows) |
65 DCHECK(!Widget::GetWidgetForNativeWindow(window)) << "Widget not closed."; | 68 DCHECK(!Widget::GetWidgetForNativeWindow(window)) << "Widget not closed."; |
66 } | 69 } |
67 | 70 |
| 71 void ViewsTestHelperMac::SetFullKeyboardAccessState(Widget* widget, |
| 72 bool new_state) { |
| 73 faked_full_keyboard_access_->set_full_keyboard_access_state(new_state); |
| 74 [NativeWidgetMac::GetBridgeForNativeWindow(widget->GetNativeWindow()) |
| 75 ->ns_view() updateFullKeyboardAccess]; |
| 76 } |
| 77 |
68 } // namespace views | 78 } // namespace views |
OLD | NEW |