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" |
16 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
17 #include "chrome/common/extensions/extension_action.h" | 18 #include "chrome/common/extensions/extension_action.h" |
18 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
19 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 21 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "ui/gfx/image/image_skia.h" | 22 #include "ui/gfx/image/image_skia.h" |
21 | 23 |
22 using extensions::Extension; | 24 using extensions::Extension; |
| 25 using ::testing::_; |
23 | 26 |
24 namespace { | 27 namespace { |
25 | 28 |
26 gfx::Image CreateNonEmptyImage() { | 29 gfx::Image CreateNonEmptyImage() { |
27 SkBitmap bitmap; | 30 SkBitmap bitmap; |
28 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 16, 16); | 31 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 16, 16); |
29 bitmap.allocPixels(); | 32 bitmap.allocPixels(); |
30 return gfx::Image(bitmap); | 33 return gfx::Image(bitmap); |
31 } | 34 } |
32 | 35 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 } | 67 } |
65 | 68 |
66 { | 69 { |
67 // Tell the extension to update the page action state again. | 70 // Tell the extension to update the page action state again. |
68 ResultCatcher catcher; | 71 ResultCatcher catcher; |
69 ui_test_utils::NavigateToURL(browser(), | 72 ui_test_utils::NavigateToURL(browser(), |
70 GURL(extension->GetResourceURL("update2.html"))); | 73 GURL(extension->GetResourceURL("update2.html"))); |
71 ASSERT_TRUE(catcher.GetNextResult()); | 74 ASSERT_TRUE(catcher.GetNextResult()); |
72 } | 75 } |
73 | 76 |
| 77 // We should not be creating icons asynchronoulsy, so we don't need an |
| 78 // observer. |
| 79 ExtensionActionIconFactory icon_factory(extension, NULL); |
| 80 |
74 // Test that we received the changes. | 81 // Test that we received the changes. |
75 tab_id = SessionTabHelper::FromWebContents( | 82 tab_id = SessionTabHelper::FromWebContents( |
76 chrome::GetActiveWebContents(browser()))->session_id().id(); | 83 chrome::GetActiveWebContents(browser()))->session_id().id(); |
77 EXPECT_FALSE(action->GetIcon(tab_id).IsEmpty()); | 84 EXPECT_FALSE(icon_factory.GetIcon(action, tab_id).IsEmpty()); |
78 } | 85 } |
79 | 86 |
80 // Test that calling chrome.pageAction.setPopup() can enable a popup. | 87 // Test that calling chrome.pageAction.setPopup() can enable a popup. |
81 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageActionAddPopup) { | 88 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageActionAddPopup) { |
82 // Load the extension, which has no default popup. | 89 // Load the extension, which has no default popup. |
83 ASSERT_TRUE(RunExtensionTest("page_action/add_popup")) << message_; | 90 ASSERT_TRUE(RunExtensionTest("page_action/add_popup")) << message_; |
84 const Extension* extension = GetSingleLoadedExtension(); | 91 const Extension* extension = GetSingleLoadedExtension(); |
85 ASSERT_TRUE(extension) << message_; | 92 ASSERT_TRUE(extension) << message_; |
86 | 93 |
87 int tab_id = ExtensionTabUtil::GetTabId( | 94 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) { | 223 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Getters) { |
217 ASSERT_TRUE(RunExtensionTest("page_action/getters")) << message_; | 224 ASSERT_TRUE(RunExtensionTest("page_action/getters")) << message_; |
218 const Extension* extension = GetSingleLoadedExtension(); | 225 const Extension* extension = GetSingleLoadedExtension(); |
219 ASSERT_TRUE(extension) << message_; | 226 ASSERT_TRUE(extension) << message_; |
220 | 227 |
221 ResultCatcher catcher; | 228 ResultCatcher catcher; |
222 ui_test_utils::NavigateToURL(browser(), | 229 ui_test_utils::NavigateToURL(browser(), |
223 GURL(extension->GetResourceURL("update.html"))); | 230 GURL(extension->GetResourceURL("update.html"))); |
224 ASSERT_TRUE(catcher.GetNextResult()); | 231 ASSERT_TRUE(catcher.GetNextResult()); |
225 } | 232 } |
OLD | NEW |