OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 DISALLOW_COPY_AND_ASSIGN(TestWebDialogView); | 77 DISALLOW_COPY_AND_ASSIGN(TestWebDialogView); |
78 }; | 78 }; |
79 | 79 |
80 } // namespace | 80 } // namespace |
81 | 81 |
82 class WebDialogBrowserTest : public InProcessBrowserTest { | 82 class WebDialogBrowserTest : public InProcessBrowserTest { |
83 public: | 83 public: |
84 WebDialogBrowserTest() {} | 84 WebDialogBrowserTest() {} |
85 }; | 85 }; |
86 | 86 |
87 // http://code.google.com/p/chromium/issues/detail?id=52602 | 87 // Windows has some issues resizing windows. An off by one problem, and a |
88 // Windows has some issues resizing windows- an off by one problem, | 88 // minimum size that seems too big. See http://crbug.com/52602. |
89 // and a minimum size that seems too big. This file isn't included in | 89 #if defined(OS_WIN) |
90 // Mac builds yet. On Chrome OS, this test doesn't apply since ChromeOS | 90 #define MAYBE_SizeWindow DISABLED_SizeWindow |
91 // doesn't allow resizing of windows. | 91 #else |
92 IN_PROC_BROWSER_TEST_F(WebDialogBrowserTest, DISABLED_SizeWindow) { | 92 #define MAYBE_SizeWindow SizeWindow |
| 93 #endif |
| 94 IN_PROC_BROWSER_TEST_F(WebDialogBrowserTest, MAYBE_SizeWindow) { |
93 ui::test::TestWebDialogDelegate* delegate = | 95 ui::test::TestWebDialogDelegate* delegate = |
94 new ui::test::TestWebDialogDelegate( | 96 new ui::test::TestWebDialogDelegate( |
95 GURL(chrome::kChromeUIChromeURLsURL)); | 97 GURL(chrome::kChromeUIChromeURLsURL)); |
96 delegate->set_size(kInitialWidth, kInitialHeight); | 98 delegate->set_size(kInitialWidth, kInitialHeight); |
97 | 99 |
98 TestWebDialogView* view = | 100 TestWebDialogView* view = |
99 new TestWebDialogView(browser()->profile(), delegate); | 101 new TestWebDialogView(browser()->profile(), delegate); |
100 WebContents* web_contents = | 102 WebContents* web_contents = |
101 browser()->tab_strip_model()->GetActiveWebContents(); | 103 browser()->tab_strip_model()->GetActiveWebContents(); |
102 ASSERT_TRUE(web_contents != NULL); | 104 ASSERT_TRUE(web_contents != NULL); |
103 views::Widget::CreateWindowWithParent( | 105 views::Widget::CreateWindowWithParent(view, web_contents->GetNativeView()); |
104 view, web_contents->GetTopLevelNativeWindow()); | |
105 view->GetWidget()->Show(); | 106 view->GetWidget()->Show(); |
106 | 107 |
107 // TestWebDialogView should quit current message loop on size change. | 108 // TestWebDialogView should quit current message loop on size change. |
108 view->set_should_quit_on_size_change(true); | 109 view->set_should_quit_on_size_change(true); |
109 | 110 |
110 gfx::Rect bounds = view->GetWidget()->GetClientAreaBoundsInScreen(); | 111 gfx::Rect bounds = view->GetWidget()->GetClientAreaBoundsInScreen(); |
111 | 112 |
112 gfx::Rect set_bounds = bounds; | 113 gfx::Rect set_bounds = bounds; |
113 gfx::Rect actual_bounds, rwhv_bounds; | 114 gfx::Rect actual_bounds, rwhv_bounds; |
114 | 115 |
(...skipping 23 matching lines...) Expand all Loading... |
138 EXPECT_EQ(set_bounds, actual_bounds); | 139 EXPECT_EQ(set_bounds, actual_bounds); |
139 | 140 |
140 rwhv_bounds = | 141 rwhv_bounds = |
141 view->web_contents()->GetRenderWidgetHostView()->GetViewBounds(); | 142 view->web_contents()->GetRenderWidgetHostView()->GetViewBounds(); |
142 EXPECT_LT(0, rwhv_bounds.width()); | 143 EXPECT_LT(0, rwhv_bounds.width()); |
143 EXPECT_LT(0, rwhv_bounds.height()); | 144 EXPECT_LT(0, rwhv_bounds.height()); |
144 EXPECT_GE(set_bounds.width(), rwhv_bounds.width()); | 145 EXPECT_GE(set_bounds.width(), rwhv_bounds.width()); |
145 EXPECT_GE(set_bounds.height(), rwhv_bounds.height()); | 146 EXPECT_GE(set_bounds.height(), rwhv_bounds.height()); |
146 | 147 |
147 // Get very small. | 148 // Get very small. |
148 gfx::Size min_size = view->GetWidget()->GetMinimumSize(); | 149 const gfx::Size min_size = view->GetWidget()->GetMinimumSize(); |
| 150 EXPECT_LT(0, min_size.width()); |
| 151 EXPECT_LT(0, min_size.height()); |
| 152 |
149 set_bounds.set_size(min_size); | 153 set_bounds.set_size(min_size); |
150 | 154 |
151 view->MoveContents(web_contents, set_bounds); | 155 view->MoveContents(web_contents, set_bounds); |
152 content::RunMessageLoop(); // TestWebDialogView will quit. | 156 content::RunMessageLoop(); // TestWebDialogView will quit. |
153 actual_bounds = view->GetWidget()->GetClientAreaBoundsInScreen(); | 157 actual_bounds = view->GetWidget()->GetClientAreaBoundsInScreen(); |
154 EXPECT_EQ(set_bounds, actual_bounds); | 158 EXPECT_EQ(set_bounds, actual_bounds); |
155 | 159 |
156 rwhv_bounds = | 160 rwhv_bounds = |
157 view->web_contents()->GetRenderWidgetHostView()->GetViewBounds(); | 161 view->web_contents()->GetRenderWidgetHostView()->GetViewBounds(); |
158 EXPECT_LT(0, rwhv_bounds.width()); | 162 EXPECT_LT(0, rwhv_bounds.width()); |
159 EXPECT_LT(0, rwhv_bounds.height()); | 163 EXPECT_LT(0, rwhv_bounds.height()); |
160 EXPECT_GE(set_bounds.width(), rwhv_bounds.width()); | 164 EXPECT_GE(set_bounds.width(), rwhv_bounds.width()); |
161 EXPECT_GE(set_bounds.height(), rwhv_bounds.height()); | 165 EXPECT_GE(set_bounds.height(), rwhv_bounds.height()); |
162 | 166 |
163 // Check to make sure we can't get to 0x0 | 167 // Check to make sure we can't get to 0x0. First expand beyond the minimum |
| 168 // size that was set above so that TestWebDialogView has a change to pick up. |
| 169 set_bounds.set_height(250); |
| 170 view->MoveContents(web_contents, set_bounds); |
| 171 content::RunMessageLoop(); // TestWebDialogView will quit. |
| 172 actual_bounds = view->GetWidget()->GetClientAreaBoundsInScreen(); |
| 173 EXPECT_EQ(set_bounds, actual_bounds); |
| 174 |
| 175 // Now verify that attempts to re-size to 0x0 enforces the minimum size. |
164 set_bounds.set_width(0); | 176 set_bounds.set_width(0); |
165 set_bounds.set_height(0); | 177 set_bounds.set_height(0); |
166 | 178 |
167 view->MoveContents(web_contents, set_bounds); | 179 view->MoveContents(web_contents, set_bounds); |
168 content::RunMessageLoop(); // TestWebDialogView will quit. | 180 content::RunMessageLoop(); // TestWebDialogView will quit. |
169 actual_bounds = view->GetWidget()->GetClientAreaBoundsInScreen(); | 181 actual_bounds = view->GetWidget()->GetClientAreaBoundsInScreen(); |
170 EXPECT_LT(0, actual_bounds.width()); | 182 EXPECT_EQ(min_size, actual_bounds.size()); |
171 EXPECT_LT(0, actual_bounds.height()); | 183 |
| 184 // And that the render view is also non-zero. |
| 185 rwhv_bounds = |
| 186 view->web_contents()->GetRenderWidgetHostView()->GetViewBounds(); |
| 187 EXPECT_LT(0, rwhv_bounds.width()); |
| 188 EXPECT_LT(0, rwhv_bounds.height()); |
172 } | 189 } |
OLD | NEW |