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

Side by Side Diff: ui/views/widget/desktop_widget_unittest.cc

Issue 927233003: MacViews: Fix positioning of top-level Widgets with parents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20150129-MacViews-Bringup5
Patch Set: Added comment to BridgedNativeWidget Created 5 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/views_test_base.h" 5 #include "ui/views/test/views_test_base.h"
6 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 6 #include "ui/views/test/widget_test.h"
7 #include "ui/views/widget/widget.h" 7 #include "ui/views/widget/widget.h"
8 #include "ui/views/window/dialog_delegate.h" 8 #include "ui/views/window/dialog_delegate.h"
9 9
10 namespace views { 10 namespace views {
11 11
12 typedef ViewsTestBase DesktopScreenPositionClientTest; 12 typedef ViewsTestBase DesktopScreenPositionClientTest;
13 13
14 // Verifies setting the bounds of a dialog parented to a Widget with a 14 // Verifies setting the bounds of a dialog parented to a Widget with a
15 // DesktopNativeWidgetAura is positioned correctly. 15 // PlatformDesktopNativeWidget is positioned correctly.
16 TEST_F(DesktopScreenPositionClientTest, PositionDialog) { 16 TEST_F(DesktopScreenPositionClientTest, PositionDialog) {
17 Widget parent_widget; 17 Widget parent_widget;
18 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); 18 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
19 params.bounds = gfx::Rect(10, 11, 200, 200); 19 params.bounds = gfx::Rect(10, 11, 200, 200);
20 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 20 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
21 params.native_widget = new DesktopNativeWidgetAura(&parent_widget); 21 params.native_widget = new PlatformDesktopNativeWidget(&parent_widget);
22 parent_widget.Init(params); 22 parent_widget.Init(params);
23 23
24 // Owned by |dialog|. 24 // Owned by |dialog|.
25 DialogDelegateView* dialog_delegate_view = new DialogDelegateView; 25 DialogDelegateView* dialog_delegate_view = new DialogDelegateView;
26 // Owned by |parent_widget|. 26 // Owned by |parent_widget|.
27 Widget* dialog = DialogDelegate::CreateDialogWidget( 27 Widget* dialog = DialogDelegate::CreateDialogWidget(
28 dialog_delegate_view, NULL, parent_widget.GetNativeView()); 28 dialog_delegate_view, NULL, parent_widget.GetNativeView());
29 dialog->SetBounds(gfx::Rect(11, 12, 200, 200)); 29 dialog->SetBounds(gfx::Rect(11, 12, 200, 200));
30 EXPECT_EQ("11,12", dialog->GetWindowBoundsInScreen().origin().ToString()); 30 EXPECT_EQ("11,12", dialog->GetWindowBoundsInScreen().origin().ToString());
31 } 31 }
(...skipping 13 matching lines...) Expand all
45 widget2.set_frame_type(Widget::FRAME_TYPE_FORCE_CUSTOM); 45 widget2.set_frame_type(Widget::FRAME_TYPE_FORCE_CUSTOM);
46 widget3.set_frame_type(Widget::FRAME_TYPE_FORCE_CUSTOM); 46 widget3.set_frame_type(Widget::FRAME_TYPE_FORCE_CUSTOM);
47 47
48 // Create 3 windows. A root window, an arbitrary window parented to the root 48 // Create 3 windows. A root window, an arbitrary window parented to the root
49 // but NOT positioned at (0,0) relative to the root, and then a third window 49 // but NOT positioned at (0,0) relative to the root, and then a third window
50 // parented to the second, also not positioned at (0,0). 50 // parented to the second, also not positioned at (0,0).
51 Widget::InitParams params1 = 51 Widget::InitParams params1 =
52 CreateParams(Widget::InitParams::TYPE_WINDOW); 52 CreateParams(Widget::InitParams::TYPE_WINDOW);
53 params1.bounds = gfx::Rect(origin, gfx::Size(700, 600)); 53 params1.bounds = gfx::Rect(origin, gfx::Size(700, 600));
54 params1.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 54 params1.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
55 params1.native_widget = new DesktopNativeWidgetAura(&widget1); 55 params1.native_widget = new PlatformDesktopNativeWidget(&widget1);
56 widget1.Init(params1); 56 widget1.Init(params1);
57 57
58 Widget::InitParams params2 = 58 Widget::InitParams params2 =
59 CreateParams(Widget::InitParams::TYPE_WINDOW); 59 CreateParams(Widget::InitParams::TYPE_WINDOW);
60 params2.bounds = gfx::Rect(origin, gfx::Size(600, 500)); 60 params2.bounds = gfx::Rect(origin, gfx::Size(600, 500));
61 params2.parent = widget1.GetNativeView(); 61 params2.parent = widget1.GetNativeView();
62 params2.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 62 params2.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
63 params2.child = true; 63 params2.child = true;
64 widget2.Init(params2); 64 widget2.Init(params2);
65 65
66 Widget::InitParams params3 = 66 Widget::InitParams params3 =
67 CreateParams(Widget::InitParams::TYPE_CONTROL); 67 CreateParams(Widget::InitParams::TYPE_CONTROL);
68 params3.parent = widget2.GetNativeView(); 68 params3.parent = widget2.GetNativeView();
69 params3.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 69 params3.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
70 params3.child = true; 70 params3.child = true;
71 params3.bounds = gfx::Rect(origin, gfx::Size(500, 400)); 71 params3.bounds = gfx::Rect(origin, gfx::Size(500, 400));
72 widget3.Init(params3); 72 widget3.Init(params3);
73 73
74 // The origin of the 3rd window should be the sum of all parent origins. 74 // The origin of the 3rd window should be the sum of all parent origins.
75 gfx::Point expected_origin(origin.x() * 3, origin.y() * 3); 75 gfx::Point expected_origin(origin.x() * 3, origin.y() * 3);
76 gfx::Rect expected_bounds(expected_origin, gfx::Size(500, 400)); 76 gfx::Rect expected_bounds(expected_origin, gfx::Size(500, 400));
77 gfx::Rect actual_bounds(widget3.GetWindowBoundsInScreen()); 77 gfx::Rect actual_bounds(widget3.GetWindowBoundsInScreen());
78 EXPECT_EQ(expected_bounds.ToString(), actual_bounds.ToString()); 78 EXPECT_EQ(expected_bounds.ToString(), actual_bounds.ToString());
79 } 79 }
80 80
81 } // namespace views 81 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_screen_position_client_unittest.cc ('k') | ui/views/widget/native_widget_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698