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

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

Issue 2865793002: Remove the BackspaceGoesBack flag. (Closed)
Patch Set: merge to trunk Created 3 years, 6 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
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 <memory> 5 #include <memory>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/test/scoped_feature_list.h"
9 #include "build/build_config.h" 8 #include "build/build_config.h"
10 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_commands.h" 10 #include "chrome/browser/ui/browser_commands.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" 11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 #include "chrome/browser/ui/views/tab_modal_confirm_dialog_views.h" 12 #include "chrome/browser/ui/views/tab_modal_confirm_dialog_views.h"
14 #include "chrome/common/chrome_features.h"
15 #include "chrome/common/url_constants.h"
16 #include "chrome/test/base/in_process_browser_test.h" 13 #include "chrome/test/base/in_process_browser_test.h"
17 #include "chrome/test/base/interactive_test_utils.h" 14 #include "chrome/test/base/interactive_test_utils.h"
18 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
19 #include "components/constrained_window/constrained_window_views.h" 16 #include "components/constrained_window/constrained_window_views.h"
20 #include "components/web_modal/web_contents_modal_dialog_host.h" 17 #include "components/web_modal/web_contents_modal_dialog_host.h"
21 #include "components/web_modal/web_contents_modal_dialog_manager.h" 18 #include "components/web_modal/web_contents_modal_dialog_manager.h"
22 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" 19 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h"
23 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
24 #include "content/public/test/browser_test_utils.h" 21 #include "content/public/test/browser_test_utils.h"
25 #include "ui/base/accelerators/accelerator.h" 22 #include "ui/base/accelerators/accelerator.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 chrome::CloseWindow(browser()); 160 chrome::CloseWindow(browser());
164 content::RunAllPendingInMessageLoop(); 161 content::RunAllPendingInMessageLoop();
165 EXPECT_TRUE(dialog->GetWidget()->IsVisible()); 162 EXPECT_TRUE(dialog->GetWidget()->IsVisible());
166 163
167 // Close the dialog's browser window. 164 // Close the dialog's browser window.
168 chrome::CloseTab(browser2); 165 chrome::CloseTab(browser2);
169 content::RunAllPendingInMessageLoop(); 166 content::RunAllPendingInMessageLoop();
170 EXPECT_EQ(NULL, dialog->GetWidget()); 167 EXPECT_EQ(NULL, dialog->GetWidget());
171 } 168 }
172 169
173 // Tests that the web contents navigates when backspace is pressed.
174 IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, NavigationOnBackspace) {
175 content::WebContents* web_contents =
176 browser()->tab_strip_model()->GetActiveWebContents();
177 content::WaitForLoadStop(web_contents);
178 const GURL original_url = web_contents->GetURL();
179 EXPECT_NE(GURL(chrome::kChromeUIVersionURL), original_url);
180 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIVersionURL));
181 content::WaitForLoadStop(web_contents);
182 EXPECT_EQ(GURL(chrome::kChromeUIVersionURL), web_contents->GetURL());
183
184 std::unique_ptr<TestDialog> dialog = ShowModalDialog(web_contents);
185
186 views::Widget* widget = dialog->GetWidget();
187
188 EXPECT_TRUE(widget->IsVisible());
189 EXPECT_EQ(dialog->GetContentsView(),
190 widget->GetFocusManager()->GetFocusedView());
191
192 // Pressing backspace should not navigate back and close the dialog
193 // with the Finch flag disabled.
194 EXPECT_TRUE(chrome::CanGoBack(browser()));
195 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_BACK,
196 false, false, false, false));
197 content::RunAllPendingInMessageLoop();
198 content::WaitForLoadStop(web_contents);
199
200 EXPECT_EQ(widget, dialog->GetWidget());
201 EXPECT_EQ(GURL(chrome::kChromeUIVersionURL), web_contents->GetURL());
202
203 // Pressing backspace should navigate back and close the dialog with the
204 // Finch flag enabled.
205 base::test::ScopedFeatureList scoped_feature_list;
206 scoped_feature_list.InitAndEnableFeature(features::kBackspaceGoesBackFeature);
207
208 EXPECT_TRUE(chrome::CanGoBack(browser()));
209 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_BACK,
210 false, false, false, false));
211 content::RunAllPendingInMessageLoop();
212 content::WaitForLoadStop(web_contents);
213
214 EXPECT_EQ(nullptr, dialog->GetWidget());
215 EXPECT_EQ(original_url, web_contents->GetURL());
216 }
217
218 // Tests that the dialog closes when the escape key is pressed. 170 // Tests that the dialog closes when the escape key is pressed.
219 IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, ClosesOnEscape) { 171 IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, ClosesOnEscape) {
220 #if defined(OS_WIN) 172 #if defined(OS_WIN)
221 // TODO(msw): The widget is not made NULL on XP. http://crbug.com/177482 173 // TODO(msw): The widget is not made NULL on XP. http://crbug.com/177482
222 if (base::win::GetVersion() < base::win::VERSION_VISTA) 174 if (base::win::GetVersion() < base::win::VERSION_VISTA)
223 return; 175 return;
224 #endif 176 #endif
225 177
226 std::unique_ptr<TestDialog> dialog = 178 std::unique_ptr<TestDialog> dialog =
227 ShowModalDialog(browser()->tab_strip_model()->GetActiveWebContents()); 179 ShowModalDialog(browser()->tab_strip_model()->GetActiveWebContents());
228 EXPECT_TRUE(dialog->GetWidget()->IsVisible()); 180 EXPECT_TRUE(dialog->GetWidget()->IsVisible());
229 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_ESCAPE, 181 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_ESCAPE,
230 false, false, false, false)); 182 false, false, false, false));
231 content::RunAllPendingInMessageLoop(); 183 content::RunAllPendingInMessageLoop();
232 EXPECT_EQ(NULL, dialog->GetWidget()); 184 EXPECT_EQ(NULL, dialog->GetWidget());
233 } 185 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_command_controller.cc ('k') | chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698