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 "chrome/browser/ui/browser_command_controller.h" | 5 #include "chrome/browser/ui/browser_command_controller.h" |
6 | 6 |
7 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/browser_commands.h" | 9 #include "chrome/browser/ui/browser_commands.h" |
10 #include "chrome/browser/ui/tab_modal_confirm_dialog_browsertest.h" | 10 #include "chrome/browser/ui/tab_modal_confirm_dialog_browsertest.h" |
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
12 #include "chrome/test/base/in_process_browser_test.h" | 12 #include "chrome/test/base/in_process_browser_test.h" |
| 13 #include "content/public/test/test_utils.h" |
13 | 14 |
14 typedef InProcessBrowserTest BrowserCommandControllerBrowserTest; | 15 typedef InProcessBrowserTest BrowserCommandControllerBrowserTest; |
15 | 16 |
16 // Verify that showing a constrained window disables find. | 17 // Verify that showing a constrained window disables find. |
17 IN_PROC_BROWSER_TEST_F(BrowserCommandControllerBrowserTest, DisableFind) { | 18 IN_PROC_BROWSER_TEST_F(BrowserCommandControllerBrowserTest, DisableFind) { |
18 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FIND)); | 19 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FIND)); |
19 | 20 |
20 // Showing constrained window should disable find. | 21 // Showing constrained window should disable find. |
21 content::WebContents* web_contents = | 22 content::WebContents* web_contents = |
22 browser()->tab_strip_model()->GetActiveWebContents(); | 23 browser()->tab_strip_model()->GetActiveWebContents(); |
23 MockTabModalConfirmDialogDelegate* delegate = | 24 MockTabModalConfirmDialogDelegate* delegate = |
24 new MockTabModalConfirmDialogDelegate(web_contents, NULL); | 25 new MockTabModalConfirmDialogDelegate(web_contents, NULL); |
25 TabModalConfirmDialog::Create(delegate, web_contents); | 26 TabModalConfirmDialog::Create(delegate, web_contents); |
26 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FIND)); | 27 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FIND)); |
27 | 28 |
28 // Switching to a new (unblocked) tab should reenable it. | 29 // Switching to a new (unblocked) tab should reenable it. |
29 AddBlankTabAndShow(browser()); | 30 AddBlankTabAndShow(browser()); |
30 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FIND)); | 31 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FIND)); |
31 | 32 |
32 // Switching back to the blocked tab should disable it again. | 33 // Switching back to the blocked tab should disable it again. |
33 browser()->tab_strip_model()->ActivateTabAt(0, false); | 34 browser()->tab_strip_model()->ActivateTabAt(0, false); |
34 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FIND)); | 35 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FIND)); |
35 | 36 |
36 // Closing the constrained window should reenable it. | 37 // Closing the constrained window should reenable it. |
37 delegate->Cancel(); | 38 delegate->Cancel(); |
| 39 content::RunAllPendingInMessageLoop(); |
38 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FIND)); | 40 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FIND)); |
39 } | 41 } |
OLD | NEW |