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

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

Issue 1169063002: MacViews: Retain non-Widget parent NSWindows, as well as the anchor NSView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 5434e93eb189a8e939491bed0623bcd3821d9288..05fd824eb7d962aac7ec1b33380c6e16d14b2536 100644
--- a/ui/views/widget/native_widget_mac_unittest.mm
+++ b/ui/views/widget/native_widget_mac_unittest.mm
@@ -409,12 +409,16 @@ TEST_F(NativeWidgetMacTest, AccessibilityIntegration) {
TEST_F(NativeWidgetMacTest, NonWidgetParent) {
NSWindow* native_parent = MakeNativeParent();
+ base::scoped_nsobject<NSView> anchor_view(
+ [[NSView alloc] initWithFrame:[[native_parent contentView] bounds]]);
+ [[native_parent contentView] addSubview:anchor_view];
+
// Note: Don't use WidgetTest::CreateChildPlatformWidget because that makes
// windows of TYPE_CONTROL which are automatically made visible. But still
// mark it as a child to test window positioning.
Widget* child = new Widget;
Widget::InitParams init_params;
- init_params.parent = [native_parent contentView];
+ init_params.parent = anchor_view;
init_params.child = true;
child->Init(init_params);
@@ -444,11 +448,17 @@ TEST_F(NativeWidgetMacTest, NonWidgetParent) {
EXPECT_EQ(native_parent, [child->GetNativeWindow() parentWindow]);
// Child should be positioned on screen relative to the parent, but note we
- // positioned the parent in Cooca coordinates, so we need to convert.
+ // positioned the parent in Cocoa coordinates, so we need to convert.
gfx::Point parent_origin = gfx::ScreenRectFromNSRect(ParentRect()).origin();
EXPECT_EQ(gfx::Rect(150, parent_origin.y() + 50, 200, 100),
child->GetWindowBoundsInScreen());
+ // Removing the anchor_view from its view hierarchy is permitted. This should
+ // not break the relationship between the two windows.
+ [anchor_view removeFromSuperview];
+ anchor_view.reset();
+ EXPECT_EQ(native_parent, bridged_native_widget->parent()->GetNSWindow());
+
// Closing the parent should close and destroy the child.
EXPECT_FALSE(child_observer.widget_closed());
[native_parent close];
« 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