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

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

Issue 1992003002: Re-add backspace-goes-back as a default disabled finch trial (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix assert in test 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
184 views::Widget* widget = dialog->GetWidget();
185
186 EXPECT_TRUE(widget->IsVisible());
187 EXPECT_EQ(dialog->GetContentsView(),
188 widget->GetFocusManager()->GetFocusedView());
189
190 // Pressing backspace should not navigate back and close the dialog.
Peter Kasting 2016/05/19 09:28:30 Nit: "... with the Finch flag disabled"?
ojan 2016/05/20 16:33:48 done
191 EXPECT_TRUE(chrome::CanGoBack(browser()));
192 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_BACK,
193 false, false, false, false));
194 content::RunAllPendingInMessageLoop();
195 content::WaitForLoadStop(web_contents);
196
197 EXPECT_EQ(widget, dialog->GetWidget());
198 EXPECT_EQ(GURL(chrome::kChromeUIVersionURL), web_contents->GetURL());
199
200 base::FeatureList::ClearInstanceForTesting();
201 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
202 feature_list->InitializeFromCommandLine("BackspaceGoesBack", std::string());
203 base::FeatureList::SetInstance(std::move(feature_list));
204
205 // Pressing backspace should navigate back and close the dialog with the
Peter Kasting 2016/05/19 09:28:30 Nit: I'd move this comment up above the previous b
ojan 2016/05/20 16:33:48 done
206 // finch flag enabled.
207 EXPECT_TRUE(chrome::CanGoBack(browser()));
208 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_BACK,
209 false, false, false, false));
210 content::RunAllPendingInMessageLoop();
211 content::WaitForLoadStop(web_contents);
212
213 EXPECT_EQ(NULL, dialog->GetWidget());
Peter Kasting 2016/05/19 09:28:30 Nit: nullptr
ojan 2016/05/20 16:33:48 done
214 EXPECT_EQ(original_url, web_contents->GetURL());
215 }
216
171 // Tests that the dialog closes when the escape key is pressed. 217 // Tests that the dialog closes when the escape key is pressed.
172 IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, ClosesOnEscape) { 218 IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, ClosesOnEscape) {
173 #if defined(OS_WIN) 219 #if defined(OS_WIN)
174 // TODO(msw): The widget is not made NULL on XP. http://crbug.com/177482 220 // TODO(msw): The widget is not made NULL on XP. http://crbug.com/177482
175 if (base::win::GetVersion() < base::win::VERSION_VISTA) 221 if (base::win::GetVersion() < base::win::VERSION_VISTA)
176 return; 222 return;
177 #endif 223 #endif
178 224
179 std::unique_ptr<TestDialog> dialog = 225 std::unique_ptr<TestDialog> dialog =
180 ShowModalDialog(browser()->tab_strip_model()->GetActiveWebContents()); 226 ShowModalDialog(browser()->tab_strip_model()->GetActiveWebContents());
181 EXPECT_TRUE(dialog->GetWidget()->IsVisible()); 227 EXPECT_TRUE(dialog->GetWidget()->IsVisible());
182 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_ESCAPE, 228 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_ESCAPE,
183 false, false, false, false)); 229 false, false, false, false));
184 content::RunAllPendingInMessageLoop(); 230 content::RunAllPendingInMessageLoop();
185 EXPECT_EQ(NULL, dialog->GetWidget()); 231 EXPECT_EQ(NULL, dialog->GetWidget());
186 } 232 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698