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

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

Issue 1772153002: Fix BridgedNativeWidgetTest test crashes after r379525 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also fix NativeWidgetMacTest.NonWidgetParent Created 4 years, 9 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/bridged_native_widget_unittest.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 635de898aed2db3dda2792532f0ebdaa202bde43..e62394eeb9495cae774ef8a765be0f63bfeb9679 100644
--- a/ui/views/widget/native_widget_mac_unittest.mm
+++ b/ui/views/widget/native_widget_mac_unittest.mm
@@ -555,12 +555,12 @@ TEST_F(NativeWidgetMacTest, NonWidgetParent) {
[[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.
+ // windows of TYPE_CONTROL which need a parent Widget to obtain the focus
+ // manager.
Widget* child = new Widget;
Widget::InitParams init_params;
init_params.parent = anchor_view;
- init_params.child = true;
+ init_params.type = Widget::InitParams::TYPE_POPUP;
child->Init(init_params);
TestWidgetObserver child_observer(child);
@@ -577,7 +577,8 @@ TEST_F(NativeWidgetMacTest, NonWidgetParent) {
NativeWidgetMac::GetBridgeForNativeWindow(child->GetNativeWindow());
EXPECT_EQ(native_parent, bridged_native_widget->parent()->GetNSWindow());
- child->SetBounds(gfx::Rect(50, 50, 200, 100));
+ const gfx::Rect child_bounds(50, 50, 200, 100);
+ child->SetBounds(child_bounds);
EXPECT_FALSE(child->IsVisible());
EXPECT_EQ(0u, [[native_parent childWindows] count]);
@@ -588,11 +589,9 @@ TEST_F(NativeWidgetMacTest, NonWidgetParent) {
[[native_parent childWindows] objectAtIndex:0]);
EXPECT_EQ(native_parent, [child->GetNativeWindow() parentWindow]);
- // Child should be positioned on screen relative to the parent, but note we
- // 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());
+ // Only non-toplevel Widgets are positioned relative to the parent, so the
+ // 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
// not break the relationship between the two windows.
« no previous file with comments | « ui/views/cocoa/bridged_native_widget_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698