Chromium Code Reviews| 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_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 Loading... | |
| 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 |
| OLD | NEW |