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

Side by Side Diff: ui/views/widget/desktop_aura/desktop_screen_position_client_unittest.cc

Issue 21504003: Don't assume that widgets of TYPE_CONTROL are parented to the RootWindow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix review issues. Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_screen_position_client.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
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));
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);
73 gfx::Rect expected_bounds(expected_origin, gfx::Size(500, 400));
74 gfx::Rect actual_bounds(widget3.GetWindowBoundsInScreen());
75 EXPECT_EQ(expected_bounds.ToString(), actual_bounds.ToString());
76 }
77
37 } // namespace views 78 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_screen_position_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698