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

Side by Side Diff: ui/views/test/views_test_helper_mac.mm

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
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_nswindow_focus.h" 11 #include "ui/base/test/scoped_fake_nswindow_focus.h"
11 #include "ui/base/test/scoped_fake_nswindow_fullscreen.h" 12 #include "ui/base/test/scoped_fake_nswindow_fullscreen.h"
12 #include "ui/base/test/ui_controls.h" 13 #include "ui/base/test/ui_controls.h"
13 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 14 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
14 #include "ui/views/test/event_generator_delegate_mac.h" 15 #include "ui/views/test/event_generator_delegate_mac.h"
15 #include "ui/views/widget/widget.h" 16 #include "ui/views/widget/widget.h"
16 17
17 namespace views { 18 namespace views {
18 19
19 // static 20 // static
(...skipping 19 matching lines...) Expand all
39 void ViewsTestHelperMac::SetUp() { 40 void ViewsTestHelperMac::SetUp() {
40 ViewsTestHelper::SetUp(); 41 ViewsTestHelper::SetUp();
41 // Assume that if the methods in the ui_controls.h test header are enabled 42 // Assume that if the methods in the ui_controls.h test header are enabled
42 // then the test runner is in a non-sharded mode, and will use "real" 43 // then the test runner is in a non-sharded mode, and will use "real"
43 // activations and fullscreen mode. This allows interactive_ui_tests to test 44 // activations and fullscreen mode. This allows interactive_ui_tests to test
44 // the actual OS window activation and fullscreen codepaths. 45 // the actual OS window activation and fullscreen codepaths.
45 if (!ui_controls::IsUIControlsEnabled()) { 46 if (!ui_controls::IsUIControlsEnabled()) {
46 faked_focus_.reset(new ui::test::ScopedFakeNSWindowFocus); 47 faked_focus_.reset(new ui::test::ScopedFakeNSWindowFocus);
47 faked_fullscreen_.reset(new ui::test::ScopedFakeNSWindowFullscreen); 48 faked_fullscreen_.reset(new ui::test::ScopedFakeNSWindowFullscreen);
48 } 49 }
50 faked_full_keyboard_access_.reset(new ui::test::ScopedFakeFullKeyboardAccess);
49 } 51 }
50 52
51 void ViewsTestHelperMac::TearDown() { 53 void ViewsTestHelperMac::TearDown() {
52 // Ensure all Widgets are closed explicitly in tests. The Widget may be 54 // Ensure all Widgets are closed explicitly in tests. The Widget may be
53 // hosting a Compositor. If that's torn down after the test ContextFactory 55 // hosting a Compositor. If that's torn down after the test ContextFactory
54 // then a lot of confusing use-after-free errors result. In browser tests, 56 // then a lot of confusing use-after-free errors result. In browser tests,
55 // this is handled automatically by views::Widget::CloseAllSecondaryWidgets(). 57 // this is handled automatically by views::Widget::CloseAllSecondaryWidgets().
56 // Unit tests on Aura may create Widgets owned by a RootWindow that gets torn 58 // Unit tests on Aura may create Widgets owned by a RootWindow that gets torn
57 // down, but on Mac we need to be more explicit. 59 // down, but on Mac we need to be more explicit.
58 base::mac::ScopedNSAutoreleasePool pool; // Ensure the NSArray is released. 60 base::mac::ScopedNSAutoreleasePool pool; // Ensure the NSArray is released.
59 NSArray* native_windows = [NSApp windows]; 61 NSArray* native_windows = [NSApp windows];
60 for (NSWindow* window : native_windows) 62 for (NSWindow* window : native_windows)
61 DCHECK(!Widget::GetWidgetForNativeWindow(window)) << "Widget not closed."; 63 DCHECK(!Widget::GetWidgetForNativeWindow(window)) << "Widget not closed.";
62 } 64 }
63 65
64 } // namespace views 66 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698