OLD | NEW |
---|---|
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" | 8 #include "base/test/scoped_feature_list.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 chrome::CloseWindow(browser()); | 163 chrome::CloseWindow(browser()); |
164 content::RunAllPendingInMessageLoop(); | 164 content::RunAllPendingInMessageLoop(); |
165 EXPECT_TRUE(dialog->GetWidget()->IsVisible()); | 165 EXPECT_TRUE(dialog->GetWidget()->IsVisible()); |
166 | 166 |
167 // Close the dialog's browser window. | 167 // Close the dialog's browser window. |
168 chrome::CloseTab(browser2); | 168 chrome::CloseTab(browser2); |
169 content::RunAllPendingInMessageLoop(); | 169 content::RunAllPendingInMessageLoop(); |
170 EXPECT_EQ(NULL, dialog->GetWidget()); | 170 EXPECT_EQ(NULL, dialog->GetWidget()); |
171 } | 171 } |
172 | 172 |
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); | |
Peter Kasting
2017/05/06 04:56:13
Looks like we can remove some #includes if we remo
ojan
2017/05/10 18:07:07
Done
| |
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. | 173 // Tests that the dialog closes when the escape key is pressed. |
219 IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, ClosesOnEscape) { | 174 IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, ClosesOnEscape) { |
220 #if defined(OS_WIN) | 175 #if defined(OS_WIN) |
221 // TODO(msw): The widget is not made NULL on XP. http://crbug.com/177482 | 176 // TODO(msw): The widget is not made NULL on XP. http://crbug.com/177482 |
222 if (base::win::GetVersion() < base::win::VERSION_VISTA) | 177 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
223 return; | 178 return; |
224 #endif | 179 #endif |
225 | 180 |
226 std::unique_ptr<TestDialog> dialog = | 181 std::unique_ptr<TestDialog> dialog = |
227 ShowModalDialog(browser()->tab_strip_model()->GetActiveWebContents()); | 182 ShowModalDialog(browser()->tab_strip_model()->GetActiveWebContents()); |
228 EXPECT_TRUE(dialog->GetWidget()->IsVisible()); | 183 EXPECT_TRUE(dialog->GetWidget()->IsVisible()); |
229 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_ESCAPE, | 184 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_ESCAPE, |
230 false, false, false, false)); | 185 false, false, false, false)); |
231 content::RunAllPendingInMessageLoop(); | 186 content::RunAllPendingInMessageLoop(); |
232 EXPECT_EQ(NULL, dialog->GetWidget()); | 187 EXPECT_EQ(NULL, dialog->GetWidget()); |
233 } | 188 } |
OLD | NEW |