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

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

Issue 1922993002: Remove the backspace/shift+backspace navigating the page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review Created 4 years, 7 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 "build/build_config.h" 8 #include "build/build_config.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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 chrome::CloseWindow(browser()); 161 chrome::CloseWindow(browser());
162 content::RunAllPendingInMessageLoop(); 162 content::RunAllPendingInMessageLoop();
163 EXPECT_TRUE(dialog->GetWidget()->IsVisible()); 163 EXPECT_TRUE(dialog->GetWidget()->IsVisible());
164 164
165 // Close the dialog's browser window. 165 // Close the dialog's browser window.
166 chrome::CloseTab(browser2); 166 chrome::CloseTab(browser2);
167 content::RunAllPendingInMessageLoop(); 167 content::RunAllPendingInMessageLoop();
168 EXPECT_EQ(NULL, dialog->GetWidget()); 168 EXPECT_EQ(NULL, dialog->GetWidget());
169 } 169 }
170 170
171 // Tests that the web contents navigates when backspace is pressed.
172 IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, NavigationOnBackspace) {
173 content::WebContents* web_contents =
174 browser()->tab_strip_model()->GetActiveWebContents();
175 content::WaitForLoadStop(web_contents);
176 const GURL original_url = web_contents->GetURL();
177 EXPECT_NE(GURL(chrome::kChromeUIVersionURL), original_url);
178 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIVersionURL));
179 content::WaitForLoadStop(web_contents);
180 EXPECT_EQ(GURL(chrome::kChromeUIVersionURL), web_contents->GetURL());
181
182 std::unique_ptr<TestDialog> dialog = ShowModalDialog(web_contents);
183 EXPECT_TRUE(dialog->GetWidget()->IsVisible());
184 EXPECT_EQ(dialog->GetContentsView(),
185 dialog->GetWidget()->GetFocusManager()->GetFocusedView());
186
187 // Pressing backspace should navigate back and close the dialog.
188 EXPECT_TRUE(chrome::CanGoBack(browser()));
189 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_BACK,
190 false, false, false, false));
191 content::RunAllPendingInMessageLoop();
192 content::WaitForLoadStop(web_contents);
193 EXPECT_EQ(NULL, dialog->GetWidget());
194 EXPECT_EQ(original_url, web_contents->GetURL());
195 }
196
197 // Tests that the dialog closes when the escape key is pressed. 171 // Tests that the dialog closes when the escape key is pressed.
198 IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, ClosesOnEscape) { 172 IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, ClosesOnEscape) {
199 #if defined(OS_WIN) 173 #if defined(OS_WIN)
200 // TODO(msw): The widget is not made NULL on XP. http://crbug.com/177482 174 // TODO(msw): The widget is not made NULL on XP. http://crbug.com/177482
201 if (base::win::GetVersion() < base::win::VERSION_VISTA) 175 if (base::win::GetVersion() < base::win::VERSION_VISTA)
202 return; 176 return;
203 #endif 177 #endif
204 178
205 std::unique_ptr<TestDialog> dialog = 179 std::unique_ptr<TestDialog> dialog =
206 ShowModalDialog(browser()->tab_strip_model()->GetActiveWebContents()); 180 ShowModalDialog(browser()->tab_strip_model()->GetActiveWebContents());
207 EXPECT_TRUE(dialog->GetWidget()->IsVisible()); 181 EXPECT_TRUE(dialog->GetWidget()->IsVisible());
208 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_ESCAPE, 182 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_ESCAPE,
209 false, false, false, false)); 183 false, false, false, false));
210 content::RunAllPendingInMessageLoop(); 184 content::RunAllPendingInMessageLoop();
211 EXPECT_EQ(NULL, dialog->GetWidget()); 185 EXPECT_EQ(NULL, dialog->GetWidget());
212 } 186 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/accelerator_table.cc ('k') | chrome/browser/ui/views/frame/browser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698