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/browser_event_router.h" | 5 #include "chrome/browser/extensions/browser_event_router.h" |
| 6 #include "chrome/browser/extensions/extension_action_icon_factory.h" |
6 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
7 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
8 #include "chrome/browser/extensions/extension_tab_util.h" | 9 #include "chrome/browser/extensions/extension_tab_util.h" |
9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/sessions/session_tab_helper.h" | 11 #include "chrome/browser/sessions/session_tab_helper.h" |
11 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/browser_tabstrip.h" | 13 #include "chrome/browser/ui/browser_tabstrip.h" |
13 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
14 #include "chrome/browser/ui/omnibox/location_bar.h" | 15 #include "chrome/browser/ui/omnibox/location_bar.h" |
15 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 16 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 } | 65 } |
65 | 66 |
66 { | 67 { |
67 // Tell the extension to update the page action state again. | 68 // Tell the extension to update the page action state again. |
68 ResultCatcher catcher; | 69 ResultCatcher catcher; |
69 ui_test_utils::NavigateToURL(browser(), | 70 ui_test_utils::NavigateToURL(browser(), |
70 GURL(extension->GetResourceURL("update2.html"))); | 71 GURL(extension->GetResourceURL("update2.html"))); |
71 ASSERT_TRUE(catcher.GetNextResult()); | 72 ASSERT_TRUE(catcher.GetNextResult()); |
72 } | 73 } |
73 | 74 |
| 75 // We should not be creating icons asynchronously, so we don't need an |
| 76 // observer. |
| 77 ExtensionActionIconFactory icon_factory(extension, action, NULL); |
| 78 |
74 // Test that we received the changes. | 79 // Test that we received the changes. |
75 tab_id = SessionTabHelper::FromWebContents( | 80 tab_id = SessionTabHelper::FromWebContents( |
76 chrome::GetActiveWebContents(browser()))->session_id().id(); | 81 chrome::GetActiveWebContents(browser()))->session_id().id(); |
77 EXPECT_FALSE(action->GetIcon(tab_id).IsEmpty()); | 82 EXPECT_FALSE(icon_factory.GetIcon(tab_id).IsEmpty()); |
78 } | 83 } |
79 | 84 |
80 // Test that calling chrome.pageAction.setPopup() can enable a popup. | 85 // Test that calling chrome.pageAction.setPopup() can enable a popup. |
81 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageActionAddPopup) { | 86 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageActionAddPopup) { |
82 // Load the extension, which has no default popup. | 87 // Load the extension, which has no default popup. |
83 ASSERT_TRUE(RunExtensionTest("page_action/add_popup")) << message_; | 88 ASSERT_TRUE(RunExtensionTest("page_action/add_popup")) << message_; |
84 const Extension* extension = GetSingleLoadedExtension(); | 89 const Extension* extension = GetSingleLoadedExtension(); |
85 ASSERT_TRUE(extension) << message_; | 90 ASSERT_TRUE(extension) << message_; |
86 | 91 |
87 int tab_id = ExtensionTabUtil::GetTabId( | 92 int tab_id = ExtensionTabUtil::GetTabId( |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Getters) { | 221 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Getters) { |
217 ASSERT_TRUE(RunExtensionTest("page_action/getters")) << message_; | 222 ASSERT_TRUE(RunExtensionTest("page_action/getters")) << message_; |
218 const Extension* extension = GetSingleLoadedExtension(); | 223 const Extension* extension = GetSingleLoadedExtension(); |
219 ASSERT_TRUE(extension) << message_; | 224 ASSERT_TRUE(extension) << message_; |
220 | 225 |
221 ResultCatcher catcher; | 226 ResultCatcher catcher; |
222 ui_test_utils::NavigateToURL(browser(), | 227 ui_test_utils::NavigateToURL(browser(), |
223 GURL(extension->GetResourceURL("update.html"))); | 228 GURL(extension->GetResourceURL("update.html"))); |
224 ASSERT_TRUE(catcher.GetNextResult()); | 229 ASSERT_TRUE(catcher.GetNextResult()); |
225 } | 230 } |
OLD | NEW |