Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/views/test/platform_test_helper.h" | |
| 6 | |
| 7 #include <Cocoa/Cocoa.h> | |
| 8 | |
| 9 #import "base/mac/scoped_nsobject.h" | |
| 10 #import "base/mac/scoped_objc_class_swizzler.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/ptr_util.h" | |
| 13 #import "ui/views/cocoa/bridged_native_widget.h" | |
| 14 #include "ui/views/widget/native_widget_mac.h" | |
| 15 #include "ui/views/widget/widget.h" | |
| 16 | |
| 17 namespace views { | |
| 18 namespace { | |
| 19 | |
| 20 class DefaultPlatformTestHelper : public PlatformTestHelper { | |
| 21 public: | |
| 22 DefaultPlatformTestHelper() {} | |
| 23 ~DefaultPlatformTestHelper() override {} | |
| 24 | |
| 25 // PlatformTestHelper: | |
| 26 void SimulateNativeDestroy(Widget* widget) override { | |
| 27 // Retain the window while closing it, otherwise the window may lose its | |
| 28 // last | |
|
msw
2016/11/11 00:29:25
nit: wrapping
sky
2016/11/11 01:09:14
Done.
| |
| 29 // owner before -[NSWindow close] completes (this offends AppKit). Usually | |
| 30 // this reference will exist on an event delivered to the runloop. | |
| 31 base::scoped_nsobject<NSWindow> window([widget->GetNativeWindow() retain]); | |
| 32 [window close]; | |
| 33 } | |
| 34 | |
| 35 private: | |
| 36 DISALLOW_COPY_AND_ASSIGN(DefaultPlatformTestHelper); | |
| 37 }; | |
| 38 | |
| 39 } // namespace | |
| 40 | |
| 41 // static | |
| 42 std::unique_ptr<PlatformTestHelper> PlatformTestHelper::Create() { | |
| 43 return base::WrapUnique(new DefaultPlatformTestHelper); | |
| 44 } | |
| 45 | |
| 46 } // namespace views | |
| OLD | NEW |