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 "build/build_config.h" | 9 #include "build/build_config.h" |
9 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_commands.h" | 11 #include "chrome/browser/ui/browser_commands.h" |
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
12 #include "chrome/browser/ui/views/tab_modal_confirm_dialog_views.h" | 13 #include "chrome/browser/ui/views/tab_modal_confirm_dialog_views.h" |
| 14 #include "chrome/common/chrome_features.h" |
13 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
14 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
15 #include "chrome/test/base/interactive_test_utils.h" | 17 #include "chrome/test/base/interactive_test_utils.h" |
16 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
17 #include "components/constrained_window/constrained_window_views.h" | 19 #include "components/constrained_window/constrained_window_views.h" |
18 #include "components/web_modal/web_contents_modal_dialog_host.h" | 20 #include "components/web_modal/web_contents_modal_dialog_host.h" |
19 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 21 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
20 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" | 22 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" |
21 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
22 #include "content/public/test/browser_test_utils.h" | 24 #include "content/public/test/browser_test_utils.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_BACK, | 195 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_BACK, |
194 false, false, false, false)); | 196 false, false, false, false)); |
195 content::RunAllPendingInMessageLoop(); | 197 content::RunAllPendingInMessageLoop(); |
196 content::WaitForLoadStop(web_contents); | 198 content::WaitForLoadStop(web_contents); |
197 | 199 |
198 EXPECT_EQ(widget, dialog->GetWidget()); | 200 EXPECT_EQ(widget, dialog->GetWidget()); |
199 EXPECT_EQ(GURL(chrome::kChromeUIVersionURL), web_contents->GetURL()); | 201 EXPECT_EQ(GURL(chrome::kChromeUIVersionURL), web_contents->GetURL()); |
200 | 202 |
201 // Pressing backspace should navigate back and close the dialog with the | 203 // Pressing backspace should navigate back and close the dialog with the |
202 // Finch flag enabled. | 204 // Finch flag enabled. |
203 base::FeatureList::ClearInstanceForTesting(); | 205 base::test::ScopedFeatureList scoped_feature_list; |
204 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); | 206 scoped_feature_list.InitAndEnableFeature(features::kBackspaceGoesBackFeature); |
205 feature_list->InitializeFromCommandLine("BackspaceGoesBack", std::string()); | |
206 base::FeatureList::SetInstance(std::move(feature_list)); | |
207 | 207 |
208 EXPECT_TRUE(chrome::CanGoBack(browser())); | 208 EXPECT_TRUE(chrome::CanGoBack(browser())); |
209 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_BACK, | 209 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_BACK, |
210 false, false, false, false)); | 210 false, false, false, false)); |
211 content::RunAllPendingInMessageLoop(); | 211 content::RunAllPendingInMessageLoop(); |
212 content::WaitForLoadStop(web_contents); | 212 content::WaitForLoadStop(web_contents); |
213 | 213 |
214 EXPECT_EQ(nullptr, dialog->GetWidget()); | 214 EXPECT_EQ(nullptr, dialog->GetWidget()); |
215 EXPECT_EQ(original_url, web_contents->GetURL()); | 215 EXPECT_EQ(original_url, web_contents->GetURL()); |
216 } | 216 } |
217 | 217 |
218 // Tests that the dialog closes when the escape key is pressed. | 218 // Tests that the dialog closes when the escape key is pressed. |
219 IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, ClosesOnEscape) { | 219 IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, ClosesOnEscape) { |
220 #if defined(OS_WIN) | 220 #if defined(OS_WIN) |
221 // TODO(msw): The widget is not made NULL on XP. http://crbug.com/177482 | 221 // TODO(msw): The widget is not made NULL on XP. http://crbug.com/177482 |
222 if (base::win::GetVersion() < base::win::VERSION_VISTA) | 222 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
223 return; | 223 return; |
224 #endif | 224 #endif |
225 | 225 |
226 std::unique_ptr<TestDialog> dialog = | 226 std::unique_ptr<TestDialog> dialog = |
227 ShowModalDialog(browser()->tab_strip_model()->GetActiveWebContents()); | 227 ShowModalDialog(browser()->tab_strip_model()->GetActiveWebContents()); |
228 EXPECT_TRUE(dialog->GetWidget()->IsVisible()); | 228 EXPECT_TRUE(dialog->GetWidget()->IsVisible()); |
229 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_ESCAPE, | 229 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_ESCAPE, |
230 false, false, false, false)); | 230 false, false, false, false)); |
231 content::RunAllPendingInMessageLoop(); | 231 content::RunAllPendingInMessageLoop(); |
232 EXPECT_EQ(NULL, dialog->GetWidget()); | 232 EXPECT_EQ(NULL, dialog->GetWidget()); |
233 } | 233 } |
OLD | NEW |