OLD | NEW |
---|---|
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/widget/desktop_aura/desktop_native_widget_aura.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 { |
(...skipping 16 matching lines...) Expand all Loading... | |
27 DialogDelegateView* dialog_delegate_view = new DialogDelegateView; | 27 DialogDelegateView* dialog_delegate_view = new DialogDelegateView; |
28 // Owned by |parent_widget|. | 28 // Owned by |parent_widget|. |
29 Widget* dialog = DialogDelegate::CreateDialogWidget( | 29 Widget* dialog = DialogDelegate::CreateDialogWidget( |
30 dialog_delegate_view, | 30 dialog_delegate_view, |
31 NULL, | 31 NULL, |
32 parent_widget.GetNativeView()); | 32 parent_widget.GetNativeView()); |
33 dialog->SetBounds(gfx::Rect(11, 12, 200, 200)); | 33 dialog->SetBounds(gfx::Rect(11, 12, 200, 200)); |
34 EXPECT_EQ("11,12", dialog->GetWindowBoundsInScreen().origin().ToString()); | 34 EXPECT_EQ("11,12", dialog->GetWindowBoundsInScreen().origin().ToString()); |
35 } | 35 } |
36 | 36 |
37 // Verifies that setting the bounds of a control parented to something other | |
38 // than the root window is positioned correctly. | |
39 TEST_F(DesktopScreenPositionClientTest, PositionControlWithNonRootParent) { | |
40 Widget widget1; | |
41 Widget widget2; | |
42 Widget widget3; | |
43 gfx::Point origin = gfx::Point(16, 16); | |
44 | |
45 // Create 3 windows. A root window, an arbitrary window parented to the root | |
46 // but NOT positioned at (0,0) relative to the root, and then a third window | |
47 // parented to the second, also not positioned at (0,0). | |
48 Widget::InitParams params1 = | |
49 CreateParams(Widget::InitParams::TYPE_WINDOW); | |
50 params1.bounds = gfx::Rect(origin, gfx::Size(700, 600)); | |
51 params1.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | |
52 params1.native_widget = new DesktopNativeWidgetAura(&widget1); | |
53 widget1.Init(params1); | |
54 | |
55 Widget::InitParams params2 = | |
56 CreateParams(Widget::InitParams::TYPE_WINDOW); | |
57 params2.bounds = gfx::Rect(origin, gfx::Size(600,500)); | |
sky
2013/08/05 21:39:15
nit: space after comma (same on 68 and 73).
| |
58 params2.parent = widget1.GetNativeView(); | |
59 params2.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | |
60 params2.child = true; | |
61 widget2.Init(params2); | |
62 | |
63 Widget::InitParams params3 = | |
64 CreateParams(Widget::InitParams::TYPE_CONTROL); | |
65 params3.parent = widget2.GetNativeView(); | |
66 params3.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | |
67 params3.child = true; | |
68 params3.bounds = gfx::Rect(origin, gfx::Size(500,400)); | |
69 widget3.Init(params3); | |
70 | |
71 // The origin of the 3rd window should be the sum of all parent origins. | |
72 gfx::Point expected_origin(origin.x()*3, origin.y()*3); | |
sky
2013/08/05 21:39:15
nit: space before/after '*'.
| |
73 gfx::Rect expected_bounds(expected_origin, gfx::Size(500,400)); | |
74 gfx::Rect actual_bounds(widget3.GetWindowBoundsInScreen()); | |
75 EXPECT_EQ(actual_bounds.ToString(), expected_bounds.ToString()); | |
sky
2013/08/05 21:39:15
Assertion order is expected, actual.
| |
76 } | |
77 | |
37 } // namespace views | 78 } // namespace views |
OLD | NEW |