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/extensions/active_tab_permission_granter.h" | 5 #include "chrome/browser/extensions/active_tab_permission_granter.h" |
6 #include "chrome/browser/extensions/browser_action_test_util.h" | 6 #include "chrome/browser/extensions/browser_action_test_util.h" |
7 #include "chrome/browser/extensions/extension_action.h" | 7 #include "chrome/browser/extensions/extension_action.h" |
8 #include "chrome/browser/extensions/extension_action_manager.h" | 8 #include "chrome/browser/extensions/extension_action_manager.h" |
9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
10 #include "chrome/browser/extensions/tab_helper.h" | 10 #include "chrome/browser/extensions/tab_helper.h" |
11 #include "chrome/browser/sessions/session_tab_helper.h" | 11 #include "chrome/browser/sessions/session_tab_helper.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_tabstrip.h" | |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
15 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
17 #include "chrome/test/base/interactive_test_utils.h" | 16 #include "chrome/test/base/interactive_test_utils.h" |
18 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
19 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
20 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
21 #include "content/public/test/browser_test_utils.h" | 20 #include "content/public/test/browser_test_utils.h" |
22 | 21 |
23 using content::WebContents; | 22 using content::WebContents; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // the page action icon. | 127 // the page action icon. |
129 ResultCatcher catcher; | 128 ResultCatcher catcher; |
130 ui_test_utils::NavigateToURL(browser(), | 129 ui_test_utils::NavigateToURL(browser(), |
131 test_server()->GetURL("files/extensions/test_file.txt")); | 130 test_server()->GetURL("files/extensions/test_file.txt")); |
132 ASSERT_TRUE(catcher.GetNextResult()); | 131 ASSERT_TRUE(catcher.GetNextResult()); |
133 } | 132 } |
134 | 133 |
135 // Make sure it appears and is the right one. | 134 // Make sure it appears and is the right one. |
136 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); | 135 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); |
137 int tab_id = SessionTabHelper::FromWebContents( | 136 int tab_id = SessionTabHelper::FromWebContents( |
138 chrome::GetActiveWebContents(browser()))->session_id().id(); | 137 browser()->tab_strip_model()->GetActiveWebContents())->session_id().id(); |
139 ExtensionAction* action = | 138 ExtensionAction* action = |
140 ExtensionActionManager::Get(browser()->profile())-> | 139 ExtensionActionManager::Get(browser()->profile())-> |
141 GetPageAction(*extension); | 140 GetPageAction(*extension); |
142 ASSERT_TRUE(action); | 141 ASSERT_TRUE(action); |
143 EXPECT_EQ("Make this page red", action->GetTitle(tab_id)); | 142 EXPECT_EQ("Make this page red", action->GetTitle(tab_id)); |
144 | 143 |
145 // Activate the shortcut (Alt+Shift+F). | 144 // Activate the shortcut (Alt+Shift+F). |
146 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 145 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
147 browser(), ui::VKEY_F, false, true, true, false)); | 146 browser(), ui::VKEY_F, false, true, true, false)); |
148 | 147 |
149 // Verify the command worked (the page action turns the page red). | 148 // Verify the command worked (the page action turns the page red). |
150 WebContents* tab = chrome::GetActiveWebContents(browser()); | 149 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
151 bool result = false; | 150 bool result = false; |
152 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 151 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
153 tab, | 152 tab, |
154 "setInterval(function(){" | 153 "setInterval(function(){" |
155 " if(document.body.bgColor == 'red'){" | 154 " if(document.body.bgColor == 'red'){" |
156 " window.domAutomationController.send(true)}}, 100)", | 155 " window.domAutomationController.send(true)}}, 100)", |
157 &result)); | 156 &result)); |
158 ASSERT_TRUE(result); | 157 ASSERT_TRUE(result); |
159 } | 158 } |
160 | 159 |
(...skipping 29 matching lines...) Expand all Loading... |
190 | 189 |
191 // This test validates that the getAll query API function returns registered | 190 // This test validates that the getAll query API function returns registered |
192 // commands as well as synthesized ones and that inactive commands (like the | 191 // commands as well as synthesized ones and that inactive commands (like the |
193 // synthesized ones are in nature) have no shortcuts. | 192 // synthesized ones are in nature) have no shortcuts. |
194 IN_PROC_BROWSER_TEST_F(CommandsApiTest, SynthesizedCommand) { | 193 IN_PROC_BROWSER_TEST_F(CommandsApiTest, SynthesizedCommand) { |
195 ASSERT_TRUE(test_server()->Start()); | 194 ASSERT_TRUE(test_server()->Start()); |
196 ASSERT_TRUE(RunExtensionTest("keybinding/synthesized")) << message_; | 195 ASSERT_TRUE(RunExtensionTest("keybinding/synthesized")) << message_; |
197 } | 196 } |
198 | 197 |
199 } // extensions | 198 } // extensions |
OLD | NEW |