Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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/platform_test_helper.h" | 5 #include "ui/views/test/platform_test_helper.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "ui/views/widget/widget.h" | |
| 11 | |
| 12 #if defined(USE_AURA) | |
| 13 #include "ui/aura/window.h" | |
| 14 #endif | |
| 15 | |
| 16 #if defined(OS_MACOSX) | |
| 17 #include <Cocoa/Cocoa.h> | |
| 18 | |
| 19 #import "base/mac/scoped_nsobject.h" | |
| 20 #include "ui/views/widget/native_widget_mac.h" | |
| 21 #endif | |
| 10 | 22 |
| 11 namespace views { | 23 namespace views { |
| 12 namespace { | 24 namespace { |
| 13 | 25 |
| 14 class DefaultPlatformTestHelper : public PlatformTestHelper { | 26 class DefaultPlatformTestHelper : public PlatformTestHelper { |
|
msw
2016/11/11 00:29:24
Can we move the default SimulateNativeDestroy impl
sky
2016/11/11 01:09:13
Done.
| |
| 15 public: | 27 public: |
| 16 DefaultPlatformTestHelper() {} | 28 DefaultPlatformTestHelper() {} |
| 17 | 29 |
| 18 ~DefaultPlatformTestHelper() override {} | 30 ~DefaultPlatformTestHelper() override {} |
| 19 | 31 |
| 32 // PlatformTestHelper: | |
| 33 void SimulateNativeDestroy(Widget* widget) override { | |
| 34 #if defined(USE_AURA) | |
| 35 delete widget->GetNativeView(); | |
| 36 #elif defined(OS_MACOSX) | |
| 37 // Retain the window while closing it, otherwise the window may lose its | |
| 38 // last | |
| 39 // owner before -[NSWindow close] completes (this offends AppKit). Usually | |
| 40 // this reference will exist on an event delivered to the runloop. | |
| 41 base::scoped_nsobject<NSWindow> window([widget->GetNativeWindow() retain]); | |
| 42 [window close]; | |
| 43 #endif | |
| 44 } | |
| 45 | |
| 20 private: | 46 private: |
| 21 DISALLOW_COPY_AND_ASSIGN(DefaultPlatformTestHelper); | 47 DISALLOW_COPY_AND_ASSIGN(DefaultPlatformTestHelper); |
| 22 }; | 48 }; |
| 23 | 49 |
| 24 PlatformTestHelper::Factory test_helper_factory; | 50 PlatformTestHelper::Factory test_helper_factory; |
| 25 bool is_mus = false; | 51 bool is_mus = false; |
| 26 bool is_aura_mus_client = false; | 52 bool is_aura_mus_client = false; |
| 27 | 53 |
| 28 } // namespace | 54 } // namespace |
| 29 | 55 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 53 void PlatformTestHelper::SetIsAuraMusClient() { | 79 void PlatformTestHelper::SetIsAuraMusClient() { |
| 54 is_aura_mus_client = true; | 80 is_aura_mus_client = true; |
| 55 } | 81 } |
| 56 | 82 |
| 57 // static | 83 // static |
| 58 bool PlatformTestHelper::IsAuraMusClient() { | 84 bool PlatformTestHelper::IsAuraMusClient() { |
| 59 return is_aura_mus_client; | 85 return is_aura_mus_client; |
| 60 } | 86 } |
| 61 | 87 |
| 62 } // namespace views | 88 } // namespace views |
| OLD | NEW |