| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 // Finch flag enabled. | 204 // Finch flag enabled. |
| 205 base::test::ScopedFeatureList scoped_feature_list; | 205 base::test::ScopedFeatureList scoped_feature_list; |
| 206 scoped_feature_list.InitAndEnableFeature(features::kBackspaceGoesBackFeature); | 206 scoped_feature_list.InitAndEnableFeature(features::kBackspaceGoesBackFeature); |
| 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 // When Widget::Close is called, a task is posted that will destroy the | |
| 215 // widget. Here the widget is closed when the navigation commits. Load stop | |
| 216 // may occur right after the commit, before the widget is destroyed. | |
| 217 // Execute pending tasks to account for this. | |
| 218 base::RunLoop().RunUntilIdle(); | |
| 219 | |
| 220 EXPECT_EQ(nullptr, dialog->GetWidget()); | 214 EXPECT_EQ(nullptr, dialog->GetWidget()); |
| 221 EXPECT_EQ(original_url, web_contents->GetURL()); | 215 EXPECT_EQ(original_url, web_contents->GetURL()); |
| 222 } | 216 } |
| 223 | 217 |
| 224 // Tests that the dialog closes when the escape key is pressed. | 218 // Tests that the dialog closes when the escape key is pressed. |
| 225 IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, ClosesOnEscape) { | 219 IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, ClosesOnEscape) { |
| 226 #if defined(OS_WIN) | 220 #if defined(OS_WIN) |
| 227 // 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 |
| 228 if (base::win::GetVersion() < base::win::VERSION_VISTA) | 222 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
| 229 return; | 223 return; |
| 230 #endif | 224 #endif |
| 231 | 225 |
| 232 std::unique_ptr<TestDialog> dialog = | 226 std::unique_ptr<TestDialog> dialog = |
| 233 ShowModalDialog(browser()->tab_strip_model()->GetActiveWebContents()); | 227 ShowModalDialog(browser()->tab_strip_model()->GetActiveWebContents()); |
| 234 EXPECT_TRUE(dialog->GetWidget()->IsVisible()); | 228 EXPECT_TRUE(dialog->GetWidget()->IsVisible()); |
| 235 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_ESCAPE, | 229 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_ESCAPE, |
| 236 false, false, false, false)); | 230 false, false, false, false)); |
| 237 content::RunAllPendingInMessageLoop(); | 231 content::RunAllPendingInMessageLoop(); |
| 238 EXPECT_EQ(NULL, dialog->GetWidget()); | 232 EXPECT_EQ(NULL, dialog->GetWidget()); |
| 239 } | 233 } |
| OLD | NEW |