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

Unified Diff: ui/views/test/platform_test_helper.cc

Issue 2488393003: Changes views_aura_mus_unittests to create DesktopNativeWidgetAura (Closed)
Patch Set: git add Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/test/platform_test_helper.cc
diff --git a/ui/views/test/platform_test_helper.cc b/ui/views/test/platform_test_helper.cc
index b6626189fa390b2141ef70e1ff3704344714770f..64ff7ffa11017fa40ef9aae903cf24591fe15cb9 100644
--- a/ui/views/test/platform_test_helper.cc
+++ b/ui/views/test/platform_test_helper.cc
@@ -7,6 +7,18 @@
#include "base/callback.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
+#include "ui/views/widget/widget.h"
+
+#if defined(USE_AURA)
+#include "ui/aura/window.h"
+#endif
+
+#if defined(OS_MACOSX)
+#include <Cocoa/Cocoa.h>
+
+#import "base/mac/scoped_nsobject.h"
+#include "ui/views/widget/native_widget_mac.h"
+#endif
namespace views {
namespace {
@@ -17,6 +29,20 @@ class DefaultPlatformTestHelper : public PlatformTestHelper {
~DefaultPlatformTestHelper() override {}
+ // PlatformTestHelper:
+ void SimulateNativeDestroy(Widget* widget) override {
+#if defined(USE_AURA)
+ delete widget->GetNativeView();
+#elif defined(OS_MACOSX)
+ // Retain the window while closing it, otherwise the window may lose its
+ // last
+ // owner before -[NSWindow close] completes (this offends AppKit). Usually
+ // this reference will exist on an event delivered to the runloop.
+ base::scoped_nsobject<NSWindow> window([widget->GetNativeWindow() retain]);
+ [window close];
+#endif
+ }
+
private:
DISALLOW_COPY_AND_ASSIGN(DefaultPlatformTestHelper);
};

Powered by Google App Engine
This is Rietveld 408576698