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