| 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 ui::test::TestWebDialogDelegate* delegate = | 93 #endif |
| 94 new ui::test::TestWebDialogDelegate( | 94 IN_PROC_BROWSER_TEST_F(WebDialogBrowserTest, MAYBE_SizeWindow) { |
| 95 GURL(chrome::kChromeUIChromeURLsURL)); | 95 ui::test::TestWebDialogDelegate delegate( |
| 96 delegate->set_size(kInitialWidth, kInitialHeight); | 96 (GURL(chrome::kChromeUIChromeURLsURL))); |
| 97 delegate.set_size(kInitialWidth, kInitialHeight); |
| 97 | 98 |
| 98 TestWebDialogView* view = | 99 TestWebDialogView* view = |
| 99 new TestWebDialogView(browser()->profile(), delegate); | 100 new TestWebDialogView(browser()->profile(), &delegate); |
| 100 WebContents* web_contents = | 101 WebContents* web_contents = |
| 101 browser()->tab_strip_model()->GetActiveWebContents(); | 102 browser()->tab_strip_model()->GetActiveWebContents(); |
| 102 ASSERT_TRUE(web_contents != NULL); | 103 ASSERT_TRUE(web_contents != NULL); |
| 103 views::Widget::CreateWindowWithParent( | 104 views::Widget::CreateWindowWithParent(view, web_contents->GetNativeView()); |
| 104 view, web_contents->GetTopLevelNativeWindow()); | |
| 105 view->GetWidget()->Show(); | 105 view->GetWidget()->Show(); |
| 106 | 106 |
| 107 // TestWebDialogView should quit current message loop on size change. | 107 // TestWebDialogView should quit current message loop on size change. |
| 108 view->set_should_quit_on_size_change(true); | 108 view->set_should_quit_on_size_change(true); |
| 109 | 109 |
| 110 gfx::Rect bounds = view->GetWidget()->GetClientAreaBoundsInScreen(); | 110 gfx::Rect bounds = view->GetWidget()->GetClientAreaBoundsInScreen(); |
| 111 | 111 |
| 112 gfx::Rect set_bounds = bounds; | 112 gfx::Rect set_bounds = bounds; |
| 113 gfx::Rect actual_bounds, rwhv_bounds; | 113 gfx::Rect actual_bounds, rwhv_bounds; |
| 114 | 114 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 138 EXPECT_EQ(set_bounds, actual_bounds); | 138 EXPECT_EQ(set_bounds, actual_bounds); |
| 139 | 139 |
| 140 rwhv_bounds = | 140 rwhv_bounds = |
| 141 view->web_contents()->GetRenderWidgetHostView()->GetViewBounds(); | 141 view->web_contents()->GetRenderWidgetHostView()->GetViewBounds(); |
| 142 EXPECT_LT(0, rwhv_bounds.width()); | 142 EXPECT_LT(0, rwhv_bounds.width()); |
| 143 EXPECT_LT(0, rwhv_bounds.height()); | 143 EXPECT_LT(0, rwhv_bounds.height()); |
| 144 EXPECT_GE(set_bounds.width(), rwhv_bounds.width()); | 144 EXPECT_GE(set_bounds.width(), rwhv_bounds.width()); |
| 145 EXPECT_GE(set_bounds.height(), rwhv_bounds.height()); | 145 EXPECT_GE(set_bounds.height(), rwhv_bounds.height()); |
| 146 | 146 |
| 147 // Get very small. | 147 // Get very small. |
| 148 gfx::Size min_size = view->GetWidget()->GetMinimumSize(); | 148 const gfx::Size min_size = view->GetWidget()->GetMinimumSize(); |
| 149 EXPECT_LT(0, min_size.width()); |
| 150 EXPECT_LT(0, min_size.height()); |
| 151 |
| 149 set_bounds.set_size(min_size); | 152 set_bounds.set_size(min_size); |
| 150 | 153 |
| 151 view->MoveContents(web_contents, set_bounds); | 154 view->MoveContents(web_contents, set_bounds); |
| 152 content::RunMessageLoop(); // TestWebDialogView will quit. | 155 content::RunMessageLoop(); // TestWebDialogView will quit. |
| 153 actual_bounds = view->GetWidget()->GetClientAreaBoundsInScreen(); | 156 actual_bounds = view->GetWidget()->GetClientAreaBoundsInScreen(); |
| 154 EXPECT_EQ(set_bounds, actual_bounds); | 157 EXPECT_EQ(set_bounds, actual_bounds); |
| 155 | 158 |
| 156 rwhv_bounds = | 159 rwhv_bounds = |
| 157 view->web_contents()->GetRenderWidgetHostView()->GetViewBounds(); | 160 view->web_contents()->GetRenderWidgetHostView()->GetViewBounds(); |
| 158 EXPECT_LT(0, rwhv_bounds.width()); | 161 EXPECT_LT(0, rwhv_bounds.width()); |
| 159 EXPECT_LT(0, rwhv_bounds.height()); | 162 EXPECT_LT(0, rwhv_bounds.height()); |
| 160 EXPECT_GE(set_bounds.width(), rwhv_bounds.width()); | 163 EXPECT_GE(set_bounds.width(), rwhv_bounds.width()); |
| 161 EXPECT_GE(set_bounds.height(), rwhv_bounds.height()); | 164 EXPECT_GE(set_bounds.height(), rwhv_bounds.height()); |
| 162 | 165 |
| 163 // Check to make sure we can't get to 0x0 | 166 // Check to make sure we can't get to 0x0. First expand beyond the minimum |
| 167 // size that was set above so that TestWebDialogView has a change to pick up. |
| 168 set_bounds.set_height(250); |
| 169 view->MoveContents(web_contents, set_bounds); |
| 170 content::RunMessageLoop(); // TestWebDialogView will quit. |
| 171 actual_bounds = view->GetWidget()->GetClientAreaBoundsInScreen(); |
| 172 EXPECT_EQ(set_bounds, actual_bounds); |
| 173 |
| 174 // Now verify that attempts to re-size to 0x0 enforces the minimum size. |
| 164 set_bounds.set_width(0); | 175 set_bounds.set_width(0); |
| 165 set_bounds.set_height(0); | 176 set_bounds.set_height(0); |
| 166 | 177 |
| 167 view->MoveContents(web_contents, set_bounds); | 178 view->MoveContents(web_contents, set_bounds); |
| 168 content::RunMessageLoop(); // TestWebDialogView will quit. | 179 content::RunMessageLoop(); // TestWebDialogView will quit. |
| 169 actual_bounds = view->GetWidget()->GetClientAreaBoundsInScreen(); | 180 actual_bounds = view->GetWidget()->GetClientAreaBoundsInScreen(); |
| 170 EXPECT_LT(0, actual_bounds.width()); | 181 EXPECT_EQ(min_size, actual_bounds.size()); |
| 171 EXPECT_LT(0, actual_bounds.height()); | 182 |
| 183 // And that the render view is also non-zero. |
| 184 rwhv_bounds = |
| 185 view->web_contents()->GetRenderWidgetHostView()->GetViewBounds(); |
| 186 EXPECT_LT(0, rwhv_bounds.width()); |
| 187 EXPECT_LT(0, rwhv_bounds.height()); |
| 188 |
| 189 view->GetWidget()->CloseNow(); |
| 172 } | 190 } |
| OLD | NEW |