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

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

Issue 23815006: [Cleanup] rename WebContentsModalDialogManager::IsShowingDialog() to IsDialogActive() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 3 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 test_dialog2.get(), 170 test_dialog2.get(),
171 web_contents->GetView()->GetNativeView(), 171 web_contents->GetView()->GetNativeView(),
172 modal_delegate->GetWebContentsModalDialogHost()->GetHostView()); 172 modal_delegate->GetWebContentsModalDialogHost()->GetHostView());
173 web_contents_modal_dialog_manager->ShowDialog(window2->GetNativeView()); 173 web_contents_modal_dialog_manager->ShowDialog(window2->GetNativeView());
174 // Should be the same focus_manager. 174 // Should be the same focus_manager.
175 ASSERT_EQ(focus_manager, window2->GetFocusManager()); 175 ASSERT_EQ(focus_manager, window2->GetFocusManager());
176 176
177 // test_dialog1's text field should still be the view that has focus. 177 // test_dialog1's text field should still be the view that has focus.
178 EXPECT_EQ(test_dialog1->GetInitiallyFocusedView(), 178 EXPECT_EQ(test_dialog1->GetInitiallyFocusedView(),
179 focus_manager->GetFocusedView()); 179 focus_manager->GetFocusedView());
180 ASSERT_TRUE(web_contents_modal_dialog_manager->IsShowingDialog()); 180 ASSERT_TRUE(web_contents_modal_dialog_manager->IsDialogActive());
181 181
182 // Now send a VKEY_RETURN to the browser. This should result in closing 182 // Now send a VKEY_RETURN to the browser. This should result in closing
183 // test_dialog1. 183 // test_dialog1.
184 EXPECT_TRUE(focus_manager->ProcessAccelerator( 184 EXPECT_TRUE(focus_manager->ProcessAccelerator(
185 ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE))); 185 ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)));
186 content::RunAllPendingInMessageLoop(); 186 content::RunAllPendingInMessageLoop();
187 187
188 EXPECT_TRUE(test_dialog1->done()); 188 EXPECT_TRUE(test_dialog1->done());
189 EXPECT_FALSE(test_dialog2->done()); 189 EXPECT_FALSE(test_dialog2->done());
190 EXPECT_TRUE(web_contents_modal_dialog_manager->IsShowingDialog()); 190 EXPECT_TRUE(web_contents_modal_dialog_manager->IsDialogActive());
191 191
192 // test_dialog2 will be shown. Focus should be on test_dialog2's text field. 192 // test_dialog2 will be shown. Focus should be on test_dialog2's text field.
193 EXPECT_EQ(test_dialog2->GetInitiallyFocusedView(), 193 EXPECT_EQ(test_dialog2->GetInitiallyFocusedView(),
194 focus_manager->GetFocusedView()); 194 focus_manager->GetFocusedView());
195 195
196 int tab_with_constrained_window = 196 int tab_with_constrained_window =
197 browser()->tab_strip_model()->active_index(); 197 browser()->tab_strip_model()->active_index();
198 198
199 // Create a new tab. 199 // Create a new tab.
200 chrome::NewTab(browser()); 200 chrome::NewTab(browser());
201 201
202 // The constrained dialog should no longer be selected. 202 // The constrained dialog should no longer be selected.
203 EXPECT_NE(test_dialog2->GetInitiallyFocusedView(), 203 EXPECT_NE(test_dialog2->GetInitiallyFocusedView(),
204 focus_manager->GetFocusedView()); 204 focus_manager->GetFocusedView());
205 205
206 browser()->tab_strip_model()->ActivateTabAt(tab_with_constrained_window, 206 browser()->tab_strip_model()->ActivateTabAt(tab_with_constrained_window,
207 false); 207 false);
208 208
209 // Activating the previous tab should bring focus to the constrained window. 209 // Activating the previous tab should bring focus to the constrained window.
210 EXPECT_EQ(test_dialog2->GetInitiallyFocusedView(), 210 EXPECT_EQ(test_dialog2->GetInitiallyFocusedView(),
211 focus_manager->GetFocusedView()); 211 focus_manager->GetFocusedView());
212 212
213 // Send another VKEY_RETURN, closing test_dialog2 213 // Send another VKEY_RETURN, closing test_dialog2
214 EXPECT_TRUE(focus_manager->ProcessAccelerator( 214 EXPECT_TRUE(focus_manager->ProcessAccelerator(
215 ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE))); 215 ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)));
216 content::RunAllPendingInMessageLoop(); 216 content::RunAllPendingInMessageLoop();
217 EXPECT_TRUE(test_dialog2->done()); 217 EXPECT_TRUE(test_dialog2->done());
218 EXPECT_FALSE(web_contents_modal_dialog_manager->IsShowingDialog()); 218 EXPECT_FALSE(web_contents_modal_dialog_manager->IsDialogActive());
219 } 219 }
220 220
221 // Tests that the constrained window is closed properly when its tab is 221 // Tests that the constrained window is closed properly when its tab is
222 // closed. 222 // closed.
223 IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, TabCloseTest) { 223 IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, TabCloseTest) {
224 content::WebContents* web_contents = 224 content::WebContents* web_contents =
225 browser()->tab_strip_model()->GetActiveWebContents(); 225 browser()->tab_strip_model()->GetActiveWebContents();
226 ASSERT_TRUE(web_contents != NULL); 226 ASSERT_TRUE(web_contents != NULL);
227 WebContentsModalDialogManager* web_contents_modal_dialog_manager = 227 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
228 WebContentsModalDialogManager::FromWebContents(web_contents); 228 WebContentsModalDialogManager::FromWebContents(web_contents);
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 // Escape is not processed as accelerator before it's sent to web contents. 447 // Escape is not processed as accelerator before it's sent to web contents.
448 EXPECT_FALSE(observer.widget_closed()); 448 EXPECT_FALSE(observer.widget_closed());
449 449
450 content::RunAllPendingInMessageLoop(); 450 content::RunAllPendingInMessageLoop();
451 451
452 // Escape is processed as accelerator after it's sent to web contents. 452 // Escape is processed as accelerator after it's sent to web contents.
453 EXPECT_TRUE(observer.widget_closed()); 453 EXPECT_TRUE(observer.widget_closed());
454 } 454 }
455 455
456 #endif // defined(OS_WIN) || (defined(USE_AURA) && defined(USE_X11)) 456 #endif // defined(OS_WIN) || (defined(USE_AURA) && defined(USE_X11))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698