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

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

Issue 231173004: [WebModal] Rename NativeWebContentsModalDialogManager to SingleWebContentsDialogManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: constrained window test Created 6 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/memory/weak_ptr.h" 5 #include "base/memory/weak_ptr.h"
6 #include "chrome/browser/platform_util.h" 6 #include "chrome/browser/platform_util.h"
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/search/search.h" 8 #include "chrome/browser/search/search.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_commands.h" 10 #include "chrome/browser/ui/browser_commands.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 ASSERT_TRUE(web_contents_modal_dialog_manager != NULL); 151 ASSERT_TRUE(web_contents_modal_dialog_manager != NULL);
152 WebContentsModalDialogManagerDelegate* modal_delegate = 152 WebContentsModalDialogManagerDelegate* modal_delegate =
153 web_contents_modal_dialog_manager->delegate(); 153 web_contents_modal_dialog_manager->delegate();
154 ASSERT_TRUE(modal_delegate != NULL); 154 ASSERT_TRUE(modal_delegate != NULL);
155 155
156 // Create a constrained dialog. It will attach itself to web_contents. 156 // Create a constrained dialog. It will attach itself to web_contents.
157 scoped_ptr<TestConstrainedDialog> test_dialog1(new TestConstrainedDialog); 157 scoped_ptr<TestConstrainedDialog> test_dialog1(new TestConstrainedDialog);
158 views::Widget* window1 = views::Widget::CreateWindowAsFramelessChild( 158 views::Widget* window1 = views::Widget::CreateWindowAsFramelessChild(
159 test_dialog1.get(), 159 test_dialog1.get(),
160 modal_delegate->GetWebContentsModalDialogHost()->GetHostView()); 160 modal_delegate->GetWebContentsModalDialogHost()->GetHostView());
161 web_contents_modal_dialog_manager->ShowDialog(window1->GetNativeView()); 161 web_contents_modal_dialog_manager->ShowModalDialog(window1->GetNativeView());
162 162
163 views::FocusManager* focus_manager = window1->GetFocusManager(); 163 views::FocusManager* focus_manager = window1->GetFocusManager();
164 ASSERT_TRUE(focus_manager); 164 ASSERT_TRUE(focus_manager);
165 165
166 // test_dialog1's text field should be focused. 166 // test_dialog1's text field should be focused.
167 EXPECT_EQ(test_dialog1->GetInitiallyFocusedView(), 167 EXPECT_EQ(test_dialog1->GetInitiallyFocusedView(),
168 focus_manager->GetFocusedView()); 168 focus_manager->GetFocusedView());
169 169
170 // Now create a second constrained dialog. This will also be attached to 170 // Now create a second constrained dialog. This will also be attached to
171 // web_contents, but will remain hidden since the test_dialog1 is still 171 // web_contents, but will remain hidden since the test_dialog1 is still
172 // showing. 172 // showing.
173 scoped_ptr<TestConstrainedDialog> test_dialog2(new TestConstrainedDialog); 173 scoped_ptr<TestConstrainedDialog> test_dialog2(new TestConstrainedDialog);
174 views::Widget* window2 = views::Widget::CreateWindowAsFramelessChild( 174 views::Widget* window2 = views::Widget::CreateWindowAsFramelessChild(
175 test_dialog2.get(), 175 test_dialog2.get(),
176 modal_delegate->GetWebContentsModalDialogHost()->GetHostView()); 176 modal_delegate->GetWebContentsModalDialogHost()->GetHostView());
177 web_contents_modal_dialog_manager->ShowDialog(window2->GetNativeView()); 177 web_contents_modal_dialog_manager->ShowModalDialog(window2->GetNativeView());
178 // Should be the same focus_manager. 178 // Should be the same focus_manager.
179 ASSERT_EQ(focus_manager, window2->GetFocusManager()); 179 ASSERT_EQ(focus_manager, window2->GetFocusManager());
180 180
181 // test_dialog1's text field should still be the view that has focus. 181 // test_dialog1's text field should still be the view that has focus.
182 EXPECT_EQ(test_dialog1->GetInitiallyFocusedView(), 182 EXPECT_EQ(test_dialog1->GetInitiallyFocusedView(),
183 focus_manager->GetFocusedView()); 183 focus_manager->GetFocusedView());
184 ASSERT_TRUE(web_contents_modal_dialog_manager->IsDialogActive()); 184 ASSERT_TRUE(web_contents_modal_dialog_manager->IsDialogActive());
185 185
186 // Now send a VKEY_RETURN to the browser. This should result in closing 186 // Now send a VKEY_RETURN to the browser. This should result in closing
187 // test_dialog1. 187 // test_dialog1.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 ASSERT_TRUE(web_contents_modal_dialog_manager != NULL); 240 ASSERT_TRUE(web_contents_modal_dialog_manager != NULL);
241 WebContentsModalDialogManagerDelegate* modal_delegate = 241 WebContentsModalDialogManagerDelegate* modal_delegate =
242 web_contents_modal_dialog_manager->delegate(); 242 web_contents_modal_dialog_manager->delegate();
243 ASSERT_TRUE(modal_delegate != NULL); 243 ASSERT_TRUE(modal_delegate != NULL);
244 244
245 // Create a constrained dialog. It will attach itself to web_contents. 245 // Create a constrained dialog. It will attach itself to web_contents.
246 scoped_ptr<TestConstrainedDialog> test_dialog(new TestConstrainedDialog); 246 scoped_ptr<TestConstrainedDialog> test_dialog(new TestConstrainedDialog);
247 views::Widget* window = views::Widget::CreateWindowAsFramelessChild( 247 views::Widget* window = views::Widget::CreateWindowAsFramelessChild(
248 test_dialog.get(), 248 test_dialog.get(),
249 modal_delegate->GetWebContentsModalDialogHost()->GetHostView()); 249 modal_delegate->GetWebContentsModalDialogHost()->GetHostView());
250 web_contents_modal_dialog_manager->ShowDialog(window->GetNativeView()); 250 web_contents_modal_dialog_manager->ShowModalDialog(window->GetNativeView());
251 251
252 bool closed = 252 bool closed =
253 browser()->tab_strip_model()->CloseWebContentsAt( 253 browser()->tab_strip_model()->CloseWebContentsAt(
254 browser()->tab_strip_model()->active_index(), 254 browser()->tab_strip_model()->active_index(),
255 TabStripModel::CLOSE_NONE); 255 TabStripModel::CLOSE_NONE);
256 EXPECT_TRUE(closed); 256 EXPECT_TRUE(closed);
257 content::RunAllPendingInMessageLoop(); 257 content::RunAllPendingInMessageLoop();
258 EXPECT_TRUE(test_dialog->done()); 258 EXPECT_TRUE(test_dialog->done());
259 } 259 }
260 260
(...skipping 14 matching lines...) Expand all
275 // Create a constrained dialog. It will attach itself to web_contents. 275 // Create a constrained dialog. It will attach itself to web_contents.
276 scoped_ptr<TestConstrainedDialog> test_dialog(new TestConstrainedDialog); 276 scoped_ptr<TestConstrainedDialog> test_dialog(new TestConstrainedDialog);
277 WebContentsModalDialogManager* web_contents_modal_dialog_manager = 277 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
278 WebContentsModalDialogManager::FromWebContents(web_contents); 278 WebContentsModalDialogManager::FromWebContents(web_contents);
279 WebContentsModalDialogManagerDelegate* modal_delegate = 279 WebContentsModalDialogManagerDelegate* modal_delegate =
280 web_contents_modal_dialog_manager->delegate(); 280 web_contents_modal_dialog_manager->delegate();
281 ASSERT_TRUE(modal_delegate != NULL); 281 ASSERT_TRUE(modal_delegate != NULL);
282 views::Widget* window = views::Widget::CreateWindowAsFramelessChild( 282 views::Widget* window = views::Widget::CreateWindowAsFramelessChild(
283 test_dialog.get(), 283 test_dialog.get(),
284 modal_delegate->GetWebContentsModalDialogHost()->GetHostView()); 284 modal_delegate->GetWebContentsModalDialogHost()->GetHostView());
285 web_contents_modal_dialog_manager->ShowDialog(window->GetNativeView()); 285 web_contents_modal_dialog_manager->ShowModalDialog(window->GetNativeView());
286 EXPECT_TRUE(window->IsVisible()); 286 EXPECT_TRUE(window->IsVisible());
287 287
288 // Open a new tab. The constrained window should hide itself. 288 // Open a new tab. The constrained window should hide itself.
289 browser()->tab_strip_model()->AppendWebContents( 289 browser()->tab_strip_model()->AppendWebContents(
290 content::WebContents::Create( 290 content::WebContents::Create(
291 content::WebContents::CreateParams(browser()->profile())), 291 content::WebContents::CreateParams(browser()->profile())),
292 true); 292 true);
293 EXPECT_FALSE(window->IsVisible()); 293 EXPECT_FALSE(window->IsVisible());
294 294
295 // Close the new tab. The constrained window should show itself again. 295 // Close the new tab. The constrained window should show itself again.
(...skipping 29 matching lines...) Expand all
325 // Create a constrained dialog. It will attach itself to web_contents. 325 // Create a constrained dialog. It will attach itself to web_contents.
326 scoped_ptr<TestConstrainedDialog> test_dialog(new TestConstrainedDialog); 326 scoped_ptr<TestConstrainedDialog> test_dialog(new TestConstrainedDialog);
327 WebContentsModalDialogManager* web_contents_modal_dialog_manager = 327 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
328 WebContentsModalDialogManager::FromWebContents(web_contents); 328 WebContentsModalDialogManager::FromWebContents(web_contents);
329 WebContentsModalDialogManagerDelegate* modal_delegate = 329 WebContentsModalDialogManagerDelegate* modal_delegate =
330 web_contents_modal_dialog_manager->delegate(); 330 web_contents_modal_dialog_manager->delegate();
331 ASSERT_TRUE(modal_delegate != NULL); 331 ASSERT_TRUE(modal_delegate != NULL);
332 views::Widget* window = views::Widget::CreateWindowAsFramelessChild( 332 views::Widget* window = views::Widget::CreateWindowAsFramelessChild(
333 test_dialog.get(), 333 test_dialog.get(),
334 modal_delegate->GetWebContentsModalDialogHost()->GetHostView()); 334 modal_delegate->GetWebContentsModalDialogHost()->GetHostView());
335 web_contents_modal_dialog_manager->ShowDialog(window->GetNativeView()); 335 web_contents_modal_dialog_manager->ShowModalDialog(window->GetNativeView());
336 EXPECT_TRUE(window->IsVisible()); 336 EXPECT_TRUE(window->IsVisible());
337 337
338 // Detach the web contents from the second browser's tab strip. 338 // Detach the web contents from the second browser's tab strip.
339 browser2->tab_strip_model()->DetachWebContentsAt( 339 browser2->tab_strip_model()->DetachWebContentsAt(
340 browser2->tab_strip_model()->GetIndexOfWebContents(web_contents)); 340 browser2->tab_strip_model()->GetIndexOfWebContents(web_contents));
341 341
342 // Append the web contents to the first browser. 342 // Append the web contents to the first browser.
343 browser()->tab_strip_model()->AppendWebContents(web_contents, true); 343 browser()->tab_strip_model()->AppendWebContents(web_contents, true);
344 EXPECT_TRUE(window->IsVisible()); 344 EXPECT_TRUE(window->IsVisible());
345 345
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 // Escape is not processed as accelerator before it's sent to web contents. 462 // Escape is not processed as accelerator before it's sent to web contents.
463 EXPECT_FALSE(observer.widget_closed()); 463 EXPECT_FALSE(observer.widget_closed());
464 464
465 content::RunAllPendingInMessageLoop(); 465 content::RunAllPendingInMessageLoop();
466 466
467 // Escape is processed as accelerator after it's sent to web contents. 467 // Escape is processed as accelerator after it's sent to web contents.
468 EXPECT_TRUE(observer.widget_closed()); 468 EXPECT_TRUE(observer.widget_closed());
469 } 469 }
470 470
471 #endif // defined(OS_WIN) || (defined(USE_AURA) && defined(USE_X11)) 471 #endif // defined(OS_WIN) || (defined(USE_AURA) && defined(USE_X11))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698