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

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

Issue 1782773002: MacViews: Fix ViewTest.HandleAccelerator by faking window activation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Delay the activatableness Created 4 years, 9 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_nswindow_focus.h"
10 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 11 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
11 #include "ui/views/test/event_generator_delegate_mac.h" 12 #include "ui/views/test/event_generator_delegate_mac.h"
12 #include "ui/views/widget/widget.h" 13 #include "ui/views/widget/widget.h"
13 14
14 namespace views { 15 namespace views {
15 16
16 // static 17 // static
17 ViewsTestHelper* ViewsTestHelper::Create(base::MessageLoopForUI* message_loop, 18 ViewsTestHelper* ViewsTestHelper::Create(base::MessageLoopForUI* message_loop,
18 ui::ContextFactory* context_factory) { 19 ui::ContextFactory* context_factory) {
19 return new ViewsTestHelperMac; 20 return new ViewsTestHelperMac;
(...skipping 19 matching lines...) Expand all
39 // then a lot of confusing use-after-free errors result. In browser tests, 40 // then a lot of confusing use-after-free errors result. In browser tests,
40 // this is handled automatically by views::Widget::CloseAllSecondaryWidgets(). 41 // this is handled automatically by views::Widget::CloseAllSecondaryWidgets().
41 // Unit tests on Aura may create Widgets owned by a RootWindow that gets torn 42 // Unit tests on Aura may create Widgets owned by a RootWindow that gets torn
42 // down, but on Mac we need to be more explicit. 43 // down, but on Mac we need to be more explicit.
43 base::mac::ScopedNSAutoreleasePool pool; // Ensure the NSArray is released. 44 base::mac::ScopedNSAutoreleasePool pool; // Ensure the NSArray is released.
44 NSArray* native_windows = [NSApp windows]; 45 NSArray* native_windows = [NSApp windows];
45 for (NSWindow* window : native_windows) 46 for (NSWindow* window : native_windows)
46 DCHECK(!Widget::GetWidgetForNativeWindow(window)) << "Widget not closed."; 47 DCHECK(!Widget::GetWidgetForNativeWindow(window)) << "Widget not closed.";
47 } 48 }
48 49
50 void ViewsTestHelperMac::EnableFakeWindowActivation() {
51 faked_focus_.reset(new ui::test::ScopedFakeNSWindowFocus);
sky 2016/03/10 18:59:16 Is there a reason not to do this always? By that I
tapted 2016/03/11 09:56:19 Done (see what you think). This has actually cros
52 }
53
49 } // namespace views 54 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698