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/api/extension_action/extension_action_api.h" | 5 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
6 #include "chrome/browser/extensions/extension_action.h" | 6 #include "chrome/browser/extensions/extension_action.h" |
7 #include "chrome/browser/extensions/extension_action_icon_factory.h" | 7 #include "chrome/browser/extensions/extension_action_icon_factory.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_action_test_util.h" | 9 #include "chrome/browser/extensions/extension_action_test_util.h" |
10 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 class PageActionApiTest : public ExtensionApiTest { | 31 class PageActionApiTest : public ExtensionApiTest { |
32 protected: | 32 protected: |
33 ExtensionAction* GetPageAction(const Extension& extension) { | 33 ExtensionAction* GetPageAction(const Extension& extension) { |
34 return ExtensionActionManager::Get(browser()->profile())-> | 34 return ExtensionActionManager::Get(browser()->profile())-> |
35 GetPageAction(extension); | 35 GetPageAction(extension); |
36 } | 36 } |
37 }; | 37 }; |
38 | 38 |
39 IN_PROC_BROWSER_TEST_F(PageActionApiTest, Basic) { | 39 IN_PROC_BROWSER_TEST_F(PageActionApiTest, Basic) { |
40 ASSERT_TRUE(test_server()->Start()); | 40 ASSERT_TRUE(embedded_test_server()->Start()); |
41 ASSERT_TRUE(RunExtensionTest("page_action/basics")) << message_; | 41 ASSERT_TRUE(RunExtensionTest("page_action/basics")) << message_; |
42 const Extension* extension = GetSingleLoadedExtension(); | 42 const Extension* extension = GetSingleLoadedExtension(); |
43 ASSERT_TRUE(extension) << message_; | 43 ASSERT_TRUE(extension) << message_; |
44 { | 44 { |
45 // Tell the extension to update the page action state. | 45 // Tell the extension to update the page action state. |
46 ResultCatcher catcher; | 46 ResultCatcher catcher; |
47 ui_test_utils::NavigateToURL(browser(), | 47 ui_test_utils::NavigateToURL(browser(), |
48 GURL(extension->GetResourceURL("update.html"))); | 48 GURL(extension->GetResourceURL("update.html"))); |
49 ASSERT_TRUE(catcher.GetNextResult()); | 49 ASSERT_TRUE(catcher.GetNextResult()); |
50 } | 50 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 ASSERT_TRUE(extension) << message_; | 194 ASSERT_TRUE(extension) << message_; |
195 | 195 |
196 ResultCatcher catcher; | 196 ResultCatcher catcher; |
197 ui_test_utils::NavigateToURL(browser(), | 197 ui_test_utils::NavigateToURL(browser(), |
198 GURL(extension->GetResourceURL("update.html"))); | 198 GURL(extension->GetResourceURL("update.html"))); |
199 ASSERT_TRUE(catcher.GetNextResult()); | 199 ASSERT_TRUE(catcher.GetNextResult()); |
200 } | 200 } |
201 | 201 |
202 // Verify triggering page action. | 202 // Verify triggering page action. |
203 IN_PROC_BROWSER_TEST_F(PageActionApiTest, TestTriggerPageAction) { | 203 IN_PROC_BROWSER_TEST_F(PageActionApiTest, TestTriggerPageAction) { |
204 ASSERT_TRUE(test_server()->Start()); | 204 ASSERT_TRUE(embedded_test_server()->Start()); |
205 | 205 |
206 ASSERT_TRUE(RunExtensionTest("trigger_actions/page_action")) << message_; | 206 ASSERT_TRUE(RunExtensionTest("trigger_actions/page_action")) << message_; |
207 const Extension* extension = GetSingleLoadedExtension(); | 207 const Extension* extension = GetSingleLoadedExtension(); |
208 ASSERT_TRUE(extension) << message_; | 208 ASSERT_TRUE(extension) << message_; |
209 | 209 |
210 // Page action icon is displayed when a tab is created. | 210 // Page action icon is displayed when a tab is created. |
211 ui_test_utils::NavigateToURL(browser(), | 211 ui_test_utils::NavigateToURL(browser(), |
212 test_server()->GetURL("files/simple.html")); | 212 embedded_test_server()->GetURL("/simple.html")); |
213 chrome::NewTab(browser()); | 213 chrome::NewTab(browser()); |
214 browser()->tab_strip_model()->ActivateTabAt(0, true); | 214 browser()->tab_strip_model()->ActivateTabAt(0, true); |
215 | 215 |
216 // Give the extension time to show the page action on the tab. | 216 // Give the extension time to show the page action on the tab. |
217 WaitForPageActionVisibilityChangeTo(1); | 217 WaitForPageActionVisibilityChangeTo(1); |
218 | 218 |
219 ExtensionAction* page_action = GetPageAction(*extension); | 219 ExtensionAction* page_action = GetPageAction(*extension); |
220 ASSERT_TRUE(page_action); | 220 ASSERT_TRUE(page_action); |
221 | 221 |
222 WebContents* tab = | 222 WebContents* tab = |
(...skipping 14 matching lines...) Expand all Loading... |
237 const std::string script = | 237 const std::string script = |
238 "window.domAutomationController.send(document.body.style." | 238 "window.domAutomationController.send(document.body.style." |
239 "backgroundColor);"; | 239 "backgroundColor);"; |
240 std::string result; | 240 std::string result; |
241 EXPECT_TRUE(content::ExecuteScriptAndExtractString(tab, script, &result)); | 241 EXPECT_TRUE(content::ExecuteScriptAndExtractString(tab, script, &result)); |
242 EXPECT_EQ(result, "red"); | 242 EXPECT_EQ(result, "red"); |
243 } | 243 } |
244 | 244 |
245 } // namespace | 245 } // namespace |
246 } // namespace extensions | 246 } // namespace extensions |
OLD | NEW |