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

Unified Diff: ui/views/widget/native_widget_mac_unittest.mm

Issue 2448243003: MacViews: Reattach children of native windows when they are exposed. (Closed)
Patch Set: respond to comments Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/cocoa/widget_owner_nswindow_adapter.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/native_widget_mac_unittest.mm
diff --git a/ui/views/widget/native_widget_mac_unittest.mm b/ui/views/widget/native_widget_mac_unittest.mm
index 85d7ec30ce630febc6aa7e13dd5f076adefcb3c6..daa0c0a4b66bb8c7b18ed269054664834f479e20 100644
--- a/ui/views/widget/native_widget_mac_unittest.mm
+++ b/ui/views/widget/native_widget_mac_unittest.mm
@@ -666,10 +666,9 @@ TEST_F(NativeWidgetMacTest, AccessibilityIntegration) {
widget->CloseNow();
}
-// Tests creating a views::Widget parented off a native NSWindow.
-TEST_F(NativeWidgetMacTest, NonWidgetParent) {
- NSWindow* native_parent = MakeNativeParent();
+namespace {
+Widget* AttachPopupToNativeParent(NSWindow* native_parent) {
base::scoped_nsobject<NSView> anchor_view(
[[NSView alloc] initWithFrame:[[native_parent contentView] bounds]]);
[[native_parent contentView] addSubview:anchor_view];
@@ -682,7 +681,15 @@ TEST_F(NativeWidgetMacTest, NonWidgetParent) {
init_params.parent = anchor_view;
init_params.type = Widget::InitParams::TYPE_POPUP;
child->Init(init_params);
+ return child;
+}
+} // namespace
+
+// Tests creating a views::Widget parented off a native NSWindow.
+TEST_F(NativeWidgetMacTest, NonWidgetParent) {
+ NSWindow* native_parent = MakeNativeParent();
+ Widget* child = AttachPopupToNativeParent(native_parent);
TestWidgetObserver child_observer(child);
// GetTopLevelNativeWidget() only goes as far as there exists a Widget (i.e.
@@ -713,10 +720,11 @@ TEST_F(NativeWidgetMacTest, NonWidgetParent) {
// bounds set above should be in screen coordinates.
EXPECT_EQ(child_bounds, child->GetWindowBoundsInScreen());
- // Removing the anchor_view from its view hierarchy is permitted. This should
+ // Removing the anchor view from its view hierarchy is permitted. This should
// not break the relationship between the two windows.
+ NSView* anchor_view = [[native_parent contentView] subviews][0];
+ EXPECT_TRUE(anchor_view);
[anchor_view removeFromSuperview];
- anchor_view.reset();
EXPECT_EQ(native_parent, bridged_native_widget->parent()->GetNSWindow());
// Closing the parent should close and destroy the child.
@@ -758,6 +766,25 @@ TEST_F(NativeWidgetMacTest, NonWidgetParentLastReference) {
EXPECT_TRUE(native_parent_dealloced);
}
+// Tests visibility for child of native NSWindow, reshowing after -[NSApp hide].
+TEST_F(NativeWidgetMacTest, VisibleAfterNativeParentShow) {
+ NSWindow* native_parent = MakeNativeParent();
+ Widget* child = AttachPopupToNativeParent(native_parent);
+ child->Show();
+ EXPECT_TRUE(child->IsVisible());
+
+ WidgetChangeObserver child_observer(child);
+ [NSApp hide:nil];
+ child_observer.WaitForVisibleCounts(0, 1);
+ EXPECT_FALSE(child->IsVisible());
+
+ [native_parent makeKeyAndOrderFront:nil];
+ child_observer.WaitForVisibleCounts(1, 1);
+ EXPECT_TRUE(child->IsVisible());
+
+ [native_parent close];
+}
+
// Use Native APIs to query the tooltip text that would be shown once the
// tooltip delay had elapsed.
base::string16 TooltipTextForWidget(Widget* widget) {
« no previous file with comments | « ui/views/cocoa/widget_owner_nswindow_adapter.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698