Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: chrome/browser/extensions/api/extension_action/page_action_apitest.cc

Issue 10905005: Change browser/page action default icon defined in manifest to support hidpi. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_apitest.h" 6 #include "chrome/browser/extensions/extension_apitest.h"
7 #include "chrome/browser/extensions/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/extensions/extension_tab_util.h" 8 #include "chrome/browser/extensions/extension_tab_util.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/sessions/session_tab_helper.h" 10 #include "chrome/browser/sessions/session_tab_helper.h"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_tabstrip.h" 12 #include "chrome/browser/ui/browser_tabstrip.h"
13 #include "chrome/browser/ui/browser_window.h" 13 #include "chrome/browser/ui/browser_window.h"
14 #include "chrome/browser/ui/omnibox/location_bar.h" 14 #include "chrome/browser/ui/omnibox/location_bar.h"
15 #include "chrome/browser/ui/tab_contents/tab_contents.h" 15 #include "chrome/browser/ui/tab_contents/tab_contents.h"
16 #include "chrome/common/extensions/extension.h" 16 #include "chrome/common/extensions/extension.h"
17 #include "chrome/common/extensions/extension_action.h" 17 #include "chrome/common/extensions/extension_action.h"
18 #include "chrome/common/extensions/extension_icon_factory_delegate.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
29 class MockActionIconFactory : public ExtensionIconFactoryDelegate {
30 public:
31 virtual ~MockActionIconFactory() {}
32
33 MOCK_METHOD2(GetIcon, gfx::ImageSkia(const ExtensionIconSet* icon_set,
34 int desired_size));
35 };
36
37 } // namespace
38
39 namespace {
40
26 gfx::Image CreateNonEmptyImage() { 41 gfx::Image CreateNonEmptyImage() {
27 SkBitmap bitmap; 42 SkBitmap bitmap;
28 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 16, 16); 43 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 16, 16);
29 bitmap.allocPixels(); 44 bitmap.allocPixels();
30 return gfx::Image(bitmap); 45 return gfx::Image(bitmap);
31 } 46 }
32 47
33 } // namespace 48 } // namespace
34 49
35 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageAction) { 50 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageAction) {
(...skipping 28 matching lines...) Expand all
64 } 79 }
65 80
66 { 81 {
67 // Tell the extension to update the page action state again. 82 // Tell the extension to update the page action state again.
68 ResultCatcher catcher; 83 ResultCatcher catcher;
69 ui_test_utils::NavigateToURL(browser(), 84 ui_test_utils::NavigateToURL(browser(),
70 GURL(extension->GetResourceURL("update2.html"))); 85 GURL(extension->GetResourceURL("update2.html")));
71 ASSERT_TRUE(catcher.GetNextResult()); 86 ASSERT_TRUE(catcher.GetNextResult());
72 } 87 }
73 88
89 MockActionIconFactory mock_icon_factory;
90 EXPECT_CALL(mock_icon_factory, GetIcon(_, _)).Times(0);
91
74 // Test that we received the changes. 92 // Test that we received the changes.
75 tab_id = chrome::GetActiveTabContents(browser())->session_tab_helper()-> 93 tab_id = chrome::GetActiveTabContents(browser())->session_tab_helper()->
76 session_id().id(); 94 session_id().id();
77 EXPECT_FALSE(action->GetIcon(tab_id).IsEmpty()); 95 EXPECT_FALSE(action->GetIcon(tab_id, &mock_icon_factory).IsEmpty());
78 } 96 }
79 97
80 // Test that calling chrome.pageAction.setPopup() can enable a popup. 98 // Test that calling chrome.pageAction.setPopup() can enable a popup.
81 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageActionAddPopup) { 99 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageActionAddPopup) {
82 // Load the extension, which has no default popup. 100 // Load the extension, which has no default popup.
83 ASSERT_TRUE(RunExtensionTest("page_action/add_popup")) << message_; 101 ASSERT_TRUE(RunExtensionTest("page_action/add_popup")) << message_;
84 const Extension* extension = GetSingleLoadedExtension(); 102 const Extension* extension = GetSingleLoadedExtension();
85 ASSERT_TRUE(extension) << message_; 103 ASSERT_TRUE(extension) << message_;
86 104
87 int tab_id = ExtensionTabUtil::GetTabId( 105 int tab_id = ExtensionTabUtil::GetTabId(
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Getters) { 259 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Getters) {
242 ASSERT_TRUE(RunExtensionTest("page_action/getters")) << message_; 260 ASSERT_TRUE(RunExtensionTest("page_action/getters")) << message_;
243 const Extension* extension = GetSingleLoadedExtension(); 261 const Extension* extension = GetSingleLoadedExtension();
244 ASSERT_TRUE(extension) << message_; 262 ASSERT_TRUE(extension) << message_;
245 263
246 ResultCatcher catcher; 264 ResultCatcher catcher;
247 ui_test_utils::NavigateToURL(browser(), 265 ui_test_utils::NavigateToURL(browser(),
248 GURL(extension->GetResourceURL("update.html"))); 266 GURL(extension->GetResourceURL("update.html")));
249 ASSERT_TRUE(catcher.GetNextResult()); 267 ASSERT_TRUE(catcher.GetNextResult());
250 } 268 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698