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

Side by Side Diff: chrome/browser/ui/views/html_dialog_view_browsertest.cc

Issue 10171006: Convert more users away from DOMView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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
OLDNEW
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/file_path.h" 7 #include "base/file_path.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 test::TestHtmlDialogUIDelegate* delegate = new test::TestHtmlDialogUIDelegate( 107 test::TestHtmlDialogUIDelegate* delegate = new test::TestHtmlDialogUIDelegate(
108 GURL(chrome::kChromeUIChromeURLsURL)); 108 GURL(chrome::kChromeUIChromeURLsURL));
109 delegate->set_size(kInitialWidth, kInitialHeight); 109 delegate->set_size(kInitialWidth, kInitialHeight);
110 110
111 TestHtmlDialogView* html_view = 111 TestHtmlDialogView* html_view =
112 new TestHtmlDialogView(browser()->profile(), browser(), delegate); 112 new TestHtmlDialogView(browser()->profile(), browser(), delegate);
113 WebContents* web_contents = browser()->GetSelectedWebContents(); 113 WebContents* web_contents = browser()->GetSelectedWebContents();
114 ASSERT_TRUE(web_contents != NULL); 114 ASSERT_TRUE(web_contents != NULL);
115 views::Widget::CreateWindowWithParent( 115 views::Widget::CreateWindowWithParent(
116 html_view, web_contents->GetView()->GetTopLevelNativeWindow()); 116 html_view, web_contents->GetView()->GetTopLevelNativeWindow());
117 html_view->InitDialog();
118 html_view->GetWidget()->Show(); 117 html_view->GetWidget()->Show();
119 118
120 // TestHtmlDialogView should quit current message loop on size change. 119 // TestHtmlDialogView should quit current message loop on size change.
121 html_view->set_should_quit_on_size_change(true); 120 html_view->set_should_quit_on_size_change(true);
122 121
123 gfx::Rect bounds = html_view->GetWidget()->GetClientAreaScreenBounds(); 122 gfx::Rect bounds = html_view->GetWidget()->GetClientAreaScreenBounds();
124 123
125 gfx::Rect set_bounds = bounds; 124 gfx::Rect set_bounds = bounds;
126 gfx::Rect actual_bounds, rwhv_bounds; 125 gfx::Rect actual_bounds, rwhv_bounds;
127 126
128 // Bigger than the default in both dimensions. 127 // Bigger than the default in both dimensions.
129 set_bounds.set_width(400); 128 set_bounds.set_width(400);
130 set_bounds.set_height(300); 129 set_bounds.set_height(300);
131 130
132 html_view->MoveContents(web_contents, set_bounds); 131 html_view->MoveContents(web_contents, set_bounds);
133 ui_test_utils::RunMessageLoop(); // TestHtmlDialogView will quit. 132 ui_test_utils::RunMessageLoop(); // TestHtmlDialogView will quit.
134 actual_bounds = html_view->GetWidget()->GetClientAreaScreenBounds(); 133 actual_bounds = html_view->GetWidget()->GetClientAreaScreenBounds();
135 EXPECT_EQ(set_bounds, actual_bounds); 134 EXPECT_EQ(set_bounds, actual_bounds);
136 135
137 rwhv_bounds = html_view->dom_contents()->web_contents()-> 136 rwhv_bounds =
138 GetRenderWidgetHostView()->GetViewBounds(); 137 html_view->web_contents()->GetRenderWidgetHostView()->GetViewBounds();
139 EXPECT_LT(0, rwhv_bounds.width()); 138 EXPECT_LT(0, rwhv_bounds.width());
140 EXPECT_LT(0, rwhv_bounds.height()); 139 EXPECT_LT(0, rwhv_bounds.height());
141 EXPECT_GE(set_bounds.width(), rwhv_bounds.width()); 140 EXPECT_GE(set_bounds.width(), rwhv_bounds.width());
142 EXPECT_GE(set_bounds.height(), rwhv_bounds.height()); 141 EXPECT_GE(set_bounds.height(), rwhv_bounds.height());
143 142
144 // Larger in one dimension and smaller in the other. 143 // Larger in one dimension and smaller in the other.
145 set_bounds.set_width(550); 144 set_bounds.set_width(550);
146 set_bounds.set_height(250); 145 set_bounds.set_height(250);
147 146
148 html_view->MoveContents(web_contents, set_bounds); 147 html_view->MoveContents(web_contents, set_bounds);
149 ui_test_utils::RunMessageLoop(); // TestHtmlDialogView will quit. 148 ui_test_utils::RunMessageLoop(); // TestHtmlDialogView will quit.
150 actual_bounds = html_view->GetWidget()->GetClientAreaScreenBounds(); 149 actual_bounds = html_view->GetWidget()->GetClientAreaScreenBounds();
151 EXPECT_EQ(set_bounds, actual_bounds); 150 EXPECT_EQ(set_bounds, actual_bounds);
152 151
153 rwhv_bounds = html_view->dom_contents()->web_contents()-> 152 rwhv_bounds =
154 GetRenderWidgetHostView()->GetViewBounds(); 153 html_view->web_contents()->GetRenderWidgetHostView()->GetViewBounds();
155 EXPECT_LT(0, rwhv_bounds.width()); 154 EXPECT_LT(0, rwhv_bounds.width());
156 EXPECT_LT(0, rwhv_bounds.height()); 155 EXPECT_LT(0, rwhv_bounds.height());
157 EXPECT_GE(set_bounds.width(), rwhv_bounds.width()); 156 EXPECT_GE(set_bounds.width(), rwhv_bounds.width());
158 EXPECT_GE(set_bounds.height(), rwhv_bounds.height()); 157 EXPECT_GE(set_bounds.height(), rwhv_bounds.height());
159 158
160 // Get very small. 159 // Get very small.
161 gfx::Size min_size = html_view->GetWidget()->GetMinimumSize(); 160 gfx::Size min_size = html_view->GetWidget()->GetMinimumSize();
162 set_bounds.set_size(min_size); 161 set_bounds.set_size(min_size);
163 162
164 html_view->MoveContents(web_contents, set_bounds); 163 html_view->MoveContents(web_contents, set_bounds);
165 ui_test_utils::RunMessageLoop(); // TestHtmlDialogView will quit. 164 ui_test_utils::RunMessageLoop(); // TestHtmlDialogView will quit.
166 actual_bounds = html_view->GetWidget()->GetClientAreaScreenBounds(); 165 actual_bounds = html_view->GetWidget()->GetClientAreaScreenBounds();
167 EXPECT_EQ(set_bounds, actual_bounds); 166 EXPECT_EQ(set_bounds, actual_bounds);
168 167
169 rwhv_bounds = html_view->dom_contents()->web_contents()-> 168 rwhv_bounds =
170 GetRenderWidgetHostView()->GetViewBounds(); 169 html_view->web_contents()->GetRenderWidgetHostView()->GetViewBounds();
171 EXPECT_LT(0, rwhv_bounds.width()); 170 EXPECT_LT(0, rwhv_bounds.width());
172 EXPECT_LT(0, rwhv_bounds.height()); 171 EXPECT_LT(0, rwhv_bounds.height());
173 EXPECT_GE(set_bounds.width(), rwhv_bounds.width()); 172 EXPECT_GE(set_bounds.width(), rwhv_bounds.width());
174 EXPECT_GE(set_bounds.height(), rwhv_bounds.height()); 173 EXPECT_GE(set_bounds.height(), rwhv_bounds.height());
175 174
176 // Check to make sure we can't get to 0x0 175 // Check to make sure we can't get to 0x0
177 set_bounds.set_width(0); 176 set_bounds.set_width(0);
178 set_bounds.set_height(0); 177 set_bounds.set_height(0);
179 178
180 html_view->MoveContents(web_contents, set_bounds); 179 html_view->MoveContents(web_contents, set_bounds);
(...skipping 19 matching lines...) Expand all
200 html_view->InitDialog(); 199 html_view->InitDialog();
201 html_view->GetWidget()->Show(); 200 html_view->GetWidget()->Show();
202 201
203 // TestHtmlDialogView::OnTabMainFrameRender() will Quit(). 202 // TestHtmlDialogView::OnTabMainFrameRender() will Quit().
204 MessageLoopForUI::current()->Run(); 203 MessageLoopForUI::current()->Run();
205 204
206 EXPECT_TRUE(html_view->painted()); 205 EXPECT_TRUE(html_view->painted());
207 206
208 html_view->GetWidget()->Close(); 207 html_view->GetWidget()->Close();
209 } 208 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/html_dialog_view.cc ('k') | chrome/browser/ui/views/keyboard_overlay_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698